Compare commits

..

1 Commits

Author SHA1 Message Date
Soybean
6eaec8705d reafctor(projects): use new elegant-router plugin 2025-08-28 00:20:04 +08:00
44 changed files with 1522 additions and 1478 deletions

View File

@@ -13,10 +13,8 @@
[![gitcode star](https://gitcode.com/soybeanjs/soybean-admin/star/badge.svg)](https://gitcode.com/soybeanjs/soybean-admin) [![gitcode star](https://gitcode.com/soybeanjs/soybean-admin/star/badge.svg)](https://gitcode.com/soybeanjs/soybean-admin)
[![Powered by DartNode](https://dartnode.com/branding/DN-Open-Source-sm.png)](https://dartnode.com "Powered by DartNode - Free VPS for Open Source") [![Powered by DartNode](https://dartnode.com/branding/DN-Open-Source-sm.png)](https://dartnode.com "Powered by DartNode - Free VPS for Open Source")
<div style="display: flex; gap: 12px; align-items: center;"> <a href="https://hellogithub.com/repository/1298f27d5fe54959a16cf9686516ddb3" target="_blank"><img src="https://abroad.hellogithub.com/v1/widgets/recommend.svg?rid=1298f27d5fe54959a16cf9686516ddb3&claim_uid=IiDXWmP4TEntjbV" alt="FeaturedHelloGitHub" style="width: 250px; height: 54px;" width="250" height="54" /></a>
<a href="https://trendshift.io/repositories/7963" target="_blank"><img src="https://trendshift.io/api/badge/repositories/7963" alt="soybeanjs%2Fsoybean-admin | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
<a href="https://hellogithub.com/repository/1298f27d5fe54959a16cf9686516ddb3" target="_blank"><img src="https://abroad.hellogithub.com/v1/widgets/recommend.svg?rid=1298f27d5fe54959a16cf9686516ddb3&claim_uid=IiDXWmP4TEntjbV" alt="FeaturedHelloGitHub" style="width: 250px; height: 54px;" width="250" height="54" /></a>
</div>
> [!NOTE] > [!NOTE]
> If you think `SoybeanAdmin` is helpful to you, or you like our project, please give us a ⭐️ on GitHub. Your support is the driving force for us to continue to improve and add new features! Thank you for your support! > If you think `SoybeanAdmin` is helpful to you, or you like our project, please give us a ⭐️ on GitHub. Your support is the driving force for us to continue to improve and add new features! Thank you for your support!

View File

@@ -13,10 +13,7 @@
[![gitcode star](https://gitcode.com/soybeanjs/soybean-admin/star/badge.svg)](https://gitcode.com/soybeanjs/soybean-admin) [![gitcode star](https://gitcode.com/soybeanjs/soybean-admin/star/badge.svg)](https://gitcode.com/soybeanjs/soybean-admin)
[![Powered by DartNode](https://dartnode.com/branding/DN-Open-Source-sm.png)](https://dartnode.com "Powered by DartNode - Free VPS for Open Source") [![Powered by DartNode](https://dartnode.com/branding/DN-Open-Source-sm.png)](https://dartnode.com "Powered by DartNode - Free VPS for Open Source")
<div style="display: flex; gap: 12px; align-items: center;"> <a href="https://hellogithub.com/repository/1298f27d5fe54959a16cf9686516ddb3" target="_blank"><img src="https://abroad.hellogithub.com/v1/widgets/recommend.svg?rid=1298f27d5fe54959a16cf9686516ddb3&claim_uid=IiDXWmP4TEntjbV" alt="FeaturedHelloGitHub" style="width: 250px; height: 54px;" width="250" height="54" /></a>
<a href="https://trendshift.io/repositories/7963" target="_blank"><img src="https://trendshift.io/api/badge/repositories/7963" alt="soybeanjs%2Fsoybean-admin | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
<a href="https://hellogithub.com/repository/1298f27d5fe54959a16cf9686516ddb3" target="_blank"><img src="https://abroad.hellogithub.com/v1/widgets/recommend.svg?rid=1298f27d5fe54959a16cf9686516ddb3&claim_uid=IiDXWmP4TEntjbV" alt="FeaturedHelloGitHub" style="width: 250px; height: 54px;" width="250" height="54" /></a>
</div>
> [!NOTE] > [!NOTE]
> 如果您觉得 `SoybeanAdmin`对您有所帮助,或者您喜欢我们的项目,请在 GitHub 上给我们一个 ⭐️。您的支持是我们持续改进和增加新功能的动力!感谢您的支持! > 如果您觉得 `SoybeanAdmin`对您有所帮助,或者您喜欢我们的项目,请在 GitHub 上给我们一个 ⭐️。您的支持是我们持续改进和增加新功能的动力!感谢您的支持!

View File

@@ -54,54 +54,54 @@
"@sa/hooks": "workspace:*", "@sa/hooks": "workspace:*",
"@sa/materials": "workspace:*", "@sa/materials": "workspace:*",
"@sa/utils": "workspace:*", "@sa/utils": "workspace:*",
"@vueuse/core": "13.9.0", "@vueuse/core": "13.8.0",
"clipboard": "2.0.11", "clipboard": "2.0.11",
"dayjs": "1.11.18", "dayjs": "1.11.14",
"defu": "6.1.4", "defu": "6.1.4",
"echarts": "6.0.0", "echarts": "6.0.0",
"json5": "2.2.3", "json5": "2.2.3",
"naive-ui": "2.43.1", "naive-ui": "2.42.0",
"nprogress": "0.2.0", "nprogress": "0.2.0",
"pinia": "3.0.3", "pinia": "3.0.3",
"tailwind-merge": "3.3.1", "tailwind-merge": "3.3.1",
"vue": "3.5.22", "vue": "3.5.20",
"vue-draggable-plus": "0.6.0", "vue-draggable-plus": "0.6.0",
"vue-i18n": "11.1.12", "vue-i18n": "11.1.11",
"vue-router": "4.5.1" "vue-router": "4.5.1"
}, },
"devDependencies": { "devDependencies": {
"@elegant-router/vue": "0.3.8", "@elegant-router/vue": "0.3.8",
"@iconify/json": "2.2.395", "@iconify/json": "2.2.378",
"@sa/scripts": "workspace:*", "@sa/scripts": "workspace:*",
"@sa/uno-preset": "workspace:*", "@sa/uno-preset": "workspace:*",
"@soybeanjs/eslint-config": "1.7.1", "@soybeanjs/eslint-config": "1.7.1",
"@types/node": "24.7.2", "@types/node": "24.3.0",
"@types/nprogress": "0.2.3", "@types/nprogress": "0.2.3",
"@unocss/eslint-config": "66.5.3", "@unocss/eslint-config": "66.4.2",
"@unocss/preset-icons": "66.5.3", "@unocss/preset-icons": "66.4.2",
"@unocss/preset-uno": "66.5.3", "@unocss/preset-uno": "66.4.2",
"@unocss/transformer-directives": "66.5.3", "@unocss/transformer-directives": "66.4.2",
"@unocss/transformer-variant-group": "66.5.3", "@unocss/transformer-variant-group": "66.4.2",
"@unocss/vite": "66.5.3", "@unocss/vite": "66.4.2",
"@vitejs/plugin-vue": "6.0.1", "@vitejs/plugin-vue": "6.0.1",
"@vitejs/plugin-vue-jsx": "5.1.1", "@vitejs/plugin-vue-jsx": "5.1.0",
"consola": "3.4.2", "consola": "3.4.2",
"elegant-router": "1.0.4", "elegant-router": "1.0.4-beta.10",
"eslint": "9.37.0", "eslint": "9.34.0",
"eslint-plugin-vue": "10.5.0", "eslint-plugin-vue": "10.4.0",
"kolorist": "1.8.0", "kolorist": "1.8.0",
"sass": "1.93.2", "sass": "1.91.0",
"simple-git-hooks": "2.13.1", "simple-git-hooks": "2.13.1",
"tsx": "4.20.6", "tsx": "4.20.5",
"typescript": "5.9.3", "typescript": "5.9.2",
"unplugin-icons": "22.4.2", "unplugin-icons": "22.2.0",
"unplugin-vue-components": "29.1.0", "unplugin-vue-components": "29.0.0",
"vite": "7.1.9", "vite": "7.1.3",
"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": "8.0.2", "vite-plugin-vue-devtools": "8.0.1",
"vue-eslint-parser": "10.2.0", "vue-eslint-parser": "10.2.0",
"vue-tsc": "3.1.1" "vue-tsc": "3.0.6"
}, },
"simple-git-hooks": { "simple-git-hooks": {
"commit-msg": "pnpm sa git-commit-verify", "commit-msg": "pnpm sa git-commit-verify",

View File

@@ -11,7 +11,7 @@
}, },
"dependencies": { "dependencies": {
"@sa/utils": "workspace:*", "@sa/utils": "workspace:*",
"axios": "1.12.2", "axios": "1.11.0",
"axios-retry": "4.5.0", "axios-retry": "4.5.0",
"qs": "6.14.0" "qs": "6.14.0"
}, },

View File

@@ -3,7 +3,6 @@ import type { AxiosResponse, CreateAxiosDefaults, InternalAxiosRequestConfig } f
import axiosRetry from 'axios-retry'; import axiosRetry from 'axios-retry';
import { nanoid } from '@sa/utils'; import { nanoid } from '@sa/utils';
import { createAxiosConfig, createDefaultOptions, createRetryOptions } from './options'; import { createAxiosConfig, createDefaultOptions, createRetryOptions } from './options';
import { transformResponse } from './shared';
import { BACKEND_ERROR_CODE, REQUEST_ID_KEY } from './constant'; import { BACKEND_ERROR_CODE, REQUEST_ID_KEY } from './constant';
import type { import type {
CustomAxiosRequestConfig, CustomAxiosRequestConfig,
@@ -54,8 +53,6 @@ function createCommonRequest<
async response => { async response => {
const responseType: ResponseType = (response.config?.responseType as ResponseType) || 'json'; const responseType: ResponseType = (response.config?.responseType as ResponseType) || 'json';
await transformResponse(response);
if (responseType !== 'json' || opts.isBackendSuccess(response)) { if (responseType !== 'json' || opts.isBackendSuccess(response)) {
return Promise.resolve(response); return Promise.resolve(response);
} }

View File

@@ -1,5 +1,4 @@
import type { AxiosHeaderValue, AxiosResponse, InternalAxiosRequestConfig } from 'axios'; import type { AxiosHeaderValue, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
import type { ResponseType } from './type';
export function getContentType(config: InternalAxiosRequestConfig) { export function getContentType(config: InternalAxiosRequestConfig) {
const contentType: AxiosHeaderValue = config.headers?.['Content-Type'] || 'application/json'; const contentType: AxiosHeaderValue = config.headers?.['Content-Type'] || 'application/json';
@@ -27,53 +26,3 @@ export function isResponseJson(response: AxiosResponse) {
return responseType === 'json' || responseType === undefined; return responseType === 'json' || responseType === undefined;
} }
export async function transformResponse(response: AxiosResponse) {
const responseType: ResponseType = (response.config?.responseType as ResponseType) || 'json';
if (responseType === 'json') return;
const isJson = response.headers['content-type']?.includes('application/json');
if (!isJson) return;
if (responseType === 'blob') {
await transformBlobToJson(response);
}
if (responseType === 'arrayBuffer') {
await transformArrayBufferToJson(response);
}
}
export async function transformBlobToJson(response: AxiosResponse) {
try {
let data = response.data;
if (typeof data === 'string') {
data = JSON.parse(data);
}
if (Object.prototype.toString.call(data) === '[object Blob]') {
const json = await data.text();
data = JSON.parse(json);
}
response.data = data;
} catch {}
}
export async function transformArrayBufferToJson(response: AxiosResponse) {
try {
let data = response.data;
if (typeof data === 'string') {
data = JSON.parse(data);
}
if (Object.prototype.toString.call(data) === '[object ArrayBuffer]') {
const json = new TextDecoder().decode(data);
data = JSON.parse(json);
}
response.data = data;
} catch {}
}

View File

@@ -95,27 +95,3 @@
.chrome-tab_dark .chrome-tab-divider { .chrome-tab_dark .chrome-tab-divider {
background-color: rgba(255, 255, 255, 0.9); background-color: rgba(255, 255, 255, 0.9);
} }
.slider-tab {
background-color: transparent;
height: 100%;
border-bottom: 2px solid transparent;
}
.slider-tab_dark {
background-color: transparent;
}
.slider-tab:hover {
color: var(--soy-primary-color);
}
.slider-tab_active {
color: var(--soy-primary-color);
background-color: var(--soy-primary-color-opacity1);
border-bottom-color: var(--soy-primary-color);
}
.slider-tab_active_dark {
background-color: var(--soy-primary-color-opacity2);
}

View File

@@ -10,10 +10,6 @@ declare const styles: {
readonly 'chrome-tab_dark': string; readonly 'chrome-tab_dark': string;
readonly 'chrome-tab-divider': string; readonly 'chrome-tab-divider': string;
readonly 'svg-close': string; readonly 'svg-close': string;
readonly 'slider-tab': string;
readonly 'slider-tab_active': string;
readonly 'slider-tab_active_dark': string;
readonly 'slider-tab_dark': string;
}; };
export default styles; export default styles;

View File

@@ -5,7 +5,6 @@ import type { PageTabMode, PageTabProps } from '../../types';
import { ACTIVE_COLOR, createTabCssVars } from './shared'; import { ACTIVE_COLOR, createTabCssVars } from './shared';
import ChromeTab from './chrome-tab.vue'; import ChromeTab from './chrome-tab.vue';
import ButtonTab from './button-tab.vue'; import ButtonTab from './button-tab.vue';
import SliderTab from './slider-tab.vue';
import SvgClose from './svg-close.vue'; import SvgClose from './svg-close.vue';
import style from './index.module.css'; import style from './index.module.css';
@@ -27,7 +26,7 @@ interface Emits {
const emit = defineEmits<Emits>(); const emit = defineEmits<Emits>();
const activeTabComponent = computed(() => { const activeTabComponent = computed(() => {
const { mode, chromeClass, buttonClass, sliderClass } = props; const { mode, chromeClass, buttonClass } = props;
const tabComponentMap = { const tabComponentMap = {
chrome: { chrome: {
@@ -37,10 +36,6 @@ const activeTabComponent = computed(() => {
button: { button: {
component: ButtonTab, component: ButtonTab,
class: buttonClass class: buttonClass
},
slider: {
component: SliderTab,
class: sliderClass
} }
} satisfies Record<PageTabMode, { component: Component; class?: string }>; } satisfies Record<PageTabMode, { component: Component; class?: string }>;
@@ -50,7 +45,7 @@ const activeTabComponent = computed(() => {
const cssVars = computed(() => createTabCssVars(props.activeColor)); const cssVars = computed(() => createTabCssVars(props.activeColor));
const bindProps = computed(() => { const bindProps = computed(() => {
const { chromeClass: _chromeCls, buttonClass: _btnCls, sliderClass: _sliderCls, ...rest } = props; const { chromeClass: _chromeCls, buttonClass: _btnCls, ...rest } = props;
return rest; return rest;
}); });

View File

@@ -1,53 +0,0 @@
<script setup lang="ts">
import type { PageTabProps } from '../../types';
import style from './index.module.css';
defineOptions({
name: 'SliderTab'
});
defineProps<PageTabProps>();
type SlotFn = (props?: Record<string, unknown>) => any;
type Slots = {
/**
* Slot
*
* The center content of the tab
*/
default?: SlotFn;
/**
* Slot
*
* The left content of the tab
*/
prefix?: SlotFn;
/**
* Slot
*
* The right content of the tab
*/
suffix?: SlotFn;
};
defineSlots<Slots>();
</script>
<template>
<div
class=":soy: relative inline-flex cursor-pointer items-center justify-center gap-6px whitespace-nowrap px-12px py-4px"
:class="[
style['slider-tab'],
{ [style['slider-tab_dark']]: darkMode },
{ [style['slider-tab_active']]: active },
{ [style['slider-tab_active_dark']]: active && darkMode }
]"
>
<slot name="prefix"></slot>
<slot></slot>
<slot name="suffix"></slot>
</div>
</template>
<style scoped></style>

View File

@@ -239,7 +239,7 @@ export type LayoutCssVars = {
* *
* @default chrome * @default chrome
*/ */
export type PageTabMode = 'button' | 'chrome' | 'slider'; export type PageTabMode = 'button' | 'chrome';
export interface PageTabProps { export interface PageTabProps {
/** Whether is dark mode */ /** Whether is dark mode */
@@ -262,8 +262,6 @@ export interface PageTabProps {
buttonClass?: string; buttonClass?: string;
/** The class of the chrome tab */ /** The class of the chrome tab */
chromeClass?: string; chromeClass?: string;
/** The class of the title tab */
sliderClass?: string;
/** Whether the tab is active */ /** Whether the tab is active */
active?: boolean; active?: boolean;
/** The color of the active tab */ /** The color of the active tab */

View File

@@ -13,15 +13,15 @@
} }
}, },
"devDependencies": { "devDependencies": {
"@soybeanjs/changelog": "0.3.25", "@soybeanjs/changelog": "0.3.24",
"bumpp": "10.3.1", "bumpp": "10.2.3",
"c12": "3.3.0", "c12": "3.2.0",
"cac": "6.7.14", "cac": "6.7.14",
"consola": "3.4.2", "consola": "3.4.2",
"enquirer": "2.4.1", "enquirer": "2.4.1",
"execa": "9.6.0", "execa": "9.6.0",
"kolorist": "1.8.0", "kolorist": "1.8.0",
"npm-check-updates": "19.0.0", "npm-check-updates": "18.0.3",
"picomatch": "4.0.3", "picomatch": "4.0.3",
"rimraf": "6.0.1" "rimraf": "6.0.1"
} }

View File

@@ -14,7 +14,7 @@
"crypto-js": "4.2.0", "crypto-js": "4.2.0",
"klona": "2.0.6", "klona": "2.0.6",
"localforage": "1.10.0", "localforage": "1.10.0",
"nanoid": "5.1.6" "nanoid": "5.1.5"
}, },
"devDependencies": { "devDependencies": {
"@types/crypto-js": "4.2.2" "@types/crypto-js": "4.2.2"

2346
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -40,8 +40,7 @@ export const themeScrollModeOptions = transformRecordToOption(themeScrollModeRec
export const themeTabModeRecord: Record<UnionKey.ThemeTabMode, App.I18n.I18nKey> = { export const themeTabModeRecord: Record<UnionKey.ThemeTabMode, App.I18n.I18nKey> = {
chrome: 'theme.layout.tab.mode.chrome', chrome: 'theme.layout.tab.mode.chrome',
button: 'theme.layout.tab.mode.button', button: 'theme.layout.tab.mode.button'
slider: 'theme.layout.tab.mode.slider'
}; };
export const themeTabModeOptions = transformRecordToOption(themeTabModeRecord); export const themeTabModeOptions = transformRecordToOption(themeTabModeRecord);
@@ -58,6 +57,13 @@ 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> = {
refresh: 'theme.layout.resetCacheStrategy.refresh',
close: 'theme.layout.resetCacheStrategy.close'
};
export const resetCacheStrategyOptions = transformRecordToOption(resetCacheStrategyRecord);
export const DARK_CLASS = 'dark'; export const DARK_CLASS = 'dark';
export const watermarkTimeFormatOptions = [ export const watermarkTimeFormatOptions = [

View File

@@ -169,9 +169,7 @@ init();
<div <div
ref="tabRef" ref="tabRef"
class="h-full flex pr-18px" class="h-full flex pr-18px"
:class="[ :class="[themeStore.tab.mode === 'chrome' ? 'items-end' : 'items-center gap-12px']"
themeStore.tab.mode === 'chrome' || themeStore.tab.mode === 'slider' ? 'items-end' : 'items-center gap-12px'
]"
> >
<PageTab <PageTab
v-for="tab in tabStore.tabs" v-for="tab in tabStore.tabs"

View File

@@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { themeTabModeOptions } from '@/constants/app'; import { resetCacheStrategyOptions, themeTabModeOptions } from '@/constants/app';
import { useThemeStore } from '@/store/modules/theme'; import { useThemeStore } from '@/store/modules/theme';
import { translateOptions } from '@/utils/common'; import { translateOptions } from '@/utils/common';
import { $t } from '@/locales'; import { $t } from '@/locales';
@@ -15,6 +15,14 @@ const themeStore = useThemeStore();
<template> <template>
<NDivider>{{ $t('theme.layout.tab.title') }}</NDivider> <NDivider>{{ $t('theme.layout.tab.title') }}</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.layout.resetCacheStrategy.title')">
<NSelect
v-model:value="themeStore.resetCacheStrategy"
:options="translateOptions(resetCacheStrategyOptions)"
size="small"
class="w-120px"
/>
</SettingItem>
<SettingItem key="1" :label="$t('theme.layout.tab.visible')"> <SettingItem key="1" :label="$t('theme.layout.tab.visible')">
<NSwitch v-model:value="themeStore.tab.visible" /> <NSwitch v-model:value="themeStore.tab.visible" />
</SettingItem> </SettingItem>

View File

@@ -16,6 +16,7 @@ type ThemePreset = Pick<
| 'themeColor' | 'themeColor'
| 'otherColor' | 'otherColor'
| 'isInfoFollowPrimary' | 'isInfoFollowPrimary'
| 'resetCacheStrategy'
| 'layout' | 'layout'
| 'page' | 'page'
| 'header' | 'header'

View File

@@ -135,7 +135,6 @@ const local: App.I18n.Schema = {
height: 'Tab Height', height: 'Tab Height',
mode: { mode: {
title: 'Tab Mode', title: 'Tab Mode',
slider: 'Slider',
chrome: 'Chrome', chrome: 'Chrome',
button: 'Button' button: 'Button'
} }
@@ -186,6 +185,11 @@ const local: App.I18n.Schema = {
} }
}, },
fixedHeaderAndTab: 'Fixed Header And Tab' fixedHeaderAndTab: 'Fixed Header And Tab'
},
resetCacheStrategy: {
title: 'Reset Cache Strategy',
close: 'Close Page',
refresh: 'Refresh Page'
} }
}, },
general: { general: {

View File

@@ -132,7 +132,6 @@ const local: App.I18n.Schema = {
height: '标签栏高度', height: '标签栏高度',
mode: { mode: {
title: '标签栏风格', title: '标签栏风格',
slider: '滑块风格',
chrome: '谷歌风格', chrome: '谷歌风格',
button: '按钮风格' button: '按钮风格'
} }
@@ -159,7 +158,7 @@ const local: App.I18n.Schema = {
visible: '显示底部', visible: '显示底部',
fixed: '固定底部', fixed: '固定底部',
height: '底部高度', height: '底部高度',
right: '底部右' right: '底部右'
}, },
content: { content: {
title: '内容区域设置', title: '内容区域设置',
@@ -183,6 +182,11 @@ const local: App.I18n.Schema = {
} }
}, },
fixedHeaderAndTab: '固定头部和标签栏' fixedHeaderAndTab: '固定头部和标签栏'
},
resetCacheStrategy: {
title: '重置缓存策略',
close: '关闭页面',
refresh: '刷新页面'
} }
}, },
general: { general: {

View File

@@ -19,7 +19,11 @@ export const views: Record<RouteFileKey, RawRouteComponent> = {
Home: () => import("@/views/home/index.vue"), Home: () => import("@/views/home/index.vue"),
IframeUrl: () => import("@/views/(builtin)/iframe/[url].vue"), IframeUrl: () => import("@/views/(builtin)/iframe/[url].vue"),
Login: () => import("@/views/(builtin)/login/index.vue"), Login: () => import("@/views/(builtin)/login/index.vue"),
ManageApi: () => import("@/views/manage/api/index.vue"),
ManageDictionary: () => import("@/views/manage/dictionary/index.vue"),
ManageMenu: () => import("@/views/manage/menu/index.vue"), ManageMenu: () => import("@/views/manage/menu/index.vue"),
ManageOrganization: () => import("@/views/manage/organization/index.vue"),
ManagePermission: () => import("@/views/manage/permission/index.vue"),
ManageRole: () => import("@/views/manage/role/index.vue"), ManageRole: () => import("@/views/manage/role/index.vue"),
ManageRoute: () => import("@/views/manage/route/index.vue"), ManageRoute: () => import("@/views/manage/route/index.vue"),
ManageUser: () => import("@/views/manage/user/index.vue"), ManageUser: () => import("@/views/manage/user/index.vue"),

View File

@@ -82,6 +82,24 @@ export const routes: AutoRouterRoute[] = [
constant: true constant: true
}, },
}, },
{
name: 'ManageApi',
path: '/manage/api',
layout: 'base',
component: 'ManageApi',
meta: {
title: "ManageApi"
}
},
{
name: 'ManageDictionary',
path: '/manage/dictionary',
layout: 'base',
component: 'ManageDictionary',
meta: {
title: "ManageDictionary"
}
},
{ {
name: 'ManageMenu', name: 'ManageMenu',
path: '/manage/menu', path: '/manage/menu',
@@ -91,6 +109,24 @@ export const routes: AutoRouterRoute[] = [
title: "ManageMenu" title: "ManageMenu"
}, },
}, },
{
name: 'ManageOrganization',
path: '/manage/organization',
layout: 'base',
component: 'ManageOrganization',
meta: {
title: "ManageOrganization"
}
},
{
name: 'ManagePermission',
path: '/manage/permission',
layout: 'base',
component: 'ManagePermission',
meta: {
title: "ManagePermission"
}
},
{ {
name: 'ManageRole', name: 'ManageRole',
path: '/manage/role', path: '/manage/role',

View File

@@ -16,7 +16,11 @@ const routePathMap: RoutePathMap = {
"Home": "/home", "Home": "/home",
"IframeUrl": "/iframe/:url", "IframeUrl": "/iframe/:url",
"Login": "/login/:module(pwd-login|code-login|register|reset-pwd|bind-wechat)?", "Login": "/login/:module(pwd-login|code-login|register|reset-pwd|bind-wechat)?",
"ManageApi": "/manage/api",
"ManageDictionary": "/manage/dictionary",
"ManageMenu": "/manage/menu", "ManageMenu": "/manage/menu",
"ManageOrganization": "/manage/organization",
"ManagePermission": "/manage/permission",
"ManageRole": "/manage/role", "ManageRole": "/manage/role",
"ManageRoute": "/manage/route", "ManageRoute": "/manage/route",
"ManageUser": "/manage/user", "ManageUser": "/manage/user",

View File

@@ -1,4 +1,4 @@
import type { AutoRouterRedirect, AutoRouterRoute } from '@elegant-router/types'; import type { AutoRouterRoute } from '@elegant-router/types';
import { routes } from '../_generated/routes'; import { routes } from '../_generated/routes';
import { layouts, views } from '../_generated/imports'; import { layouts, views } from '../_generated/imports';
import { transformToVueRoutes } from '../_generated/transformer'; import { transformToVueRoutes } from '../_generated/transformer';
@@ -8,24 +8,17 @@ export function createStaticRoutes() {
const constantRoutes: AutoRouterRoute[] = []; const constantRoutes: AutoRouterRoute[] = [];
const authRoutes: AutoRouterRoute[] = []; const authRoutes: AutoRouterRoute[] = [];
let rootRoute: AutoRouterRedirect | undefined;
routes.forEach(item => { routes.forEach(item => {
if (item.meta?.constant) { if (item.meta?.constant) {
constantRoutes.push(item); constantRoutes.push(item);
} else { } else {
authRoutes.push(item); authRoutes.push(item);
} }
if (item.name === 'Root') {
rootRoute = item as AutoRouterRedirect;
}
}); });
return { return {
constantRoutes, constantRoutes,
authRoutes, authRoutes
rootRoute: rootRoute as AutoRouterRedirect
}; };
} }

View File

@@ -46,7 +46,10 @@ export const useAppStore = defineStore(SetupStoreId.App, () => {
}); });
setReloadFlag(true); setReloadFlag(true);
routeStore.resetRouteCache();
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');

View File

@@ -112,8 +112,10 @@ export const useTabStore = defineStore(SetupStoreId.Tab, () => {
await switchRouteByTab(nextTab); await switchRouteByTab(nextTab);
} }
// reset route cache // reset route cache if cache strategy is close
routeStore.resetRouteCache(removedTabRouteKey); if (themeStore.resetCacheStrategy === 'close') {
routeStore.resetRouteCache(removedTabRouteKey);
}
} }
/** remove active tab */ /** remove active tab */
@@ -145,8 +147,10 @@ export const useTabStore = defineStore(SetupStoreId.Tab, () => {
const tabsToRemove = tabs.value.filter(tab => !remainTabIds.includes(tab.id)); const tabsToRemove = tabs.value.filter(tab => !remainTabIds.includes(tab.id));
const routeKeysToReset: RouteKey[] = []; const routeKeysToReset: RouteKey[] = [];
for (const tab of tabsToRemove) { if (themeStore.resetCacheStrategy === 'close') {
routeKeysToReset.push(tab.routeKey); for (const tab of tabsToRemove) {
routeKeysToReset.push(tab.routeKey);
}
} }
const removedTabsIds = tabsToRemove.map(tab => tab.id); const removedTabsIds = tabsToRemove.map(tab => tab.id);

View File

@@ -15,6 +15,7 @@
"error": "#c49a9a" "error": "#c49a9a"
}, },
"isInfoFollowPrimary": true, "isInfoFollowPrimary": true,
"resetCacheStrategy": "refresh",
"layout": { "layout": {
"mode": "vertical-mix", "mode": "vertical-mix",
"scrollMode": "wrapper" "scrollMode": "wrapper"

View File

@@ -15,6 +15,7 @@
"error": "#f5222d" "error": "#f5222d"
}, },
"isInfoFollowPrimary": true, "isInfoFollowPrimary": true,
"resetCacheStrategy": "close",
"layout": { "layout": {
"mode": "vertical", "mode": "vertical",
"scrollMode": "content" "scrollMode": "content"

View File

@@ -15,6 +15,7 @@
"error": "#f5222d" "error": "#f5222d"
}, },
"isInfoFollowPrimary": true, "isInfoFollowPrimary": true,
"resetCacheStrategy": "close",
"layout": { "layout": {
"mode": "vertical", "mode": "vertical",
"scrollMode": "content" "scrollMode": "content"

View File

@@ -15,6 +15,7 @@
"error": "#f5222d" "error": "#f5222d"
}, },
"isInfoFollowPrimary": true, "isInfoFollowPrimary": true,
"resetCacheStrategy": "close",
"layout": { "layout": {
"mode": "vertical", "mode": "vertical",
"scrollMode": "content" "scrollMode": "content"

View File

@@ -12,6 +12,7 @@ export const themeSettings: App.Theme.ThemeSetting = {
error: '#f5222d' error: '#f5222d'
}, },
isInfoFollowPrimary: true, isInfoFollowPrimary: true,
resetCacheStrategy: 'refresh',
layout: { layout: {
mode: 'vertical', mode: 'vertical',
scrollMode: 'content' scrollMode: 'content'

View File

@@ -5,38 +5,46 @@
*/ */
declare namespace Api { declare namespace Api {
namespace Common { namespace Common {
interface CreatedUpdatedDTO { /** common params of paginating */
/** 创建人 */ interface PaginatingCommonParams {
createdBy: string; /** current page number */
/** 创建时间 */ current: number;
createdTime: string; /** page size */
/** 更新人 */ size: number;
updatedBy: string; /** total count */
/** 更新时间 */
updatedTime: string;
}
interface CommonRecordDTO extends CreatedUpdatedDTO {
/** 主键 */
id: number;
/**
* 启用状态 Enable status
*
* - "1": 启用
* - "2": 禁用
*/
status: Union.EnableStatus | null;
}
interface PaginationQueryDTO {
page: number;
pageSize: number;
sort: string;
}
interface PaginationDTO extends Pick<PaginationQueryDTO, 'page' | 'pageSize'> {
/** 总条数 */
total: number; total: number;
} }
/** common params of paginating query list data */
interface PaginatingQueryRecord<T = any> extends PaginatingCommonParams {
records: T[];
}
/** common search params of table */
type CommonSearchParams = Pick<Common.PaginatingCommonParams, 'current' | 'size'>;
/**
* enable status
*
* - "1": enabled
* - "2": disabled
*/
type EnableStatus = '1' | '2';
/** common record */
type CommonRecord<T = any> = {
/** record id */
id: number;
/** record creator */
createBy: string;
/** record create time */
createTime: string;
/** record updater */
updateBy: string;
/** record update time */
updateTime: string;
/** record status */
status: EnableStatus | null;
} & T;
} }
} }

View File

@@ -1,42 +0,0 @@
declare namespace Api {
namespace Menu {
type RouteKey = import('@elegant-router/types').RouteKey;
interface Menu extends Common.CommonRecordDTO {
/** 菜单名称 */
name: string;
/** 菜单类型 */
menuType: Union.MenuType;
/** 菜单描述 */
description?: string | null;
/** 菜单图标 */
icon?: string | null;
/** 菜单图标类型 */
iconType?: string | null;
/** 父级菜单ID */
parentId?: number | null;
/** 菜单排序 */
order?: number | null;
/** 是否隐藏 */
isHidden?: boolean | null;
/** iframe 页面URL */
iframeUrl?: string | null;
/** 链接 */
href?: string | null;
/** 路由名称 */
routeName?: RouteKey | null;
/** 路由查询参数 */
routeQueries?: Record<string, string | number | boolean> | null;
/** 路由路径参数 */
routeParams?: Record<string, string | number | boolean> | null;
}
interface MenuListDTO extends Common.PaginationDTO {
list: Menu[];
}
interface MenuTreeDTO extends Menu {
children?: MenuTreeDTO[];
}
}
}

View File

@@ -1,34 +1,19 @@
declare namespace Api { declare namespace Api {
/**
* namespace Route
*
* backend api module: "route"
*/
namespace Route { namespace Route {
interface RouteDTO extends Common.CommonRecordDTO { type ElegantConstRoute = import('@elegant-router/types').ElegantConstRoute;
/** 路由路径 */
path: string; interface MenuRoute extends ElegantConstRoute {
/** 路由名称 */ id: string;
name: string;
/** 路由布局 */
layout: string;
/** 路由组件 */
component: string;
/** 重定向路径 */
redirect?: string | null;
/** 路由图标 */
icon?: string | null;
/** 路由图标类型 */
iconType?: string | null;
/** 是否缓存 */
isCache?: boolean | null;
/** 是否支持多开 */
isMultiple?: boolean | null;
/** 固定索引 */
fixedIndex?: number | null;
/** 是否需要权限 */
requireAuth?: boolean | null;
/** 路由属性 */
props?: Record<string, string | number | boolean> | null;
} }
interface RouteListDTO extends Common.PaginationDTO { interface UserRoute {
list: RouteDTO[]; routes: MenuRoute[];
home: import('@elegant-router/types').LastLevelRouteKey;
} }
} }
} }

View File

@@ -1,31 +0,0 @@
declare namespace Api {
namespace Union {
/**
* 是否 Yes or No
*
* - "Y": yes
* - "N": no
*/
type YesOrNo = 'Y' | 'N';
/**
* 启用状态 Enable status
*
* - "1": 启用
* - "2": 禁用
*/
type EnableStatus = '1' | '2';
/**
* 菜单类型
*
* - "directory": 目录
* - "menu": 菜单
* - "iframe": iframe 页面iframe 嵌入页面)
* - "link": 链接(跳转外部链接)
* - "page": 页面(不展示在菜单中,可用于作为菜单类型的子菜单展示在面包屑中)
* - "other": 其他(作用自行定义)
*/
type MenuType = 'page' | 'directory' | 'menu' | 'iframe' | 'link' | 'other';
}
}

97
src/typings/app.d.ts vendored
View File

@@ -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 */
@@ -179,9 +181,9 @@ declare namespace App {
type VNode = import('vue').VNode; type VNode = import('vue').VNode;
type RouteLocationNormalizedLoaded = import('vue-router').RouteLocationNormalizedLoaded; type RouteLocationNormalizedLoaded = import('vue-router').RouteLocationNormalizedLoaded;
type RouteKey = import('@elegant-router/types').RouteKey; type RouteKey = import('@elegant-router/types').RouteKey;
type RoutePathMap = import('@elegant-router/types').RoutePathMap; type RouteMap = import('@elegant-router/types').RouteMap;
type RoutePath = import('@elegant-router/types').RoutePath; type RoutePath = import('@elegant-router/types').RoutePath;
type RouteFileKey = import('@elegant-router/types').RouteFileKey; type LastLevelRouteKey = import('@elegant-router/types').LastLevelRouteKey;
/** The router push options */ /** The router push options */
type RouterPushOptions = { type RouterPushOptions = {
@@ -199,25 +201,77 @@ declare namespace App {
showMenu?: boolean; showMenu?: boolean;
} }
type MenuType = 'page' | 'directory' | 'menu' | 'iframe' | 'link' | 'button' | 'other';
/** The global menu */ /** The global menu */
interface Menu { type Menu = {
id: number; /**
name: string; * The menu key
menuType: MenuType; *
description?: string | null; * Equal to the route key
icon?: string | null; */
iconType?: string | null; key: string;
parentId?: number | null; /** The menu label */
order?: number | null; label: string;
isHidden?: boolean | null; /** The menu i18n key */
iframeUrl?: string | null; i18nKey?: I18n.I18nKey | null;
href?: string | null; /** The route key */
routeName?: RouteKey | null; routeKey: RouteKey;
routeQueries?: Record<string, string | number | boolean> | null; /** The route path */
routeParams?: Record<string, string | number | boolean> | null; routePath: RoutePath;
} /** The menu icon */
icon?: () => VNode;
/** The menu children */
children?: Menu[];
};
type Breadcrumb = Omit<Menu, 'children'> & {
options?: Breadcrumb[];
};
/** Tab route */
type TabRoute = Pick<RouteLocationNormalizedLoaded, 'name' | 'path' | 'meta'> &
Partial<Pick<RouteLocationNormalizedLoaded, 'fullPath' | 'query' | 'matched'>>;
/** The global tab */
type Tab = {
/** The tab id */
id: string;
/** The tab label */
label: string;
/**
* The new tab label
*
* If set, the tab label will be replaced by this value
*/
newLabel?: string;
/**
* The old tab label
*
* when reset the tab label, the tab label will be replaced by this value
*/
oldLabel?: string;
/** The tab route key */
routeKey: LastLevelRouteKey;
/** The tab route path */
routePath: RouteMap[LastLevelRouteKey];
/** The tab route full path */
fullPath: string;
/** The tab fixed index */
fixedIndex?: number | null;
/**
* Tab icon
*
* Iconify icon
*/
icon?: string;
/**
* Tab local icon
*
* Local icon
*/
localIcon?: string;
/** I18n key */
i18nKey?: I18n.I18nKey | null;
};
/** Form rule */ /** Form rule */
type FormRule = import('naive-ui').FormItemRule; type FormRule = import('naive-ui').FormItemRule;
@@ -322,7 +376,7 @@ declare namespace App {
themeColor: { themeColor: {
title: string; title: string;
followPrimary: string; followPrimary: string;
} & Record<Theme.ThemeColorKey, string>; } & Theme.ThemeColor;
recommendColor: string; recommendColor: string;
recommendColorDesc: string; recommendColorDesc: string;
preset: { preset: {
@@ -382,6 +436,7 @@ declare namespace App {
}; };
fixedHeaderAndTab: string; fixedHeaderAndTab: string;
}; };
resetCacheStrategy: { title: string } & Record<UnionKey.ResetCacheStrategy, string>;
}; };
general: { general: {
title: string; title: string;

View File

@@ -31,7 +31,11 @@ declare module "@elegant-router/types" {
"Home": "/home"; "Home": "/home";
"IframeUrl": "/iframe/:url"; "IframeUrl": "/iframe/:url";
"Login": "/login/:module(pwd-login|code-login|register|reset-pwd|bind-wechat)?"; "Login": "/login/:module(pwd-login|code-login|register|reset-pwd|bind-wechat)?";
"ManageApi": "/manage/api";
"ManageDictionary": "/manage/dictionary";
"ManageMenu": "/manage/menu"; "ManageMenu": "/manage/menu";
"ManageOrganization": "/manage/organization";
"ManagePermission": "/manage/permission";
"ManageRole": "/manage/role"; "ManageRole": "/manage/role";
"ManageRoute": "/manage/route"; "ManageRoute": "/manage/route";
"ManageUser": "/manage/user"; "ManageUser": "/manage/user";

View File

@@ -31,7 +31,11 @@ declare module "vue-router/auto-routes" {
"Home": RouteRecordInfo<"Home", "/home", Record<never, never>, Record<never, never>>; "Home": RouteRecordInfo<"Home", "/home", Record<never, never>, Record<never, never>>;
"IframeUrl": RouteRecordInfo<"IframeUrl", "/iframe/:url", { url: ParamValue<true> }, { url: ParamValue<false> }>; "IframeUrl": RouteRecordInfo<"IframeUrl", "/iframe/:url", { url: ParamValue<true> }, { url: ParamValue<false> }>;
"Login": RouteRecordInfo<"Login", "/login/:module(pwd-login|code-login|register|reset-pwd|bind-wechat)?", { module?: ParamValueZeroOrOne<true> }, { module?: ParamValueZeroOrOne<false> }>; "Login": RouteRecordInfo<"Login", "/login/:module(pwd-login|code-login|register|reset-pwd|bind-wechat)?", { module?: ParamValueZeroOrOne<true> }, { module?: ParamValueZeroOrOne<false> }>;
"ManageApi": RouteRecordInfo<"ManageApi", "/manage/api", Record<never, never>, Record<never, never>>;
"ManageDictionary": RouteRecordInfo<"ManageDictionary", "/manage/dictionary", Record<never, never>, Record<never, never>>;
"ManageMenu": RouteRecordInfo<"ManageMenu", "/manage/menu", Record<never, never>, Record<never, never>>; "ManageMenu": RouteRecordInfo<"ManageMenu", "/manage/menu", Record<never, never>, Record<never, never>>;
"ManageOrganization": RouteRecordInfo<"ManageOrganization", "/manage/organization", Record<never, never>, Record<never, never>>;
"ManagePermission": RouteRecordInfo<"ManagePermission", "/manage/permission", Record<never, never>, Record<never, never>>;
"ManageRole": RouteRecordInfo<"ManageRole", "/manage/role", Record<never, never>, Record<never, never>>; "ManageRole": RouteRecordInfo<"ManageRole", "/manage/role", Record<never, never>, Record<never, never>>;
"ManageRoute": RouteRecordInfo<"ManageRoute", "/manage/route", Record<never, never>, Record<never, never>>; "ManageRoute": RouteRecordInfo<"ManageRoute", "/manage/route", Record<never, never>, Record<never, never>>;
"ManageUser": RouteRecordInfo<"ManageUser", "/manage/user", Record<never, never>, Record<never, never>>; "ManageUser": RouteRecordInfo<"ManageUser", "/manage/user", Record<never, never>, Record<never, never>>;

View File

@@ -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
* *

View File

@@ -23,7 +23,7 @@ const appStore = useAppStore();
const themeStore = useThemeStore(); const themeStore = useThemeStore();
interface LoginModule { interface LoginModule {
label: App.I18n.I18nKey; label: string;
component: Component; component: Component;
} }

View File

@@ -0,0 +1,5 @@
<script setup lang="ts"></script>
<template>
<div>ManageApi</div>
</template>

View File

@@ -0,0 +1,5 @@
<script setup lang="ts"></script>
<template>
<div>ManageDictionary</div>
</template>

View File

@@ -0,0 +1,5 @@
<script setup lang="ts"></script>
<template>
<div>ManageOrganization</div>
</template>

View File

@@ -0,0 +1,5 @@
<script setup lang="ts"></script>
<template>
<div>ManagePermission</div>
</template>