ab4f40ba5d
- 克隆 art-design-pro v3.0.2(GitHub depth1),rm .git,pnpm clean:dev 精简演示页(92 文件) - .env.development/.env.production 均设 VITE_API_URL=/api,代理目标 127.0.0.1:8000(移除 Apifox Mock) - http 封装信封适配:code===200 解包 data;msg/message 字段兼容(拦截器/error/类型) - /api/admin/auth/token 登录适配(access->Bearer token, refresh->refreshToken);/api/admin/auth/me 映射 UserInfo(userName/roles/is_admin) - 登录页演示账号替换为真实 admin;logOut 按路由名判登录页修复 redirect 嵌套 - 根 .gitignore 补 !admin/.env(模板公共 env 非密钥,需入库) - 验证:Playwright 全链路(错误密码 401 留登页/正确登录进工作台/登出/受保护路由重定向/redirect 回跳)+ pnpm build(vue-tsc 通过,产物无 mock 域名) Co-Authored-By: Claude Code <noreply@anthropic.com>
79 lines
1.6 KiB
TypeScript
79 lines
1.6 KiB
TypeScript
/**
|
|
* Iframe 路由管理器
|
|
*
|
|
* 负责管理 iframe 类型的路由
|
|
*
|
|
* @module router/core/IframeRouteManager
|
|
* @author Art Design Pro Team
|
|
*/
|
|
|
|
import type { AppRouteRecord } from '@/types/router'
|
|
|
|
export class IframeRouteManager {
|
|
private static instance: IframeRouteManager
|
|
private iframeRoutes: AppRouteRecord[] = []
|
|
|
|
private constructor() {}
|
|
|
|
static getInstance(): IframeRouteManager {
|
|
if (!IframeRouteManager.instance) {
|
|
IframeRouteManager.instance = new IframeRouteManager()
|
|
}
|
|
return IframeRouteManager.instance
|
|
}
|
|
|
|
/**
|
|
* 添加 iframe 路由
|
|
*/
|
|
add(route: AppRouteRecord): void {
|
|
if (!this.iframeRoutes.find((r) => r.path === route.path)) {
|
|
this.iframeRoutes.push(route)
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取所有 iframe 路由
|
|
*/
|
|
getAll(): AppRouteRecord[] {
|
|
return this.iframeRoutes
|
|
}
|
|
|
|
/**
|
|
* 根据路径查找 iframe 路由
|
|
*/
|
|
findByPath(path: string): AppRouteRecord | undefined {
|
|
return this.iframeRoutes.find((route) => route.path === path)
|
|
}
|
|
|
|
/**
|
|
* 清空所有 iframe 路由
|
|
*/
|
|
clear(): void {
|
|
this.iframeRoutes = []
|
|
}
|
|
|
|
/**
|
|
* 保存到 sessionStorage
|
|
*/
|
|
save(): void {
|
|
if (this.iframeRoutes.length > 0) {
|
|
sessionStorage.setItem('iframeRoutes', JSON.stringify(this.iframeRoutes))
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 从 sessionStorage 加载
|
|
*/
|
|
load(): void {
|
|
try {
|
|
const data = sessionStorage.getItem('iframeRoutes')
|
|
if (data) {
|
|
this.iframeRoutes = JSON.parse(data)
|
|
}
|
|
} catch (error) {
|
|
console.error('[IframeRouteManager] 加载 iframe 路由失败:', error)
|
|
this.iframeRoutes = []
|
|
}
|
|
}
|
|
}
|