Merge branch 'main' into example

This commit is contained in:
Soybean 2024-06-14 00:05:12 +08:00
commit 799ebcc714
14 changed files with 48 additions and 13 deletions

View File

@ -1,6 +1,18 @@
# Changelog # Changelog
## [v1.2.4](https://github.com/soybeanjs/soybean-admin/compare/v1.2.3...v1.2.4) (2024-06-14)
###    🛠 Optimizations
- **projects**:
- optimize `setupAppVersionNotification` &nbsp;-&nbsp; by @soybeanjs [<samp>(b5a72)</samp>](https://github.com/soybeanjs/soybean-admin/commit/b5a723c)
- get buildTime with timezone 'Asia/Shanghai' &nbsp;-&nbsp; by @soybeanjs [<samp>(069fa)</samp>](https://github.com/soybeanjs/soybean-admin/commit/069fa8a)
### &nbsp;&nbsp;&nbsp;❤️ Contributors
[![soybeanjs](https://github.com/soybeanjs.png?size=48)](https://github.com/soybeanjs)&nbsp;&nbsp;
## [v1.2.3](https://github.com/soybeanjs/soybean-admin/compare/v1.2.2...v1.2.3) (2024-06-13) ## [v1.2.3](https://github.com/soybeanjs/soybean-admin/compare/v1.2.2...v1.2.3) (2024-06-13)
### &nbsp;&nbsp;&nbsp;🐞 Bug Fixes ### &nbsp;&nbsp;&nbsp;🐞 Bug Fixes

View File

@ -1 +1,2 @@
export * from './proxy'; export * from './proxy';
export * from './time';

12
build/config/time.ts Normal file
View File

@ -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;
}

View File

@ -1,7 +1,7 @@
{ {
"name": "soybean-admin", "name": "soybean-admin",
"type": "module", "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的清新优雅的中后台模版。", "description": "A fresh and elegant admin template, based on Vue3、Vite3、TypeScript、NaiveUI and UnoCSS. 一个基于Vue3、Vite3、TypeScript、NaiveUI and UnoCSS的清新优雅的中后台模版。",
"author": { "author": {
"name": "Soybean", "name": "Soybean",

View File

@ -1,6 +1,6 @@
{ {
"name": "@sa/axios", "name": "@sa/axios",
"version": "1.2.3", "version": "1.2.4",
"exports": { "exports": {
".": "./src/index.ts" ".": "./src/index.ts"
}, },

View File

@ -1,6 +1,6 @@
{ {
"name": "@sa/color", "name": "@sa/color",
"version": "1.2.3", "version": "1.2.4",
"exports": { "exports": {
".": "./src/index.ts" ".": "./src/index.ts"
}, },

View File

@ -1,6 +1,6 @@
{ {
"name": "@sa/hooks", "name": "@sa/hooks",
"version": "1.2.3", "version": "1.2.4",
"exports": { "exports": {
".": "./src/index.ts" ".": "./src/index.ts"
}, },

View File

@ -1,6 +1,6 @@
{ {
"name": "@sa/materials", "name": "@sa/materials",
"version": "1.2.3", "version": "1.2.4",
"exports": { "exports": {
".": "./src/index.ts" ".": "./src/index.ts"
}, },

View File

@ -1,6 +1,6 @@
{ {
"name": "@sa/fetch", "name": "@sa/fetch",
"version": "1.2.3", "version": "1.2.4",
"exports": { "exports": {
".": "./src/index.ts" ".": "./src/index.ts"
}, },

View File

@ -1,6 +1,6 @@
{ {
"name": "@sa/scripts", "name": "@sa/scripts",
"version": "1.2.3", "version": "1.2.4",
"bin": { "bin": {
"sa": "./bin.ts" "sa": "./bin.ts"
}, },

View File

@ -1,6 +1,6 @@
{ {
"name": "@sa/uno-preset", "name": "@sa/uno-preset",
"version": "1.2.3", "version": "1.2.4",
"exports": { "exports": {
".": "./src/index.ts" ".": "./src/index.ts"
}, },

View File

@ -1,6 +1,6 @@
{ {
"name": "@sa/utils", "name": "@sa/utils",
"version": "1.2.3", "version": "1.2.4",
"exports": { "exports": {
".": "./src/index.ts" ".": "./src/index.ts"
}, },

View File

@ -3,10 +3,18 @@ import { NButton } from 'naive-ui';
import { $t } from '../locales'; import { $t } from '../locales';
export function setupAppVersionNotification() { export function setupAppVersionNotification() {
let isShow = false;
document.addEventListener('visibilitychange', async () => { document.addEventListener('visibilitychange', async () => {
const preConditions = [!isShow, document.visibilityState === 'visible', !import.meta.env.DEV];
if (!preConditions.every(Boolean)) return;
const buildTime = await getHtmlBuildTime(); 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({ const n = window.$notification?.create({
title: $t('system.updateTitle'), title: $t('system.updateTitle'),
content: $t('system.updateContent'), content: $t('system.updateContent'),
@ -32,6 +40,9 @@ export function setupAppVersionNotification() {
() => $t('system.updateConfirm') () => $t('system.updateConfirm')
) )
]); ]);
},
onClose() {
isShow = false;
} }
}); });
} }

View File

@ -1,14 +1,13 @@
import process from 'node:process'; import process from 'node:process';
import { URL, fileURLToPath } from 'node:url'; import { URL, fileURLToPath } from 'node:url';
import { defineConfig, loadEnv } from 'vite'; import { defineConfig, loadEnv } from 'vite';
import dayjs from 'dayjs';
import { setupVitePlugins } from './build/plugins'; import { setupVitePlugins } from './build/plugins';
import { createViteProxy } from './build/config'; import { createViteProxy, getBuildTime } from './build/config';
export default defineConfig(configEnv => { export default defineConfig(configEnv => {
const viteEnv = loadEnv(configEnv.mode, process.cwd()) as unknown as Env.ImportMeta; 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 { return {
base: viteEnv.VITE_BASE_URL, base: viteEnv.VITE_BASE_URL,