perf: 路由子集显示可配置

This commit is contained in:
xingyu 2022-12-20 16:05:16 +08:00
parent ec0bb01e07
commit 1ef6016d9d
4 changed files with 12 additions and 3 deletions

View File

@ -12,3 +12,6 @@ VITE_APP_TENANT_ENABLE=true
# 验证码的开关 # 验证码的开关
VITE_APP_CAPTCHA_ENABLE=true VITE_APP_CAPTCHA_ENABLE=true
# 路由在只有一个子集的时候是否显示父级
VITE_ROUTE_ALWAYSSHOW_ENABLE=true

View File

@ -57,7 +57,12 @@ export const generateRoute = (routes: AppCustomRouteRecordRaw[]): AppRouteRecord
icon: route.icon, icon: route.icon,
hidden: !route.visible, hidden: !route.visible,
noCache: !route.keepAlive, noCache: !route.keepAlive,
alwaysShow: route.children && route.children.length == 1 ? true : false alwaysShow:
route.children &&
route.children.length === 1 &&
import.meta.env.VITE_ROUTE_ALWAYSSHOW_ENABLE === 'true'
? true
: false
} }
// 路由地址转首字母大写驼峰作为路由名称适配keepAlive // 路由地址转首字母大写驼峰作为路由名称适配keepAlive
let data: AppRouteRecordRaw = { let data: AppRouteRecordRaw = {

View File

@ -10,7 +10,8 @@ declare module '*.vue' {
interface ImportMetaEnv { interface ImportMetaEnv {
readonly VITE_APP_TITLE: string readonly VITE_APP_TITLE: string
readonly VITE_PORT: number readonly VITE_PORT: number
readonly VITE_OPEN: boolean readonly VITE_OPEN: string
readonly VITE_ROUTE_ALWAYSSHOW_ENABLE: string
readonly VITE_APP_CAPTCHA_ENABLE: string readonly VITE_APP_CAPTCHA_ENABLE: string
readonly VITE_APP_TENANT_ENABLE: string readonly VITE_APP_TENANT_ENABLE: string
readonly VITE_BASE_URL: string readonly VITE_BASE_URL: string

View File

@ -30,7 +30,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
// 端口号 // 端口号
port: env.VITE_PORT, port: env.VITE_PORT,
host: "0.0.0.0", host: "0.0.0.0",
open: env.VITE_OPEN, open: env.VITE_OPEN === 'true',
// 本地跨域代理 // 本地跨域代理
proxy: { proxy: {
['/admin-api']: { ['/admin-api']: {