支持配置后台页面入口

This commit is contained in:
yml2213
2026-06-11 08:00:13 +08:00
parent 7130135e23
commit 6d61a336d6
27 changed files with 157 additions and 85 deletions
+23
View File
@@ -0,0 +1,23 @@
const DEFAULT_ADMIN_BASE_PATH = '/admin'
function normalizeAdminBasePath(value: string | undefined) {
const raw = (value || DEFAULT_ADMIN_BASE_PATH).trim()
if (!raw || raw === '/') return DEFAULT_ADMIN_BASE_PATH
const withLeadingSlash = raw.startsWith('/') ? raw : `/${raw}`
return withLeadingSlash.replace(/\/+$/, '') || DEFAULT_ADMIN_BASE_PATH
}
export const ADMIN_BASE_PATH = normalizeAdminBasePath(import.meta.env.VITE_ADMIN_BASE_PATH)
export function adminPath(path = '') {
const suffix = path.trim().replace(/^\/+/, '')
if (!suffix) return ADMIN_BASE_PATH
return `${ADMIN_BASE_PATH}/${suffix}`
}
export const ADMIN_LOGIN_PATH = adminPath('login')
export const ADMIN_DASHBOARD_PATH = adminPath('dashboard')
export function isAdminPath(path: string) {
return path === ADMIN_BASE_PATH || path.startsWith(`${ADMIN_BASE_PATH}/`)
}