diff --git a/src/router/backEnd.ts b/src/router/backEnd.ts index 19142e4ffa172bf996d4408f0ad32c67e079fc7f..6b5b9efab0b684d54fb5c982d83ccac761b7085a 100644 --- a/src/router/backEnd.ts +++ b/src/router/backEnd.ts @@ -116,6 +116,16 @@ export function getBackEndControlRoutes() { export async function setBackEndControlRefreshRoutes() { await getBackEndControlRoutes(); } +/** + * 将含有中文的字符串转换为 Base64 编码 + */ +const toBase64 = (str: string) => { + const uint8Array = new TextEncoder().encode(str); + const binaryString = Array.from(uint8Array) + .map((byte) => String.fromCharCode(byte)) + .join(''); + return btoa(binaryString); +}; /** * 后端路由 component 转换 @@ -125,6 +135,10 @@ export async function setBackEndControlRefreshRoutes() { export function backEndComponent(routes: any) { if (!routes) return; return routes.map((item: any) => { + // 合并 item.name 和 item.path + const combinedString = String(item.name) + String(item.path); + // 进行 Base64 编码并赋值 + item.name = toBase64(combinedString); if (item.path && item.path.startsWith('http')) { if (item.meta.isIframe) { item.component = () => import('/@/layout/routerView/iframes.vue');