diff --git a/.vscode/settings.json b/.vscode/settings.json index f7b20e53..1a42d1dc 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -15,5 +15,5 @@ "prettier.enable": false, "typescript.tsdk": "node_modules/typescript/lib", "unocss.root": ["./"], - "vue.server.hybridMode": false + "vue.server.hybridMode": true } diff --git a/CHANGELOG.md b/CHANGELOG.md index ea7e433c..40cb9968 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,37 @@ # Changelog +## [v1.2.0](https://github.com/soybeanjs/soybean-admin/compare/v1.1.5...v1.2.0) (2024-06-06) + +### 🚀 Features + +- **projects**: + - support system new version update notification. close #420 - by @soybeanjs in https://github.com/soybeanjs/soybean-admin/issues/420 [(584cd)](https://github.com/soybeanjs/soybean-admin/commit/584cd54) + - get user info in router guard and remove in localStorage. close #459 - by @soybeanjs in https://github.com/soybeanjs/soybean-admin/issues/459 [(5531a)](https://github.com/soybeanjs/soybean-admin/commit/5531a68) + +### 📖 Documentation + +- **projects**: update CHANGELOG - by @soybeanjs [(2bec8)](https://github.com/soybeanjs/soybean-admin/commit/2bec899) + +### ❤️ Contributors + +[](https://github.com/soybeanjs) + +## [v1.1.5](https://github.com/soybeanjs/soybean-admin/compare/v1.1.4...v1.1.5) (2024-06-06) + +### 🐞 Bug Fixes + +- **projects**: fix register name, CodeLogin => Register - by @m-xlsea in https://github.com/soybeanjs/soybean-admin/issues/478 [(ddf38)](https://github.com/soybeanjs/soybean-admin/commit/ddf3823) + +### 🏡 Chore + +- **deps**: update deps - by @soybeanjs [(060c0)](https://github.com/soybeanjs/soybean-admin/commit/060c0a9) +- **projects**: update vscode settings: vue official - by @soybeanjs [(76649)](https://github.com/soybeanjs/soybean-admin/commit/76649e2) + +### ❤️ Contributors + +[](https://github.com/soybeanjs) [](https://github.com/m-xlsea) + ## [v1.1.4](https://github.com/honghuangdc/soybean-admin/compare/v1.1.3...v1.1.4) (2024-06-06) ### 🐞 Bug Fixes diff --git a/CHANGELOG.zh_CN.md b/CHANGELOG.zh_CN.md index cd3d2da5..0d11c7d9 100644 --- a/CHANGELOG.zh_CN.md +++ b/CHANGELOG.zh_CN.md @@ -1,5 +1,67 @@ # 更新日志 + +## [v1.2.0](https://github.com/soybeanjs/soybean-admin/compare/v1.1.5...v1.2.0) (2024-06-06) + +### 🚀 功能 + +- **项目**: + - 支持系统新版本更新通知。关闭 #420 - 由 @soybeanjs 在 https://github.com/soybeanjs/soybean-admin/issues/420 [(584cd)](https://github.com/soybeanjs/soybean-admin/commit/584cd54) + - 在路由守卫中获取用户信息并从localStorage中移除。关闭 #459 - 由 @soybeanjs 在 https://github.com/soybeanjs/soybean-admin/issues/459 [(5531a)](https://github.com/soybeanjs/soybean-admin/commit/5531a68) + +### 📖 文档 + +- **项目**: 更新CHANGELOG - 由 @soybeanjs [(2bec8)](https://github.com/soybeanjs/soybean-admin/commit/2bec899) + +### ❤️ 贡献者 + +[](https://github.com/soybeanjs) + +## [v1.1.5](https://github.com/soybeanjs/soybean-admin/compare/v1.1.4...v1.1.5) (2024-06-06) + +### 🐞 错误修复 + +- **项目**: 修复注册组件名,CodeLogin => Register - 由 @m-xlsea 在 https://github.com/soybeanjs/soybean-admin/issues/478 [(ddf38)](https://github.com/soybeanjs/soybean-admin/commit/ddf3823) + +### 🏡 杂务 + +- **依赖**: 更新依赖 - 由 @soybeanjs [(060c0)](https://github.com/soybeanjs/soybean-admin/commit/060c0a9) +- **项目**: 更新 vscode 设置: vue 官方 - 由 @soybeanjs [(76649)](https://github.com/soybeanjs/soybean-admin/commit/76649e2) + +### ❤️ 贡献者 + +[](https://github.com/soybeanjs) [](https://github.com/m-xlsea) + +## [v1.1.4](https://github.com/honghuangdc/soybean-admin/compare/v1.1.3...v1.1.4) (2024-06-06) + +### 🐞 错误修复 + +- **utils**: 修复了按esc键时modalLogout的错误 - 由 @sigma-plus 在 https://github.com/honghuangdc/soybean-admin/issues/470 中提出 [(bd69c)](https://github.com/honghuangdc/soybean-admin/commit/bd69c00) + +### 🛠 优化 + +- **projects**: 优化了RouteMeta的备注 - 由 @soybeanjs 提出 [(ffb48)](https://github.com/honghuangdc/soybean-admin/commit/ffb48b1) + +### 📖 文档 + +- **projects**: + - 更新了CHANGELOG - 由 @soybeanjs 提出 [(756f8)](https://github.com/honghuangdc/soybean-admin/commit/756f84a) + - 更新了Node&pnpm版本 - 由 @Azir-11 在 https://github.com/honghuangdc/soybean-admin/issues/472 中提出 [(9b05d)](https://github.com/honghuangdc/soybean-admin/commit/9b05d73) + +### 🏡 杂项 + +- **deps**: + - 更新了依赖 - 由 @soybeanjs 提出 [(d0380)](https://github.com/honghuangdc/soybean-admin/commit/d0380ce) + - 更新了依赖 - 由 @soybeanjs 提出 [(1f464)](https://github.com/honghuangdc/soybean-admin/commit/1f4647b) +- **projects**: + - 关闭了http代理 - 由 @soybeanjs 提出 [(d08a3)](https://github.com/honghuangdc/soybean-admin/commit/d08a381) + - 更新了mock url - 由 @soybeanjs 提出 [(e6086)](https://github.com/honghuangdc/soybean-admin/commit/e6086f0) + - 更新了vscode设置 - 由 @soybeanjs 提出 [(910df)](https://github.com/honghuangdc/soybean-admin/commit/910dfca) + +### ❤️ 贡献者 + +[](https://github.com/soybeanjs) [](https://github.com/Azir-11) [](https://github.com/sigma-plus) + ## [v1.1.3](https://github.com/soybeanjs/soybean-admin/compare/v1.1.2...v1.1.3) (2024-06-02) ### 🐞 错误修复 diff --git a/build/plugins/html.ts b/build/plugins/html.ts new file mode 100644 index 00000000..b94d24fe --- /dev/null +++ b/build/plugins/html.ts @@ -0,0 +1,13 @@ +import type { Plugin } from 'vite'; + +export function setupHtmlPlugin(buildTime: string) { + const plugin: Plugin = { + name: 'html-plugin', + apply: 'build', + transformIndexHtml(html) { + return html.replace('
', `\n `); + } + }; + + return plugin; +} diff --git a/build/plugins/index.ts b/build/plugins/index.ts index d437da70..debec678 100644 --- a/build/plugins/index.ts +++ b/build/plugins/index.ts @@ -6,8 +6,9 @@ import progress from 'vite-plugin-progress'; import { setupElegantRouter } from './router'; import { setupUnocss } from './unocss'; import { setupUnplugin } from './unplugin'; +import { setupHtmlPlugin } from './html'; -export function setupVitePlugins(viteEnv: Env.ImportMeta) { +export function setupVitePlugins(viteEnv: Env.ImportMeta, buildTime: string) { const plugins: PluginOption = [ vue({ script: { @@ -19,7 +20,8 @@ export function setupVitePlugins(viteEnv: Env.ImportMeta) { setupElegantRouter(), setupUnocss(viteEnv), ...setupUnplugin(viteEnv), - progress() + progress(), + setupHtmlPlugin(buildTime) ]; return plugins; diff --git a/eslint.config.js b/eslint.config.js index cc9dfd08..00537e3f 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -7,7 +7,7 @@ export default defineConfig( 'vue/multi-word-component-names': [ 'warn', { - ignores: ['index', 'App', '[id]', '[url]'] + ignores: ['index', 'App', 'Register', '[id]', '[url]'] } ], 'vue/component-name-in-template-casing': [ diff --git a/package.json b/package.json index 93efea11..ed74e100 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "soybean-admin", "type": "module", - "version": "1.1.4", + "version": "1.2.0", "description": "A fresh and elegant admin template, based on Vue3、Vite3、TypeScript、NaiveUI and UnoCSS. 一个基于Vue3、Vite3、TypeScript、NaiveUI and UnoCSS的清新优雅的中后台模版。", "author": { "name": "Soybean", @@ -99,7 +99,7 @@ "lint-staged": "15.2.5", "sass": "1.77.4", "simple-git-hooks": "2.11.1", - "tsx": "4.11.2", + "tsx": "4.12.0", "typescript": "5.4.5", "unplugin-icons": "0.19.0", "unplugin-vue-components": "0.27.0", diff --git a/packages/axios/package.json b/packages/axios/package.json index 9ee38aef..c81267ee 100644 --- a/packages/axios/package.json +++ b/packages/axios/package.json @@ -1,6 +1,6 @@ { "name": "@sa/axios", - "version": "1.1.4", + "version": "1.2.0", "exports": { ".": "./src/index.ts" }, diff --git a/packages/color/package.json b/packages/color/package.json index 34996d95..43d1f58d 100644 --- a/packages/color/package.json +++ b/packages/color/package.json @@ -1,6 +1,6 @@ { "name": "@sa/color", - "version": "1.1.4", + "version": "1.2.0", "exports": { ".": "./src/index.ts" }, diff --git a/packages/hooks/package.json b/packages/hooks/package.json index 98dd65ec..fffe7415 100644 --- a/packages/hooks/package.json +++ b/packages/hooks/package.json @@ -1,6 +1,6 @@ { "name": "@sa/hooks", - "version": "1.1.4", + "version": "1.2.0", "exports": { ".": "./src/index.ts" }, diff --git a/packages/materials/package.json b/packages/materials/package.json index c8b79f32..d40c5ec7 100644 --- a/packages/materials/package.json +++ b/packages/materials/package.json @@ -1,6 +1,6 @@ { "name": "@sa/materials", - "version": "1.1.4", + "version": "1.2.0", "exports": { ".": "./src/index.ts" }, diff --git a/packages/ofetch/package.json b/packages/ofetch/package.json index 21d043bd..2a8b7a5d 100644 --- a/packages/ofetch/package.json +++ b/packages/ofetch/package.json @@ -1,6 +1,6 @@ { "name": "@sa/fetch", - "version": "1.1.4", + "version": "1.2.0", "exports": { ".": "./src/index.ts" }, diff --git a/packages/scripts/package.json b/packages/scripts/package.json index be1ceb41..354f3158 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -1,6 +1,6 @@ { "name": "@sa/scripts", - "version": "1.1.4", + "version": "1.2.0", "bin": { "sa": "./bin.ts" }, diff --git a/packages/uno-preset/package.json b/packages/uno-preset/package.json index 3bc13c46..8b318bc1 100644 --- a/packages/uno-preset/package.json +++ b/packages/uno-preset/package.json @@ -1,6 +1,6 @@ { "name": "@sa/uno-preset", - "version": "1.1.4", + "version": "1.2.0", "exports": { ".": "./src/index.ts" }, diff --git a/packages/utils/package.json b/packages/utils/package.json index e1135c1b..d61af636 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@sa/utils", - "version": "1.1.4", + "version": "1.2.0", "exports": { ".": "./src/index.ts" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e51f97ab..95a98c08 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -163,8 +163,8 @@ importers: specifier: 2.11.1 version: 2.11.1 tsx: - specifier: 4.11.2 - version: 4.11.2 + specifier: 4.12.0 + version: 4.12.0 typescript: specifier: 5.4.5 version: 5.4.5 @@ -1635,8 +1635,8 @@ packages: can-use-dom@0.1.0: resolution: {integrity: sha512-ceOhN1DL7Y4O6M0j9ICgmTYziV89WMd96SvSl0REd8PMgrY0B/WBOPoed5S1KUmJqXgUXh8gzSe6E3ae27upsQ==} - caniuse-lite@1.0.30001628: - resolution: {integrity: sha512-S3BnR4Kh26TBxbi5t5kpbcUlLJb9lhtDXISDPwOfI+JoC+ik0QksvkZtUVyikw3hjnkgkMPSJ8oIM9yMm9vflA==} + caniuse-lite@1.0.30001629: + resolution: {integrity: sha512-c3dl911slnQhmxUIT4HhYzT7wnBK/XYpGnYLOj4nJBaRiw52Ibe7YxlDaAeRECvA786zCuExhxIUJ2K7nHMrBw==} center-align@0.1.3: resolution: {integrity: sha512-Baz3aNe2gd2LP2qk5U+sDk/m4oSuwSDcBfayTCTBoWpfIGO5XFxPmjILQII4NGiZjD6DoDI6kf7gKaxkf7s3VQ==} @@ -2189,8 +2189,8 @@ packages: echarts@5.5.0: resolution: {integrity: sha512-rNYnNCzqDAPCr4m/fqyUFv7fD9qIsd50S6GDFgO1DxZhncCsNsG7IfUlAlvZe5oSEQxtsjnHiUuppzccry93Xw==} - electron-to-chromium@1.4.790: - resolution: {integrity: sha512-eVGeQxpaBYbomDBa/Mehrs28MdvCXfJmEFzaMFsv8jH/MJDLIylJN81eTJ5kvx7B7p18OiPK0BkC06lydEy63A==} + electron-to-chromium@1.4.792: + resolution: {integrity: sha512-rkg5/N3L+Y844JyfgPUyuKK0Hk0efo3JNxUDKvz3HgP6EmN4rNGhr2D8boLsfTV/hGo7ZGAL8djw+jlg99zQyA==} emoji-regex@10.3.0: resolution: {integrity: sha512-QpLs9D9v9kArv4lfDEgg1X/gN5XLnf/A6l9cs8SPZLRZR3ZkY9+kwIQTxm+fsSej5UMYGE8fdoaZVIBlqG0XTw==} @@ -3173,8 +3173,8 @@ packages: resolution: {integrity: sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==} engines: {node: '>=0.10.0'} - jackspeak@3.3.0: - resolution: {integrity: sha512-glPiBfKguqA7v8JsXO3iLjJWZ9FV1vNpoI0I9hI9Mnk5yetO9uPLSpiCEmiVijAssv2f54HpvtzvAHfhPieiDQ==} + jackspeak@3.4.0: + resolution: {integrity: sha512-JVYhQnN59LVPFCEcVa2C3CrEKYacvjRfqIQl+h8oi91aLYQVWRYbxjPcv1bUiUy/kLmQaANrYfNMCO3kuEDHfw==} engines: {node: '>=14'} jiti@1.21.3: @@ -4672,8 +4672,8 @@ packages: tslib@2.6.3: resolution: {integrity: sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==} - tsx@4.11.2: - resolution: {integrity: sha512-V5DL5v1BuItjsQ2FN9+4OjR7n5cr8hSgN+VGmm/fd2/0cgQdBIWHcQ3bFYm/5ZTmyxkTDBUIaRuW2divgfPe0A==} + tsx@4.12.0: + resolution: {integrity: sha512-642NAWAbDqPZINjmL32Lh/B+pd8vbVj6LHPsWm09IIHqQuWhCrNfcPTjRlHFWvv3FfM4vt9NLReBIjUNj5ZhDg==} engines: {node: '>=18.0.0'} hasBin: true @@ -6651,8 +6651,8 @@ snapshots: browserslist@4.23.0: dependencies: - caniuse-lite: 1.0.30001628 - electron-to-chromium: 1.4.790 + caniuse-lite: 1.0.30001629 + electron-to-chromium: 1.4.792 node-releases: 2.0.14 update-browserslist-db: 1.0.16(browserslist@4.23.0) @@ -6774,7 +6774,7 @@ snapshots: can-use-dom@0.1.0: {} - caniuse-lite@1.0.30001628: {} + caniuse-lite@1.0.30001629: {} center-align@0.1.3: dependencies: @@ -7317,7 +7317,7 @@ snapshots: tslib: 2.3.0 zrender: 5.5.0 - electron-to-chromium@1.4.790: {} + electron-to-chromium@1.4.792: {} emoji-regex@10.3.0: {} @@ -7965,7 +7965,7 @@ snapshots: glob@10.4.1: dependencies: foreground-child: 3.1.1 - jackspeak: 3.3.0 + jackspeak: 3.4.0 minimatch: 9.0.4 minipass: 7.1.2 path-scurry: 1.11.1 @@ -8419,7 +8419,7 @@ snapshots: isobject@3.0.1: {} - jackspeak@3.3.0: + jackspeak@3.4.0: dependencies: '@isaacs/cliui': 8.0.2 optionalDependencies: @@ -10164,7 +10164,7 @@ snapshots: tslib@2.6.3: {} - tsx@4.11.2: + tsx@4.12.0: dependencies: esbuild: 0.20.2 get-tsconfig: 4.7.5 diff --git a/src/locales/langs/en-us.ts b/src/locales/langs/en-us.ts index fd5c974e..3bfc227c 100644 --- a/src/locales/langs/en-us.ts +++ b/src/locales/langs/en-us.ts @@ -1,6 +1,10 @@ const local: App.I18n.Schema = { system: { - title: 'SoybeanAdmin' + title: 'SoybeanAdmin', + updateTitle: 'System Version Update Notification', + updateContent: 'A new version of the system has been detected. Do you want to refresh the page immediately?', + updateConfirm: 'Refresh immediately', + updateCancel: 'Later' }, common: { action: 'Action', diff --git a/src/locales/langs/zh-cn.ts b/src/locales/langs/zh-cn.ts index d3a77d01..d58d1b47 100644 --- a/src/locales/langs/zh-cn.ts +++ b/src/locales/langs/zh-cn.ts @@ -1,6 +1,10 @@ const local: App.I18n.Schema = { system: { - title: 'Soybean 管理系统' + title: 'Soybean 管理系统', + updateTitle: '系统版本更新通知', + updateContent: '检测到系统有新版本发布,是否立即刷新页面?', + updateConfirm: '立即刷新', + updateCancel: '稍后再说' }, common: { action: '操作', diff --git a/src/main.ts b/src/main.ts index efb97f89..b97a0d93 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,6 +1,6 @@ import { createApp } from 'vue'; import './plugins/assets'; -import { setupDayjs, setupIconifyOffline, setupLoading, setupNProgress } from './plugins'; +import { setupAppVersionNotification, setupDayjs, setupIconifyOffline, setupLoading, setupNProgress } from './plugins'; import { setupStore } from './store'; import { setupRouter } from './router'; import { setupI18n } from './locales'; @@ -23,6 +23,8 @@ async function setupApp() { setupI18n(app); + setupAppVersionNotification(); + app.mount('#app'); } diff --git a/src/plugins/app.ts b/src/plugins/app.ts new file mode 100644 index 00000000..ffe6f586 --- /dev/null +++ b/src/plugins/app.ts @@ -0,0 +1,53 @@ +import { h } from 'vue'; +import { NButton } from 'naive-ui'; +import { $t } from '../locales'; + +export function setupAppVersionNotification() { + document.addEventListener('visibilitychange', async () => { + const buildTime = await getHtmlBuildTime(); + + if (buildTime !== BUILD_TIME && document.visibilityState === 'visible') { + const n = window.$notification?.create({ + title: $t('system.updateTitle'), + content: $t('system.updateContent'), + action() { + return h('div', { style: { display: 'flex', justifyContent: 'end', gap: '12px', width: '325px' } }, [ + h( + NButton, + { + onClick() { + n?.destroy(); + } + }, + $t('system.updateCancel') + ), + h( + NButton, + { + type: 'primary', + onClick() { + location.reload(); + } + }, + $t('system.updateConfirm') + ) + ]); + } + }); + } + }); +} + +async function getHtmlBuildTime() { + const baseURL = import.meta.env.VITE_BASE_URL; + + const res = await fetch(`${baseURL}index.html`); + + const html = await res.text(); + + const match = html.match(//); + + const buildTime = match?.[1] || ''; + + return buildTime; +} diff --git a/src/plugins/index.ts b/src/plugins/index.ts index 5d10c3aa..b2c9f9b5 100644 --- a/src/plugins/index.ts +++ b/src/plugins/index.ts @@ -2,3 +2,4 @@ export * from './loading'; export * from './nprogress'; export * from './iconify'; export * from './dayjs'; +export * from './app'; diff --git a/src/router/guard/route.ts b/src/router/guard/route.ts index 03a5121d..0a00ac71 100644 --- a/src/router/guard/route.ts +++ b/src/router/guard/route.ts @@ -92,6 +92,7 @@ export function createRouteGuard(router: Router) { * @param to to route */ async function initRoute(to: RouteLocationNormalized): Promise