From e17cb7c24a233417ab34a1de3b04cbdc32ebc2e0 Mon Sep 17 00:00:00 2001 From: nongyehong <2439646234@qq.com> Date: Mon, 29 Apr 2024 21:20:01 +0800 Subject: [PATCH] =?UTF-8?q?feat(style):=20:sparkles:=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=89=88=E6=9C=AC=E4=BF=A1=E6=81=AF=E6=89=93?= =?UTF-8?q?=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除主题切换时的Transitions效果 --- build/config/console.ts | 44 +++ build/config/version.ts | 42 +++ package.json | 2 +- pnpm-lock.yaml | 10 +- src/components/common/ContextMenu.vue | 11 +- src/components/common/InfoPopover.vue | 3 +- src/hooks/useChatMain.ts | 12 +- src/hooks/useMsgInput.ts | 2 +- src/hooks/useWindow.ts | 3 +- src/main.ts | 3 + src/services/webSocket.ts | 4 +- src/styles/scss/toggle-theme.scss | 22 -- src/utils/Common.ts | 11 + .../home-window/more/settings/General.vue | 33 +-- src/views/login-window/Login.vue | 11 +- src/views/login-window/QRCode.vue | 2 +- vite.config.ts | 6 +- ....timestamp-1714396493254-f861d26eee0a5.mjs | 257 ++++++++++++++++++ 18 files changed, 400 insertions(+), 78 deletions(-) create mode 100644 build/config/console.ts create mode 100644 build/config/version.ts delete mode 100644 src/styles/scss/toggle-theme.scss create mode 100644 src/utils/Common.ts create mode 100644 vite.config.ts.timestamp-1714396493254-f861d26eee0a5.mjs diff --git a/build/config/console.ts b/build/config/console.ts new file mode 100644 index 0000000..d5367c7 --- /dev/null +++ b/build/config/console.ts @@ -0,0 +1,44 @@ +import pkg from '../../package.json' + +/** + * 启动时打印信息 + * @param env 环境变量 + * @param mode 运行模式 + */ +export const atStartup = (env: { [key: string]: string }, mode: string) => { + return () => { + if (mode === 'dev') { + console.log( + ` 🍀 ${'\x1b[32m'}${'\x1b[38;2;19;152;127m'}${env.VITE_APP_NAME} ${'\x1b[0m'}${'\x1b[90m'}${pkg.version}${'\x1b[0m'}` + ) + console.log( + ` ${'\u001b[38;2;26;178;146m'}${'\x1b[1m'}${'➜'}${'\x1b[0m'} ` + + `${'当前环境: '}` + + `${'\x1b[38;2;215;95;135m'}${mode}${'\x1b[0m'}` + ) + console.log( + ` ${'\u001b[38;2;26;178;146m'}${'\x1b[1m'}${'➜'}${'\x1b[0m'} ${'\x1b[38;2;0;215;175m'}${'\x1b[1m'}${'Vue'}${'\x1b[0m'}: ` + + `${'\x1b[90m'}${pkg.dependencies.vue}${'\x1b[0m'}` + + ` ${'\x1b[38;2;95;215;255m'}${'\x1b[1m'}${'Vite'}${'\x1b[0m'}: ` + + `${'\x1b[90m'}${pkg.devDependencies.vite}${'\x1b[0m'}` + + ` ${'\u001b[38;5;33m'}${'\x1b[1m'}${'Node.js'}${'\x1b[0m'}: ` + + `${'\x1b[90m'}${process.version}${'\x1b[0m'}` + ) + console.log( + ` ${'\u001b[38;2;26;178;146m'}${'\x1b[1m'}${'➜'}${'\x1b[0m'} ` + + `当前 ${'\x1b[38;2;215;135;0m'}${'\x1b[1m'}Tauri${'\x1b[0m'} 版本: `, + `${'\x1b[90m'}${pkg.dependencies['@tauri-apps/api']}${'\x1b[0m'}` + ) + console.log( + ` ${'\u001b[38;2;26;178;146m'}${'\x1b[1m'}${'\u001b[2m'}${'➜'}${'\x1b[0m'} ` + + '后端服务地址: ' + + `${'\x1b[38;2;95;175;255m'}待开发中 -->${'\x1b[0m'}` + ) + console.log( + ` ${'\u001b[38;2;26;178;146m'}${'\x1b[1m'}${'\u001b[2m'}${'➜'}${'\x1b[0m'} ` + + '项目地址: ' + + `${pkg.author.url}` + ) + } + } +} diff --git a/build/config/version.ts b/build/config/version.ts new file mode 100644 index 0000000..772a56d --- /dev/null +++ b/build/config/version.ts @@ -0,0 +1,42 @@ +import pkg from '../../package.json' + +/** npm依赖包版本信息 */ +export interface PkgVersionInfo { + name: string + version: string +} + +interface Package { + name: string + version: string + author: Record + dependencies: Record + devDependencies: Record + [key: string]: any +} + +interface PkgJson { + name: string + version: string + author: Record + dependencies: PkgVersionInfo[] + devDependencies: PkgVersionInfo[] +} + +const pkgWithType = pkg as Package + +const transformVersionData = (tuple: [string, string]): PkgVersionInfo => { + const [name, version] = tuple + return { + name, + version + } +} + +export const pkgJson: PkgJson = { + name: pkgWithType.name, + version: pkgWithType.version, + author: pkgWithType.author, + dependencies: Object.entries(pkgWithType.dependencies).map((item) => transformVersionData(item)), + devDependencies: Object.entries(pkgWithType.devDependencies).map((item) => transformVersionData(item)) +} diff --git a/package.json b/package.json index edaa337..3befd96 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "prepare": "husky install" }, "dependencies": { - "@tauri-apps/api": "^1.5.3", + "@tauri-apps/api": "^1.5.4", "axios": "^1.6.8", "colorthief": "^2.4.0", "dayjs": "^1.11.10", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 11d0cbe..7631c58 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: dependencies: '@tauri-apps/api': - specifier: ^1.5.3 - version: 1.5.3 + specifier: ^1.5.4 + version: 1.5.4 axios: specifier: ^1.6.8 version: 1.6.8 @@ -816,8 +816,8 @@ packages: cpu: [x64] os: [win32] - '@tauri-apps/api@1.5.3': - resolution: {integrity: sha512-zxnDjHHKjOsrIzZm6nO5Xapb/BxqUq1tc7cGkFXsFkGTsSWgCPH1D8mm0XS9weJY2OaR73I3k3S+b7eSzJDfqA==} + '@tauri-apps/api@1.5.4': + resolution: {integrity: sha512-LKYae9URbdEdbHrOXBeXb/lZgVyWTX0E98rSFBuQlmkLr8OeG+akuE41PfLjBVyk1Q+fq7wxo4ieenLSMUAUhA==} engines: {node: '>= 14.6.0', npm: '>= 6.6.0', yarn: '>= 1.19.1'} '@tauri-apps/cli-darwin-arm64@1.5.11': @@ -4095,7 +4095,7 @@ snapshots: '@rollup/rollup-win32-x64-msvc@4.14.3': optional: true - '@tauri-apps/api@1.5.3': {} + '@tauri-apps/api@1.5.4': {} '@tauri-apps/cli-darwin-arm64@1.5.11': optional: true diff --git a/src/components/common/ContextMenu.vue b/src/components/common/ContextMenu.vue index 6052ea2..b55b04e 100644 --- a/src/components/common/ContextMenu.vue +++ b/src/components/common/ContextMenu.vue @@ -18,9 +18,14 @@ align="center" justify="space-between" class="emoji-list"> - - {{ item.label }} - + + + {{ item.title }} + diff --git a/src/components/common/InfoPopover.vue b/src/components/common/InfoPopover.vue index abc01a8..c61badc 100644 --- a/src/components/common/InfoPopover.vue +++ b/src/components/common/InfoPopover.vue @@ -45,8 +45,7 @@ diff --git a/src/hooks/useChatMain.ts b/src/hooks/useChatMain.ts index 3522dd4..3ad11d0 100644 --- a/src/hooks/useChatMain.ts +++ b/src/hooks/useChatMain.ts @@ -180,16 +180,20 @@ export const useChatMain = (activeItem: MockItem) => { /** emoji表情菜单 */ const emojiList = ref([ { - label: '👍' + label: '👍', + title: '好赞' }, { - label: '😆' + label: '😆', + title: '开心' }, { - label: '🥳' + label: '🥳', + title: '恭喜' }, { - label: '🤯' + label: '🤯', + title: '惊呆了' } ]) diff --git a/src/hooks/useMsgInput.ts b/src/hooks/useMsgInput.ts index 38075a0..8d92d5b 100644 --- a/src/hooks/useMsgInput.ts +++ b/src/hooks/useMsgInput.ts @@ -159,7 +159,7 @@ export const useMsgInput = (messageInputDom: Ref) => { if (foundHyperlinks && foundHyperlinks.length > 0) { msg.content = msg.content.replace(hyperlinkRegex, (match) => { const href = match.startsWith('www.') ? 'https://' + match : match - return `${match}` + return `${match}` }) } // 判断文本信息是否超过限制 diff --git a/src/hooks/useWindow.ts b/src/hooks/useWindow.ts index 1d8e7c2..9376a87 100644 --- a/src/hooks/useWindow.ts +++ b/src/hooks/useWindow.ts @@ -1,5 +1,6 @@ import { LogicalSize, WebviewWindow } from '@tauri-apps/api/window' import { invoke } from '@tauri-apps/api/tauri' +import { EventEnum } from '@/enums' export const useWindow = () => { /** @@ -27,7 +28,7 @@ export const useWindow = () => { ) => { const checkLabel = computed(() => { /** 如果是打开独立窗口就截取label中的固定label名称 */ - if (label.includes('alone')) { + if (label.includes(EventEnum.ALONE)) { return label.replace(/\d/g, '') } else { return label diff --git a/src/main.ts b/src/main.ts index b1b59e6..bd6a60b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,6 +6,9 @@ import vResize from '@/directives/v-resize' import vSlide from '@/directives/v-slide.ts' import router from '@/router' import App from '@/App.vue' +import { consolePrint } from '@/utils/Common.ts' const app = createApp(App) app.use(router).use(pinia).directive('resize', vResize).directive('slide', vSlide).mount('#app') +/**! 控制台打印项目版本信息(不需要可手动关闭)*/ +consolePrint() diff --git a/src/services/webSocket.ts b/src/services/webSocket.ts index 713870e..c5d4814 100644 --- a/src/services/webSocket.ts +++ b/src/services/webSocket.ts @@ -44,7 +44,7 @@ const initWebSocket = () => { reconnectAttempts++ initWebSocket() } else { - console.error('已达到最大重连次数,放弃重连') + window.$message.error('尝试重连失败,请检查后端服务是否正常') } }, reconnectDelay) } @@ -68,7 +68,7 @@ const sendToServer = (data: Record) => { ws.send(json) return Promise.resolve(true) } else { - return Promise.reject('网络连接失败,请检查网络设置') + return Promise.reject('服务连接失败,请联系管理员') } } diff --git a/src/styles/scss/toggle-theme.scss b/src/styles/scss/toggle-theme.scss deleted file mode 100644 index 597667a..0000000 --- a/src/styles/scss/toggle-theme.scss +++ /dev/null @@ -1,22 +0,0 @@ -/**!使用比较新的View Transitions API来实现主图切换效果*/ -::view-transition-old(root), -::view-transition-new(root) { - animation: none; - mix-blend-mode: normal; -} - -/** 进入dark模式和退出dark模式时,两个图像的位置顺序正好相反 */ -.dark::view-transition-old(root) { - z-index: 1; -} -.dark::view-transition-new(root) { - z-index: 999; -} - -::view-transition-old(root) { - z-index: 999; -} -::view-transition-new(root) { - z-index: 1; -} -/**!end*/ \ No newline at end of file diff --git a/src/utils/Common.ts b/src/utils/Common.ts new file mode 100644 index 0000000..0c61c8d --- /dev/null +++ b/src/utils/Common.ts @@ -0,0 +1,11 @@ +import { pkgJson } from '~/build/config/version.ts' +const { VITE_APP_NAME } = import.meta.env + +/** 控制台打印版本信息 */ +export const consolePrint = () => { + console.log( + `%c 🍀 ${VITE_APP_NAME} ${pkgJson.version}`, + 'font-size:20px;border-left: 4px solid #13987f;background: #cef9ec;font-family: Comic Sans MS, cursive;color:#581845;padding:10px;border-radius:4px;', + `${pkgJson.author.url}` + ) +} diff --git a/src/views/home-window/more/settings/General.vue b/src/views/home-window/more/settings/General.vue index 4bbcc4a..352a5c0 100644 --- a/src/views/home-window/more/settings/General.vue +++ b/src/views/home-window/more/settings/General.vue @@ -13,7 +13,7 @@ v-for="(item, index) in titleList" :key="index">
@@ -89,7 +89,7 @@