koishi-plugin-chat-patch 3.0.2 → 5.0.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.
- package/client/vue/index.vue +60 -634
- package/client/web/dist/assets/AppIcon-DIku6-h0.png +0 -0
- package/client/web/dist/assets/AppIconDark-BYymN71t.png +0 -0
- package/client/web/dist/assets/CapacitorAppIcon-CSZwNhvi.png +0 -0
- package/client/web/dist/assets/CapacitorAppIconDark-BMvMOzsg.png +0 -0
- package/client/web/dist/assets/Chat-CTdyeaX2.css +1 -0
- package/client/web/dist/assets/Chat-DkZvD7d8.js +28 -0
- package/client/web/dist/assets/MealHungryPan-Beos3lRI.js +1 -0
- package/client/web/dist/assets/MsgBody-aZ4_aija.js +1 -0
- package/client/web/dist/assets/MsgBody.vue_vue_type_script_setup_true_lang-CPZjRLp6.js +67 -0
- package/client/web/dist/assets/NapcatAppIcon-C7VOAkW9.png +0 -0
- package/client/web/dist/assets/Vue-lEhHouxB.png +0 -0
- package/client/web/dist/assets/append_darwin-CqBNU62J.css +1 -0
- package/client/web/dist/assets/append_full_vibrancy-j0D2LM9m.css +1 -0
- package/client/web/dist/assets/append_linux-uhxeBqeC.css +1 -0
- package/client/web/dist/assets/append_linux_vibrancy-COiZq8MS.css +1 -0
- package/client/web/dist/assets/append_napcat-DV8CAyAd.css +1 -0
- package/client/web/dist/assets/append_new-407Lo5_V.css +1 -0
- package/client/web/dist/assets/append_vibrancy-6FHctkOY.css +1 -0
- package/client/web/dist/assets/append_win32-srmD-78y.css +1 -0
- package/client/web/dist/assets/cakes-CxTVKdnK.svg +189 -0
- package/client/web/dist/assets/core-DhEqZVGG.js +1 -0
- package/client/web/dist/assets/event-Cadp6m6J.js +1 -0
- package/client/web/dist/assets/index-CPTXiemn.js +4045 -0
- package/client/web/dist/assets/index-Cg_esKB0.js +1 -0
- package/client/web/dist/assets/index-Cln012sP.css +1 -0
- package/client/web/dist/assets//346/226/271/346/255/243/345/226/265/345/221/234/344/275/223-CJKIKBn3.ttf +0 -0
- package/client/web/dist/assets//346/234/237/345/276/205-C90_OY60.png +0 -0
- package/client/web/dist/bcui/css/color-dark.css +35 -0
- package/client/web/dist/bcui/css/color-light.css +35 -0
- package/client/web/dist/bcui/css/style.css +468 -0
- package/client/web/dist/bcui/js/main.js +193 -0
- package/client/web/dist/css/append-dark.css +13 -0
- package/client/web/dist/css/append-light.css +13 -0
- package/client/web/dist/css/append-napcat-dark.css +14 -0
- package/client/web/dist/css/append-napcat-light.css +14 -0
- package/client/web/dist/favicon.ico +0 -0
- package/client/web/dist/img/icons/icon-for-fuck-apple.png +0 -0
- package/client/web/dist/img/icons/icon-maskable.png +0 -0
- package/client/web/dist/img/icons/icon.png +0 -0
- package/client/web/dist/img/icons/icon.svg +10 -0
- package/client/web/dist/index.html +22 -0
- package/client/web/dist/robots.txt +2 -0
- package/client/web/dist/sw.js +58 -0
- package/client/web/env.d.ts +56 -0
- package/client/web/index.html +21 -0
- package/client/web/package-lock.json +3419 -0
- package/client/web/package.json +62 -0
- package/client/web/public/bcui/css/color-dark.css +35 -0
- package/client/web/public/bcui/css/color-light.css +35 -0
- package/client/web/public/bcui/css/style.css +468 -0
- package/client/web/public/bcui/js/main.js +193 -0
- package/client/web/public/css/append-dark.css +13 -0
- package/client/web/public/css/append-light.css +13 -0
- package/client/web/public/css/append-napcat-dark.css +14 -0
- package/client/web/public/css/append-napcat-light.css +14 -0
- package/client/web/public/favicon.ico +0 -0
- package/client/web/public/img/icons/icon-for-fuck-apple.png +0 -0
- package/client/web/public/img/icons/icon-maskable.png +0 -0
- package/client/web/public/img/icons/icon.png +0 -0
- package/client/web/public/img/icons/icon.svg +10 -0
- package/client/web/public/robots.txt +2 -0
- package/client/web/public/sw.js +58 -0
- package/client/web/scripts/copy-bcui.mjs +17 -0
- package/client/web/src/App.vue +1127 -0
- package/client/web/src/assets/css/append/append_darwin.css +68 -0
- package/client/web/src/assets/css/append/append_full_vibrancy.css +290 -0
- package/client/web/src/assets/css/append/append_linux.css +125 -0
- package/client/web/src/assets/css/append/append_linux_vibrancy.css +22 -0
- package/client/web/src/assets/css/append/append_napcat.css +35 -0
- package/client/web/src/assets/css/append/append_new.css +843 -0
- package/client/web/src/assets/css/append/append_vibrancy.css +113 -0
- package/client/web/src/assets/css/append/append_win32.css +109 -0
- package/client/web/src/assets/css/append/mobile/append_mobile_horizontal.css +349 -0
- package/client/web/src/assets/css/append/mobile/append_mobile_vertical.css +96 -0
- package/client/web/src/assets/css/chat.css +2104 -0
- package/client/web/src/assets/css/msg.css +941 -0
- package/client/web/src/assets/css/options.css +811 -0
- package/client/web/src/assets/css/sys_notice.css +62 -0
- package/client/web/src/assets/css/view.css +2105 -0
- package/client/web/src/assets/font//346/226/271/346/255/243/345/226/265/345/221/234/344/275/223.ttf +0 -0
- package/client/web/src/assets/img/Vue.png +0 -0
- package/client/web/src/assets/img/cakes.svg +189 -0
- package/client/web/src/assets/img/icons/AppIcon.png +0 -0
- package/client/web/src/assets/img/icons/AppIconDark.png +0 -0
- package/client/web/src/assets/img/icons/CapacitorAppIcon.png +0 -0
- package/client/web/src/assets/img/icons/CapacitorAppIconDark.png +0 -0
- package/client/web/src/assets/img/icons/NapcatAppIcon.png +0 -0
- package/client/web/src/assets/img/icons/NapcatAppIconDark.png +0 -0
- package/client/web/src/assets/img/icons/exit.png +0 -0
- package/client/web/src/assets/img/icons/pen.png +0 -0
- package/client/web/src/assets/img/stars.svg +89 -0
- package/client/web/src/assets/img//346/234/237/345/276/205.png +0 -0
- package/client/web/src/assets/l10n/_About I10n.md +35 -0
- package/client/web/src/assets/l10n/_l10nconfig.json +7 -0
- package/client/web/src/assets/l10n/zh-CN.po +1941 -0
- package/client/web/src/assets/logo.png +0 -0
- package/client/web/src/assets/pathMap/LLOneBot.yaml +2 -0
- package/client/web/src/assets/pathMap/Lagrange.OneBot.yaml +180 -0
- package/client/web/src/assets/pathMap/NapCat.Onebot.yaml +224 -0
- package/client/web/src/assets/pathMap/SnowLuma.yaml +80 -0
- package/client/web/src/assets/qed.txt +1 -0
- package/client/web/src/components/AboutPan.vue +197 -0
- package/client/web/src/components/BulletinBody.vue +129 -0
- package/client/web/src/components/DepPan.vue +310 -0
- package/client/web/src/components/EmojiFace.vue +32 -0
- package/client/web/src/components/FacePan.vue +461 -0
- package/client/web/src/components/FileBody.vue +129 -0
- package/client/web/src/components/FileManager.vue +532 -0
- package/client/web/src/components/FriendBody.vue +54 -0
- package/client/web/src/components/GlobalSessionSearchBar.vue +301 -0
- package/client/web/src/components/History.vue +49 -0
- package/client/web/src/components/LazyLottie.vue +82 -0
- package/client/web/src/components/MergePan.vue +127 -0
- package/client/web/src/components/MsgBody.vue +1478 -0
- package/client/web/src/components/MusicPlayer.vue +549 -0
- package/client/web/src/components/NoticeBody.vue +168 -0
- package/client/web/src/components/QzonePermissionPan.vue +150 -0
- package/client/web/src/components/RawMsgRenderPreviewPan.vue +190 -0
- package/client/web/src/components/ThemeColorPickerPan.vue +420 -0
- package/client/web/src/components/TinySessionBody.vue +51 -0
- package/client/web/src/components/UmamiInfoPan.vue +1549 -0
- package/client/web/src/components/UpdatePan.vue +263 -0
- package/client/web/src/components/ViewerCom.vue +1360 -0
- package/client/web/src/components/VoiceMsg.vue +626 -0
- package/client/web/src/components/WelPan.vue +894 -0
- package/client/web/src/components/msg-body/.gitkeep +0 -0
- package/client/web/src/components/msg-component/JsonSegComp.vue +138 -0
- package/client/web/src/components/msg-component/XmlSegComp.vue +132 -0
- package/client/web/src/components/msg-component/jsonComp/AutoReply.vue +97 -0
- package/client/web/src/components/msg-component/jsonComp/Contact.lua.vue +129 -0
- package/client/web/src/components/msg-component/jsonComp/Feed.lua.vue +94 -0
- package/client/web/src/components/msg-component/jsonComp/Forum.vue +84 -0
- package/client/web/src/components/msg-component/jsonComp/Mannounce.vue +111 -0
- package/client/web/src/components/msg-component/jsonComp/Map.vue +52 -0
- package/client/web/src/components/msg-component/jsonComp/Miniapp.lua.vue +53 -0
- package/client/web/src/components/msg-component/jsonComp/Miniapp.vue +69 -0
- package/client/web/src/components/msg-component/jsonComp/Music.lua.vue +135 -0
- package/client/web/src/components/msg-component/jsonComp/Tuwen.lua.vue +56 -0
- package/client/web/src/components/notice-component/.gitkeep +0 -0
- package/client/web/src/components/notice-component/MealHungryPan.vue +119 -0
- package/client/web/src/components/tooltip/CustomFaceTooltip.vue +22 -0
- package/client/web/src/components/tooltip/Tooltip.vue +50 -0
- package/client/web/src/components/tooltip/Tooltips.vue +14 -0
- package/client/web/src/components/tooltip/UserInfoTooltip.vue +69 -0
- package/client/web/src/function/base.ts +238 -0
- package/client/web/src/function/connect.ts +2042 -0
- package/client/web/src/function/debug.ts +10 -0
- package/client/web/src/function/elements/information.ts +141 -0
- package/client/web/src/function/elements/system.ts +101 -0
- package/client/web/src/function/elements/vueComp.ts +62 -0
- package/client/web/src/function/favicon.ts +76 -0
- package/client/web/src/function/input.ts +69 -0
- package/client/web/src/function/model/emoji.ts +127 -0
- package/client/web/src/function/model/img.ts +150 -0
- package/client/web/src/function/model/msg-body.ts +51 -0
- package/client/web/src/function/msg.ts +2674 -0
- package/client/web/src/function/notify.ts +225 -0
- package/client/web/src/function/option.ts +749 -0
- package/client/web/src/function/satori-model.ts +818 -0
- package/client/web/src/function/satori.ts +325 -0
- package/client/web/src/function/sender.ts +178 -0
- package/client/web/src/function/tooltip.ts +49 -0
- package/client/web/src/function/utils/appUtil.ts +2288 -0
- package/client/web/src/function/utils/avatarUtil.ts +31 -0
- package/client/web/src/function/utils/backgroundUtil.ts +110 -0
- package/client/web/src/function/utils/linkViewUtil.ts +101 -0
- package/client/web/src/function/utils/localHistoryUtil.ts +517 -0
- package/client/web/src/function/utils/msgUtil.ts +1242 -0
- package/client/web/src/function/utils/pinyin.ts +141 -0
- package/client/web/src/function/utils/recordUtil.ts +187 -0
- package/client/web/src/function/utils/sessionUtil.ts +114 -0
- package/client/web/src/function/utils/systemUtil.ts +664 -0
- package/client/web/src/main.ts +91 -0
- package/client/web/src/pages/Chat.vue +3453 -0
- package/client/web/src/pages/Friends.vue +636 -0
- package/client/web/src/pages/Info.vue +717 -0
- package/client/web/src/pages/Messages.vue +875 -0
- package/client/web/src/pages/Options.vue +82 -0
- package/client/web/src/pages/Qzone.vue +1178 -0
- package/client/web/src/pages/chat-view/ChatDanmaku.vue +759 -0
- package/client/web/src/pages/chat-view/ChatGlagame.vue +642 -0
- package/client/web/src/pages/chat-view/ChatTerminal.vue +1044 -0
- package/client/web/src/pages/chat-view/SystemNotice.vue +171 -0
- package/client/web/src/pages/options/OptAccount.vue +107 -0
- package/client/web/src/pages/options/OptAddon.vue +185 -0
- package/client/web/src/pages/options/OptDev.vue +704 -0
- package/client/web/src/pages/options/OptFunction.vue +403 -0
- package/client/web/src/pages/options/OptInfo.vue +165 -0
- package/client/web/src/pages/options/OptView.vue +846 -0
- package/client/web/src/runtime/backend.ts +310 -0
- package/client/web/src/state/auth.ts +14 -0
- package/client/web/src/state/chat.ts +36 -0
- package/client/web/src/state/connection.ts +20 -0
- package/client/web/src/state/contact.ts +37 -0
- package/client/web/src/state/qzone.ts +18 -0
- package/client/web/src/state/sessionHistory.ts +25 -0
- package/client/web/src/state/settings.ts +18 -0
- package/client/web/src/state/sticker.ts +10 -0
- package/client/web/src/state/ui.ts +56 -0
- package/client/web/tsconfig.json +27 -0
- package/client/web/tsconfig.tsbuildinfo +1 -0
- package/client/web/vite.config.ts +33 -0
- package/dist/index.js +1 -12
- package/dist/style.css +1 -1
- package/lib/index.js +2070 -2077
- package/package.json +15 -2
- package/readme.md +0 -22
- package/src/bootstrap.ts +71 -0
- package/src/cache.ts +319 -0
- package/src/config.ts +23 -35
- package/src/database.ts +650 -0
- package/src/index.ts +27 -59
- package/src/media.ts +302 -0
- package/src/recorder.ts +175 -0
- package/src/self-message.ts +456 -0
- package/src/server.d.ts +26 -0
- package/src/types.ts +108 -48
- package/src/web.ts +712 -0
- package/client/vue/chat-logic.ts +0 -683
- package/client/vue/composables/useChatActions.ts +0 -61
- package/client/vue/composables/useChatData.ts +0 -185
- package/client/vue/composables/useImageCache.ts +0 -281
- package/client/vue/composables/useVideoCache.ts +0 -125
- package/client/vue/types.ts +0 -72
- package/lib/api-handlers.d.ts +0 -25
- package/lib/config.d.ts +0 -14
- package/lib/file-manager.d.ts +0 -124
- package/lib/index.d.ts +0 -17
- package/lib/logger.d.ts +0 -9
- package/lib/message-handler.d.ts +0 -35
- package/lib/types.d.ts +0 -57
- package/lib/utils.d.ts +0 -18
- package/src/api-handlers.ts +0 -646
- package/src/file-manager.ts +0 -1436
- package/src/message-handler.ts +0 -507
- package/src/utils.ts +0 -189
|
@@ -0,0 +1,636 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @FileDescription: 联系人列表页面
|
|
3
|
+
* @Author: Stapxs
|
|
4
|
+
* @Date:
|
|
5
|
+
* 2022/08/14
|
|
6
|
+
* 2022/12/12
|
|
7
|
+
* @Version:
|
|
8
|
+
* 1.0 - 初始版本
|
|
9
|
+
* 1.5 - 重构为 ts 版本,代码格式优化
|
|
10
|
+
-->
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<div class="friend-view">
|
|
14
|
+
<div id="friend-list" :class="'friend-list' + (uiStore.openSideBar ? ' open' : '')">
|
|
15
|
+
<div>
|
|
16
|
+
<div class="base">
|
|
17
|
+
<span>{{ $t('列表') }}</span>
|
|
18
|
+
<div style="flex: 1" />
|
|
19
|
+
<font-awesome-icon :icon="['fas', 'rotate-right']" @click="reloadUser" />
|
|
20
|
+
</div>
|
|
21
|
+
<div id="friend-small-search" class="small">
|
|
22
|
+
<label>
|
|
23
|
+
<input
|
|
24
|
+
id="friend-search-small"
|
|
25
|
+
v-model="searchInfo"
|
|
26
|
+
v-auto-focus type="text"
|
|
27
|
+
:placeholder="$t('搜索 ……')" @input="search">
|
|
28
|
+
<font-awesome-icon :icon="['fas', 'magnifying-glass']" />
|
|
29
|
+
</label>
|
|
30
|
+
<div class="reload" @click="reloadUser">
|
|
31
|
+
<font-awesome-icon :icon="['fas', 'rotate-right']" />
|
|
32
|
+
</div>
|
|
33
|
+
<div @click="openLeftBar">
|
|
34
|
+
<font-awesome-icon :icon="['fas', 'bars-staggered']" />
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
<label>
|
|
38
|
+
<input
|
|
39
|
+
id="friend-search"
|
|
40
|
+
v-model="searchInfo"
|
|
41
|
+
v-auto-focus
|
|
42
|
+
type="text"
|
|
43
|
+
:placeholder="$t('搜索 ……')" @input="search">
|
|
44
|
+
<font-awesome-icon :icon="['fas', 'magnifying-glass']" />
|
|
45
|
+
</label>
|
|
46
|
+
</div>
|
|
47
|
+
<div class="robot-accordion-list">
|
|
48
|
+
<div v-if="isSearch" class="search-result-list">
|
|
49
|
+
<div v-if="contactStore.showList.length === 0" class="empty-state">
|
|
50
|
+
{{ $t('空') }}
|
|
51
|
+
</div>
|
|
52
|
+
<FriendBody v-for="item in contactStore.showList"
|
|
53
|
+
:key="'search-' + item.user_id + '-' + item.group_id"
|
|
54
|
+
:data="item"
|
|
55
|
+
from="friend"
|
|
56
|
+
@click="userClick(item, $event)" />
|
|
57
|
+
</div>
|
|
58
|
+
<template v-else>
|
|
59
|
+
<div v-for="bot in satoriLogins" :key="'bot-' + bot.selfId"
|
|
60
|
+
:class="['robot-accordion', { expanded: bot.selfId === activeBotId }]">
|
|
61
|
+
<div class="robot-accordion-header" @click="toggleRobot(bot)">
|
|
62
|
+
<img :src="bot.avatar || '/img/icons/icon.svg'" :alt="bot.name" @error="avatarError">
|
|
63
|
+
<div>
|
|
64
|
+
<span :title="bot.name">{{ bot.name }}</span>
|
|
65
|
+
<small>{{ bot.platform }}</small>
|
|
66
|
+
</div>
|
|
67
|
+
<font-awesome-icon :icon="['fas', bot.selfId === activeBotId ? 'angle-up' : 'angle-down']" />
|
|
68
|
+
</div>
|
|
69
|
+
<div v-if="bot.selfId === activeBotId" class="robot-accordion-content">
|
|
70
|
+
<div v-if="!contactStore.friendLoading && contactStore.userList.length === 0"
|
|
71
|
+
class="empty-state">
|
|
72
|
+
{{ $t('空') }}
|
|
73
|
+
</div>
|
|
74
|
+
<div v-else :class="uiStore.openSideBar ? 'open' : ''">
|
|
75
|
+
<template v-if="contactStore.showList.length <= 0">
|
|
76
|
+
<template v-if="settingsStore.classes.length > 0">
|
|
77
|
+
<template v-for="info in settingsStore.classes"
|
|
78
|
+
:key="'class-' + info.class_id">
|
|
79
|
+
<div :class=" 'list exp-body' +
|
|
80
|
+
(classStatus[info.class_id] == true ? ' open' : '')">
|
|
81
|
+
<header :title="info.class_name"
|
|
82
|
+
:class="'exp-header' +
|
|
83
|
+
(uiStore.openSideBar ? ' open' : '')"
|
|
84
|
+
@click="classClick(info.class_id)">
|
|
85
|
+
<div />
|
|
86
|
+
<span>{{ info.class_name }}</span>
|
|
87
|
+
<a v-if="contactStore.friendLoading && info.class_id == 0">{{
|
|
88
|
+
contactStore.friendLoadedCount
|
|
89
|
+
}} / {{ contactStore.friendTotalCount }}</a>
|
|
90
|
+
<a v-else>{{
|
|
91
|
+
info.user_count ??
|
|
92
|
+
contactStore.userList.filter((get) => {
|
|
93
|
+
return get.class_id == info.class_id
|
|
94
|
+
}).length
|
|
95
|
+
}}</a>
|
|
96
|
+
</header>
|
|
97
|
+
<div :id="'class-' + info.class_id">
|
|
98
|
+
<FriendBody v-for="item in contactStore.userList.filter(
|
|
99
|
+
(get) => {
|
|
100
|
+
return ( get.class_id == info.class_id )
|
|
101
|
+
},
|
|
102
|
+
)"
|
|
103
|
+
:key=" 'fb-' + (item.user_id ? item.user_id : item.group_id) "
|
|
104
|
+
:data="item" from="friend"
|
|
105
|
+
@click="userClick(item, $event)" />
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
</template>
|
|
109
|
+
<div :class="'list exp-body' + (classStatus['-1'] == true ? ' open' : '')">
|
|
110
|
+
<header :title="$t('群组')"
|
|
111
|
+
:class="'exp-header' +
|
|
112
|
+
(uiStore.openSideBar ? ' open' : '') "
|
|
113
|
+
@click="classClick('-1')">
|
|
114
|
+
<div />
|
|
115
|
+
<span>{{ $t('群组') }}</span>
|
|
116
|
+
<a>{{
|
|
117
|
+
contactStore.userList.filter((get) => {
|
|
118
|
+
return get.class_id == undefined
|
|
119
|
+
}).length
|
|
120
|
+
}}</a>
|
|
121
|
+
</header>
|
|
122
|
+
<div>
|
|
123
|
+
<FriendBody v-for="item in contactStore.userList.filter(
|
|
124
|
+
(get) => {
|
|
125
|
+
return get.class_id == undefined
|
|
126
|
+
},
|
|
127
|
+
)"
|
|
128
|
+
:key="'fb-' + (item.user_id ? item.user_id : item.group_id)"
|
|
129
|
+
:data="item"
|
|
130
|
+
from="friend"
|
|
131
|
+
@click="userClick(item, $event)" />
|
|
132
|
+
</div>
|
|
133
|
+
</div>
|
|
134
|
+
</template>
|
|
135
|
+
<template v-else>
|
|
136
|
+
<FriendBody v-for="item in contactStore.userList"
|
|
137
|
+
:key="'fb-' + (item.user_id ? item.user_id : item.group_id)"
|
|
138
|
+
:data="item"
|
|
139
|
+
from="friend"
|
|
140
|
+
@click="userClick(item, $event)" />
|
|
141
|
+
</template>
|
|
142
|
+
</template>
|
|
143
|
+
<!-- 搜索用的 -->
|
|
144
|
+
<div v-else class="list">
|
|
145
|
+
<div>
|
|
146
|
+
<FriendBody v-for="item in contactStore.showList"
|
|
147
|
+
:key="'fb-' + (item.user_id ? item.user_id : item.group_id)"
|
|
148
|
+
:data="item" from="friend"
|
|
149
|
+
@click="userClick(item, $event)" />
|
|
150
|
+
</div>
|
|
151
|
+
</div>
|
|
152
|
+
</div>
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
</template>
|
|
156
|
+
</div>
|
|
157
|
+
</div>
|
|
158
|
+
<div :class="'friend-list-space' + (uiStore.openSideBar ? ' open' : '')">
|
|
159
|
+
<div v-if="!loginInfo.status || chatStore.chatInfo.show.id == 0" class="ss-card">
|
|
160
|
+
<font-awesome-icon :icon="['fas', 'inbox']" />
|
|
161
|
+
<span>{{ $t('选择联系人开始聊天') }}</span>
|
|
162
|
+
</div>
|
|
163
|
+
<div v-else-if="chatStore.messageList.length > 0" class="ss-card cd">
|
|
164
|
+
<font-awesome-icon :icon="['fas', 'angles-right']" />
|
|
165
|
+
<span>(っ≧ω≦)っ</span>
|
|
166
|
+
<span>{{ $t('别划了别划了被看见了啦') }}</span>
|
|
167
|
+
</div>
|
|
168
|
+
</div>
|
|
169
|
+
</div>
|
|
170
|
+
</template>
|
|
171
|
+
|
|
172
|
+
<script setup lang="ts">
|
|
173
|
+
import { computed, ref, onMounted, watch } from 'vue'
|
|
174
|
+
import { vAutoFocus } from '../function/utils/appUtil'
|
|
175
|
+
|
|
176
|
+
import FriendBody from '../components/FriendBody.vue'
|
|
177
|
+
|
|
178
|
+
import {
|
|
179
|
+
BaseChatInfoElem,
|
|
180
|
+
UserFriendElem,
|
|
181
|
+
UserGroupElem,
|
|
182
|
+
} from '../function/elements/information'
|
|
183
|
+
|
|
184
|
+
import { reloadUsers } from '../function/utils/appUtil'
|
|
185
|
+
import { Connector, flushPendingBotEvents, loadContactsFromCache, login as loginInfo } from '../function/connect'
|
|
186
|
+
import { getActiveBot, getLogins, setActiveBot } from '../function/satori'
|
|
187
|
+
import { normalizeSessionId } from '../function/utils/sessionUtil'
|
|
188
|
+
import { avatarError } from '../function/utils/avatarUtil'
|
|
189
|
+
import { backend } from '../runtime/backend'
|
|
190
|
+
import { matchPinyin } from '../function/utils/pinyin'
|
|
191
|
+
import { useUIStore } from '../state/ui'
|
|
192
|
+
import { useSettingsStore } from '../state/settings'
|
|
193
|
+
import { useContactStore } from '../state/contact'
|
|
194
|
+
import { useChatStore } from '../state/chat'
|
|
195
|
+
import { useAuthStore } from '../state/auth'
|
|
196
|
+
|
|
197
|
+
defineOptions({ name: 'ViewFriends' })
|
|
198
|
+
|
|
199
|
+
const uiStore = useUIStore()
|
|
200
|
+
const settingsStore = useSettingsStore()
|
|
201
|
+
const contactStore = useContactStore()
|
|
202
|
+
const chatStore = useChatStore()
|
|
203
|
+
const authStore = useAuthStore()
|
|
204
|
+
const { list } = defineProps<{ list: (UserFriendElem & UserGroupElem)[] }>()
|
|
205
|
+
const emit = defineEmits<{
|
|
206
|
+
userClick: [data: BaseChatInfoElem]
|
|
207
|
+
loadHistory: [data: BaseChatInfoElem]
|
|
208
|
+
}>()
|
|
209
|
+
|
|
210
|
+
type ContactWithBot = UserFriendElem & UserGroupElem & {
|
|
211
|
+
_bot?: {
|
|
212
|
+
platform: string
|
|
213
|
+
selfId: string
|
|
214
|
+
name: string
|
|
215
|
+
avatar?: string
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const isSearch = ref(false)
|
|
220
|
+
const searchInfo = ref('')
|
|
221
|
+
const classStatus = ref<{ [key: string]: boolean }>({})
|
|
222
|
+
const satoriLogins = ref<Array<{ platform: string; selfId: string; name: string; avatar?: string; status?: number; features?: string[] }>>(getLogins())
|
|
223
|
+
const activeBotId = ref(getActiveBot()?.selfId ?? loginInfo.selectedSatoriBot ?? '')
|
|
224
|
+
|
|
225
|
+
watch(() => loginInfo.satoriLogins, (list) => {
|
|
226
|
+
satoriLogins.value = list ?? []
|
|
227
|
+
if (activeBotId.value && contactStore.userList.length === 0) {
|
|
228
|
+
void loadContactsFromCache()
|
|
229
|
+
}
|
|
230
|
+
}, { immediate: true })
|
|
231
|
+
|
|
232
|
+
const currentBotName = computed(() => {
|
|
233
|
+
return satoriLogins.value.find((item) => item.selfId === activeBotId.value)?.name ?? ''
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
const allContacts = computed<ContactWithBot[]>(() => {
|
|
237
|
+
const map = new Map<string, ContactWithBot>()
|
|
238
|
+
const addContacts = (
|
|
239
|
+
items: (UserFriendElem & UserGroupElem)[],
|
|
240
|
+
bot?: ContactWithBot['_bot'],
|
|
241
|
+
) => {
|
|
242
|
+
for (const item of items) {
|
|
243
|
+
const id = String(item.user_id ?? item.group_id ?? '')
|
|
244
|
+
const key = [bot?.platform ?? '', bot?.selfId ?? '', id]
|
|
245
|
+
.map((value) => encodeURIComponent(String(value)))
|
|
246
|
+
.join(':')
|
|
247
|
+
map.set(key, { ...item, _bot: bot })
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
const currentBot = satoriLogins.value.find((item) => item.selfId === activeBotId.value)
|
|
251
|
+
addContacts(contactStore.userList, currentBot)
|
|
252
|
+
for (const [selfId, state] of contactStore.botStates) {
|
|
253
|
+
const bot = satoriLogins.value.find((item) => item.selfId === selfId)
|
|
254
|
+
addContacts(state.userList, bot)
|
|
255
|
+
}
|
|
256
|
+
return [...map.values()]
|
|
257
|
+
})
|
|
258
|
+
|
|
259
|
+
function snapshotCurrentBot() {
|
|
260
|
+
const id = activeBotId.value
|
|
261
|
+
if (!id) return
|
|
262
|
+
contactStore.botStates.set(id, {
|
|
263
|
+
userList: [...contactStore.userList],
|
|
264
|
+
baseList: Array.from(contactStore.baseOnMsgList.entries()),
|
|
265
|
+
onMsgList: [...contactStore.onMsgList],
|
|
266
|
+
})
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function backToRobots() {
|
|
270
|
+
snapshotCurrentBot()
|
|
271
|
+
activeBotId.value = ''
|
|
272
|
+
chatStore.messageList = []
|
|
273
|
+
chatStore.chatInfo.show.id = 0
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function selectRobot(bot: { platform: string; selfId: string; name: string; avatar?: string; features?: string[] }) {
|
|
277
|
+
if (bot.selfId === activeBotId.value) return
|
|
278
|
+
snapshotCurrentBot()
|
|
279
|
+
activeBotId.value = bot.selfId
|
|
280
|
+
setActiveBot(bot.platform, bot.selfId)
|
|
281
|
+
loginInfo.uin = bot.selfId
|
|
282
|
+
loginInfo.nickname = bot.name
|
|
283
|
+
loginInfo.platform = bot.platform
|
|
284
|
+
authStore.loginInfo = {
|
|
285
|
+
...authStore.loginInfo,
|
|
286
|
+
uin: bot.selfId,
|
|
287
|
+
user_id: bot.selfId,
|
|
288
|
+
nickname: bot.name,
|
|
289
|
+
platform: bot.platform,
|
|
290
|
+
avatar: bot.avatar,
|
|
291
|
+
satoriLogins: satoriLogins.value,
|
|
292
|
+
selectedSatoriBot: bot.selfId,
|
|
293
|
+
}
|
|
294
|
+
const saved = contactStore.botStates.get(bot.selfId)
|
|
295
|
+
if (saved) {
|
|
296
|
+
contactStore.userList = saved.userList
|
|
297
|
+
contactStore.baseOnMsgList.clear()
|
|
298
|
+
for (const [key, value] of saved.baseList) {
|
|
299
|
+
contactStore.baseOnMsgList.set(normalizeSessionId(key), value)
|
|
300
|
+
}
|
|
301
|
+
contactStore.onMsgList = saved.onMsgList
|
|
302
|
+
flushPendingBotEvents(bot.platform, bot.selfId)
|
|
303
|
+
} else {
|
|
304
|
+
contactStore.userList = []
|
|
305
|
+
contactStore.baseOnMsgList.clear()
|
|
306
|
+
contactStore.onMsgList = []
|
|
307
|
+
chatStore.messageList = []
|
|
308
|
+
chatStore.chatInfo.show.id = 0
|
|
309
|
+
flushPendingBotEvents(bot.platform, bot.selfId)
|
|
310
|
+
void loadContactsFromCache()
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function toggleRobot(bot: { platform: string; selfId: string; name: string; avatar?: string; features?: string[] }) {
|
|
315
|
+
if (activeBotId.value === bot.selfId) {
|
|
316
|
+
backToRobots()
|
|
317
|
+
} else {
|
|
318
|
+
selectRobot(bot)
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
onMounted(() => {
|
|
323
|
+
if (activeBotId.value && contactStore.userList.length === 0) {
|
|
324
|
+
void loadContactsFromCache()
|
|
325
|
+
}
|
|
326
|
+
// 判断 friend-small-search 是否 display none
|
|
327
|
+
const smallSearch = document.getElementById('friend-small-search')
|
|
328
|
+
if(smallSearch) {
|
|
329
|
+
const style = window.getComputedStyle(smallSearch)
|
|
330
|
+
let name = 'friend-search'
|
|
331
|
+
if(style.display != 'none') {
|
|
332
|
+
name = 'friend-search-small'
|
|
333
|
+
}
|
|
334
|
+
// 将焦点移动到搜索框
|
|
335
|
+
if(backend.isDesktop()) {
|
|
336
|
+
const search = document.getElementById(name)
|
|
337
|
+
if(search) {
|
|
338
|
+
search.focus()
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
})
|
|
343
|
+
|
|
344
|
+
function getShowName(data: UserFriendElem & UserGroupElem) {
|
|
345
|
+
const group = data.group_name
|
|
346
|
+
const remark = data.remark
|
|
347
|
+
const nickname = data.nickname
|
|
348
|
+
if (group) return group
|
|
349
|
+
else {
|
|
350
|
+
if (!remark || remark == nickname) {
|
|
351
|
+
return nickname
|
|
352
|
+
} else {
|
|
353
|
+
return remark + '(' + nickname + ')'
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function openLeftBar() {
|
|
359
|
+
uiStore.openSideBar = !uiStore.openSideBar
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function classClick(id: string) {
|
|
363
|
+
if (classStatus.value[id]) {
|
|
364
|
+
classStatus.value[id] = !classStatus.value[id]
|
|
365
|
+
} else {
|
|
366
|
+
classStatus.value[id] = true
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function userClick(data: ContactWithBot, event: Event) {
|
|
371
|
+
if (data._bot && data._bot.selfId !== activeBotId.value) {
|
|
372
|
+
selectRobot(data._bot)
|
|
373
|
+
}
|
|
374
|
+
const sender = event.currentTarget as HTMLDivElement
|
|
375
|
+
if (uiStore.openSideBar) {
|
|
376
|
+
openLeftBar()
|
|
377
|
+
}
|
|
378
|
+
isSearch.value = false
|
|
379
|
+
searchInfo.value = ''
|
|
380
|
+
contactStore.showList = [] as any[]
|
|
381
|
+
|
|
382
|
+
const back = {
|
|
383
|
+
type: data.user_id ? 'user' : 'group',
|
|
384
|
+
id: data.user_id ? data.user_id : data.group_id,
|
|
385
|
+
name: getShowName(data),
|
|
386
|
+
avatar: data.avatar || '/img/icons/icon.svg',
|
|
387
|
+
jump: sender.dataset.jump,
|
|
388
|
+
channel_id: data.channel_id,
|
|
389
|
+
guild_id: data.guild_id,
|
|
390
|
+
} as BaseChatInfoElem
|
|
391
|
+
if (back.id === undefined || back.id === null || String(back.id) === '' || String(back.id) === '0') return
|
|
392
|
+
// 更新聊天框
|
|
393
|
+
emit('userClick', back)
|
|
394
|
+
contactStore.baseOnMsgList.set(normalizeSessionId(back.id), data)
|
|
395
|
+
// 获取历史消息
|
|
396
|
+
if(!uiStore.nowGetHistory) {
|
|
397
|
+
emit('loadHistory', back)
|
|
398
|
+
}
|
|
399
|
+
// 切换标签卡
|
|
400
|
+
const barMsg = document.getElementById('bar-msg')
|
|
401
|
+
if (barMsg !== null) {
|
|
402
|
+
barMsg.click()
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function search(event: Event) {
|
|
407
|
+
const value = (event.target as HTMLInputElement).value.toLocaleLowerCase()
|
|
408
|
+
if (value !== '') {
|
|
409
|
+
isSearch.value = true
|
|
410
|
+
contactStore.showList = allContacts.value.filter(
|
|
411
|
+
(item: ContactWithBot) => {
|
|
412
|
+
const name = (
|
|
413
|
+
item.user_id? item.nickname + item.remark: item.group_name
|
|
414
|
+
).toLowerCase()
|
|
415
|
+
if (name.includes(value)) return true
|
|
416
|
+
const id = item.user_id? item.user_id: item.group_id
|
|
417
|
+
if (id.toString() === value) return true
|
|
418
|
+
if (item.py_name && matchPinyin(item.py_name, value)) return true
|
|
419
|
+
return false
|
|
420
|
+
},
|
|
421
|
+
)
|
|
422
|
+
} else {
|
|
423
|
+
isSearch.value = false
|
|
424
|
+
contactStore.showList = [] as any[]
|
|
425
|
+
}
|
|
426
|
+
// macOS: 刷新 TouchBar
|
|
427
|
+
if(backend.isDesktop()) {
|
|
428
|
+
// list 只需要 id 和 name
|
|
429
|
+
backend.call(undefined, 'sys:flushFriendSearch', false,
|
|
430
|
+
contactStore.showList.map((item) => {
|
|
431
|
+
return {
|
|
432
|
+
id: item.user_id ? item.user_id : item.group_id,
|
|
433
|
+
name: getShowName(item)
|
|
434
|
+
}
|
|
435
|
+
}))
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function reloadUser() {
|
|
440
|
+
reloadUsers()
|
|
441
|
+
}
|
|
442
|
+
</script>
|
|
443
|
+
|
|
444
|
+
<style scoped>
|
|
445
|
+
.robot-list-body {
|
|
446
|
+
padding: 4px 0;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
.robot-item {
|
|
450
|
+
display: flex;
|
|
451
|
+
align-items: center;
|
|
452
|
+
gap: 8px;
|
|
453
|
+
padding: 10px 12px;
|
|
454
|
+
cursor: pointer;
|
|
455
|
+
border-left: 3px solid transparent;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
.robot-item:hover {
|
|
459
|
+
background: var(--color-hover-bg, rgba(0, 0, 0, 0.04));
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
.robot-item.active {
|
|
463
|
+
border-left-color: var(--color-main, #3b82f6);
|
|
464
|
+
background: var(--color-active-bg, rgba(59, 130, 246, 0.08));
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
.robot-item img {
|
|
468
|
+
width: 32px;
|
|
469
|
+
height: 32px;
|
|
470
|
+
border-radius: 50%;
|
|
471
|
+
object-fit: cover;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
.robot-item div {
|
|
475
|
+
display: flex;
|
|
476
|
+
flex-direction: column;
|
|
477
|
+
min-width: 0;
|
|
478
|
+
flex: 1;
|
|
479
|
+
overflow: hidden;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
.robot-item span {
|
|
483
|
+
display: block;
|
|
484
|
+
font-size: 13px;
|
|
485
|
+
font-weight: 600;
|
|
486
|
+
max-width: 100%;
|
|
487
|
+
white-space: nowrap;
|
|
488
|
+
overflow: hidden;
|
|
489
|
+
text-overflow: ellipsis;
|
|
490
|
+
-webkit-mask-image: linear-gradient(to right, black 0%, black 70%, transparent 100%);
|
|
491
|
+
mask-image: linear-gradient(to right, black 0%, black 70%, transparent 100%);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
.robot-item small {
|
|
495
|
+
font-size: 11px;
|
|
496
|
+
opacity: 0.6;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
.robot-accordion-list {
|
|
500
|
+
height: 100%;
|
|
501
|
+
overflow-y: auto;
|
|
502
|
+
overflow-x: hidden;
|
|
503
|
+
}
|
|
504
|
+
.robot-accordion {
|
|
505
|
+
border-bottom: 1px solid var(--color-card-2, rgba(0, 0, 0, 0.08));
|
|
506
|
+
}
|
|
507
|
+
.robot-accordion-header {
|
|
508
|
+
display: flex;
|
|
509
|
+
align-items: center;
|
|
510
|
+
gap: 8px;
|
|
511
|
+
padding: 10px 12px;
|
|
512
|
+
cursor: pointer;
|
|
513
|
+
}
|
|
514
|
+
.robot-accordion-header:hover {
|
|
515
|
+
background: var(--color-hover-bg, rgba(0, 0, 0, 0.04));
|
|
516
|
+
}
|
|
517
|
+
.robot-accordion.expanded > .robot-accordion-header {
|
|
518
|
+
background: var(--color-active-bg, rgba(59, 130, 246, 0.08));
|
|
519
|
+
}
|
|
520
|
+
.robot-accordion-header img {
|
|
521
|
+
width: 32px;
|
|
522
|
+
height: 32px;
|
|
523
|
+
border-radius: 50%;
|
|
524
|
+
object-fit: cover;
|
|
525
|
+
flex-shrink: 0;
|
|
526
|
+
}
|
|
527
|
+
.robot-accordion-header > div {
|
|
528
|
+
display: flex;
|
|
529
|
+
flex-direction: column;
|
|
530
|
+
min-width: 0;
|
|
531
|
+
flex: 1;
|
|
532
|
+
overflow: hidden;
|
|
533
|
+
}
|
|
534
|
+
.robot-accordion-header span {
|
|
535
|
+
display: block;
|
|
536
|
+
font-size: 13px;
|
|
537
|
+
font-weight: 600;
|
|
538
|
+
max-width: 100%;
|
|
539
|
+
white-space: nowrap;
|
|
540
|
+
overflow: hidden;
|
|
541
|
+
text-overflow: ellipsis;
|
|
542
|
+
}
|
|
543
|
+
.robot-accordion-header small {
|
|
544
|
+
font-size: 11px;
|
|
545
|
+
opacity: 0.6;
|
|
546
|
+
}
|
|
547
|
+
.robot-accordion-header > svg {
|
|
548
|
+
opacity: 0.7;
|
|
549
|
+
flex-shrink: 0;
|
|
550
|
+
}
|
|
551
|
+
.robot-accordion-content {
|
|
552
|
+
padding: 2px 0 6px;
|
|
553
|
+
}
|
|
554
|
+
.search-result-list {
|
|
555
|
+
padding: 4px 0;
|
|
556
|
+
}
|
|
557
|
+
.empty-state {
|
|
558
|
+
display: flex;
|
|
559
|
+
align-items: center;
|
|
560
|
+
justify-content: center;
|
|
561
|
+
padding: 40px 0;
|
|
562
|
+
color: var(--color-font-2, #888);
|
|
563
|
+
opacity: 0.65;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
.friend-list > div:first-child > div.base > span {
|
|
567
|
+
min-width: 0;
|
|
568
|
+
overflow: hidden;
|
|
569
|
+
white-space: nowrap;
|
|
570
|
+
text-overflow: clip;
|
|
571
|
+
-webkit-mask-image: linear-gradient(to right, black 0%, black 65%, transparent 100%);
|
|
572
|
+
mask-image: linear-gradient(to right, black 0%, black 65%, transparent 100%);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
.exp-body > div {
|
|
576
|
+
/* transition: transform .3s;
|
|
577
|
+
transform-origin: top; */
|
|
578
|
+
transform: scaleY(0);
|
|
579
|
+
height: 0;
|
|
580
|
+
}
|
|
581
|
+
.exp-body.open > div {
|
|
582
|
+
transform: scaleY(1);
|
|
583
|
+
height: unset;
|
|
584
|
+
}
|
|
585
|
+
.exp-body > header > div {
|
|
586
|
+
transition:
|
|
587
|
+
margin-right 0.3s,
|
|
588
|
+
transform 0.3s;
|
|
589
|
+
transform: scaleY(0);
|
|
590
|
+
margin-right: 0;
|
|
591
|
+
width: 0;
|
|
592
|
+
}
|
|
593
|
+
.exp-body.open > header > div {
|
|
594
|
+
transform: scaleY(1);
|
|
595
|
+
margin-right: 10px;
|
|
596
|
+
width: 5px;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
.exp-header {
|
|
600
|
+
color: var(--color-font);
|
|
601
|
+
align-items: center;
|
|
602
|
+
border-radius: 7px;
|
|
603
|
+
cursor: pointer;
|
|
604
|
+
margin: 0 10px;
|
|
605
|
+
padding: 10px;
|
|
606
|
+
display: flex;
|
|
607
|
+
}
|
|
608
|
+
.exp-header:hover {
|
|
609
|
+
background: var(--color-card-2);
|
|
610
|
+
}
|
|
611
|
+
.exp-header > div {
|
|
612
|
+
background: var(--color-main);
|
|
613
|
+
margin-right: 10px;
|
|
614
|
+
border-radius: 7px;
|
|
615
|
+
height: 1rem;
|
|
616
|
+
width: 5px;
|
|
617
|
+
}
|
|
618
|
+
.exp-header > span {
|
|
619
|
+
flex: 1;
|
|
620
|
+
}
|
|
621
|
+
.exp-header > a {
|
|
622
|
+
color: var(--color-font-2);
|
|
623
|
+
font-size: 0.9rem;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
@media (max-width: 700px) {
|
|
627
|
+
.exp-header:not(.open) {
|
|
628
|
+
display: none;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
@media (max-width: 500px) {
|
|
632
|
+
.exp-header > span {
|
|
633
|
+
display: block !important;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
</style>
|