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.
Files changed (237) hide show
  1. package/client/vue/index.vue +60 -634
  2. package/client/web/dist/assets/AppIcon-DIku6-h0.png +0 -0
  3. package/client/web/dist/assets/AppIconDark-BYymN71t.png +0 -0
  4. package/client/web/dist/assets/CapacitorAppIcon-CSZwNhvi.png +0 -0
  5. package/client/web/dist/assets/CapacitorAppIconDark-BMvMOzsg.png +0 -0
  6. package/client/web/dist/assets/Chat-CTdyeaX2.css +1 -0
  7. package/client/web/dist/assets/Chat-DkZvD7d8.js +28 -0
  8. package/client/web/dist/assets/MealHungryPan-Beos3lRI.js +1 -0
  9. package/client/web/dist/assets/MsgBody-aZ4_aija.js +1 -0
  10. package/client/web/dist/assets/MsgBody.vue_vue_type_script_setup_true_lang-CPZjRLp6.js +67 -0
  11. package/client/web/dist/assets/NapcatAppIcon-C7VOAkW9.png +0 -0
  12. package/client/web/dist/assets/Vue-lEhHouxB.png +0 -0
  13. package/client/web/dist/assets/append_darwin-CqBNU62J.css +1 -0
  14. package/client/web/dist/assets/append_full_vibrancy-j0D2LM9m.css +1 -0
  15. package/client/web/dist/assets/append_linux-uhxeBqeC.css +1 -0
  16. package/client/web/dist/assets/append_linux_vibrancy-COiZq8MS.css +1 -0
  17. package/client/web/dist/assets/append_napcat-DV8CAyAd.css +1 -0
  18. package/client/web/dist/assets/append_new-407Lo5_V.css +1 -0
  19. package/client/web/dist/assets/append_vibrancy-6FHctkOY.css +1 -0
  20. package/client/web/dist/assets/append_win32-srmD-78y.css +1 -0
  21. package/client/web/dist/assets/cakes-CxTVKdnK.svg +189 -0
  22. package/client/web/dist/assets/core-DhEqZVGG.js +1 -0
  23. package/client/web/dist/assets/event-Cadp6m6J.js +1 -0
  24. package/client/web/dist/assets/index-CPTXiemn.js +4045 -0
  25. package/client/web/dist/assets/index-Cg_esKB0.js +1 -0
  26. package/client/web/dist/assets/index-Cln012sP.css +1 -0
  27. package/client/web/dist/assets//346/226/271/346/255/243/345/226/265/345/221/234/344/275/223-CJKIKBn3.ttf +0 -0
  28. package/client/web/dist/assets//346/234/237/345/276/205-C90_OY60.png +0 -0
  29. package/client/web/dist/bcui/css/color-dark.css +35 -0
  30. package/client/web/dist/bcui/css/color-light.css +35 -0
  31. package/client/web/dist/bcui/css/style.css +468 -0
  32. package/client/web/dist/bcui/js/main.js +193 -0
  33. package/client/web/dist/css/append-dark.css +13 -0
  34. package/client/web/dist/css/append-light.css +13 -0
  35. package/client/web/dist/css/append-napcat-dark.css +14 -0
  36. package/client/web/dist/css/append-napcat-light.css +14 -0
  37. package/client/web/dist/favicon.ico +0 -0
  38. package/client/web/dist/img/icons/icon-for-fuck-apple.png +0 -0
  39. package/client/web/dist/img/icons/icon-maskable.png +0 -0
  40. package/client/web/dist/img/icons/icon.png +0 -0
  41. package/client/web/dist/img/icons/icon.svg +10 -0
  42. package/client/web/dist/index.html +22 -0
  43. package/client/web/dist/robots.txt +2 -0
  44. package/client/web/dist/sw.js +58 -0
  45. package/client/web/env.d.ts +56 -0
  46. package/client/web/index.html +21 -0
  47. package/client/web/package-lock.json +3419 -0
  48. package/client/web/package.json +62 -0
  49. package/client/web/public/bcui/css/color-dark.css +35 -0
  50. package/client/web/public/bcui/css/color-light.css +35 -0
  51. package/client/web/public/bcui/css/style.css +468 -0
  52. package/client/web/public/bcui/js/main.js +193 -0
  53. package/client/web/public/css/append-dark.css +13 -0
  54. package/client/web/public/css/append-light.css +13 -0
  55. package/client/web/public/css/append-napcat-dark.css +14 -0
  56. package/client/web/public/css/append-napcat-light.css +14 -0
  57. package/client/web/public/favicon.ico +0 -0
  58. package/client/web/public/img/icons/icon-for-fuck-apple.png +0 -0
  59. package/client/web/public/img/icons/icon-maskable.png +0 -0
  60. package/client/web/public/img/icons/icon.png +0 -0
  61. package/client/web/public/img/icons/icon.svg +10 -0
  62. package/client/web/public/robots.txt +2 -0
  63. package/client/web/public/sw.js +58 -0
  64. package/client/web/scripts/copy-bcui.mjs +17 -0
  65. package/client/web/src/App.vue +1127 -0
  66. package/client/web/src/assets/css/append/append_darwin.css +68 -0
  67. package/client/web/src/assets/css/append/append_full_vibrancy.css +290 -0
  68. package/client/web/src/assets/css/append/append_linux.css +125 -0
  69. package/client/web/src/assets/css/append/append_linux_vibrancy.css +22 -0
  70. package/client/web/src/assets/css/append/append_napcat.css +35 -0
  71. package/client/web/src/assets/css/append/append_new.css +843 -0
  72. package/client/web/src/assets/css/append/append_vibrancy.css +113 -0
  73. package/client/web/src/assets/css/append/append_win32.css +109 -0
  74. package/client/web/src/assets/css/append/mobile/append_mobile_horizontal.css +349 -0
  75. package/client/web/src/assets/css/append/mobile/append_mobile_vertical.css +96 -0
  76. package/client/web/src/assets/css/chat.css +2104 -0
  77. package/client/web/src/assets/css/msg.css +941 -0
  78. package/client/web/src/assets/css/options.css +811 -0
  79. package/client/web/src/assets/css/sys_notice.css +62 -0
  80. package/client/web/src/assets/css/view.css +2105 -0
  81. package/client/web/src/assets/font//346/226/271/346/255/243/345/226/265/345/221/234/344/275/223.ttf +0 -0
  82. package/client/web/src/assets/img/Vue.png +0 -0
  83. package/client/web/src/assets/img/cakes.svg +189 -0
  84. package/client/web/src/assets/img/icons/AppIcon.png +0 -0
  85. package/client/web/src/assets/img/icons/AppIconDark.png +0 -0
  86. package/client/web/src/assets/img/icons/CapacitorAppIcon.png +0 -0
  87. package/client/web/src/assets/img/icons/CapacitorAppIconDark.png +0 -0
  88. package/client/web/src/assets/img/icons/NapcatAppIcon.png +0 -0
  89. package/client/web/src/assets/img/icons/NapcatAppIconDark.png +0 -0
  90. package/client/web/src/assets/img/icons/exit.png +0 -0
  91. package/client/web/src/assets/img/icons/pen.png +0 -0
  92. package/client/web/src/assets/img/stars.svg +89 -0
  93. package/client/web/src/assets/img//346/234/237/345/276/205.png +0 -0
  94. package/client/web/src/assets/l10n/_About I10n.md +35 -0
  95. package/client/web/src/assets/l10n/_l10nconfig.json +7 -0
  96. package/client/web/src/assets/l10n/zh-CN.po +1941 -0
  97. package/client/web/src/assets/logo.png +0 -0
  98. package/client/web/src/assets/pathMap/LLOneBot.yaml +2 -0
  99. package/client/web/src/assets/pathMap/Lagrange.OneBot.yaml +180 -0
  100. package/client/web/src/assets/pathMap/NapCat.Onebot.yaml +224 -0
  101. package/client/web/src/assets/pathMap/SnowLuma.yaml +80 -0
  102. package/client/web/src/assets/qed.txt +1 -0
  103. package/client/web/src/components/AboutPan.vue +197 -0
  104. package/client/web/src/components/BulletinBody.vue +129 -0
  105. package/client/web/src/components/DepPan.vue +310 -0
  106. package/client/web/src/components/EmojiFace.vue +32 -0
  107. package/client/web/src/components/FacePan.vue +461 -0
  108. package/client/web/src/components/FileBody.vue +129 -0
  109. package/client/web/src/components/FileManager.vue +532 -0
  110. package/client/web/src/components/FriendBody.vue +54 -0
  111. package/client/web/src/components/GlobalSessionSearchBar.vue +301 -0
  112. package/client/web/src/components/History.vue +49 -0
  113. package/client/web/src/components/LazyLottie.vue +82 -0
  114. package/client/web/src/components/MergePan.vue +127 -0
  115. package/client/web/src/components/MsgBody.vue +1478 -0
  116. package/client/web/src/components/MusicPlayer.vue +549 -0
  117. package/client/web/src/components/NoticeBody.vue +168 -0
  118. package/client/web/src/components/QzonePermissionPan.vue +150 -0
  119. package/client/web/src/components/RawMsgRenderPreviewPan.vue +190 -0
  120. package/client/web/src/components/ThemeColorPickerPan.vue +420 -0
  121. package/client/web/src/components/TinySessionBody.vue +51 -0
  122. package/client/web/src/components/UmamiInfoPan.vue +1549 -0
  123. package/client/web/src/components/UpdatePan.vue +263 -0
  124. package/client/web/src/components/ViewerCom.vue +1360 -0
  125. package/client/web/src/components/VoiceMsg.vue +626 -0
  126. package/client/web/src/components/WelPan.vue +894 -0
  127. package/client/web/src/components/msg-body/.gitkeep +0 -0
  128. package/client/web/src/components/msg-component/JsonSegComp.vue +138 -0
  129. package/client/web/src/components/msg-component/XmlSegComp.vue +132 -0
  130. package/client/web/src/components/msg-component/jsonComp/AutoReply.vue +97 -0
  131. package/client/web/src/components/msg-component/jsonComp/Contact.lua.vue +129 -0
  132. package/client/web/src/components/msg-component/jsonComp/Feed.lua.vue +94 -0
  133. package/client/web/src/components/msg-component/jsonComp/Forum.vue +84 -0
  134. package/client/web/src/components/msg-component/jsonComp/Mannounce.vue +111 -0
  135. package/client/web/src/components/msg-component/jsonComp/Map.vue +52 -0
  136. package/client/web/src/components/msg-component/jsonComp/Miniapp.lua.vue +53 -0
  137. package/client/web/src/components/msg-component/jsonComp/Miniapp.vue +69 -0
  138. package/client/web/src/components/msg-component/jsonComp/Music.lua.vue +135 -0
  139. package/client/web/src/components/msg-component/jsonComp/Tuwen.lua.vue +56 -0
  140. package/client/web/src/components/notice-component/.gitkeep +0 -0
  141. package/client/web/src/components/notice-component/MealHungryPan.vue +119 -0
  142. package/client/web/src/components/tooltip/CustomFaceTooltip.vue +22 -0
  143. package/client/web/src/components/tooltip/Tooltip.vue +50 -0
  144. package/client/web/src/components/tooltip/Tooltips.vue +14 -0
  145. package/client/web/src/components/tooltip/UserInfoTooltip.vue +69 -0
  146. package/client/web/src/function/base.ts +238 -0
  147. package/client/web/src/function/connect.ts +2042 -0
  148. package/client/web/src/function/debug.ts +10 -0
  149. package/client/web/src/function/elements/information.ts +141 -0
  150. package/client/web/src/function/elements/system.ts +101 -0
  151. package/client/web/src/function/elements/vueComp.ts +62 -0
  152. package/client/web/src/function/favicon.ts +76 -0
  153. package/client/web/src/function/input.ts +69 -0
  154. package/client/web/src/function/model/emoji.ts +127 -0
  155. package/client/web/src/function/model/img.ts +150 -0
  156. package/client/web/src/function/model/msg-body.ts +51 -0
  157. package/client/web/src/function/msg.ts +2674 -0
  158. package/client/web/src/function/notify.ts +225 -0
  159. package/client/web/src/function/option.ts +749 -0
  160. package/client/web/src/function/satori-model.ts +818 -0
  161. package/client/web/src/function/satori.ts +325 -0
  162. package/client/web/src/function/sender.ts +178 -0
  163. package/client/web/src/function/tooltip.ts +49 -0
  164. package/client/web/src/function/utils/appUtil.ts +2288 -0
  165. package/client/web/src/function/utils/avatarUtil.ts +31 -0
  166. package/client/web/src/function/utils/backgroundUtil.ts +110 -0
  167. package/client/web/src/function/utils/linkViewUtil.ts +101 -0
  168. package/client/web/src/function/utils/localHistoryUtil.ts +517 -0
  169. package/client/web/src/function/utils/msgUtil.ts +1242 -0
  170. package/client/web/src/function/utils/pinyin.ts +141 -0
  171. package/client/web/src/function/utils/recordUtil.ts +187 -0
  172. package/client/web/src/function/utils/sessionUtil.ts +114 -0
  173. package/client/web/src/function/utils/systemUtil.ts +664 -0
  174. package/client/web/src/main.ts +91 -0
  175. package/client/web/src/pages/Chat.vue +3453 -0
  176. package/client/web/src/pages/Friends.vue +636 -0
  177. package/client/web/src/pages/Info.vue +717 -0
  178. package/client/web/src/pages/Messages.vue +875 -0
  179. package/client/web/src/pages/Options.vue +82 -0
  180. package/client/web/src/pages/Qzone.vue +1178 -0
  181. package/client/web/src/pages/chat-view/ChatDanmaku.vue +759 -0
  182. package/client/web/src/pages/chat-view/ChatGlagame.vue +642 -0
  183. package/client/web/src/pages/chat-view/ChatTerminal.vue +1044 -0
  184. package/client/web/src/pages/chat-view/SystemNotice.vue +171 -0
  185. package/client/web/src/pages/options/OptAccount.vue +107 -0
  186. package/client/web/src/pages/options/OptAddon.vue +185 -0
  187. package/client/web/src/pages/options/OptDev.vue +704 -0
  188. package/client/web/src/pages/options/OptFunction.vue +403 -0
  189. package/client/web/src/pages/options/OptInfo.vue +165 -0
  190. package/client/web/src/pages/options/OptView.vue +846 -0
  191. package/client/web/src/runtime/backend.ts +310 -0
  192. package/client/web/src/state/auth.ts +14 -0
  193. package/client/web/src/state/chat.ts +36 -0
  194. package/client/web/src/state/connection.ts +20 -0
  195. package/client/web/src/state/contact.ts +37 -0
  196. package/client/web/src/state/qzone.ts +18 -0
  197. package/client/web/src/state/sessionHistory.ts +25 -0
  198. package/client/web/src/state/settings.ts +18 -0
  199. package/client/web/src/state/sticker.ts +10 -0
  200. package/client/web/src/state/ui.ts +56 -0
  201. package/client/web/tsconfig.json +27 -0
  202. package/client/web/tsconfig.tsbuildinfo +1 -0
  203. package/client/web/vite.config.ts +33 -0
  204. package/dist/index.js +1 -12
  205. package/dist/style.css +1 -1
  206. package/lib/index.js +2070 -2077
  207. package/package.json +15 -2
  208. package/readme.md +0 -22
  209. package/src/bootstrap.ts +71 -0
  210. package/src/cache.ts +319 -0
  211. package/src/config.ts +23 -35
  212. package/src/database.ts +650 -0
  213. package/src/index.ts +27 -59
  214. package/src/media.ts +302 -0
  215. package/src/recorder.ts +175 -0
  216. package/src/self-message.ts +456 -0
  217. package/src/server.d.ts +26 -0
  218. package/src/types.ts +108 -48
  219. package/src/web.ts +712 -0
  220. package/client/vue/chat-logic.ts +0 -683
  221. package/client/vue/composables/useChatActions.ts +0 -61
  222. package/client/vue/composables/useChatData.ts +0 -185
  223. package/client/vue/composables/useImageCache.ts +0 -281
  224. package/client/vue/composables/useVideoCache.ts +0 -125
  225. package/client/vue/types.ts +0 -72
  226. package/lib/api-handlers.d.ts +0 -25
  227. package/lib/config.d.ts +0 -14
  228. package/lib/file-manager.d.ts +0 -124
  229. package/lib/index.d.ts +0 -17
  230. package/lib/logger.d.ts +0 -9
  231. package/lib/message-handler.d.ts +0 -35
  232. package/lib/types.d.ts +0 -57
  233. package/lib/utils.d.ts +0 -18
  234. package/src/api-handlers.ts +0 -646
  235. package/src/file-manager.ts +0 -1436
  236. package/src/message-handler.ts +0 -507
  237. package/src/utils.ts +0 -189
@@ -0,0 +1,704 @@
1
+ <!--
2
+ * @FileDescription: 设置页面(开发者子页面)
3
+ * @Author: Stapxs
4
+ * @Date: 2022/09/28
5
+ * @Version: 1.0
6
+ -->
7
+
8
+ <template>
9
+ <div class="opt-page">
10
+ <div class="ss-card">
11
+ <header>{{ $t('开发者选项') }}</header>
12
+ <div class="opt-item">
13
+ <div :class="checkDefault('log_level')" />
14
+ <font-awesome-icon :icon="['fas', 'book']" />
15
+ <div>
16
+ <label for="opt-dev-log-level">{{ $t('日志等级') }}</label>
17
+ <span>{{ $t('ReferenceError: moYu is not defined') }}</span>
18
+ </div>
19
+ <div class="select-wrapper">
20
+ <select id="opt-dev-log-level" v-model="settingsStore.sysConfig.log_level"
21
+ name="log_level" title="log_level" @change="save">
22
+ <option value="err">
23
+ {{ $t('错误模式') }}
24
+ </option>
25
+ <option value="debug">
26
+ {{ $t('调试模式') }}
27
+ </option>
28
+ </select>
29
+ </div>
30
+ </div>
31
+ <div class="opt-item">
32
+ <div :class="checkDefault('debug_msg')" />
33
+ <font-awesome-icon :icon="['fas', 'robot']" />
34
+ <div>
35
+ <label for="opt-dev-debug-msg">{{ $t('禁用消息渲染') }}</label>
36
+ <span>
37
+ <a style="cursor: pointer" @click="sendAbab">{{ $t('点击进行 CAPTCHA 验证') }}</a>
38
+ </span>
39
+ </div>
40
+ <label class="ss-switch">
41
+ <input id="opt-dev-debug-msg" v-model="settingsStore.sysConfig.debug_msg"
42
+ type="checkbox" name="debug_msg" @change="save">
43
+ <div>
44
+ <div />
45
+ </div>
46
+ </label>
47
+ </div>
48
+ <div class="opt-item">
49
+ <font-awesome-icon :icon="['fas', 'rotate-left']" />
50
+ <div>
51
+ <span>{{ $t('恢复 WebUI 所有默认配置项') }}</span>
52
+ <span>{{ $t('将所有 WebUI 配置恢复为默认值') }}</span>
53
+ </div>
54
+ <button
55
+ style="width: 100px; font-size: 0.8rem"
56
+ class="ss-button"
57
+ @click="resetDefaults">
58
+ {{ $t('恢复') }}
59
+ </button>
60
+ </div>
61
+ </div>
62
+ </div>
63
+ </template>
64
+
65
+ <script setup lang="ts">
66
+ import app from '../../main'
67
+ import { i18n } from '../../main'
68
+ import packageInfo from '../../../package.json'
69
+
70
+ import { ref, onMounted, watch, useTemplateRef, markRaw } from 'vue'
71
+ import {
72
+ runASWEvent as save,
73
+ saveAll,
74
+ checkDefault,
75
+ optDefault,
76
+ runAS,
77
+ get,
78
+ getRaw,
79
+ } from '../../function/option'
80
+ import { Connector } from '../../function/connect'
81
+ import { PopInfo, PopType } from '../../function/base'
82
+ import { isDebugMode } from '../../function/debug'
83
+ import { dispatch } from '../../function/msg'
84
+ import { BrowserInfo, detect } from 'detect-browser'
85
+ import { BotMsgType } from '../../function/elements/information'
86
+ import { uptime } from '../../main'
87
+ import { loadJsonMap } from '../../function/utils/appUtil'
88
+ import { backend } from '../../runtime/backend'
89
+ import RawMsgRenderPreviewPan from '../../components/RawMsgRenderPreviewPan.vue'
90
+ import { useSettingsStore } from '../../state/settings'
91
+ import { useAuthStore } from '../../state/auth'
92
+ import { useUIStore } from '../../state/ui'
93
+
94
+ const settingsStore = useSettingsStore()
95
+ const authStore = useAuthStore()
96
+ const uiStore = useUIStore()
97
+ const botTypeOptions = Object.values(BotMsgType).filter((value): value is BotMsgType => typeof value === 'number')
98
+
99
+ defineOptions({ name: 'ViewOptDev' })
100
+
101
+ const $t = i18n.global.t
102
+
103
+ const napcat = import.meta.env.VITE_NAPCAT
104
+ const dev = import.meta.env.DEV
105
+
106
+ const jsonMapName = ref(authStore.jsonMap?.name ?? '')
107
+ const ws_text = ref('')
108
+ const parse_text = ref('')
109
+ const appmsg_text = ref('')
110
+ const customCssLoaded = ref(false)
111
+ const customCssSize = ref('')
112
+ const cssFileInput = useTemplateRef<HTMLInputElement>('cssFileInput')
113
+
114
+ watch(
115
+ () => authStore.jsonMap?.name,
116
+ () => { jsonMapName.value = authStore.jsonMap?.name ?? '' },
117
+ )
118
+
119
+ onMounted(() => {
120
+ // 检查是否已加载自定义 CSS
121
+ updateCustomCssStatus()
122
+ })
123
+
124
+ function resetDefaults() {
125
+ const popInfo = {
126
+ title: $t('提醒'),
127
+ html: `<span>${$t('确认要将 WebUI 所有配置恢复为默认值吗?')}</span>`,
128
+ button: [
129
+ {
130
+ text: $t('确认'),
131
+ fun: () => {
132
+ uiStore.popBoxList.shift()
133
+ settingsStore.sysConfig = JSON.parse(JSON.stringify(optDefault))
134
+ saveAll(settingsStore.sysConfig)
135
+ if (backend.isDesktop()) {
136
+ backend.call(undefined, 'win:relaunch', false)
137
+ } else {
138
+ location.reload()
139
+ }
140
+ },
141
+ },
142
+ {
143
+ text: $t('取消'),
144
+ master: true,
145
+ fun: () => {
146
+ uiStore.popBoxList.shift()
147
+ },
148
+ },
149
+ ],
150
+ }
151
+ uiStore.popBoxList.push(popInfo)
152
+ }
153
+
154
+ function sendTestWs(event: KeyboardEvent) {
155
+ // 发送测试 WS 消息
156
+ if (event.keyCode === 13 && ws_text.value !== '') {
157
+ const info = JSON.parse(ws_text.value)
158
+ ws_text.value = ''
159
+ // 修改 echo 防止被消息处理机处理
160
+ info.echo = 'websocketTest'
161
+ Connector.sendRawJson(JSON.stringify(info))
162
+ }
163
+ }
164
+
165
+ function sendTestParse(event: KeyboardEvent) {
166
+ // 发送测试解析消息
167
+ if (event.keyCode === 13 && parse_text.value !== '') {
168
+ const text = JSON.parse(parse_text.value)
169
+ setTimeout(() => {
170
+ dispatch(text)
171
+ }, 5000)
172
+ parse_text.value = ''
173
+ }
174
+ }
175
+
176
+ function sendTestAppmsg(event: KeyboardEvent) {
177
+ if (event.keyCode === 13 && appmsg_text.value !== '') {
178
+ new PopInfo().add(PopType.INFO, appmsg_text.value, false)
179
+ appmsg_text.value = ''
180
+ }
181
+ }
182
+
183
+ function openRawRenderPreview() {
184
+ uiStore.popBoxList.push({
185
+ title: $t('消息渲染器'),
186
+ template: markRaw(RawMsgRenderPreviewPan),
187
+ data: {
188
+ text: parse_text.value,
189
+ },
190
+ full: true,
191
+ })
192
+ }
193
+
194
+ function sendAbab() {
195
+ new PopInfo().add(
196
+ PopType.INFO,
197
+ $t('你不是人(逃'),
198
+ )
199
+ }
200
+
201
+ function printRuntime() {
202
+ if(backend.isMobile()) {
203
+ const switcher = document.getElementById('__vconsole')?.getElementsByClassName('vc-switch')[0]
204
+ if (switcher) {
205
+ (switcher as HTMLDivElement).click()
206
+ // safeArea
207
+ backend.call('SafeArea', 'getSafeArea', true).then((safeArea) => {
208
+ if (safeArea) {
209
+ const vcPanel = document.getElementById('__vconsole')?.getElementsByClassName('vc-panel')[0]
210
+ if (vcPanel) {
211
+ // vc-content、vc-toolbar
212
+ const vcContent = vcPanel.getElementsByClassName('vc-content')[0] as HTMLDivElement
213
+ const vcToolbar = vcPanel.getElementsByClassName('vc-toolbar')[0] as HTMLDivElement
214
+ if (vcContent && vcToolbar) {
215
+ vcContent.style.marginBottom = safeArea.bottom + 'px'
216
+ vcToolbar.style.marginBottom = safeArea.bottom + 'px'
217
+ }
218
+ }
219
+ }
220
+ })
221
+ }
222
+ }
223
+ /* eslint-disable no-console */
224
+ if (isDebugMode()) {
225
+ console.log('=========================')
226
+ console.log('settingsStore:', settingsStore.$state)
227
+ console.log('authStore:', authStore.$state)
228
+ console.log('uiStore:', uiStore.$state)
229
+ console.log('=========================')
230
+ }
231
+ /* eslint-enable no-console */
232
+ if(!backend.isMobile()) {
233
+ backend.call(undefined, 'win:openDevTools', false)
234
+ }
235
+ }
236
+
237
+ async function printVersionInfo() {
238
+ new PopInfo().add(
239
+ PopType.INFO,
240
+ $t('正在收集调试消息……'),
241
+ )
242
+
243
+ // 索要框架信息
244
+ const addInfo = await backend.call('Onebot', 'opt:getSystemInfo', true)
245
+ if(backend.isMobile() && backend.function && 'vConsole' in backend.function && backend.function.vConsole) {
246
+ addInfo.vconsole = ['vConsole Version', backend.function.vConsole.version ?? 'Not loaded']
247
+ }
248
+
249
+ const browser = detect() as BrowserInfo
250
+ let info = '```\n'
251
+ info +=
252
+ 'Debug Info - ' +
253
+ new Date().toLocaleString() +
254
+ '\n================================\n'
255
+ info += 'System Info:\n'
256
+ info += ` OS Name -> ${browser.os}\n`
257
+ info += ` Browser Name -> ${browser.name}\n`
258
+ info += ` Browser Version -> ${browser.version}\n`
259
+ if (addInfo) {
260
+ const get = addInfo as { [key: string]: [string, string] }
261
+ Object.keys(get).forEach((name: string) => {
262
+ info += ` ${get[name][0]} -> ${get[name][1]}\n`
263
+ })
264
+ }
265
+ // 获取安装信息,这儿主要判断几种已提交的包管理安装方式
266
+ if (backend.isDesktop() && backend.release) {
267
+ const process = window.electron?.process
268
+ switch (process && process.platform) {
269
+ case 'linux': {
270
+ // archlinux
271
+ if (backend.release.toLowerCase().indexOf('arch') > 0) {
272
+ let pacmanInfo =
273
+ await backend.call(undefined, 'sys:runCommand', true,
274
+ 'pacman -Q stapxs-qq-lite-bin',
275
+ )
276
+ if (pacmanInfo.success) {
277
+ info += ' Install Type -> aur\n'
278
+ } else if(backend.function && 'invoke' in backend.function) {
279
+ // 也有可能是 stapxs-qq-lite,这是我自己打的原生包
280
+ pacmanInfo = await backend.function.invoke(
281
+ 'sys:runCommand',
282
+ 'pacman -Q stapxs-qq-lite',
283
+ )
284
+ if (pacmanInfo.success) {
285
+ info += ' Install Type -> pacman\n'
286
+ }
287
+ }
288
+ }
289
+ break
290
+ }
291
+ }
292
+ }
293
+
294
+ info += 'Application Info:\n'
295
+ info += ` Uptime -> ${Math.floor(((new Date().getTime() - uptime) / 1000) * 100) / 100} s\n`
296
+ info += ` Package Version -> ${packageInfo.version}\n`
297
+ info += ` Service Work -> ${navigator.serviceWorker?.controller ? 'active' : 'none'}\n`
298
+
299
+ info += 'Backend Info:\n'
300
+ info += ` Bot Info Name -> ${authStore.botInfo.app_name}\n`
301
+ info += ` Bot Info Version -> ${authStore.botInfo.app_version !== undefined ? authStore.botInfo.app_version : authStore.botInfo.version}\n`
302
+ info += ` Loaded Config -> ${authStore.jsonMap?.name}\n`
303
+
304
+ info += 'View Info:\n'
305
+ info += ` Doc Width -> ${document.getElementById('app')?.offsetWidth} px\n`
306
+
307
+ // capactior:索要 safeArea
308
+ if (backend.isMobile()) {
309
+ const safeArea = await backend.call('SafeArea', 'getSafeArea', true)
310
+ if (safeArea) {
311
+ // 按照前端习惯,这儿的 safeArea 顺序是 top, right, bottom, left
312
+ const safeAreaStr = safeArea.top + ', ' + safeArea.right + ', ' + safeArea.bottom + ', ' + safeArea.left
313
+ info += ` Safe Area -> ${safeAreaStr}\n`
314
+ }
315
+ }
316
+
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
+ }
332
+ info += '```'
333
+ // 构建 popBox 内容
334
+ const popInfo = {
335
+ svg: 'screwdriver-wrench',
336
+ html:
337
+ '<textarea class="debug-info">' + info + '</textarea>',
338
+ title: $t('调试信息'),
339
+ button: [
340
+ {
341
+ text: $t('复制'),
342
+ fun: () => {
343
+ app.config.globalProperties.$copyText(info)
344
+ new PopInfo().add(
345
+ PopType.INFO,
346
+ $t('复制成功'),
347
+ )
348
+ },
349
+ },
350
+ {
351
+ text: $t('确定'),
352
+ master: true,
353
+ fun: () => {
354
+ uiStore.popBoxList.shift()
355
+ },
356
+ },
357
+ ],
358
+ }
359
+ uiStore.popBoxList.push(popInfo)
360
+ }
361
+
362
+ function printSetUpInfo() {
363
+ const json = JSON.stringify(settingsStore.sysConfig)
364
+ const popInfo = {
365
+ svg: 'upload',
366
+ html:
367
+ '<textarea style="width: calc(100% - 40px);min-height: 90px;background: var(--color-card-1);color: var(--color-font);border: 0;padding: 20px;border-radius: 7px;margin-top: -10px;">' +
368
+ json +
369
+ '</textarea>',
370
+ title: $t('导出设置项'),
371
+ button: [
372
+ {
373
+ text: $t('复制'),
374
+ fun: () => {
375
+ app.config.globalProperties.$copyText(json)
376
+ new PopInfo().add(
377
+ PopType.INFO,
378
+ $t('复制成功'),
379
+ )
380
+ },
381
+ },
382
+ {
383
+ text: $t('确定'),
384
+ master: true,
385
+ fun: () => {
386
+ uiStore.popBoxList.shift()
387
+ },
388
+ },
389
+ ],
390
+ }
391
+ uiStore.popBoxList.push(popInfo)
392
+ }
393
+
394
+ function importSetUpInfo() {
395
+ const popInfo = {
396
+ svg: 'download',
397
+ html: '<textarea id="importSetUpInfoTextArea" style="width: calc(100% - 40px);min-height: 90px;background: var(--color-card-1);color: var(--color-font);border: 0;padding: 20px;border-radius: 7px;margin-top: -10px;"></textarea>',
398
+ title: $t('导入设置项'),
399
+ button: [
400
+ {
401
+ text: $t('取消'),
402
+ fun: () => {
403
+ uiStore.popBoxList.shift()
404
+ },
405
+ },
406
+ {
407
+ text: $t('确定'),
408
+ master: true,
409
+ fun: () => {
410
+ const input = document.getElementById(
411
+ 'importSetUpInfoTextArea',
412
+ ) as HTMLTextAreaElement
413
+ if (input) {
414
+ try {
415
+ const json = JSON.parse(input.value)
416
+ settingsStore.sysConfig = json
417
+ saveAll(json)
418
+ location.reload()
419
+ } catch (e) {
420
+ new PopInfo().add(
421
+ PopType.ERR,
422
+ $t(
423
+ '导入设置项失败',
424
+ ),
425
+ )
426
+ }
427
+ }
428
+ },
429
+ },
430
+ ],
431
+ }
432
+ uiStore.popBoxList.push(popInfo)
433
+ }
434
+
435
+ function resetApp() {
436
+ const popInfo = {
437
+ svg: 'trash-arrow-up',
438
+ html:
439
+ '<span>' +
440
+ $t(
441
+ '确认要重置应用吗,重置应用将会失去所有设置内容(包括设置的置顶群组),但是可能可以解决一些因为浏览器缓存导致的奇怪问题。',
442
+ ) +
443
+ '</span>',
444
+ title: $t('重置应用'),
445
+ button: [
446
+ {
447
+ text: $t('确定'),
448
+ fun: () => {
449
+ localStorage.clear()
450
+ document.cookie.split(';').forEach((c) => {
451
+ document.cookie = c.replace(/^ +/, '')
452
+ .replace(/=.*/,'=;expires=' + new Date().toUTCString() + ';path=/')
453
+ })
454
+ backend.call(undefined, 'opt:clearAll', false)
455
+ location.reload()
456
+ },
457
+ },
458
+ {
459
+ text: $t('取消'),
460
+ master: true,
461
+ fun: () => {
462
+ uiStore.popBoxList.shift()
463
+ },
464
+ },
465
+ ],
466
+ }
467
+ uiStore.popBoxList.push(popInfo)
468
+ }
469
+
470
+ function restartapp() {
471
+ backend.call(undefined, 'win:relaunch', false)
472
+ }
473
+
474
+ function getBotTypeName(index: BotMsgType) {
475
+ switch (index) {
476
+ case BotMsgType.CQCode:
477
+ return $t('CQ 码')
478
+ case BotMsgType.Array:
479
+ return $t('Array 数组')
480
+ }
481
+ }
482
+
483
+ function getPathMapList() {
484
+ const pathMap = import.meta.glob('../../assets/pathMap/*.yaml')
485
+ const pathMapList: string[] = []
486
+ Object.keys(pathMap).forEach((key: string) => {
487
+ const name = key.split('/').pop()?.replace('.yaml', '')
488
+ if (name) pathMapList.push(name)
489
+ })
490
+ return pathMapList
491
+ }
492
+
493
+ function changeJsonMap() {
494
+ const getPath = loadJsonMap(jsonMapName.value)
495
+ if (getPath) authStore.jsonMap = getPath
496
+ }
497
+
498
+ // 查看配置文件
499
+ function rmNeedlessOption() {
500
+ const needless: string[] = []
501
+ for (const key of Object.keys(settingsStore.sysConfig)) {
502
+ if (optDefault[key] === undefined) {
503
+ needless.push(key)
504
+ }
505
+ }
506
+ if (needless.length === 0) {
507
+ new PopInfo().add(
508
+ PopType.INFO,
509
+ $t('没有需要删除的配置项'),
510
+ )
511
+ return
512
+ }
513
+ const popInfo = {
514
+ title: $t('转发消息'),
515
+ html: `
516
+ <header>以下配置将被删除</header>
517
+ <div style="color: var(--color-red);font-weight: 700;">
518
+ ` + needless.join('<br>') + '</div>',
519
+ button: [{
520
+ text: $t('确定'),
521
+ fun: () => {
522
+ for (const key of needless) {
523
+ delete settingsStore.sysConfig[key]
524
+ }
525
+ saveAll(settingsStore.sysConfig)
526
+ uiStore.popBoxList.shift()
527
+ },
528
+ },
529
+ {
530
+ text: $t('取消'),
531
+ master: true,
532
+ fun: () => {
533
+ uiStore.popBoxList.shift()
534
+ },
535
+ },
536
+ ],
537
+ }
538
+ uiStore.popBoxList.push(popInfo)
539
+ }
540
+
541
+ // 自定义 CSS 相关方法
542
+ async function updateCustomCssStatus() {
543
+ const customCss = await getRaw('custom_css')
544
+ customCssLoaded.value = customCss && customCss.trim().indexOf('null') < 0
545
+ if (customCssLoaded.value) {
546
+ // 计算 CSS 大小
547
+ const sizeInBytes = new Blob([customCss]).size
548
+ if (sizeInBytes < 1024) {
549
+ customCssSize.value = sizeInBytes + ' B'
550
+ } else if (sizeInBytes < 1024 * 1024) {
551
+ customCssSize.value = (sizeInBytes / 1024).toFixed(2) + ' KB'
552
+ } else {
553
+ customCssSize.value = (sizeInBytes / (1024 * 1024)).toFixed(2) + ' MB'
554
+ }
555
+ }
556
+ }
557
+
558
+ function selectCssFile() {
559
+ // 触发文件选择
560
+ if (cssFileInput.value) {
561
+ cssFileInput.value.click()
562
+ }
563
+ }
564
+
565
+ function handleCssFileUpload(event: Event) {
566
+ const target = event.target as HTMLInputElement
567
+ const file = target.files?.[0]
568
+
569
+ if (!file) return
570
+
571
+ // 检查文件类型
572
+ if (!file.name.endsWith('.css')) {
573
+ new PopInfo().add(
574
+ PopType.ERR,
575
+ $t('请选择 CSS 文件'),
576
+ )
577
+ return
578
+ }
579
+
580
+ // 检查文件大小(限制为 1MB)
581
+ if (file.size > 1024 * 1024) {
582
+ new PopInfo().add(
583
+ PopType.ERR,
584
+ $t('CSS 文件大小不能超过 1MB'),
585
+ )
586
+ return
587
+ }
588
+
589
+ // 显示风险警告弹窗
590
+ const popInfo = {
591
+ svg: 'triangle-exclamation',
592
+ html: '<div style="text-align: left;"><p>' +
593
+ $t('注意:自定义样式功能具有一定风险,请确保您了解以下事项:') +
594
+ '</p><ul style="margin: 10px 0; padding-left: 20px;">' +
595
+ '<li>' + $t('错误的 CSS 代码可能导致界面显示异常') + '</li>' +
596
+ '<li>' + $t('某些样式可能会隐藏或覆盖重要的界面元素') + '</li>' +
597
+ '<li>' + $t('如果出现严重问题,可能会导致完全无法重置此设置') + '</li>' +
598
+ '</ul><p>' + $t('确认要继续上传并加载此 CSS 文件吗?') + '</p></div>',
599
+ title: $t('自定义样式风险提醒'),
600
+ button: [
601
+ {
602
+ text: $t('确认上传'),
603
+ fun: () => {
604
+ uiStore.popBoxList.shift()
605
+ // 读取文件内容
606
+ const reader = new FileReader()
607
+ reader.onload = (e) => {
608
+ const cssContent = e.target?.result as string
609
+ if (cssContent) {
610
+ // 保存并注入 CSS
611
+ runAS('custom_css', cssContent)
612
+ updateCustomCssStatus()
613
+ new PopInfo().add(
614
+ PopType.INFO,
615
+ $t('自定义样式已加载'),
616
+ )
617
+ }
618
+ }
619
+ reader.onerror = () => {
620
+ new PopInfo().add(
621
+ PopType.ERR,
622
+ $t('读取文件失败'),
623
+ )
624
+ }
625
+ reader.readAsText(file)
626
+ // 清空 input 值,允许重复选择同一文件
627
+ target.value = ''
628
+ },
629
+ },
630
+ {
631
+ text: $t('取消'),
632
+ master: true,
633
+ fun: () => {
634
+ uiStore.popBoxList.shift()
635
+ // 清空 input 值
636
+ target.value = ''
637
+ },
638
+ },
639
+ ],
640
+ }
641
+ uiStore.popBoxList.push(popInfo)
642
+ }
643
+
644
+ function viewCustomCss() {
645
+ const customCss = get('custom_css')
646
+ const popInfo = {
647
+ svg: 'eye',
648
+ html: '<textarea style="width: calc(100% - 40px);min-height: 300px;background: var(--color-card-1);color: var(--color-font);border: 0;padding: 20px;border-radius: 7px;margin-top: -10px;font-family: monospace;font-size: 0.9rem;" readonly>' +
649
+ (customCss || '') +
650
+ '</textarea>',
651
+ title: $t('查看自定义样式'),
652
+ button: [
653
+ {
654
+ text: $t('复制'),
655
+ fun: () => {
656
+ app.config.globalProperties.$copyText(customCss)
657
+ new PopInfo().add(
658
+ PopType.INFO,
659
+ $t('复制成功'),
660
+ )
661
+ },
662
+ },
663
+ {
664
+ text: $t('确定'),
665
+ master: true,
666
+ fun: () => {
667
+ uiStore.popBoxList.shift()
668
+ },
669
+ },
670
+ ],
671
+ }
672
+ uiStore.popBoxList.push(popInfo)
673
+ }
674
+
675
+ function clearCustomCss() {
676
+ const popInfo = {
677
+ svg: 'trash',
678
+ html: '<span>' + $t('确认要清除自定义样式吗?') + '</span>',
679
+ title: $t('清除自定义样式'),
680
+ button: [
681
+ {
682
+ text: $t('确定'),
683
+ fun: () => {
684
+ runAS('custom_css', null)
685
+ updateCustomCssStatus()
686
+ new PopInfo().add(
687
+ PopType.INFO,
688
+ $t('已清除自定义样式'),
689
+ )
690
+ uiStore.popBoxList.shift()
691
+ },
692
+ },
693
+ {
694
+ text: $t('取消'),
695
+ master: true,
696
+ fun: () => {
697
+ uiStore.popBoxList.shift()
698
+ },
699
+ },
700
+ ],
701
+ }
702
+ uiStore.popBoxList.push(popInfo)
703
+ }
704
+ </script>