From 74b46203045a65d33c3f269c2d9336756f1435e7 Mon Sep 17 00:00:00 2001 From: BaboonKing Date: Mon, 11 Mar 2024 14:00:09 +0800 Subject: [PATCH 1/5] chore: correct pnpm version and fixed it --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 77d5399e..d6b37e15 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "picx", "version": "3.0.0", "private": false, + "packageManager": "pnpm@7.33.7", "author": "XPoet ", "license": "AGPL-3.0", "bugs": { From 2544ab96d7268a63cd7f2bcd679104748229baa2 Mon Sep 17 00:00:00 2001 From: BaboonKing Date: Mon, 11 Mar 2024 15:38:10 +0800 Subject: [PATCH 2/5] feat: support update notification --- .eslintrc.js | 3 ++- package.json | 1 + pnpm-lock.yaml | 15 +++++++++++++++ src/plugins/vite/index.ts | 6 ++++++ src/shims-vue.d.ts | 1 + src/views/app-wrap/app-wrap.vue | 3 +++ 6 files changed, 28 insertions(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index d391a86c..50d61829 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -41,7 +41,8 @@ module.exports = { 'import/prefer-default-export': 'off', camelcase: 'off', 'no-param-reassign': 'off', - 'no-await-in-loop': 'off' + 'no-await-in-loop': 'off', + 'no-underscore-dangle': 'off' }, globals: { ...dts2Globals() diff --git a/package.json b/package.json index d6b37e15..254dd638 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "@commitlint/cli": "17.0.3", "@commitlint/config-conventional": "^17.0.3", "@iconify-json/ep": "^1.1.10", + "@plugin-web-update-notification/vite": "1.7.1", "@types/node": "^15.0.1", "@typescript-eslint/eslint-plugin": "^4.22.0", "@typescript-eslint/parser": "^4.22.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 03d552f5..ea9af870 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,7 @@ specifiers: '@commitlint/cli': 17.0.3 '@commitlint/config-conventional': ^17.0.3 '@iconify-json/ep': ^1.1.10 + '@plugin-web-update-notification/vite': 1.7.1 '@types/node': ^15.0.1 '@typescript-eslint/eslint-plugin': ^4.22.0 '@typescript-eslint/parser': ^4.22.0 @@ -53,6 +54,7 @@ devDependencies: '@commitlint/cli': 17.0.3 '@commitlint/config-conventional': 17.8.1 '@iconify-json/ep': 1.1.11 + '@plugin-web-update-notification/vite': 1.7.1_vite@2.7.13 '@types/node': 15.14.9 '@typescript-eslint/eslint-plugin': 4.33.0_s2qqtxhzmb7vugvfoyripfgp7i '@typescript-eslint/parser': 4.33.0_jofidmxrjzhj7l6vknpw5ecvfe @@ -1724,6 +1726,19 @@ packages: fastq: 1.15.0 dev: true + /@plugin-web-update-notification/core/1.7.1: + resolution: {integrity: sha512-G5xbuFE4B3TGxM9FxYwUlbGleuWNUzdbw3ZNcht1WDn85Qbhgzk7lQwuXVilxZII6LhsghJ4Zdapw0jgzuCJQw==} + dev: true + + /@plugin-web-update-notification/vite/1.7.1_vite@2.7.13: + resolution: {integrity: sha512-qIP2JBt19gZGWjagZOGc0qatoLGa2h4GnrHjF1ETzVgHUuJMgBeZpqMjzO81MwbmOUQdWbvwlF3ZZhXopeXB/w==} + peerDependencies: + vite: ^5.0.0 || >4.0.0 || ^3.0.0 + dependencies: + '@plugin-web-update-notification/core': 1.7.1 + vite: 2.7.13_stylus@0.59.0 + dev: true + /@rollup/plugin-babel/5.3.1_ruiheq7dzqj4xl2pvehe77v5xa: resolution: {integrity: sha512-WFfdLWU/xVWKeRQnKmIAQULUI7Il0gZnBIH/ZFO069wYIfPu+8zrfp/KMW0atmELoRDq8FbiP3VCss9MhCut7Q==} engines: {node: '>= 10.0.0'} diff --git a/src/plugins/vite/index.ts b/src/plugins/vite/index.ts index 013023d7..4996f0d6 100644 --- a/src/plugins/vite/index.ts +++ b/src/plugins/vite/index.ts @@ -5,6 +5,7 @@ import Components from 'unplugin-vue-components/vite' import { ElementPlusResolver } from 'unplugin-vue-components/resolvers' import IconsResolver from 'unplugin-icons/resolver' import Icons from 'unplugin-icons/vite' +import { webUpdateNotice } from '@plugin-web-update-notification/vite' import { ViteEnv } from '@/common/model' import configPWAPlugin from './pwa' @@ -45,6 +46,11 @@ export default function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) { // add plugin vite-plugin-pwa if (viteEnv.VITE_USE_PWA) { vitePlugins.push(configPWAPlugin()) + vitePlugins.push( + webUpdateNotice({ + logVersion: true + }) + ) } } diff --git a/src/shims-vue.d.ts b/src/shims-vue.d.ts index d53ab3db..a54fa01b 100644 --- a/src/shims-vue.d.ts +++ b/src/shims-vue.d.ts @@ -1,3 +1,4 @@ +/// declare module '*.vue' { import { DefineComponent } from 'vue' diff --git a/src/views/app-wrap/app-wrap.vue b/src/views/app-wrap/app-wrap.vue index 0f248e6a..8fd9978b 100644 --- a/src/views/app-wrap/app-wrap.vue +++ b/src/views/app-wrap/app-wrap.vue @@ -48,12 +48,15 @@ const elementPlusSizeHandle = (width: number) => { const setLanguage = (language: LanguageEnum) => { if (language === LanguageEnum.zhCN) { + window.pluginWebUpdateNotice_.setLocale('zh_CN') elementPlusLocale.value = zhCN // 设置 Element Plus 组件库语言 instance!.proxy!.$i18n.locale = 'zh-CN' // 设置 i18n 语言 } else if (language === LanguageEnum.zhTW) { + window.pluginWebUpdateNotice_.setLocale('zh_TW') elementPlusLocale.value = zhTW instance!.proxy!.$i18n.locale = 'zh-TW' } else if (language === LanguageEnum.en) { + window.pluginWebUpdateNotice_.setLocale('en_US') elementPlusLocale.value = en instance!.proxy!.$i18n.locale = 'en' } else { From 4f7a584cc578d823305667f8c26ce8ab331d2726 Mon Sep 17 00:00:00 2001 From: XPoet Date: Tue, 12 Mar 2024 17:38:55 +0800 Subject: [PATCH 3/5] fix: optimize the use of update notification plugin --- .eslintrc.js | 3 +-- index.html | 2 +- src/plugins/vite/index.ts | 13 +++++++------ src/views/app-wrap/app-wrap.vue | 17 +++++++++++------ 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 50d61829..d391a86c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -41,8 +41,7 @@ module.exports = { 'import/prefer-default-export': 'off', camelcase: 'off', 'no-param-reassign': 'off', - 'no-await-in-loop': 'off', - 'no-underscore-dangle': 'off' + 'no-await-in-loop': 'off' }, globals: { ...dts2Globals() diff --git a/index.html b/index.html index dc244c48..a7adae22 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ - PicX 图床神器 + PicX diff --git a/src/plugins/vite/index.ts b/src/plugins/vite/index.ts index 4996f0d6..176ff5fd 100644 --- a/src/plugins/vite/index.ts +++ b/src/plugins/vite/index.ts @@ -12,7 +12,6 @@ import configPWAPlugin from './pwa' export default function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) { const vitePlugins: (Plugin | Plugin[])[] = [vue()] - // 按需自动导入 Element Plus 组件 vitePlugins.push( AutoImport({ resolvers: [ @@ -25,6 +24,7 @@ export default function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) { ], dts: 'src/auto-imports.d.ts' }), + Components({ resolvers: [ // 自动导入 Element Plus 组件 @@ -36,8 +36,14 @@ export default function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) { ], dts: 'src/components.d.ts' }), + Icons({ autoInstall: true + }), + + // 更新通知插件 + webUpdateNotice({ + logVersion: true }) ) @@ -46,11 +52,6 @@ export default function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) { // add plugin vite-plugin-pwa if (viteEnv.VITE_USE_PWA) { vitePlugins.push(configPWAPlugin()) - vitePlugins.push( - webUpdateNotice({ - logVersion: true - }) - ) } } diff --git a/src/views/app-wrap/app-wrap.vue b/src/views/app-wrap/app-wrap.vue index 8fd9978b..50fc68f7 100644 --- a/src/views/app-wrap/app-wrap.vue +++ b/src/views/app-wrap/app-wrap.vue @@ -48,20 +48,25 @@ const elementPlusSizeHandle = (width: number) => { const setLanguage = (language: LanguageEnum) => { if (language === LanguageEnum.zhCN) { - window.pluginWebUpdateNotice_.setLocale('zh_CN') - elementPlusLocale.value = zhCN // 设置 Element Plus 组件库语言 instance!.proxy!.$i18n.locale = 'zh-CN' // 设置 i18n 语言 + elementPlusLocale.value = zhCN // 设置 Element Plus 组件库语言 + // eslint-disable-next-line no-underscore-dangle + window.pluginWebUpdateNotice_?.setLocale('zh_CN') } else if (language === LanguageEnum.zhTW) { - window.pluginWebUpdateNotice_.setLocale('zh_TW') - elementPlusLocale.value = zhTW instance!.proxy!.$i18n.locale = 'zh-TW' + elementPlusLocale.value = zhTW + // eslint-disable-next-line no-underscore-dangle + window.pluginWebUpdateNotice_?.setLocale('zh_TW') } else if (language === LanguageEnum.en) { - window.pluginWebUpdateNotice_.setLocale('en_US') - elementPlusLocale.value = en instance!.proxy!.$i18n.locale = 'en' + elementPlusLocale.value = en + // eslint-disable-next-line no-underscore-dangle + window.pluginWebUpdateNotice_?.setLocale('en_US') } else { elementPlusLocale.value = zhCN instance!.proxy!.$i18n.locale = 'zh-CN' + // eslint-disable-next-line no-underscore-dangle + window.pluginWebUpdateNotice_?.setLocale('zh_CN') } setWindowTitle(router.currentRoute.value.meta.title as string) } From 426f4459a63ea201e1ca00b961bac8493b865f06 Mon Sep 17 00:00:00 2001 From: XPoet Date: Tue, 12 Mar 2024 17:59:28 +0800 Subject: [PATCH 4/5] perf: optimize language setting --- src/views/app-wrap/app-wrap.vue | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/views/app-wrap/app-wrap.vue b/src/views/app-wrap/app-wrap.vue index 50fc68f7..351270f2 100644 --- a/src/views/app-wrap/app-wrap.vue +++ b/src/views/app-wrap/app-wrap.vue @@ -113,6 +113,9 @@ const setLanguageByIP = () => { store.dispatch('SET_USER_SETTINGS', { language }) + store.dispatch('SET_GLOBAL_SETTINGS', { + language + }) msgInstance.close() }) } From 6875c077819bccf621caa2c2aec0fa9c92e05fda Mon Sep 17 00:00:00 2001 From: XPoet Date: Tue, 12 Mar 2024 18:00:00 +0800 Subject: [PATCH 5/5] chore: release v3.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 254dd638..ec2b94ea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "picx", - "version": "3.0.0", + "version": "3.0.1", "private": false, "packageManager": "pnpm@7.33.7", "author": "XPoet ",