From 43b9e151cd926ac2ae8a9b5dd11c2c6fa457ed92 Mon Sep 17 00:00:00 2001 From: XiaoFans <57002549+6get-xiaofan@users.noreply.github.com> Date: Tue, 20 Feb 2024 17:47:49 +0800 Subject: [PATCH 1/5] Rollback dispute code --- .gitignore | 3 ++- src/config/index.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 91361d9..00d60e9 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,5 @@ tests/**/coverage/ *.ntvs* *.njsproj *.sln -tsconfig.tsbuildinfo \ No newline at end of file +tsconfig.tsbuildinfo +.vscode/settings.json diff --git a/src/config/index.ts b/src/config/index.ts index 1395088..4cd3016 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -31,7 +31,7 @@ export const getServerConfig = async (app: App): Promise => { app.config.globalProperties.$config = getConfig(); return axios({ method: "get", - url: `${window.location.origin}/serverConfig.json` + url: `${VITE_PUBLIC_PATH}serverConfig.json` }) .then(({ data: config }) => { let $config = app.config.globalProperties.$config; From ec5e7ebf795ce7637abcb6901ad6f79511675224 Mon Sep 17 00:00:00 2001 From: XiaoFans <57002549+6get-xiaofan@users.noreply.github.com> Date: Wed, 21 Feb 2024 21:51:50 +0800 Subject: [PATCH 2/5] Fix: serverConfig.json fetching behavior across nested routes --- .gitignore | 1 - .vscode/settings.json | 2 +- src/config/index.ts | 4 ++-- src/utils/rootConver.ts | 22 ++++++++++++++++++++++ 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 src/utils/rootConver.ts diff --git a/.gitignore b/.gitignore index 00d60e9..c97a6db 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,3 @@ tests/**/coverage/ *.njsproj *.sln tsconfig.tsbuildinfo -.vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json index 9b434de..3bb4678 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -25,7 +25,7 @@ "editor.defaultFormatter": "esbenp.prettier-vscode" }, "editor.codeActionsOnSave": { - "source.fixAll.eslint": true + "source.fixAll.eslint": "explicit" }, "iconify.excludes": ["el"], "cSpell.words": ["iconify", "Qrcode"] diff --git a/src/config/index.ts b/src/config/index.ts index 4cd3016..d5402ae 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -1,8 +1,8 @@ import { App } from "vue"; import axios from "axios"; +import { configConver } from "@/utils/rootConver"; let config: object = {}; -const { VITE_PUBLIC_PATH } = import.meta.env; const setConfig = (cfg?: unknown) => { config = Object.assign(config, cfg); @@ -31,7 +31,7 @@ export const getServerConfig = async (app: App): Promise => { app.config.globalProperties.$config = getConfig(); return axios({ method: "get", - url: `${VITE_PUBLIC_PATH}serverConfig.json` + url: `${configConver()}serverConfig.json` }) .then(({ data: config }) => { let $config = app.config.globalProperties.$config; diff --git a/src/utils/rootConver.ts b/src/utils/rootConver.ts new file mode 100644 index 0000000..54dc9cc --- /dev/null +++ b/src/utils/rootConver.ts @@ -0,0 +1,22 @@ +const { VITE_PUBLIC_PATH } = import.meta.env; + +export const configConver = () => { + if (VITE_PUBLIC_PATH === "./") { + return window.location.origin + "/"; + } + return window.location.origin + processPath(VITE_PUBLIC_PATH); +}; + +function processPath(str: string): string { + if (str.startsWith("./")) { + str = str.substring(1); + } else if (!str.startsWith("/")) { + str = "/" + str; + } + + if (!str.endsWith("/")) { + str += "/"; + } + + return str; +} From 1a8322a5d3adc896d9a9d9657be3c9eee55cf622 Mon Sep 17 00:00:00 2001 From: XiaoFans <57002549+6get-xiaofan@users.noreply.github.com> Date: Wed, 21 Feb 2024 21:53:29 +0800 Subject: [PATCH 3/5] Normative --- .gitignore | 2 +- .vscode/settings.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index c97a6db..91361d9 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,4 @@ tests/**/coverage/ *.ntvs* *.njsproj *.sln -tsconfig.tsbuildinfo +tsconfig.tsbuildinfo \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 3bb4678..a0d6152 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -25,7 +25,7 @@ "editor.defaultFormatter": "esbenp.prettier-vscode" }, "editor.codeActionsOnSave": { - "source.fixAll.eslint": "explicit" + "source.fixAll.eslint": "true" }, "iconify.excludes": ["el"], "cSpell.words": ["iconify", "Qrcode"] From d370a0e6b5a5f7f06d518009ff472507e99b1768 Mon Sep 17 00:00:00 2001 From: XiaoFans <57002549+6get-xiaofan@users.noreply.github.com> Date: Wed, 21 Feb 2024 21:53:57 +0800 Subject: [PATCH 4/5] Normative --- .vscode/settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index a0d6152..9b434de 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -25,7 +25,7 @@ "editor.defaultFormatter": "esbenp.prettier-vscode" }, "editor.codeActionsOnSave": { - "source.fixAll.eslint": "true" + "source.fixAll.eslint": true }, "iconify.excludes": ["el"], "cSpell.words": ["iconify", "Qrcode"] From 59c9c3e26742c13f122757759695bbc903455ba6 Mon Sep 17 00:00:00 2001 From: XiaoFans <57002549+6get-xiaofan@users.noreply.github.com> Date: Wed, 21 Feb 2024 21:58:31 +0800 Subject: [PATCH 5/5] Fix: Ensure route.children existence before accessing in initRouter() --- src/config/index.ts | 1 + src/router/index.ts | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/config/index.ts b/src/config/index.ts index ce6e994..d5402ae 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -30,6 +30,7 @@ const getConfig = (key?: string): ServerConfigs => { export const getServerConfig = async (app: App): Promise => { app.config.globalProperties.$config = getConfig(); return axios({ + method: "get", url: `${configConver()}serverConfig.json` }) .then(({ data: config }) => { diff --git a/src/router/index.ts b/src/router/index.ts index 8565cd2..9df7082 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -158,7 +158,12 @@ router.beforeEach((to: ToRouteType, _from, next) => { getTopMenu(true); // query、params模式路由传参数的标签页不在此处处理 if (route && route.meta?.title) { - if (isAllEmpty(route.parentId) && route.meta?.backstage) { + if ( + isAllEmpty(route.parentId) && + route.meta?.backstage && + route.children && + route.children.length > 0 + ) { // 此处为动态顶级路由(目录) const { path, name, meta } = route.children[0]; useMultiTagsStoreHook().handleTags("push", {