diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f545f52..794b2791 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,18 @@ # Changelog +## [v1.2.4](https://github.com/soybeanjs/soybean-admin/compare/v1.2.3...v1.2.4) (2024-06-14) + +###    🛠 Optimizations + +- **projects**: + - optimize `setupAppVersionNotification`  -  by @soybeanjs [(b5a72)](https://github.com/soybeanjs/soybean-admin/commit/b5a723c) + - get buildTime with timezone 'Asia/Shanghai'  -  by @soybeanjs [(069fa)](https://github.com/soybeanjs/soybean-admin/commit/069fa8a) + +###    ❤️ Contributors + +[![soybeanjs](https://github.com/soybeanjs.png?size=48)](https://github.com/soybeanjs)   + ## [v1.2.3](https://github.com/soybeanjs/soybean-admin/compare/v1.2.2...v1.2.3) (2024-06-13) ###    🐞 Bug Fixes diff --git a/build/config/index.ts b/build/config/index.ts index 9bcd8689..8a9621a6 100644 --- a/build/config/index.ts +++ b/build/config/index.ts @@ -1 +1,2 @@ export * from './proxy'; +export * from './time'; diff --git a/build/config/time.ts b/build/config/time.ts new file mode 100644 index 00000000..3b571460 --- /dev/null +++ b/build/config/time.ts @@ -0,0 +1,12 @@ +import dayjs from 'dayjs'; +import utc from 'dayjs/plugin/utc'; +import timezone from 'dayjs/plugin/timezone'; + +export function getBuildTime() { + dayjs.extend(utc); + dayjs.extend(timezone); + + const buildTime = dayjs.tz(Date.now(), 'Asia/Shanghai').format('YYYY-MM-DD HH:mm:ss'); + + return buildTime; +} diff --git a/package.json b/package.json index 88518ad0..6968a3d8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "soybean-admin", "type": "module", - "version": "1.2.3", + "version": "1.2.4", "description": "A fresh and elegant admin template, based on Vue3、Vite3、TypeScript、NaiveUI and UnoCSS. 一个基于Vue3、Vite3、TypeScript、NaiveUI and UnoCSS的清新优雅的中后台模版。", "author": { "name": "Soybean", diff --git a/packages/axios/package.json b/packages/axios/package.json index 7908dfa2..d5a29aeb 100644 --- a/packages/axios/package.json +++ b/packages/axios/package.json @@ -1,6 +1,6 @@ { "name": "@sa/axios", - "version": "1.2.3", + "version": "1.2.4", "exports": { ".": "./src/index.ts" }, diff --git a/packages/color/package.json b/packages/color/package.json index 0bf44a3d..a6685034 100644 --- a/packages/color/package.json +++ b/packages/color/package.json @@ -1,6 +1,6 @@ { "name": "@sa/color", - "version": "1.2.3", + "version": "1.2.4", "exports": { ".": "./src/index.ts" }, diff --git a/packages/hooks/package.json b/packages/hooks/package.json index 19de0c72..d5430c6a 100644 --- a/packages/hooks/package.json +++ b/packages/hooks/package.json @@ -1,6 +1,6 @@ { "name": "@sa/hooks", - "version": "1.2.3", + "version": "1.2.4", "exports": { ".": "./src/index.ts" }, diff --git a/packages/materials/package.json b/packages/materials/package.json index 4d54af08..e1108a56 100644 --- a/packages/materials/package.json +++ b/packages/materials/package.json @@ -1,6 +1,6 @@ { "name": "@sa/materials", - "version": "1.2.3", + "version": "1.2.4", "exports": { ".": "./src/index.ts" }, diff --git a/packages/ofetch/package.json b/packages/ofetch/package.json index fecf1b26..3255ab43 100644 --- a/packages/ofetch/package.json +++ b/packages/ofetch/package.json @@ -1,6 +1,6 @@ { "name": "@sa/fetch", - "version": "1.2.3", + "version": "1.2.4", "exports": { ".": "./src/index.ts" }, diff --git a/packages/scripts/package.json b/packages/scripts/package.json index bca7a397..762238fd 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -1,6 +1,6 @@ { "name": "@sa/scripts", - "version": "1.2.3", + "version": "1.2.4", "bin": { "sa": "./bin.ts" }, diff --git a/packages/uno-preset/package.json b/packages/uno-preset/package.json index 04f7add3..5b12df8a 100644 --- a/packages/uno-preset/package.json +++ b/packages/uno-preset/package.json @@ -1,6 +1,6 @@ { "name": "@sa/uno-preset", - "version": "1.2.3", + "version": "1.2.4", "exports": { ".": "./src/index.ts" }, diff --git a/packages/utils/package.json b/packages/utils/package.json index f9bd6c76..331b3af0 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@sa/utils", - "version": "1.2.3", + "version": "1.2.4", "exports": { ".": "./src/index.ts" }, diff --git a/src/plugins/app.ts b/src/plugins/app.ts index 553fef7c..edaeb752 100644 --- a/src/plugins/app.ts +++ b/src/plugins/app.ts @@ -3,10 +3,18 @@ import { NButton } from 'naive-ui'; import { $t } from '../locales'; export function setupAppVersionNotification() { + let isShow = false; + document.addEventListener('visibilitychange', async () => { + const preConditions = [!isShow, document.visibilityState === 'visible', !import.meta.env.DEV]; + + if (!preConditions.every(Boolean)) return; + const buildTime = await getHtmlBuildTime(); - if (!import.meta.env.DEV && buildTime !== BUILD_TIME && document.visibilityState === 'visible') { + if (buildTime !== BUILD_TIME) { + isShow = true; + const n = window.$notification?.create({ title: $t('system.updateTitle'), content: $t('system.updateContent'), @@ -32,6 +40,9 @@ export function setupAppVersionNotification() { () => $t('system.updateConfirm') ) ]); + }, + onClose() { + isShow = false; } }); } diff --git a/vite.config.ts b/vite.config.ts index c3ea6d06..218d28c9 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,14 +1,13 @@ import process from 'node:process'; import { URL, fileURLToPath } from 'node:url'; import { defineConfig, loadEnv } from 'vite'; -import dayjs from 'dayjs'; import { setupVitePlugins } from './build/plugins'; -import { createViteProxy } from './build/config'; +import { createViteProxy, getBuildTime } from './build/config'; export default defineConfig(configEnv => { const viteEnv = loadEnv(configEnv.mode, process.cwd()) as unknown as Env.ImportMeta; - const buildTime = dayjs().format('YYYY-MM-DD HH:mm:ss'); + const buildTime = getBuildTime(); return { base: viteEnv.VITE_BASE_URL,