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,69 @@
1
+ <!--
2
+ * @FileDescription: 群成员消息悬浮窗
3
+ * @Author: Mr.Lee
4
+ * @Date: 2025/09/01
5
+ * 2026/01/03
6
+ * @Version: 1.0
7
+ * 2.0 并入新式提示工具系统
8
+ -->
9
+ <template>
10
+ <div v-if="userInfo" class="member-info ss-card"
11
+ :class="{
12
+ leave: typeof userInfo === 'number',
13
+ }">
14
+ <!-- 已退群 -->
15
+ <template v-if="typeof userInfo === 'number'">
16
+ <div>
17
+ <img :src="'/img/icons/icon.svg'">
18
+ <div>
19
+ <span name="id">{{ userInfo }}</span>
20
+ <div>
21
+ <a>{{ $t('已退群( {userId} )', { userId: userInfo }) }}</a>
22
+ </div>
23
+ </div>
24
+ </div>
25
+ </template>
26
+ <!-- 群成员 -->
27
+ <template v-else>
28
+ <div>
29
+ <img :src="userInfo.avatar || '/img/icons/icon.svg'">
30
+ <div>
31
+ <span name="id">{{ userInfo.user_id }}</span>
32
+ <div>
33
+ <a>{{ userInfo.card || userInfo.nickname || userInfo.name || userInfo.user_id }}</a>
34
+ </div>
35
+ </div>
36
+ </div>
37
+ </template>
38
+ </div>
39
+ </template>
40
+
41
+ <script setup lang="ts">
42
+ type IUser = any
43
+
44
+ const { user: userProp } = defineProps<{
45
+ user: IUser | number | (() => IUser | number)
46
+ }>()
47
+
48
+ let userInfo: IUser | number
49
+ if (typeof userProp === 'function') {
50
+ userInfo = userProp()
51
+ } else {
52
+ userInfo = userProp
53
+ }
54
+ </script>
55
+
56
+ <style scoped>
57
+ .tooltip-enter-active, .tooltip-leave-active {
58
+ transition: opacity 0.2s, transform 0.2s;
59
+ transform-origin: top;
60
+ }
61
+ .tooltip-enter-from, .tooltip-leave-to {
62
+ opacity: 0;
63
+ transform: scaleY(0) translate(-20px, calc(-100% - 0.8rem));
64
+ }
65
+ .tooltip-enter-to, .tooltip-leave-from {
66
+ opacity: 1;
67
+ transform: scaleY(1) translate(-20px, calc(-100% - 0.8rem));
68
+ }
69
+ </style>
@@ -0,0 +1,238 @@
1
+ /*
2
+ * @FileDescription: 基础功能模块
3
+ * @Author: Stapxs
4
+ * @Date: 2022/10/20
5
+ * @Version: 1.0
6
+ * @Description: 此模块主要为程序相关的基础功能
7
+ */
8
+
9
+ import Option from './option'
10
+ import { isDebugMode } from './debug'
11
+ import { reactive } from 'vue'
12
+ import { PopInfoElem } from './elements/system'
13
+
14
+ // =============== 日志 ===============
15
+
16
+ export enum LogType {
17
+ WS,
18
+ UI,
19
+ ERR,
20
+ INFO,
21
+ DEBUG,
22
+ SYSTEM
23
+ }
24
+
25
+ export { isDebugMode }
26
+
27
+ export class Logger {
28
+ private logTypeInfo: [string, string][]
29
+
30
+ constructor() {
31
+ // 日志类型输出文本前缀样式,顺序对应 LogType
32
+ this.logTypeInfo = [
33
+ ['7abb7e', 'fff'],
34
+ ['b573f7', 'fff'],
35
+ ['ff5370', 'fff'],
36
+ ['99b3db', 'fff'],
37
+ ['677480', 'fff'],
38
+ ['e5a5a9', 'fff'],
39
+ ]
40
+ }
41
+
42
+ /**
43
+ * 输出一条日志
44
+ * @param mode 日志类型
45
+ * @param args 日志内容
46
+ */
47
+ add(type: LogType, args: string, data = '' as any, hidden = false) {
48
+ const logLevel = Option.get('log_level')
49
+ // 错误模式只输出 ERR;调试模式输出全部日志
50
+ if (logLevel === 'debug') {
51
+ this.print(type, args, data, hidden)
52
+ } else if (type === LogType.ERR) {
53
+ this.print(type, args, data, hidden)
54
+ }
55
+ }
56
+ info(args: string, hidden = false) {
57
+ this.add(LogType.INFO, args, undefined, hidden)
58
+ }
59
+ error(e: Error | null, args: string, hidden = false) {
60
+ if (e) {
61
+ // this.add(LogType.ERR, args + '\n' + e.stack?.replaceAll('webpack-internal:///./', 'webpack-internal:///'), undefined, hidden)
62
+ this.add(LogType.ERR, args + '\n', e, hidden)
63
+ } else {
64
+ this.add(LogType.ERR, args, undefined, hidden)
65
+ }
66
+ }
67
+ debug(args: string, hidden = false) {
68
+ this.add(LogType.DEBUG, args, undefined, hidden)
69
+ }
70
+ system(args: string) {
71
+ this.add(LogType.SYSTEM, args, undefined, true)
72
+ }
73
+ /**
74
+ * 打印一条日志
75
+ * @param type 日志类型
76
+ * @param args 日志内容
77
+ */
78
+ private print(type: LogType, args: string, data: any, hidden: boolean) {
79
+ const error = new Error()
80
+ // 浏览器类型,用于判断是不是 webkit
81
+ let isWebkit = /webkit/i.test(navigator.userAgent)
82
+ if(window.electron != undefined) {
83
+ // electron 是 chrome,但是 userAgent 里面含有 webkit 字样
84
+ isWebkit = false
85
+ }
86
+ // 从调用栈中获取调用者信息
87
+ let from = undefined as string | undefined
88
+ const stack = error.stack
89
+ if (stack) {
90
+ const stackArr = stack.split('\n')
91
+ // 找到第一个不是 at Logger 开头的调用者信息(WebKit 为第一个 @ 开头)
92
+ for (let i = 1; i < stackArr.length; i++) {
93
+ if (isWebkit ? stackArr[i].startsWith('@') : !stackArr[i].includes('at Logger')) {
94
+ // 取出链接部分,去除括号
95
+ from = stackArr[i].replace(/\(|\)/g, '').split(' ').pop() || ''
96
+ from = from.replace(
97
+ 'webpack-internal:///./',
98
+ 'webpack-internal:///',
99
+ )
100
+ if(from.startsWith('@')) {
101
+ from = from.substring(1)
102
+ }
103
+ if (from.startsWith('webpack-internal:///node_modules')) {
104
+ from = undefined
105
+ }
106
+ break
107
+ }
108
+ }
109
+ }
110
+ // 打印日志
111
+ let typeStr = LogType[type]
112
+ if (typeStr === 'WS') {
113
+ if (args.startsWith('GET')) {
114
+ args = args.substring(4)
115
+ typeStr = '◀'
116
+ if(data.echo) {
117
+ typeStr += ` ${data.echo.replace('send_', '')}`
118
+ } else if(data.post_type) {
119
+ typeStr += ` ${data.post_type}`
120
+ }
121
+ } else if (args.startsWith('PUT')) {
122
+ args = args.substring(4)
123
+ typeStr = '▶'
124
+ if(data.action) {
125
+ typeStr += ` ${data.action}`
126
+ }
127
+ if(data.echo) {
128
+ typeStr += ` -> ${data.echo.replace('send_', '')}`
129
+ }
130
+ }
131
+ }
132
+
133
+ // 如果存在 vconsole 就不打印带 css 样式的日志(它不支持)
134
+ // 因为在 capturer 下 from 是无意义的,所以也不显示
135
+ if (document.getElementById('__vconsole')) {
136
+ const { message } = this.buildLogParams(typeStr, args, hidden, type)
137
+ this.logOutput(message.replaceAll('%c', ' | '), [], data, false)
138
+ } else {
139
+ const { message, styles } = this.buildLogParams(typeStr, args, hidden, type, from)
140
+ this.logOutput(message, styles, data)
141
+ }
142
+ }
143
+
144
+ private buildLogParams(
145
+ typeStr: string,
146
+ args: string,
147
+ hidden: boolean,
148
+ type: LogType,
149
+ from?: string
150
+ ): { message: string; styles: string[] } {
151
+ const hasFrom = !hidden && from;
152
+ if (hasFrom) {
153
+ return {
154
+ message: `%c${typeStr}%c${from}%c\n${args}`,
155
+ styles: [
156
+ `background:#${this.logTypeInfo[type][0]};color:#${this.logTypeInfo[type][1]};border-radius:7px 0 0 7px;padding:2px 4px 2px 7px;margin-bottom:7px;`,
157
+ 'background:#e3e8ec;color:#000;padding:2px 7px 4px 4px;border-radius:0 7px 7px 0;margin-bottom:7px;',
158
+ ''
159
+ ]
160
+ }
161
+ } else {
162
+ return {
163
+ message: `%c${typeStr}%c ${args}`,
164
+ styles: [
165
+ `background:#${this.logTypeInfo[type][0]};color:#${this.logTypeInfo[type][1]};border-radius:7px;padding:2px 4px 2px 7px;margin-bottom:7px;`,
166
+ '',
167
+ ''
168
+ ]
169
+ }
170
+ }
171
+ }
172
+
173
+ private logOutput(message: string, styles: string[], data: any, useStyles = true) {
174
+ if (useStyles) {
175
+ // eslint-disable-next-line no-console
176
+ console.log(message, ...styles, data)
177
+ } else {
178
+ // eslint-disable-next-line no-console
179
+ console.log(message, data)
180
+ }
181
+ }
182
+ }
183
+
184
+ // =============== 系统消息 ===============
185
+
186
+ export enum PopType {
187
+ INFO = 'circle-info',
188
+ ERR = 'circle-exclamation',
189
+ }
190
+
191
+ export class PopInfo {
192
+ /**
193
+ *
194
+ * @param typeInfo 消息类型
195
+ * @param args 消息内容
196
+ * @param isAutoClose 是否自动关闭(默认为 true)
197
+ */
198
+ add(icon: PopType, args: string, isAutoClose = true) {
199
+ const data: PopInfoElem = {
200
+ id: popList.length,
201
+ svg: icon,
202
+ text: args,
203
+ autoClose: isAutoClose,
204
+ }
205
+ popList.splice(popList.length, 0, data)
206
+ // 创建定时器
207
+ if (data.autoClose) {
208
+ setTimeout(() => {
209
+ this.remove(data.id)
210
+ }, 5000)
211
+ }
212
+ }
213
+
214
+ /**
215
+ * 移除一条消息
216
+ * @param id 消息编号
217
+ */
218
+ remove(id: number) {
219
+ const index = popList.findIndex((item) => {
220
+ return item.id === id
221
+ })
222
+ if (index !== -1) {
223
+ popList.splice(index, 1)
224
+ }
225
+ }
226
+
227
+ /**
228
+ * 清空所有消息
229
+ */
230
+ clear() {
231
+ // 因为消息是有动画的,所以需要延迟清空
232
+ setTimeout(() => {
233
+ popList.splice(0, popList.length)
234
+ }, 300)
235
+ }
236
+ }
237
+
238
+ export const popList: PopInfoElem[] = reactive([])