Merge branch 'main' into example

This commit is contained in:
Soybean 2024-10-25 01:19:37 +08:00
commit 7e436b6328
25 changed files with 1171 additions and 1019 deletions

View File

@ -1,6 +1,42 @@
# 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 &nbsp;-&nbsp; by @soybeanjs [<samp>(b667e)</samp>](https://github.com/soybeanjs/soybean-admin/commit/b667eab)
### &nbsp;&nbsp;&nbsp;🚀 Features
- **packages**:
- add subpackage `@sa/alova` &nbsp;-&nbsp; 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` &nbsp;-&nbsp; 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. &nbsp;-&nbsp; by @Azir-11 in https://github.com/soybeanjs/soybean-admin/issues/637 [<samp>(cfaab)</samp>](https://github.com/soybeanjs/soybean-admin/commit/cfaab85)
### &nbsp;&nbsp;&nbsp;🐞 Bug Fixes
- **utils**: fix `isPC`. fixed #644 &nbsp;-&nbsp; by @soybeanjs in https://github.com/soybeanjs/soybean-admin/issues/644 [<samp>(47264)</samp>](https://github.com/soybeanjs/soybean-admin/commit/4726498)
### &nbsp;&nbsp;&nbsp;🏡 Chore
- **deps**:
- update deps &nbsp;-&nbsp; by @soybeanjs [<samp>(8dcda)</samp>](https://github.com/soybeanjs/soybean-admin/commit/8dcda38)
- **projects**:
- update vscode extensions &nbsp;-&nbsp; by @soybeanjs [<samp>(24bb6)</samp>](https://github.com/soybeanjs/soybean-admin/commit/24bb6d9)
- update deps & fix sass usage &nbsp;-&nbsp; 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) &nbsp;-&nbsp; by @NHZEX in https://github.com/soybeanjs/soybean-admin/issues/633 [<samp>(83ba7)</samp>](https://github.com/soybeanjs/soybean-admin/commit/83ba798)
### &nbsp;&nbsp;&nbsp;🎨 Styles
- **projects**: reduce ambiguity in theme configuration instructions. &nbsp;-&nbsp; by @Azir-11 [<samp>(75cbf)</samp>](https://github.com/soybeanjs/soybean-admin/commit/75cbfbb)
### &nbsp;&nbsp;&nbsp;❤️ Contributors
[![soybeanjs](https://github.com/soybeanjs.png?size=48)](https://github.com/soybeanjs)&nbsp;&nbsp;[![JOU-amjs](https://github.com/JOU-amjs.png?size=48)](https://github.com/JOU-amjs)&nbsp;&nbsp;[![Azir-11](https://github.com/Azir-11.png?size=48)](https://github.com/Azir-11)&nbsp;&nbsp;[![NHZEX](https://github.com/NHZEX.png?size=48)](https://github.com/NHZEX)&nbsp;&nbsp;
## [v1.3.7](https://github.com/soybeanjs/soybean-admin/compare/v1.3.6...v1.3.7) (2024-09-21)
### &nbsp;&nbsp;&nbsp;🚨 Breaking Changes

View File

@ -1,7 +1,7 @@
{
"name": "soybean-admin",
"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的清新优雅的中后台模版。",
"author": {
"name": "Soybean",
@ -49,7 +49,7 @@
"dependencies": {
"@antv/data-set": "0.11.8",
"@antv/g2": "5.2.5",
"@antv/g6": "^5.0.26",
"@antv/g6": "5.0.26",
"@better-scroll/core": "2.5.1",
"@iconify/vue": "4.1.2",
"@sa/alova": "workspace:*",
@ -58,7 +58,7 @@
"@sa/hooks": "workspace:*",
"@sa/materials": "workspace:*",
"@sa/utils": "workspace:*",
"@vueuse/components": "^11.1.0",
"@vueuse/components": "11.1.0",
"@vueuse/core": "11.1.0",
"clipboard": "2.0.11",
"dayjs": "1.11.13",
@ -73,11 +73,11 @@
"pinyin-pro": "3.24.2",
"print-js": "1.6.0",
"swiper": "11.1.12",
"tailwind-merge": "2.5.3",
"tailwind-merge": "2.5.4",
"typeit": "8.8.4",
"vditor": "3.10.5",
"vue": "3.5.11",
"vue-draggable-plus": "0.5.3",
"vue": "3.5.12",
"vue-draggable-plus": "0.5.4",
"vue-i18n": "10.0.4",
"vue-pdf-embed": "2.1.0",
"vue-router": "4.4.5",
@ -88,35 +88,35 @@
"devDependencies": {
"@amap/amap-jsapi-types": "0.0.15",
"@elegant-router/vue": "0.3.8",
"@iconify/json": "2.2.258",
"@iconify/json": "2.2.263",
"@sa/scripts": "workspace:*",
"@sa/uno-preset": "workspace:*",
"@soybeanjs/eslint-config": "1.4.1",
"@soybeanjs/eslint-config": "1.4.2",
"@types/bmapgl": "0.0.7",
"@types/dompurify": "3.0.5",
"@types/node": "22.7.5",
"@types/node": "22.7.9",
"@types/nprogress": "0.2.3",
"@unocss/eslint-config": "0.63.4",
"@unocss/preset-icons": "0.63.4",
"@unocss/preset-uno": "0.63.4",
"@unocss/transformer-directives": "0.63.4",
"@unocss/transformer-variant-group": "0.63.4",
"@unocss/vite": "0.63.4",
"@unocss/eslint-config": "0.63.6",
"@unocss/preset-icons": "0.63.6",
"@unocss/preset-uno": "0.63.6",
"@unocss/transformer-directives": "0.63.6",
"@unocss/transformer-variant-group": "0.63.6",
"@unocss/vite": "0.63.6",
"@vitejs/plugin-vue": "5.1.4",
"@vitejs/plugin-vue-jsx": "4.0.1",
"eslint": "9.12.0",
"eslint-plugin-vue": "9.28.0",
"eslint": "9.13.0",
"eslint-plugin-vue": "9.29.1",
"lint-staged": "15.2.10",
"sass": "1.79.4",
"sass": "1.80.4",
"simple-git-hooks": "2.11.1",
"tsx": "4.19.1",
"typescript": "5.6.3",
"unplugin-icons": "0.19.3",
"unplugin-vue-components": "0.27.4",
"vite": "5.4.8",
"vite": "5.4.10",
"vite-plugin-progress": "0.0.7",
"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-tsc": "2.1.6"
},

View File

@ -1,6 +1,6 @@
{
"name": "@sa/alova",
"version": "0.1.0",
"version": "1.3.8",
"exports": {
".": "./src/index.ts",
"./fetch": "./src/fetch.ts",
@ -13,8 +13,8 @@
}
},
"dependencies": {
"@alova/mock": "2.0.7",
"@alova/mock": "2.0.8",
"@sa/utils": "workspace:*",
"alova": "3.0.20"
"alova": "3.1.1"
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@sa/scripts",
"version": "1.3.7",
"version": "1.3.8",
"bin": {
"sa": "./bin.ts"
},
@ -19,9 +19,9 @@
"cac": "6.7.14",
"consola": "3.2.3",
"enquirer": "2.4.1",
"execa": "9.4.0",
"execa": "9.4.1",
"kolorist": "1.8.0",
"npm-check-updates": "17.1.3",
"npm-check-updates": "17.1.4",
"rimraf": "6.0.1"
}
}

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -54,3 +54,10 @@ export const themePageAnimationModeRecord: Record<UnionKey.ThemePageAnimateMode,
};
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);

View File

@ -42,7 +42,7 @@ function resetScroll() {
@after-leave="resetScroll"
@after-enter="appStore.setContentXScrollable(false)"
>
<KeepAlive :include="routeStore.cacheRoutes">
<KeepAlive :include="routeStore.cacheRoutes" :exclude="routeStore.excludeCacheRoutes">
<component
:is="Component"
v-if="appStore.reloadFlag"

View File

@ -84,7 +84,10 @@ function getContextMenuDisabledKeys(tabId: string) {
async function handleCloseTab(tab: App.Global.Tab) {
await tabStore.removeTab(tab.id);
await routeStore.reCacheRoutesByKey(tab.routeKey);
if (themeStore.resetCacheStrategy === 'close') {
routeStore.resetRouteCache(tab.routeKey);
}
}
async function refresh() {

View File

@ -2,7 +2,12 @@
import { computed } from 'vue';
import { $t } from '@/locales';
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 SettingItem from '../components/setting-item.vue';
@ -22,6 +27,14 @@ const isWrapperScrollMode = computed(() => themeStore.layout.scrollMode === 'wra
<template>
<NDivider>{{ $t('theme.pageFunTitle') }}</NDivider>
<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')">
<NSelect
v-model:value="themeStore.layout.scrollMode"

View File

@ -141,6 +141,11 @@ const local: App.I18n.Schema = {
},
themeDrawerTitle: 'Theme Configuration',
pageFunTitle: 'Page Function',
resetCacheStrategy: {
title: 'Reset Cache Strategy',
close: 'Close Page',
refresh: 'Refresh Page'
},
configOperation: {
copyConfig: 'Copy Config',
copySuccessMsg: 'Copy Success, Please replace the variable "themeSettings" in "src/theme/settings.ts"',

View File

@ -141,6 +141,11 @@ const local: App.I18n.Schema = {
},
themeDrawerTitle: '主题配置',
pageFunTitle: '页面功能',
resetCacheStrategy: {
title: '重置缓存策略',
close: '关闭页面',
refresh: '刷新页面'
},
configOperation: {
copyConfig: '复制配置',
copySuccessMsg: '复制成功,请替换 src/theme/settings.ts 中的变量 themeSettings',

View File

@ -46,6 +46,10 @@ export const useAppStore = defineStore(SetupStoreId.App, () => {
});
setReloadFlag(true);
if (themeStore.resetCacheStrategy === 'refresh') {
routeStore.resetRouteCache();
}
}
const locale = ref<App.I18n.LangType>(localStg.get('lang') || 'zh-CN');

View File

@ -1,4 +1,4 @@
import { computed, ref, shallowRef } from 'vue';
import { computed, nextTick, ref, shallowRef } from 'vue';
import type { RouteRecordRaw } from 'vue-router';
import { defineStore } from 'pinia';
import { useBoolean } from '@sa/hooks';
@ -9,7 +9,6 @@ import { createStaticRoutes, getAuthVueRoutes } from '@/router/routes';
import { ROOT_ROUTE } from '@/router/routes/builtin';
import { getRouteName, getRoutePath } from '@/router/elegant/transform';
import { fetchGetConstantRoutes, fetchGetUserRoutes, fetchIsRouteExist } from '@/service/api';
import { useAppStore } from '../app';
import { useAuthStore } from '../auth';
import { useTabStore } from '../tab';
import {
@ -25,7 +24,6 @@ import {
} from './shared';
export const useRouteStore = defineStore(SetupStoreId.Route, () => {
const appStore = useAppStore();
const authStore = useAuthStore();
const tabStore = useTabStore();
const { bool: isInitConstantRoute, setBool: setIsInitConstantRoute } = useBoolean();
@ -97,8 +95,12 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
/** Cache routes */
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
@ -106,69 +108,23 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
* @param routes Vue routes
*/
function getCacheRoutes(routes: RouteRecordRaw[]) {
const alls = getCacheRouteNames(routes);
cacheRoutes.value = alls;
allCacheRoutes.value = [...alls];
cacheRoutes.value = getCacheRouteNames(routes);
}
/**
* Add cache routes
* Reset route cache
*
* @default router.currentRoute.value.name current route name
* @param routeKey
*/
function addCacheRoutes(routeKey: RouteKey) {
if (cacheRoutes.value.includes(routeKey)) return;
async function resetRouteCache(routeKey?: RouteKey) {
const routeName = routeKey || (router.currentRoute.value.name as RouteKey);
cacheRoutes.value.push(routeKey);
}
excludeCacheRoutes.value.push(routeName);
/**
* Remove cache routes
*
* @param routeKey
*/
function removeCacheRoutes(routeKey: RouteKey) {
const index = cacheRoutes.value.findIndex(item => item === routeKey);
await nextTick();
if (index === -1) return;
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);
}
excludeCacheRoutes.value = [];
}
/** Global breadcrumbs */
@ -361,8 +317,8 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
searchMenus,
updateGlobalMenusByLocale,
cacheRoutes,
reCacheRoutesByKey,
reCacheRoutesByKeys,
excludeCacheRoutes,
resetRouteCache,
breadcrumbs,
initConstantRoute,
isInitConstantRoute,

View File

@ -1 +1 @@
@import './scrollbar.scss';
@forward 'scrollbar';

View File

@ -12,6 +12,7 @@ export const themeSettings: App.Theme.ThemeSetting = {
error: '#f5222d'
},
isInfoFollowPrimary: true,
resetCacheStrategy: 'close',
layout: {
mode: 'vertical',
scrollMode: 'content',
@ -83,6 +84,7 @@ export const themeSettings: App.Theme.ThemeSetting = {
* If publish new version, use `overrideThemeSettings` to override certain theme settings
*/
export const overrideThemeSettings: Partial<App.Theme.ThemeSetting> = {
resetCacheStrategy: 'close',
watermark: {
visible: false,
text: 'SoybeanAdmin'

View File

@ -20,6 +20,8 @@ declare namespace App {
otherColor: OtherColor;
/** Whether info color is followed by the primary color */
isInfoFollowPrimary: boolean;
/** Reset cache strategy */
resetCacheStrategy?: UnionKey.ResetCacheStrategy;
/** Layout */
layout: {
/** Layout mode */
@ -388,6 +390,7 @@ declare namespace App {
};
themeDrawerTitle: string;
pageFunTitle: string;
resetCacheStrategy: { title: string } & Record<UnionKey.ResetCacheStrategy, string>;
configOperation: {
copyConfig: string;
copySuccessMsg: string;

View File

@ -14,6 +14,14 @@ declare namespace UnionKey {
/** Theme scheme */
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
*

View File

@ -43,7 +43,7 @@ const { loading, data, refresh, reload, page, pageSize, pageCount, send, remove
);
const getDataByPage = (newPage = 1) => {
page.value = newPage;
send();
send(page.value, pageSize.value);
};
const {