mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-09-18 01:36:37 +08:00
Merge branch 'main' into example
This commit is contained in:
commit
7e436b6328
36
CHANGELOG.md
36
CHANGELOG.md
@ -1,6 +1,42 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
|
||||||
|
## [v1.3.8](https://github.com/soybeanjs/soybean-admin/compare/v1.3.7...v1.3.8) (2024-10-25)
|
||||||
|
|
||||||
|
### 🚨 Breaking Changes
|
||||||
|
|
||||||
|
- **projects**: refactor route cache & support reset route cache strategy - by @soybeanjs [<samp>(b667e)</samp>](https://github.com/soybeanjs/soybean-admin/commit/b667eab)
|
||||||
|
|
||||||
|
### 🚀 Features
|
||||||
|
|
||||||
|
- **packages**:
|
||||||
|
- add subpackage `@sa/alova` - by @JOU-amjs in https://github.com/soybeanjs/soybean-admin/issues/640 [<samp>(2072f)</samp>](https://github.com/soybeanjs/soybean-admin/commit/2072f58)
|
||||||
|
- optimistic subpackage `@sa/alova` - by @JOU-amjs in https://github.com/soybeanjs/soybean-admin/issues/646 [<samp>(4b3ac)</samp>](https://github.com/soybeanjs/soybean-admin/commit/4b3ac11)
|
||||||
|
- **projects**:
|
||||||
|
- login supports accessible operation. - by @Azir-11 in https://github.com/soybeanjs/soybean-admin/issues/637 [<samp>(cfaab)</samp>](https://github.com/soybeanjs/soybean-admin/commit/cfaab85)
|
||||||
|
|
||||||
|
### 🐞 Bug Fixes
|
||||||
|
|
||||||
|
- **utils**: fix `isPC`. fixed #644 - by @soybeanjs in https://github.com/soybeanjs/soybean-admin/issues/644 [<samp>(47264)</samp>](https://github.com/soybeanjs/soybean-admin/commit/4726498)
|
||||||
|
|
||||||
|
### 🏡 Chore
|
||||||
|
|
||||||
|
- **deps**:
|
||||||
|
- update deps - by @soybeanjs [<samp>(8dcda)</samp>](https://github.com/soybeanjs/soybean-admin/commit/8dcda38)
|
||||||
|
- **projects**:
|
||||||
|
- update vscode extensions - by @soybeanjs [<samp>(24bb6)</samp>](https://github.com/soybeanjs/soybean-admin/commit/24bb6d9)
|
||||||
|
- update deps & fix sass usage - by @soybeanjs [<samp>(71e63)</samp>](https://github.com/soybeanjs/soybean-admin/commit/71e6307)
|
||||||
|
- **types**:
|
||||||
|
- remove type declaration for document.startViewTransition (TypeScript 5.6 includes it) - by @NHZEX in https://github.com/soybeanjs/soybean-admin/issues/633 [<samp>(83ba7)</samp>](https://github.com/soybeanjs/soybean-admin/commit/83ba798)
|
||||||
|
|
||||||
|
### 🎨 Styles
|
||||||
|
|
||||||
|
- **projects**: reduce ambiguity in theme configuration instructions. - by @Azir-11 [<samp>(75cbf)</samp>](https://github.com/soybeanjs/soybean-admin/commit/75cbfbb)
|
||||||
|
|
||||||
|
### ❤️ Contributors
|
||||||
|
|
||||||
|
[](https://github.com/soybeanjs) [](https://github.com/JOU-amjs) [](https://github.com/Azir-11) [](https://github.com/NHZEX)
|
||||||
|
|
||||||
## [v1.3.7](https://github.com/soybeanjs/soybean-admin/compare/v1.3.6...v1.3.7) (2024-09-21)
|
## [v1.3.7](https://github.com/soybeanjs/soybean-admin/compare/v1.3.6...v1.3.7) (2024-09-21)
|
||||||
|
|
||||||
### 🚨 Breaking Changes
|
### 🚨 Breaking Changes
|
||||||
|
40
package.json
40
package.json
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "soybean-admin",
|
"name": "soybean-admin",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "1.3.7",
|
"version": "1.3.8",
|
||||||
"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",
|
||||||
@ -49,7 +49,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@antv/data-set": "0.11.8",
|
"@antv/data-set": "0.11.8",
|
||||||
"@antv/g2": "5.2.5",
|
"@antv/g2": "5.2.5",
|
||||||
"@antv/g6": "^5.0.26",
|
"@antv/g6": "5.0.26",
|
||||||
"@better-scroll/core": "2.5.1",
|
"@better-scroll/core": "2.5.1",
|
||||||
"@iconify/vue": "4.1.2",
|
"@iconify/vue": "4.1.2",
|
||||||
"@sa/alova": "workspace:*",
|
"@sa/alova": "workspace:*",
|
||||||
@ -58,7 +58,7 @@
|
|||||||
"@sa/hooks": "workspace:*",
|
"@sa/hooks": "workspace:*",
|
||||||
"@sa/materials": "workspace:*",
|
"@sa/materials": "workspace:*",
|
||||||
"@sa/utils": "workspace:*",
|
"@sa/utils": "workspace:*",
|
||||||
"@vueuse/components": "^11.1.0",
|
"@vueuse/components": "11.1.0",
|
||||||
"@vueuse/core": "11.1.0",
|
"@vueuse/core": "11.1.0",
|
||||||
"clipboard": "2.0.11",
|
"clipboard": "2.0.11",
|
||||||
"dayjs": "1.11.13",
|
"dayjs": "1.11.13",
|
||||||
@ -73,11 +73,11 @@
|
|||||||
"pinyin-pro": "3.24.2",
|
"pinyin-pro": "3.24.2",
|
||||||
"print-js": "1.6.0",
|
"print-js": "1.6.0",
|
||||||
"swiper": "11.1.12",
|
"swiper": "11.1.12",
|
||||||
"tailwind-merge": "2.5.3",
|
"tailwind-merge": "2.5.4",
|
||||||
"typeit": "8.8.4",
|
"typeit": "8.8.4",
|
||||||
"vditor": "3.10.5",
|
"vditor": "3.10.5",
|
||||||
"vue": "3.5.11",
|
"vue": "3.5.12",
|
||||||
"vue-draggable-plus": "0.5.3",
|
"vue-draggable-plus": "0.5.4",
|
||||||
"vue-i18n": "10.0.4",
|
"vue-i18n": "10.0.4",
|
||||||
"vue-pdf-embed": "2.1.0",
|
"vue-pdf-embed": "2.1.0",
|
||||||
"vue-router": "4.4.5",
|
"vue-router": "4.4.5",
|
||||||
@ -88,35 +88,35 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@amap/amap-jsapi-types": "0.0.15",
|
"@amap/amap-jsapi-types": "0.0.15",
|
||||||
"@elegant-router/vue": "0.3.8",
|
"@elegant-router/vue": "0.3.8",
|
||||||
"@iconify/json": "2.2.258",
|
"@iconify/json": "2.2.263",
|
||||||
"@sa/scripts": "workspace:*",
|
"@sa/scripts": "workspace:*",
|
||||||
"@sa/uno-preset": "workspace:*",
|
"@sa/uno-preset": "workspace:*",
|
||||||
"@soybeanjs/eslint-config": "1.4.1",
|
"@soybeanjs/eslint-config": "1.4.2",
|
||||||
"@types/bmapgl": "0.0.7",
|
"@types/bmapgl": "0.0.7",
|
||||||
"@types/dompurify": "3.0.5",
|
"@types/dompurify": "3.0.5",
|
||||||
"@types/node": "22.7.5",
|
"@types/node": "22.7.9",
|
||||||
"@types/nprogress": "0.2.3",
|
"@types/nprogress": "0.2.3",
|
||||||
"@unocss/eslint-config": "0.63.4",
|
"@unocss/eslint-config": "0.63.6",
|
||||||
"@unocss/preset-icons": "0.63.4",
|
"@unocss/preset-icons": "0.63.6",
|
||||||
"@unocss/preset-uno": "0.63.4",
|
"@unocss/preset-uno": "0.63.6",
|
||||||
"@unocss/transformer-directives": "0.63.4",
|
"@unocss/transformer-directives": "0.63.6",
|
||||||
"@unocss/transformer-variant-group": "0.63.4",
|
"@unocss/transformer-variant-group": "0.63.6",
|
||||||
"@unocss/vite": "0.63.4",
|
"@unocss/vite": "0.63.6",
|
||||||
"@vitejs/plugin-vue": "5.1.4",
|
"@vitejs/plugin-vue": "5.1.4",
|
||||||
"@vitejs/plugin-vue-jsx": "4.0.1",
|
"@vitejs/plugin-vue-jsx": "4.0.1",
|
||||||
"eslint": "9.12.0",
|
"eslint": "9.13.0",
|
||||||
"eslint-plugin-vue": "9.28.0",
|
"eslint-plugin-vue": "9.29.1",
|
||||||
"lint-staged": "15.2.10",
|
"lint-staged": "15.2.10",
|
||||||
"sass": "1.79.4",
|
"sass": "1.80.4",
|
||||||
"simple-git-hooks": "2.11.1",
|
"simple-git-hooks": "2.11.1",
|
||||||
"tsx": "4.19.1",
|
"tsx": "4.19.1",
|
||||||
"typescript": "5.6.3",
|
"typescript": "5.6.3",
|
||||||
"unplugin-icons": "0.19.3",
|
"unplugin-icons": "0.19.3",
|
||||||
"unplugin-vue-components": "0.27.4",
|
"unplugin-vue-components": "0.27.4",
|
||||||
"vite": "5.4.8",
|
"vite": "5.4.10",
|
||||||
"vite-plugin-progress": "0.0.7",
|
"vite-plugin-progress": "0.0.7",
|
||||||
"vite-plugin-svg-icons": "2.0.1",
|
"vite-plugin-svg-icons": "2.0.1",
|
||||||
"vite-plugin-vue-devtools": "7.4.6",
|
"vite-plugin-vue-devtools": "7.5.4",
|
||||||
"vue-eslint-parser": "9.4.3",
|
"vue-eslint-parser": "9.4.3",
|
||||||
"vue-tsc": "2.1.6"
|
"vue-tsc": "2.1.6"
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sa/alova",
|
"name": "@sa/alova",
|
||||||
"version": "0.1.0",
|
"version": "1.3.8",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/index.ts",
|
".": "./src/index.ts",
|
||||||
"./fetch": "./src/fetch.ts",
|
"./fetch": "./src/fetch.ts",
|
||||||
@ -13,8 +13,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@alova/mock": "2.0.7",
|
"@alova/mock": "2.0.8",
|
||||||
"@sa/utils": "workspace:*",
|
"@sa/utils": "workspace:*",
|
||||||
"alova": "3.0.20"
|
"alova": "3.1.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sa/axios",
|
"name": "@sa/axios",
|
||||||
"version": "1.3.7",
|
"version": "1.3.8",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/index.ts"
|
".": "./src/index.ts"
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sa/color",
|
"name": "@sa/color",
|
||||||
"version": "1.3.7",
|
"version": "1.3.8",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/index.ts"
|
".": "./src/index.ts"
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sa/hooks",
|
"name": "@sa/hooks",
|
||||||
"version": "1.3.7",
|
"version": "1.3.8",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/index.ts"
|
".": "./src/index.ts"
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sa/materials",
|
"name": "@sa/materials",
|
||||||
"version": "1.3.7",
|
"version": "1.3.8",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/index.ts"
|
".": "./src/index.ts"
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sa/fetch",
|
"name": "@sa/fetch",
|
||||||
"version": "1.3.7",
|
"version": "1.3.8",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/index.ts"
|
".": "./src/index.ts"
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sa/scripts",
|
"name": "@sa/scripts",
|
||||||
"version": "1.3.7",
|
"version": "1.3.8",
|
||||||
"bin": {
|
"bin": {
|
||||||
"sa": "./bin.ts"
|
"sa": "./bin.ts"
|
||||||
},
|
},
|
||||||
@ -19,9 +19,9 @@
|
|||||||
"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.4.0",
|
"execa": "9.4.1",
|
||||||
"kolorist": "1.8.0",
|
"kolorist": "1.8.0",
|
||||||
"npm-check-updates": "17.1.3",
|
"npm-check-updates": "17.1.4",
|
||||||
"rimraf": "6.0.1"
|
"rimraf": "6.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sa/uno-preset",
|
"name": "@sa/uno-preset",
|
||||||
"version": "1.3.7",
|
"version": "1.3.8",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/index.ts"
|
".": "./src/index.ts"
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sa/utils",
|
"name": "@sa/utils",
|
||||||
"version": "1.3.7",
|
"version": "1.3.8",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/index.ts"
|
".": "./src/index.ts"
|
||||||
},
|
},
|
||||||
|
1950
pnpm-lock.yaml
1950
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
@ -54,3 +54,10 @@ export const themePageAnimationModeRecord: Record<UnionKey.ThemePageAnimateMode,
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const themePageAnimationModeOptions = transformRecordToOption(themePageAnimationModeRecord);
|
export const themePageAnimationModeOptions = transformRecordToOption(themePageAnimationModeRecord);
|
||||||
|
|
||||||
|
export const resetCacheStrategyRecord: Record<UnionKey.ResetCacheStrategy, App.I18n.I18nKey> = {
|
||||||
|
close: 'theme.resetCacheStrategy.close',
|
||||||
|
refresh: 'theme.resetCacheStrategy.refresh'
|
||||||
|
};
|
||||||
|
|
||||||
|
export const resetCacheStrategyOptions = transformRecordToOption(resetCacheStrategyRecord);
|
||||||
|
@ -42,7 +42,7 @@ function resetScroll() {
|
|||||||
@after-leave="resetScroll"
|
@after-leave="resetScroll"
|
||||||
@after-enter="appStore.setContentXScrollable(false)"
|
@after-enter="appStore.setContentXScrollable(false)"
|
||||||
>
|
>
|
||||||
<KeepAlive :include="routeStore.cacheRoutes">
|
<KeepAlive :include="routeStore.cacheRoutes" :exclude="routeStore.excludeCacheRoutes">
|
||||||
<component
|
<component
|
||||||
:is="Component"
|
:is="Component"
|
||||||
v-if="appStore.reloadFlag"
|
v-if="appStore.reloadFlag"
|
||||||
|
@ -84,7 +84,10 @@ function getContextMenuDisabledKeys(tabId: string) {
|
|||||||
|
|
||||||
async function handleCloseTab(tab: App.Global.Tab) {
|
async function handleCloseTab(tab: App.Global.Tab) {
|
||||||
await tabStore.removeTab(tab.id);
|
await tabStore.removeTab(tab.id);
|
||||||
await routeStore.reCacheRoutesByKey(tab.routeKey);
|
|
||||||
|
if (themeStore.resetCacheStrategy === 'close') {
|
||||||
|
routeStore.resetRouteCache(tab.routeKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function refresh() {
|
async function refresh() {
|
||||||
|
@ -2,7 +2,12 @@
|
|||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import { $t } from '@/locales';
|
import { $t } from '@/locales';
|
||||||
import { useThemeStore } from '@/store/modules/theme';
|
import { useThemeStore } from '@/store/modules/theme';
|
||||||
import { themePageAnimationModeOptions, themeScrollModeOptions, themeTabModeOptions } from '@/constants/app';
|
import {
|
||||||
|
resetCacheStrategyOptions,
|
||||||
|
themePageAnimationModeOptions,
|
||||||
|
themeScrollModeOptions,
|
||||||
|
themeTabModeOptions
|
||||||
|
} from '@/constants/app';
|
||||||
import { translateOptions } from '@/utils/common';
|
import { translateOptions } from '@/utils/common';
|
||||||
import SettingItem from '../components/setting-item.vue';
|
import SettingItem from '../components/setting-item.vue';
|
||||||
|
|
||||||
@ -22,6 +27,14 @@ const isWrapperScrollMode = computed(() => themeStore.layout.scrollMode === 'wra
|
|||||||
<template>
|
<template>
|
||||||
<NDivider>{{ $t('theme.pageFunTitle') }}</NDivider>
|
<NDivider>{{ $t('theme.pageFunTitle') }}</NDivider>
|
||||||
<TransitionGroup tag="div" name="setting-list" class="flex-col-stretch gap-12px">
|
<TransitionGroup tag="div" name="setting-list" class="flex-col-stretch gap-12px">
|
||||||
|
<SettingItem key="0" :label="$t('theme.resetCacheStrategy.title')">
|
||||||
|
<NSelect
|
||||||
|
v-model:value="themeStore.resetCacheStrategy"
|
||||||
|
:options="translateOptions(resetCacheStrategyOptions)"
|
||||||
|
size="small"
|
||||||
|
class="w-120px"
|
||||||
|
/>
|
||||||
|
</SettingItem>
|
||||||
<SettingItem key="1" :label="$t('theme.scrollMode.title')">
|
<SettingItem key="1" :label="$t('theme.scrollMode.title')">
|
||||||
<NSelect
|
<NSelect
|
||||||
v-model:value="themeStore.layout.scrollMode"
|
v-model:value="themeStore.layout.scrollMode"
|
||||||
|
@ -141,6 +141,11 @@ const local: App.I18n.Schema = {
|
|||||||
},
|
},
|
||||||
themeDrawerTitle: 'Theme Configuration',
|
themeDrawerTitle: 'Theme Configuration',
|
||||||
pageFunTitle: 'Page Function',
|
pageFunTitle: 'Page Function',
|
||||||
|
resetCacheStrategy: {
|
||||||
|
title: 'Reset Cache Strategy',
|
||||||
|
close: 'Close Page',
|
||||||
|
refresh: 'Refresh Page'
|
||||||
|
},
|
||||||
configOperation: {
|
configOperation: {
|
||||||
copyConfig: 'Copy Config',
|
copyConfig: 'Copy Config',
|
||||||
copySuccessMsg: 'Copy Success, Please replace the variable "themeSettings" in "src/theme/settings.ts"',
|
copySuccessMsg: 'Copy Success, Please replace the variable "themeSettings" in "src/theme/settings.ts"',
|
||||||
|
@ -141,6 +141,11 @@ const local: App.I18n.Schema = {
|
|||||||
},
|
},
|
||||||
themeDrawerTitle: '主题配置',
|
themeDrawerTitle: '主题配置',
|
||||||
pageFunTitle: '页面功能',
|
pageFunTitle: '页面功能',
|
||||||
|
resetCacheStrategy: {
|
||||||
|
title: '重置缓存策略',
|
||||||
|
close: '关闭页面',
|
||||||
|
refresh: '刷新页面'
|
||||||
|
},
|
||||||
configOperation: {
|
configOperation: {
|
||||||
copyConfig: '复制配置',
|
copyConfig: '复制配置',
|
||||||
copySuccessMsg: '复制成功,请替换 src/theme/settings.ts 中的变量 themeSettings',
|
copySuccessMsg: '复制成功,请替换 src/theme/settings.ts 中的变量 themeSettings',
|
||||||
|
@ -46,6 +46,10 @@ export const useAppStore = defineStore(SetupStoreId.App, () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
setReloadFlag(true);
|
setReloadFlag(true);
|
||||||
|
|
||||||
|
if (themeStore.resetCacheStrategy === 'refresh') {
|
||||||
|
routeStore.resetRouteCache();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const locale = ref<App.I18n.LangType>(localStg.get('lang') || 'zh-CN');
|
const locale = ref<App.I18n.LangType>(localStg.get('lang') || 'zh-CN');
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { computed, ref, shallowRef } from 'vue';
|
import { computed, nextTick, ref, shallowRef } from 'vue';
|
||||||
import type { RouteRecordRaw } from 'vue-router';
|
import type { RouteRecordRaw } from 'vue-router';
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { useBoolean } from '@sa/hooks';
|
import { useBoolean } from '@sa/hooks';
|
||||||
@ -9,7 +9,6 @@ import { createStaticRoutes, getAuthVueRoutes } from '@/router/routes';
|
|||||||
import { ROOT_ROUTE } from '@/router/routes/builtin';
|
import { ROOT_ROUTE } from '@/router/routes/builtin';
|
||||||
import { getRouteName, getRoutePath } from '@/router/elegant/transform';
|
import { getRouteName, getRoutePath } from '@/router/elegant/transform';
|
||||||
import { fetchGetConstantRoutes, fetchGetUserRoutes, fetchIsRouteExist } from '@/service/api';
|
import { fetchGetConstantRoutes, fetchGetUserRoutes, fetchIsRouteExist } from '@/service/api';
|
||||||
import { useAppStore } from '../app';
|
|
||||||
import { useAuthStore } from '../auth';
|
import { useAuthStore } from '../auth';
|
||||||
import { useTabStore } from '../tab';
|
import { useTabStore } from '../tab';
|
||||||
import {
|
import {
|
||||||
@ -25,7 +24,6 @@ import {
|
|||||||
} from './shared';
|
} from './shared';
|
||||||
|
|
||||||
export const useRouteStore = defineStore(SetupStoreId.Route, () => {
|
export const useRouteStore = defineStore(SetupStoreId.Route, () => {
|
||||||
const appStore = useAppStore();
|
|
||||||
const authStore = useAuthStore();
|
const authStore = useAuthStore();
|
||||||
const tabStore = useTabStore();
|
const tabStore = useTabStore();
|
||||||
const { bool: isInitConstantRoute, setBool: setIsInitConstantRoute } = useBoolean();
|
const { bool: isInitConstantRoute, setBool: setIsInitConstantRoute } = useBoolean();
|
||||||
@ -97,8 +95,12 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
|
|||||||
/** Cache routes */
|
/** Cache routes */
|
||||||
const cacheRoutes = ref<RouteKey[]>([]);
|
const cacheRoutes = ref<RouteKey[]>([]);
|
||||||
|
|
||||||
/** All cache routes */
|
/**
|
||||||
const allCacheRoutes = shallowRef<RouteKey[]>([]);
|
* Exclude cache routes
|
||||||
|
*
|
||||||
|
* for reset route cache
|
||||||
|
*/
|
||||||
|
const excludeCacheRoutes = ref<RouteKey[]>([]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get cache routes
|
* Get cache routes
|
||||||
@ -106,69 +108,23 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
|
|||||||
* @param routes Vue routes
|
* @param routes Vue routes
|
||||||
*/
|
*/
|
||||||
function getCacheRoutes(routes: RouteRecordRaw[]) {
|
function getCacheRoutes(routes: RouteRecordRaw[]) {
|
||||||
const alls = getCacheRouteNames(routes);
|
cacheRoutes.value = getCacheRouteNames(routes);
|
||||||
|
|
||||||
cacheRoutes.value = alls;
|
|
||||||
allCacheRoutes.value = [...alls];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add cache routes
|
* Reset route cache
|
||||||
*
|
*
|
||||||
|
* @default router.currentRoute.value.name current route name
|
||||||
* @param routeKey
|
* @param routeKey
|
||||||
*/
|
*/
|
||||||
function addCacheRoutes(routeKey: RouteKey) {
|
async function resetRouteCache(routeKey?: RouteKey) {
|
||||||
if (cacheRoutes.value.includes(routeKey)) return;
|
const routeName = routeKey || (router.currentRoute.value.name as RouteKey);
|
||||||
|
|
||||||
cacheRoutes.value.push(routeKey);
|
excludeCacheRoutes.value.push(routeName);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
await nextTick();
|
||||||
* Remove cache routes
|
|
||||||
*
|
|
||||||
* @param routeKey
|
|
||||||
*/
|
|
||||||
function removeCacheRoutes(routeKey: RouteKey) {
|
|
||||||
const index = cacheRoutes.value.findIndex(item => item === routeKey);
|
|
||||||
|
|
||||||
if (index === -1) return;
|
excludeCacheRoutes.value = [];
|
||||||
|
|
||||||
cacheRoutes.value.splice(index, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Is cached route
|
|
||||||
*
|
|
||||||
* @param routeKey
|
|
||||||
*/
|
|
||||||
function isCachedRoute(routeKey: RouteKey) {
|
|
||||||
return allCacheRoutes.value.includes(routeKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Re cache routes by route key
|
|
||||||
*
|
|
||||||
* @param routeKey
|
|
||||||
*/
|
|
||||||
async function reCacheRoutesByKey(routeKey: RouteKey) {
|
|
||||||
if (!isCachedRoute(routeKey)) return;
|
|
||||||
|
|
||||||
removeCacheRoutes(routeKey);
|
|
||||||
|
|
||||||
await appStore.reloadPage();
|
|
||||||
|
|
||||||
addCacheRoutes(routeKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Re cache routes by route keys
|
|
||||||
*
|
|
||||||
* @param routeKeys
|
|
||||||
*/
|
|
||||||
async function reCacheRoutesByKeys(routeKeys: RouteKey[]) {
|
|
||||||
for await (const key of routeKeys) {
|
|
||||||
await reCacheRoutesByKey(key);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Global breadcrumbs */
|
/** Global breadcrumbs */
|
||||||
@ -361,8 +317,8 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
|
|||||||
searchMenus,
|
searchMenus,
|
||||||
updateGlobalMenusByLocale,
|
updateGlobalMenusByLocale,
|
||||||
cacheRoutes,
|
cacheRoutes,
|
||||||
reCacheRoutesByKey,
|
excludeCacheRoutes,
|
||||||
reCacheRoutesByKeys,
|
resetRouteCache,
|
||||||
breadcrumbs,
|
breadcrumbs,
|
||||||
initConstantRoute,
|
initConstantRoute,
|
||||||
isInitConstantRoute,
|
isInitConstantRoute,
|
||||||
|
@ -1 +1 @@
|
|||||||
@import './scrollbar.scss';
|
@forward 'scrollbar';
|
||||||
|
@ -12,6 +12,7 @@ export const themeSettings: App.Theme.ThemeSetting = {
|
|||||||
error: '#f5222d'
|
error: '#f5222d'
|
||||||
},
|
},
|
||||||
isInfoFollowPrimary: true,
|
isInfoFollowPrimary: true,
|
||||||
|
resetCacheStrategy: 'close',
|
||||||
layout: {
|
layout: {
|
||||||
mode: 'vertical',
|
mode: 'vertical',
|
||||||
scrollMode: 'content',
|
scrollMode: 'content',
|
||||||
@ -83,6 +84,7 @@ export const themeSettings: App.Theme.ThemeSetting = {
|
|||||||
* If publish new version, use `overrideThemeSettings` to override certain theme settings
|
* If publish new version, use `overrideThemeSettings` to override certain theme settings
|
||||||
*/
|
*/
|
||||||
export const overrideThemeSettings: Partial<App.Theme.ThemeSetting> = {
|
export const overrideThemeSettings: Partial<App.Theme.ThemeSetting> = {
|
||||||
|
resetCacheStrategy: 'close',
|
||||||
watermark: {
|
watermark: {
|
||||||
visible: false,
|
visible: false,
|
||||||
text: 'SoybeanAdmin'
|
text: 'SoybeanAdmin'
|
||||||
|
3
src/typings/app.d.ts
vendored
3
src/typings/app.d.ts
vendored
@ -20,6 +20,8 @@ declare namespace App {
|
|||||||
otherColor: OtherColor;
|
otherColor: OtherColor;
|
||||||
/** Whether info color is followed by the primary color */
|
/** Whether info color is followed by the primary color */
|
||||||
isInfoFollowPrimary: boolean;
|
isInfoFollowPrimary: boolean;
|
||||||
|
/** Reset cache strategy */
|
||||||
|
resetCacheStrategy?: UnionKey.ResetCacheStrategy;
|
||||||
/** Layout */
|
/** Layout */
|
||||||
layout: {
|
layout: {
|
||||||
/** Layout mode */
|
/** Layout mode */
|
||||||
@ -388,6 +390,7 @@ declare namespace App {
|
|||||||
};
|
};
|
||||||
themeDrawerTitle: string;
|
themeDrawerTitle: string;
|
||||||
pageFunTitle: string;
|
pageFunTitle: string;
|
||||||
|
resetCacheStrategy: { title: string } & Record<UnionKey.ResetCacheStrategy, string>;
|
||||||
configOperation: {
|
configOperation: {
|
||||||
copyConfig: string;
|
copyConfig: string;
|
||||||
copySuccessMsg: string;
|
copySuccessMsg: string;
|
||||||
|
8
src/typings/union-key.d.ts
vendored
8
src/typings/union-key.d.ts
vendored
@ -14,6 +14,14 @@ declare namespace UnionKey {
|
|||||||
/** Theme scheme */
|
/** Theme scheme */
|
||||||
type ThemeScheme = 'light' | 'dark' | 'auto';
|
type ThemeScheme = 'light' | 'dark' | 'auto';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset cache strategy
|
||||||
|
*
|
||||||
|
* - close: re-cache when close page
|
||||||
|
* - refresh: re-cache when refresh page
|
||||||
|
*/
|
||||||
|
type ResetCacheStrategy = 'close' | 'refresh';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The layout mode
|
* The layout mode
|
||||||
*
|
*
|
||||||
|
@ -43,7 +43,7 @@ const { loading, data, refresh, reload, page, pageSize, pageCount, send, remove
|
|||||||
);
|
);
|
||||||
const getDataByPage = (newPage = 1) => {
|
const getDataByPage = (newPage = 1) => {
|
||||||
page.value = newPage;
|
page.value = newPage;
|
||||||
send();
|
send(page.value, pageSize.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
Loading…
Reference in New Issue
Block a user