koishi-plugin-chat-patch 5.1.0 → 5.3.0

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.
Files changed (30) hide show
  1. package/client/web/dist/assets/Chat-B448YOeN.js +28 -0
  2. package/client/web/dist/assets/{MsgBody-DLeOklIb.js → MsgBody-DDacjWJ9.js} +1 -1
  3. package/client/web/dist/assets/MsgBody.vue_vue_type_script_setup_true_lang-B1dWyCB0.js +67 -0
  4. package/client/web/dist/assets/{index-Cz89G4we.js → index-BlLut5xn.js} +121 -129
  5. package/client/web/dist/assets/index-fW_zcub3.css +1 -0
  6. package/client/web/dist/assets/pinyin-Dsq98249.js +157657 -0
  7. package/client/web/dist/index.html +2 -2
  8. package/client/web/dist/notice_local.json +1 -0
  9. package/client/web/package-lock.json +49 -0
  10. package/client/web/package.json +1 -0
  11. package/client/web/public/notice_local.json +1 -0
  12. package/client/web/src/components/EmojiFace.vue +0 -6
  13. package/client/web/src/components/FacePan.vue +0 -12
  14. package/client/web/src/components/MsgBody.vue +3 -4
  15. package/client/web/src/components/SettingsTab.vue +133 -0
  16. package/client/web/src/function/connect.ts +34 -14
  17. package/client/web/src/function/model/emoji.ts +7 -67
  18. package/client/web/src/function/msg.ts +68 -26
  19. package/client/web/src/function/utils/appUtil.ts +1 -4
  20. package/client/web/src/function/utils/msgUtil.ts +86 -52
  21. package/client/web/src/function/utils/pinyin.ts +25 -65
  22. package/client/web/src/function/utils/sessionUtil.ts +90 -14
  23. package/client/web/src/pages/Friends.vue +49 -13
  24. package/client/web/src/pages/Messages.vue +39 -12
  25. package/client/web/src/pages/Options.vue +4 -4
  26. package/client/web/src/pages/options/OptDev.vue +1 -14
  27. package/package.json +1 -1
  28. package/client/web/dist/assets/Chat-BoNiWGxb.js +0 -28
  29. package/client/web/dist/assets/MsgBody.vue_vue_type_script_setup_true_lang-CGjy4Jzz.js +0 -67
  30. package/client/web/dist/assets/index-BgOX_tNa.css +0 -1
@@ -50,7 +50,7 @@
50
50
  {{ $t('空') }}
51
51
  </div>
52
52
  <FriendBody v-for="item in contactStore.showList"
53
- :key="'search-' + item.user_id + '-' + item.group_id"
53
+ :key="'search-' + (item.channel_id || item.channelId || item.user_id || item.group_id)"
54
54
  :data="item"
55
55
  from="friend"
56
56
  @click="userClick(item, $event)" />
@@ -100,7 +100,7 @@
100
100
  return ( get.class_id == info.class_id )
101
101
  },
102
102
  )"
103
- :key=" 'fb-' + (item.user_id ? item.user_id : item.group_id) "
103
+ :key=" 'fb-' + (item.channel_id || item.channelId || item.user_id || item.group_id) "
104
104
  :data="item" from="friend"
105
105
  @click="userClick(item, $event)" />
106
106
  </div>
@@ -125,7 +125,7 @@
125
125
  return get.class_id == undefined
126
126
  },
127
127
  )"
128
- :key="'fb-' + (item.user_id ? item.user_id : item.group_id)"
128
+ :key="'fb-' + (item.channel_id || item.channelId || item.user_id || item.group_id)"
129
129
  :data="item"
130
130
  from="friend"
131
131
  @click="userClick(item, $event)" />
@@ -134,7 +134,7 @@
134
134
  </template>
135
135
  <template v-else>
136
136
  <FriendBody v-for="item in contactStore.userList"
137
- :key="'fb-' + (item.user_id ? item.user_id : item.group_id)"
137
+ :key="'fb-' + (item.channel_id || item.channelId || item.user_id || item.group_id)"
138
138
  :data="item"
139
139
  from="friend"
140
140
  @click="userClick(item, $event)" />
@@ -144,7 +144,7 @@
144
144
  <div v-else class="list">
145
145
  <div>
146
146
  <FriendBody v-for="item in contactStore.showList"
147
- :key="'fb-' + (item.user_id ? item.user_id : item.group_id)"
147
+ :key="'fb-' + (item.channel_id || item.channelId || item.user_id || item.group_id)"
148
148
  :data="item" from="friend"
149
149
  @click="userClick(item, $event)" />
150
150
  </div>
@@ -184,7 +184,7 @@
184
184
  import { reloadUsers } from '../function/utils/appUtil'
185
185
  import { Connector, flushPendingBotEvents, loadContactsFromCache, login as loginInfo } from '../function/connect'
186
186
  import { getActiveBot, getLogins, setActiveBot } from '../function/satori'
187
- import { normalizeSessionId } from '../function/utils/sessionUtil'
187
+ import { normalizeGroupId, normalizeSessionId } from '../function/utils/sessionUtil'
188
188
  import { avatarError } from '../function/utils/avatarUtil'
189
189
  import { backend } from '../runtime/backend'
190
190
  import { matchPinyin } from '../function/utils/pinyin'
@@ -240,7 +240,17 @@
240
240
  bot?: ContactWithBot['_bot'],
241
241
  ) => {
242
242
  for (const item of items) {
243
- const id = String(item.user_id ?? item.group_id ?? '')
243
+ const rawId = String(
244
+ item.channel_id
245
+ || item.channelId
246
+ || item.user_id
247
+ || item.group_id
248
+ || '',
249
+ )
250
+ const groupId = String(item.group_id || '')
251
+ const id = groupId
252
+ ? `group:${normalizeGroupId(rawId || groupId)}`
253
+ : `user:${rawId.replace(/^(?:private|direct):/i, '')}`
244
254
  const key = [bot?.platform ?? '', bot?.selfId ?? '', id]
245
255
  .map((value) => encodeURIComponent(String(value)))
246
256
  .join(':')
@@ -295,8 +305,25 @@
295
305
  if (saved) {
296
306
  contactStore.userList = saved.userList
297
307
  contactStore.baseOnMsgList.clear()
298
- for (const [key, value] of saved.baseList) {
299
- contactStore.baseOnMsgList.set(normalizeSessionId(key), value)
308
+ for (const [, value] of saved.baseList) {
309
+ const id = String(value.channel_id || value.channelId || value.user_id || value.group_id || '')
310
+ if (id && id !== '0') {
311
+ contactStore.baseOnMsgList.set(normalizeSessionId(id), value)
312
+ const legacyId = String(value.user_id || value.group_id || '')
313
+ if (legacyId && legacyId !== id) {
314
+ contactStore.baseOnMsgList.set(normalizeSessionId(legacyId), value)
315
+ }
316
+ }
317
+ }
318
+ for (const item of saved.onMsgList) {
319
+ const id = String(item.channel_id || item.channelId || item.user_id || item.group_id || '')
320
+ if (id && id !== '0') {
321
+ contactStore.baseOnMsgList.set(normalizeSessionId(id), item)
322
+ const legacyId = String(item.user_id || item.group_id || '')
323
+ if (legacyId && legacyId !== id) {
324
+ contactStore.baseOnMsgList.set(normalizeSessionId(legacyId), item)
325
+ }
326
+ }
300
327
  }
301
328
  contactStore.onMsgList = saved.onMsgList
302
329
  flushPendingBotEvents(bot.platform, bot.selfId)
@@ -380,18 +407,27 @@
380
407
  contactStore.showList = [] as any[]
381
408
 
382
409
  const back = {
383
- type: data.user_id ? 'user' : 'group',
384
- id: data.user_id ? data.user_id : data.group_id,
410
+ type: data.group_id ? 'group' : 'user',
411
+ id: data.group_id || data.user_id,
385
412
  name: getShowName(data),
386
413
  avatar: data.avatar || '/img/icons/icon.svg',
387
414
  jump: sender.dataset.jump,
388
- channel_id: data.channel_id,
415
+ channel_id: data.channel_id || data.channelId,
389
416
  guild_id: data.guild_id,
390
417
  } as BaseChatInfoElem
391
418
  if (back.id === undefined || back.id === null || String(back.id) === '' || String(back.id) === '0') return
392
419
  // 更新聊天框
393
420
  emit('userClick', back)
394
- contactStore.baseOnMsgList.set(normalizeSessionId(back.id), data)
421
+ const sessionId = String(
422
+ data.channel_id
423
+ || data.channelId
424
+ || data.user_id
425
+ || data.group_id
426
+ || '',
427
+ )
428
+ if (sessionId && sessionId !== '0') {
429
+ contactStore.baseOnMsgList.set(normalizeSessionId(sessionId), data)
430
+ }
395
431
  // 获取历史消息
396
432
  if(!uiStore.nowGetHistory) {
397
433
  emit('loadHistory', back)
@@ -98,7 +98,7 @@
98
98
  <!-- 其他消息 -->
99
99
  <FriendBody
100
100
  v-for="item in contactStore.onMsgList"
101
- :key="'inMessage-' + (item.user_id ? item.user_id : item.group_id)"
101
+ :key="'inMessage-' + (item.channel_id || item.channelId || item.user_id || item.group_id)"
102
102
  :select="chat.show.id === item.user_id || (chat.show.id === item.group_id && chat.group_name != '')"
103
103
  :menu="menu.select && menu.select == item"
104
104
  :data="item"
@@ -150,7 +150,7 @@
150
150
  <!-- 其他消息 -->
151
151
  <FriendBody
152
152
  v-for="item in contactStore.groupAssistList"
153
- :key="'inMessage-' + (item.user_id ? item.user_id : item.group_id)"
153
+ :key="'inMessage-' + (item.channel_id || item.channelId || item.user_id || item.group_id)"
154
154
  :select="chat.show.id === item.user_id || (chat.show.id === item.group_id && chat.group_name != '')"
155
155
  :menu="menu.select && menu.select == item"
156
156
  :data="item"
@@ -232,7 +232,7 @@
232
232
  import { refreshFavicon } from '../function/favicon'
233
233
  import { backend } from '../runtime/backend'
234
234
  import History from '../components/History.vue'
235
- import { normalizeSessionId } from '../function/utils/sessionUtil'
235
+ import { findSessionContact, normalizeSessionId } from '../function/utils/sessionUtil'
236
236
  import { avatarError } from '../function/utils/avatarUtil'
237
237
  import { useUIStore } from '../state/ui'
238
238
  import { useAuthStore } from '../state/auth'
@@ -283,16 +283,27 @@
283
283
  const restored = contactStore.botStates.get(bot.selfId)
284
284
  if (!restored) return
285
285
  contactStore.baseOnMsgList.clear()
286
- for (const [key, value] of restored.baseList) {
287
- contactStore.baseOnMsgList.set(normalizeSessionId(key), value)
286
+ for (const [, value] of restored.baseList) {
287
+ const id = String(value.channel_id || value.channelId || value.user_id || value.group_id || '')
288
+ if (id && id !== '0') {
289
+ contactStore.baseOnMsgList.set(normalizeSessionId(id), value)
290
+ const legacyId = String(value.user_id || value.group_id || '')
291
+ if (legacyId && legacyId !== id) {
292
+ contactStore.baseOnMsgList.set(normalizeSessionId(legacyId), value)
293
+ }
294
+ }
288
295
  }
289
296
  for (const item of restored.onMsgList) {
290
- const id = String(item.user_id ?? item.group_id ?? '')
297
+ const id = String(item.channel_id || item.channelId || item.user_id || item.group_id || '')
291
298
  if (!id || id === '0') continue
292
299
  contactStore.baseOnMsgList.set(
293
300
  normalizeSessionId(id),
294
301
  item as UserFriendElem & UserGroupElem,
295
302
  )
303
+ const legacyId = String(item.user_id || item.group_id || '')
304
+ if (legacyId && legacyId !== id) {
305
+ contactStore.baseOnMsgList.set(normalizeSessionId(legacyId), item as UserFriendElem & UserGroupElem)
306
+ }
296
307
  }
297
308
  contactStore.onMsgList = restored.onMsgList
298
309
  }
@@ -376,7 +387,7 @@
376
387
  * @param data 联系人对象
377
388
  */
378
389
  function userClick(data: UserFriendElem & UserGroupElem) {
379
- const id = data.user_id ? data.user_id : data.group_id
390
+ const id = data.group_id || data.user_id
380
391
  if (id === undefined || id === null || String(id) === '' || String(id) === '0') return
381
392
  if (!trRead.value && id != props.chat.show.id) {
382
393
  if (uiStore.openSideBar) {
@@ -385,11 +396,11 @@
385
396
  const back = {
386
397
  // 临时会话标志
387
398
  temp: data.group_name == '' ? data.group_id : undefined,
388
- type: data.user_id ? 'user' : 'group',
399
+ type: data.group_id ? 'group' : 'user',
389
400
  id: id,
390
401
  name: getShowName(data.group_name || data.nickname, data.remark),
391
402
  avatar: data.avatar || '/img/icons/icon.svg',
392
- channel_id: data.channel_id ?? data.channelId,
403
+ channel_id: data.channel_id || data.channelId,
393
404
  guild_id: data.guild_id ?? data.guildId,
394
405
  }
395
406
  if (props.chat.id != back.id) {
@@ -401,9 +412,10 @@
401
412
  }
402
413
  }
403
414
  // 清除新消息标记
404
- const sessionKey = data.channel_id ?? data.channelId ?? id
415
+ const sessionKey = data.channel_id || data.channelId || id
405
416
  const item = contactStore.baseOnMsgList.get(normalizeSessionId(sessionKey))
406
417
  ?? contactStore.baseOnMsgList.get(normalizeSessionId(id))
418
+ ?? findSessionContact(Array.from(contactStore.baseOnMsgList.values()), id)
407
419
  if(item) {
408
420
  if(item.new_msg) {
409
421
  item.new_msg = false
@@ -411,6 +423,7 @@
411
423
  }
412
424
  item.highlight = undefined
413
425
  contactStore.baseOnMsgList.set(normalizeSessionId(sessionKey), item)
426
+ updateBaseOnMsgList()
414
427
  // 关闭所有通知
415
428
  new Notify().closeAll((item.group_id ?? item.user_id).toString())
416
429
  }
@@ -474,9 +487,10 @@
474
487
  */
475
488
  function readMsg(data: UserFriendElem & UserGroupElem) {
476
489
  const id = data.group_id ? data.group_id : data.user_id
477
- const sessionKey = data.channel_id ?? data.channelId ?? id
490
+ const sessionKey = data.channel_id || data.channelId || id
478
491
  const item = contactStore.baseOnMsgList.get(normalizeSessionId(sessionKey))
479
492
  ?? contactStore.baseOnMsgList.get(normalizeSessionId(id))
493
+ ?? findSessionContact(Array.from(contactStore.baseOnMsgList.values()), id)
480
494
  if(item) {
481
495
  if(item.new_msg) {
482
496
  item.new_msg = false
@@ -484,6 +498,7 @@
484
498
  }
485
499
  item.highlight = undefined
486
500
  contactStore.baseOnMsgList.set(normalizeSessionId(sessionKey), item)
501
+ updateBaseOnMsgList()
487
502
  }
488
503
  // pop
489
504
  new PopInfo().add(
@@ -518,7 +533,16 @@
518
533
  )
519
534
  if (topList.indexOf(id) >= 0) {
520
535
  item.always_top = true
521
- contactStore.baseOnMsgList.set(normalizeSessionId(id), item)
536
+ const sessionId = String(
537
+ item.channel_id
538
+ ?? item.channelId
539
+ ?? item.user_id
540
+ ?? item.group_id
541
+ ?? '',
542
+ )
543
+ if (sessionId && sessionId !== '0') {
544
+ contactStore.baseOnMsgList.set(normalizeSessionId(sessionId), item)
545
+ }
522
546
  }
523
547
  })
524
548
  }
@@ -558,7 +582,10 @@
558
582
  break
559
583
  case 'remove': {
560
584
  const id = item.user_id ? item.user_id : item.group_id
585
+ const sessionId = String(item.channel_id || item.channelId || id || '')
561
586
  contactStore.baseOnMsgList.delete(normalizeSessionId(id))
587
+ contactStore.baseOnMsgList.delete(normalizeSessionId(sessionId))
588
+ updateBaseOnMsgList()
562
589
  refreshFavicon()
563
590
  break
564
591
  }
@@ -11,7 +11,7 @@
11
11
  <!-- 保留占位元素,避免设置页右侧布局被原有左侧选择器样式影响 -->
12
12
  <div class="opt-side-placeholder" style="display: none" />
13
13
  <div>
14
- <BcTab v-show="show" :title="$t('设置')" class="opt-tab">
14
+ <SettingsTab v-show="show" class="opt-tab">
15
15
  <div :name="$t('账号')">
16
16
  <OptAccount :config="config" />
17
17
  </div>
@@ -27,18 +27,18 @@
27
27
  <div v-if="showAbout" :name="$t('关于')">
28
28
  <AboutPan class="opt-about" show-u-i />
29
29
  </div>
30
- </BcTab>
30
+ </SettingsTab>
31
31
  </div>
32
32
  </div>
33
33
  </template>
34
34
 
35
35
  <script setup lang="ts">
36
- import { ref, watch, onMounted, nextTick } from 'vue'
36
+ import { ref, watch, onMounted } from 'vue'
37
37
 
38
38
  import { i18n } from '../main'
39
39
  import { useSettingsStore } from '../state/settings'
40
40
 
41
- import BcTab from 'vue3-bcui/packages/bc-tab'
41
+ import SettingsTab from '../components/SettingsTab.vue'
42
42
  import OptAccount from './options/OptAccount.vue'
43
43
  import OptView from './options/OptView.vue'
44
44
  import OptDev from './options/OptDev.vue'
@@ -315,20 +315,7 @@ import packageInfo from '../../../package.json'
315
315
  }
316
316
 
317
317
  info += 'Network Info:\n'
318
- const testList = [
319
- ['Github ', 'https://api.github.com'],
320
- ['SSQQ API ', 'https://api.stapxs.cn'],
321
- ]
322
- for (const item of testList) {
323
- const start = new Date().getTime()
324
- try {
325
- await fetch(item[1], { method: 'GET' })
326
- const end = new Date().getTime()
327
- info += ` ${item[0]} -> ${end - start} ms\n`
328
- } catch (e) {
329
- info += ` ${item[0]} -> failed\n`
330
- }
331
- }
318
+ info += ' local only\n'
332
319
  info += '```'
333
320
  // 构建 popBox 内容
334
321
  const popInfo = {
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.1.0",
4
+ "version": "5.3.0",
5
5
  "scripts": {
6
6
  "build:web": "npm --prefix client/web run build",
7
7
  "prepack": "npm run build:web",