koishi-plugin-chat-patch 5.5.0 → 5.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,7 @@
11
11
  <link rel="stylesheet" href="./bcui/css/style.css">
12
12
  <link rel="stylesheet" href="./bcui/css/color-light.css">
13
13
  <link rel="stylesheet" href="./css/append-light.css">
14
- <script type="module" crossorigin src="./assets/index-BA37EQGa.js"></script>
14
+ <script type="module" crossorigin src="./assets/index-CSGfOsfr.js"></script>
15
15
  <link rel="stylesheet" crossorigin href="./assets/index-B71pPwae.css">
16
16
  </head>
17
17
 
@@ -43,7 +43,7 @@ import {
43
43
  sendStatEvent,
44
44
  } from '../function/utils/appUtil'
45
45
 
46
- const SATORI_MARKUP_PATTERN = /<(?:img|image|audio|video|file|mface|face|quote|at|forward|json|xml|markdown|keyboard|p|br|i18n|a|text|sharp)(?:\s|\/|>)/i
46
+ const SATORI_MARKUP_PATTERN = /(?:<|&(?:amp;)?lt;)(?:img|image|audio|video|file|mface|face|faceType|quote|at|forward|json|xml|markdown|keyboard|p|br|i18n|a|text|sharp)(?:\s|\/|>|&(?:amp;)?gt;)/i
47
47
 
48
48
  function splitSatoriMarkupText(message: any[]): any[] {
49
49
  return message.flatMap((segment) => {
@@ -229,16 +229,23 @@ function normalizeAtText(name: string, id: string): string {
229
229
  }
230
230
 
231
231
  function containsElementMarkup(source: string): boolean {
232
- return /<(img|image|audio|video|file|mface|face|quote|at|forward|json|xml|markdown|keyboard|p|br|i18n|a|text|sharp)(?:\s|\/|>)/i.test(source)
232
+ return /(?:<|&(?:amp;)?lt;)(?:img|image|audio|video|file|mface|face|faceType|quote|at|forward|json|xml|markdown|keyboard|p|br|i18n|a|text|sharp)(?:\s|\/|>|&(?:amp;)?gt;)/i.test(source)
233
233
  }
234
234
 
235
235
  // QQ 官方机器人会把部分大表情/图片消息的私有标记塞进 content,渲染前需要去掉
236
236
  function cleanQqFaceMarkup(source: string): string {
237
237
  return source
238
238
  .replace(/<faceType\b[^>]*>/gi, '')
239
- .replace(/&lt;faceType\b[^>]*&gt;/gi, '')
239
+ .replace(/&(?:amp;)?lt;faceType\b[^>]*&(?:amp;)?gt;/gi, '')
240
240
  }
241
241
 
242
+ const QQ_EXPRESSION_PLACEHOLDER = 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(
243
+ '<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120" viewBox="0 0 120 120">'
244
+ + '<rect width="120" height="120" rx="12" fill="#f3f4f6"/>'
245
+ + '<text x="60" y="62" text-anchor="middle" dominant-baseline="middle" font-size="18" fill="#333">表情消息</text>'
246
+ + '</svg>',
247
+ )
248
+
242
249
  function splitMarkupTextSegments(
243
250
  segments: Array<Record<string, unknown>>,
244
251
  ): Array<Record<string, unknown>> {
@@ -255,7 +262,18 @@ function splitMarkupTextSegments(
255
262
  }
256
263
 
257
264
  export function parseSatoriMarkup(source: string): Array<Record<string, unknown>> {
265
+ const hadQqFaceMarkup = /(?:&(?:amp;)?lt;|<)faceType\b/i.test(source)
258
266
  source = cleanQqFaceMarkup(source)
267
+ if (hadQqFaceMarkup && !source.trim()) {
268
+ return [{
269
+ type: 'image',
270
+ file: QQ_EXPRESSION_PLACEHOLDER,
271
+ url: QQ_EXPRESSION_PLACEHOLDER,
272
+ summary: '表情消息',
273
+ width: 120,
274
+ height: 120,
275
+ }]
276
+ }
259
277
  const result: Array<Record<string, unknown>> = []
260
278
  let index = 0
261
279
  while (index < source.length) {
@@ -394,12 +394,11 @@
394
394
  function userClick(data: UserFriendElem & UserGroupElem) {
395
395
  const id = data.group_id || data.user_id
396
396
  if (id === undefined || id === null || String(id) === '' || String(id) === '0') return
397
- // 从群收纳盒进入群时先收起收纳盒,避免头部切换导致返回标记闪烁
398
- if (showGroupAssist.value) {
399
- showGroupAssist.value = false
400
- }
397
+ const fromGroupAssist = showGroupAssist.value
401
398
  if (!trRead.value && id != props.chat.show.id) {
402
- if (uiStore.openSideBar) {
399
+ if (fromGroupAssist) {
400
+ uiStore.openSideBar = false
401
+ } else if (uiStore.openSideBar) {
403
402
  openLeftBar()
404
403
  }
405
404
  const back = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-chat-patch",
3
3
  "description": "[<ruby>chat-patch<rp>(</rp><rt>点我预览效果</rt><rp>)</rp></ruby>](https://i0.hdslb.com/bfs/openplatform/71074dfc9e5256fc3333d8bd8478bec1af874046.png) 视奸小插件((bushi( (低性能警告)。手机端适配。灵感来自 chat 插件。",
4
- "version": "5.5.0",
4
+ "version": "5.5.1",
5
5
  "scripts": {
6
6
  "build:web": "npm --prefix client/web run build",
7
7
  "prepack": "npm run build:web",