From b4ae05fef2a5ce458b2a614e15b765a5b7046794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=A9?= <19910352037@163.com> Date: Tue, 10 Sep 2024 17:39:49 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E8=B7=AF=E7=94=B1):=20=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E9=87=8D=E5=A4=8D=E5=AF=BC=E8=87=B4404?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/backEnd.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/router/backEnd.ts b/src/router/backEnd.ts index 19142e4f..6b5b9efa 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'); -- Gitee