Merge branch 'main' into example

This commit is contained in:
Soybean 2024-06-07 11:55:56 +08:00
commit 599d0f10e8
14 changed files with 85 additions and 35 deletions

View File

@ -1,6 +1,26 @@
# Changelog # Changelog
## [v1.2.1](https://github.com/honghuangdc/soybean-admin/compare/v1.2.0...v1.2.1) (2024-06-07)
###    🐞 Bug Fixes
- **projects**:
- fix get user info when page reload &nbsp;-&nbsp; by @soybeanjs [<samp>(ff51b)</samp>](https://github.com/honghuangdc/soybean-admin/commit/ff51b72)
- fix setupAppVersionNotification render &nbsp;-&nbsp; by @soybeanjs [<samp>(6a6eb)</samp>](https://github.com/honghuangdc/soybean-admin/commit/6a6eb9a)
### &nbsp;&nbsp;&nbsp;📖 Documentation
- **projects**: update CHANGELOG &nbsp;-&nbsp; by @soybeanjs [<samp>(fe06b)</samp>](https://github.com/honghuangdc/soybean-admin/commit/fe06b8c)
### &nbsp;&nbsp;&nbsp;🏡 Chore
- **deps**: update deps &nbsp;-&nbsp; by @soybeanjs [<samp>(08827)</samp>](https://github.com/honghuangdc/soybean-admin/commit/08827a4)
### &nbsp;&nbsp;&nbsp;❤️ Contributors
[![soybeanjs](https://github.com/soybeanjs.png?size=48)](https://github.com/soybeanjs)&nbsp;&nbsp;
## [v1.2.0](https://github.com/soybeanjs/soybean-admin/compare/v1.1.5...v1.2.0) (2024-06-06) ## [v1.2.0](https://github.com/soybeanjs/soybean-admin/compare/v1.1.5...v1.2.0) (2024-06-06)
### &nbsp;&nbsp;&nbsp;🚀 Features ### &nbsp;&nbsp;&nbsp;🚀 Features

View File

@ -1,7 +1,7 @@
{ {
"name": "soybean-admin", "name": "soybean-admin",
"type": "module", "type": "module",
"version": "1.2.0", "version": "1.2.1",
"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",
@ -78,7 +78,7 @@
"devDependencies": { "devDependencies": {
"@amap/amap-jsapi-types": "0.0.8", "@amap/amap-jsapi-types": "0.0.8",
"@elegant-router/vue": "0.3.7", "@elegant-router/vue": "0.3.7",
"@iconify/json": "2.2.216", "@iconify/json": "2.2.217",
"@sa/scripts": "workspace:*", "@sa/scripts": "workspace:*",
"@sa/uno-preset": "workspace:*", "@sa/uno-preset": "workspace:*",
"@soybeanjs/eslint-config": "1.3.6", "@soybeanjs/eslint-config": "1.3.6",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
{ {
"name": "@sa/scripts", "name": "@sa/scripts",
"version": "1.2.0", "version": "1.2.1",
"bin": { "bin": {
"sa": "./bin.ts" "sa": "./bin.ts"
}, },
@ -19,7 +19,7 @@
"cac": "6.7.14", "cac": "6.7.14",
"consola": "3.2.3", "consola": "3.2.3",
"enquirer": "2.4.1", "enquirer": "2.4.1",
"execa": "9.1.0", "execa": "9.2.0",
"kolorist": "1.8.0", "kolorist": "1.8.0",
"npm-check-updates": "16.14.20", "npm-check-updates": "16.14.20",
"rimraf": "5.0.7" "rimraf": "5.0.7"

View File

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

View File

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

View File

@ -100,8 +100,8 @@ importers:
specifier: 0.3.7 specifier: 0.3.7
version: 0.3.7 version: 0.3.7
'@iconify/json': '@iconify/json':
specifier: 2.2.216 specifier: 2.2.217
version: 2.2.216 version: 2.2.217
'@sa/scripts': '@sa/scripts':
specifier: workspace:* specifier: workspace:*
version: link:packages/scripts version: link:packages/scripts
@ -267,8 +267,8 @@ importers:
specifier: 2.4.1 specifier: 2.4.1
version: 2.4.1 version: 2.4.1
execa: execa:
specifier: 9.1.0 specifier: 9.2.0
version: 9.1.0 version: 9.2.0
kolorist: kolorist:
specifier: 1.8.0 specifier: 1.8.0
version: 1.8.0 version: 1.8.0
@ -770,8 +770,8 @@ packages:
resolution: {integrity: sha512-d2CGZR2o7fS6sWB7DG/3a95bGKQyHMACZ5aW8qGkkqQpUoZV6C0X7Pc7l4ZNMZkfNBf4VWNe9E1jRsf0G146Ew==} resolution: {integrity: sha512-d2CGZR2o7fS6sWB7DG/3a95bGKQyHMACZ5aW8qGkkqQpUoZV6C0X7Pc7l4ZNMZkfNBf4VWNe9E1jRsf0G146Ew==}
engines: {node: '>=18.18'} engines: {node: '>=18.18'}
'@iconify/json@2.2.216': '@iconify/json@2.2.217':
resolution: {integrity: sha512-dS2yVIAel1oIAGnaxR+EJyDRjKV9GGm9tUd8Pd8VEF91HB4HJrsMzkvz23GHDWyIITGdinx4ZUjMz3hOAv+D4Q==} resolution: {integrity: sha512-+sSR9iKsoThUmgG4wA9xdtyazROIqMOo5h5otOXYRyOQjMNJCpJltq5hEhHInC5aG/DUQmXDiN/YsCoJdCYUbQ==}
'@iconify/types@2.0.0': '@iconify/types@2.0.0':
resolution: {integrity: sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==} resolution: {integrity: sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==}
@ -2189,8 +2189,8 @@ packages:
echarts@5.5.0: echarts@5.5.0:
resolution: {integrity: sha512-rNYnNCzqDAPCr4m/fqyUFv7fD9qIsd50S6GDFgO1DxZhncCsNsG7IfUlAlvZe5oSEQxtsjnHiUuppzccry93Xw==} resolution: {integrity: sha512-rNYnNCzqDAPCr4m/fqyUFv7fD9qIsd50S6GDFgO1DxZhncCsNsG7IfUlAlvZe5oSEQxtsjnHiUuppzccry93Xw==}
electron-to-chromium@1.4.792: electron-to-chromium@1.4.794:
resolution: {integrity: sha512-rkg5/N3L+Y844JyfgPUyuKK0Hk0efo3JNxUDKvz3HgP6EmN4rNGhr2D8boLsfTV/hGo7ZGAL8djw+jlg99zQyA==} resolution: {integrity: sha512-6FApLtsYhDCY0Vglq3AptsdxQ+PJLc6AxlAM0HjEihUAiOPPbkASEsq9gtxUeZY9o0sJIEa3WnF0vVH4VT4iug==}
emoji-regex@10.3.0: emoji-regex@10.3.0:
resolution: {integrity: sha512-QpLs9D9v9kArv4lfDEgg1X/gN5XLnf/A6l9cs8SPZLRZR3ZkY9+kwIQTxm+fsSej5UMYGE8fdoaZVIBlqG0XTw==} resolution: {integrity: sha512-QpLs9D9v9kArv4lfDEgg1X/gN5XLnf/A6l9cs8SPZLRZR3ZkY9+kwIQTxm+fsSej5UMYGE8fdoaZVIBlqG0XTw==}
@ -2313,8 +2313,8 @@ packages:
eslint-parser-plain@0.1.0: eslint-parser-plain@0.1.0:
resolution: {integrity: sha512-oOeA6FWU0UJT/Rxc3XF5Cq0nbIZbylm7j8+plqq0CZoE6m4u32OXJrR+9iy4srGMmF6v6pmgvP1zPxSRIGh3sg==} resolution: {integrity: sha512-oOeA6FWU0UJT/Rxc3XF5Cq0nbIZbylm7j8+plqq0CZoE6m4u32OXJrR+9iy4srGMmF6v6pmgvP1zPxSRIGh3sg==}
eslint-plugin-es-x@7.6.0: eslint-plugin-es-x@7.7.0:
resolution: {integrity: sha512-I0AmeNgevgaTR7y2lrVCJmGYF0rjoznpDvqV/kIkZSZbZ8Rw3eu4cGlvBBULScfkSOCzqKbff5LR4CNrV7mZHA==} resolution: {integrity: sha512-aP3qj8BwiEDPttxQkZdI221DLKq9sI/qHolE2YSQL1/9+xk7dTV+tB1Fz8/IaCA+lnLA1bDEnvaS2LKs0k2Uig==}
engines: {node: ^14.18.0 || >=16.0.0} engines: {node: ^14.18.0 || >=16.0.0}
peerDependencies: peerDependencies:
eslint: '>=8' eslint: '>=8'
@ -2442,6 +2442,10 @@ packages:
resolution: {integrity: sha512-lSgHc4Elo2m6bUDhc3Hl/VxvUDJdQWI40RZ4KMY9bKRc+hgMOT7II/JjbNDhI8VnMtrCb7U/fhpJIkLORZozWw==} resolution: {integrity: sha512-lSgHc4Elo2m6bUDhc3Hl/VxvUDJdQWI40RZ4KMY9bKRc+hgMOT7II/JjbNDhI8VnMtrCb7U/fhpJIkLORZozWw==}
engines: {node: '>=18'} engines: {node: '>=18'}
execa@9.2.0:
resolution: {integrity: sha512-vpOyYg7UAVKLAWWtRS2gAdgkT7oJbCn0me3gmUmxZih4kd3MF/oo8kNTBTIbkO3yuuF5uB4ZCZfn8BOolITYhg==}
engines: {node: ^18.19.0 || >=20.5.0}
expand-brackets@2.1.4: expand-brackets@2.1.4:
resolution: {integrity: sha512-w/ozOKR9Obk3qoWeY/WDi6MFta9AoMR+zud60mdnbniMcBxRuFJyDt2LdX/14A1UABeqk+Uk+LDfUpvoGKppZA==} resolution: {integrity: sha512-w/ozOKR9Obk3qoWeY/WDi6MFta9AoMR+zud60mdnbniMcBxRuFJyDt2LdX/14A1UABeqk+Uk+LDfUpvoGKppZA==}
engines: {node: '>=0.10.0'} engines: {node: '>=0.10.0'}
@ -5740,7 +5744,7 @@ snapshots:
'@humanwhocodes/retry@0.3.0': {} '@humanwhocodes/retry@0.3.0': {}
'@iconify/json@2.2.216': '@iconify/json@2.2.217':
dependencies: dependencies:
'@iconify/types': 2.0.0 '@iconify/types': 2.0.0
pathe: 1.1.2 pathe: 1.1.2
@ -6652,7 +6656,7 @@ snapshots:
browserslist@4.23.0: browserslist@4.23.0:
dependencies: dependencies:
caniuse-lite: 1.0.30001629 caniuse-lite: 1.0.30001629
electron-to-chromium: 1.4.792 electron-to-chromium: 1.4.794
node-releases: 2.0.14 node-releases: 2.0.14
update-browserslist-db: 1.0.16(browserslist@4.23.0) update-browserslist-db: 1.0.16(browserslist@4.23.0)
@ -7317,7 +7321,7 @@ snapshots:
tslib: 2.3.0 tslib: 2.3.0
zrender: 5.5.0 zrender: 5.5.0
electron-to-chromium@1.4.792: {} electron-to-chromium@1.4.794: {}
emoji-regex@10.3.0: {} emoji-regex@10.3.0: {}
@ -7500,7 +7504,7 @@ snapshots:
eslint-parser-plain@0.1.0: {} eslint-parser-plain@0.1.0: {}
eslint-plugin-es-x@7.6.0(eslint@9.4.0): eslint-plugin-es-x@7.7.0(eslint@9.4.0):
dependencies: dependencies:
'@eslint-community/eslint-utils': 4.4.0(eslint@9.4.0) '@eslint-community/eslint-utils': 4.4.0(eslint@9.4.0)
'@eslint-community/regexpp': 4.10.1 '@eslint-community/regexpp': 4.10.1
@ -7528,7 +7532,7 @@ snapshots:
'@eslint-community/eslint-utils': 4.4.0(eslint@9.4.0) '@eslint-community/eslint-utils': 4.4.0(eslint@9.4.0)
enhanced-resolve: 5.17.0 enhanced-resolve: 5.17.0
eslint: 9.4.0 eslint: 9.4.0
eslint-plugin-es-x: 7.6.0(eslint@9.4.0) eslint-plugin-es-x: 7.7.0(eslint@9.4.0)
get-tsconfig: 4.7.5 get-tsconfig: 4.7.5
globals: 15.3.0 globals: 15.3.0
ignore: 5.3.1 ignore: 5.3.1
@ -7720,6 +7724,21 @@ snapshots:
strip-final-newline: 4.0.0 strip-final-newline: 4.0.0
yoctocolors: 2.0.2 yoctocolors: 2.0.2
execa@9.2.0:
dependencies:
'@sindresorhus/merge-streams': 4.0.0
cross-spawn: 7.0.3
figures: 6.1.0
get-stream: 9.0.1
human-signals: 7.0.0
is-plain-obj: 4.1.0
is-stream: 4.0.1
npm-run-path: 5.3.0
pretty-ms: 9.0.0
signal-exit: 4.1.0
strip-final-newline: 4.0.0
yoctocolors: 2.0.2
expand-brackets@2.1.4: expand-brackets@2.1.4:
dependencies: dependencies:
debug: 2.6.9 debug: 2.6.9

View File

@ -19,7 +19,7 @@ export function setupAppVersionNotification() {
n?.destroy(); n?.destroy();
} }
}, },
$t('system.updateCancel') () => $t('system.updateCancel')
), ),
h( h(
NButton, NButton,
@ -29,7 +29,7 @@ export function setupAppVersionNotification() {
location.reload(); location.reload();
} }
}, },
$t('system.updateConfirm') () => $t('system.updateConfirm')
) )
]); ]);
} }

View File

@ -126,9 +126,6 @@ async function initRoute(to: RouteLocationNormalized): Promise<RouteLocationRaw
// the auth route is initialized // the auth route is initialized
// it is not the "not-found" route, then it is allowed to access // it is not the "not-found" route, then it is allowed to access
if (routeStore.isInitAuthRoute && !isNotFoundRoute) { if (routeStore.isInitAuthRoute && !isNotFoundRoute) {
// update user info
await authStore.updateUserInfo();
return null; return null;
} }
// it is captured by the "not-found" route, then check whether the route exists // it is captured by the "not-found" route, then check whether the route exists
@ -164,6 +161,8 @@ async function initRoute(to: RouteLocationNormalized): Promise<RouteLocationRaw
return location; return location;
} }
await authStore.initUserInfo();
// initialize the auth route // initialize the auth route
await routeStore.initAuthRoute(); await routeStore.initAuthRoute();

View File

@ -92,8 +92,8 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
localStg.set('token', loginToken.token); localStg.set('token', loginToken.token);
localStg.set('refreshToken', loginToken.refreshToken); localStg.set('refreshToken', loginToken.refreshToken);
// 2. get user info and update store // 2. get user info
const pass = await updateUserInfo(); const pass = await getUserInfo();
if (pass) { if (pass) {
token.value = loginToken.token; token.value = loginToken.token;
@ -104,7 +104,7 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
return false; return false;
} }
async function updateUserInfo() { async function getUserInfo() {
const { data: info, error } = await fetchGetUserInfo(); const { data: info, error } = await fetchGetUserInfo();
if (!error) { if (!error) {
@ -117,6 +117,18 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
return false; return false;
} }
async function initUserInfo() {
const hasToken = getToken();
if (hasToken) {
const pass = await getUserInfo();
if (!pass) {
resetStore();
}
}
}
return { return {
token, token,
userInfo, userInfo,
@ -125,6 +137,6 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
loginLoading, loginLoading,
resetStore, resetStore,
login, login,
updateUserInfo initUserInfo
}; };
}); });