Files
reader-star/apps/admin/src/typings/vite-env.d.ts
rjl f6d2a643e8 feat(router): 增加强制登录配置选项
添加 VITE_AUTH_ROUTE_FORCE_LOGIN 环境变量以控制是否强制用户登录
当设置为 Y 时,未登录用户访问非白名单路由将被重定向到登录页
同时更新开发环境配置并添加相应的 TypeScript 类型定义
2026-01-27 10:01:55 +08:00

121 lines
3.9 KiB
TypeScript

/**
* Namespace Env
*
* It is used to declare the type of the import.meta object
*/
declare namespace Env {
/** The router history mode */
type RouterHistoryMode = 'hash' | 'history' | 'memory'
/** Interface for import.meta */
// eslint-disable-next-line ts/no-shadow
interface ImportMeta extends ImportMetaEnv {
/** The base url of the application */
readonly VITE_BASE_URL: string
/** The title of the application */
readonly VITE_APP_TITLE: string
/** The description of the application */
readonly VITE_APP_DESC: string
/** The router history mode */
readonly VITE_ROUTER_HISTORY_MODE?: RouterHistoryMode
/** The prefix of the iconify icon */
readonly VITE_ICON_PREFIX: 'icon'
/**
* The prefix of the local icon
*
* This prefix is start with the icon prefix
*/
readonly VITE_ICON_LOCAL_PREFIX: 'icon-local'
/** backend service base url */
readonly VITE_SERVICE_BASE_URL: string
/**
* success code of backend service
*
* when the code is received, the request is successful
*/
readonly VITE_SERVICE_SUCCESS_CODE: string
/**
* logout codes of backend service
*
* when the code is received, the user will be logged out and redirected to login page
*
* use "," to separate multiple codes
*/
readonly VITE_SERVICE_LOGOUT_CODES: string
/**
* modal logout codes of backend service
*
* when the code is received, the user will be logged out by displaying a modal
*
* use "," to separate multiple codes
*/
readonly VITE_SERVICE_MODAL_LOGOUT_CODES: string
/**
* token expired codes of backend service
*
* when the code is received, it will refresh the token and resend the request
*
* use "," to separate multiple codes
*/
readonly VITE_SERVICE_EXPIRED_TOKEN_CODES: string
/** when the route mode is static, the defined super role */
readonly VITE_STATIC_SUPER_ROLE: string
/**
* other backend service base url
*
* the value is a json
*/
readonly VITE_OTHER_SERVICE_BASE_URL: string
/**
* Whether to enable the http proxy
*
* Only valid in the development environment
*/
readonly VITE_HTTP_PROXY?: CommonType.YesOrNo
/**
* The auth route mode
*
* - Static: the auth routes is generated in front-end
* - Dynamic: the auth routes is generated in back-end
*/
readonly VITE_AUTH_ROUTE_MODE: 'static' | 'dynamic'
/** Whether to enforce login */
readonly VITE_AUTH_ROUTE_FORCE_LOGIN?: CommonType.YesOrNo
/**
* The home route key
*
* It only has effect when the auth route mode is static, if the route mode is dynamic, the home route key is
* defined in the back-end
*/
readonly VITE_ROUTE_HOME: import('@elegant-router/types').LastLevelRouteKey
/**
* Default menu icon if menu icon is not set
*
* Iconify icon name
*/
readonly VITE_MENU_ICON: string
/** Whether to build with sourcemap */
readonly VITE_SOURCE_MAP?: CommonType.YesOrNo
/**
* Iconify api provider url
*
* If the project is deployed in intranet, you can set the api provider url to the local iconify server
*
* @link https://docs.iconify.design/api/providers.html
*/
readonly VITE_ICONIFY_URL?: string
/** Used to differentiate storage across different domains */
readonly VITE_STORAGE_PREFIX?: string
/** Whether to automatically detect updates after configuring application packaging */
readonly VITE_AUTOMATICALLY_DETECT_UPDATE?: CommonType.YesOrNo
/** show proxy url log in terminal */
readonly VITE_PROXY_LOG?: CommonType.YesOrNo
/** The launch editor */
readonly VITE_DEVTOOLS_LAUNCH_EDITOR?: import('vite-plugin-vue-devtools').VitePluginVueDevToolsOptions['launchEditor']
}
}
interface ImportMeta {
readonly env: Env.ImportMeta
}