From c337d4b6bac9e6dd3b32bf925c62195dba292817 Mon Sep 17 00:00:00 2001 From: guanj Date: Mon, 21 Jul 2025 08:33:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=89=8D=E7=AB=AF=E5=8E=BB?= =?UTF-8?q?=E9=99=A4=E5=90=8E=E7=AB=AF=E6=A8=A1=E5=9D=97=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.removeMode | 5 +++ README.md | 8 +++++ package.json | 2 ++ src/utils/request.ts | 33 ++++++++++++++----- .../cleaning/components/abnormal.vue | 8 +---- 5 files changed, 41 insertions(+), 15 deletions(-) create mode 100644 .env.removeMode diff --git a/.env.removeMode b/.env.removeMode new file mode 100644 index 00000000..4bc0a025 --- /dev/null +++ b/.env.removeMode @@ -0,0 +1,5 @@ +NODE_ENV = removeMode +VITE_NAME="removeMode" +# 电网一张图 地图图层 +VITE_NARIMAP=null +VITE_NRGISCOMMON=null \ No newline at end of file diff --git a/README.md b/README.md index 0fe7fc3a..04bf15e6 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,14 @@ pnpm i #运行项目 npm run dev +#冀北现场启动命令 区分是否加载现场电网一张图内网api +npm run dev:jibei + +#去除后台所有模块名 如除/xxxx-boot +npm run dev:removeMode + + + #因海南和冀北技术监督不同 通过修改文件的方式来区分 #海南打包 需要吧pqs目录下supervise_hn 文件夹改成supervise 原文件改成supervise_jb #冀北打包 需要吧pqs目录下supervise_jb 文件夹改成supervise 原文件改成supervise_hn diff --git a/package.json b/package.json index a0646379..d8c8c3f2 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,10 @@ "scripts": { "dev": "vite --mode dev", "dev:jibei": "vite --mode jibei", + "dev:removeMode": "vite --mode removeMode", "build": "vite build --mode dev", "build:jibei": "vite build --mode jibei", + "build:removeMode": "vite build --mode removeMode", "preview": "vite preview" }, "dependencies": { diff --git a/src/utils/request.ts b/src/utils/request.ts index 95063ed0..936479d5 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -12,14 +12,30 @@ const loadingInstance: LoadingInstance = { target: null, count: 0 } - +const VITE_FLAG = import.meta.env.VITE_NAME == 'removeMode' +// console.log('🚀 ~ import.meta.env.VITE_NAME:', import.meta.env.VITE_NAME) /** * 根据运行环境获取基础请求URL */ export const getUrl = (): string => { return '/api' } - +function removeBeforeSecondSlash(str: string) { + // 找到第一个斜杠的位置 + const firstSlashIndex = str.indexOf('/') + if (firstSlashIndex === -1) { + // 如果没有斜杠,返回原字符串 + return str + } + // 从第一个斜杠之后开始找第二个斜杠 + const secondSlashIndex = str.indexOf('/', firstSlashIndex + 1) + if (secondSlashIndex === -1) { + // 如果只有一个斜杠,返回原字符串 + return str + } + // 返回第二个斜杠及之后的内容 + return str.substring(secondSlashIndex) +} /** * 创建`Axios` * 默认开启`reductDataFormat(简洁响应)`,返回类型为`ApiPromise` @@ -54,11 +70,12 @@ function createAxios>( // 请求拦截 Axios.interceptors.request.use( - config => { - // if(config.url?.substring(0, 13)=='/advance-boot'){ - // config.url=config.url?.slice(13) - // config.baseURL='/hzj' - // } + async (config: any) => { + //嵌入去除所有请求头 + if (VITE_FLAG) { + config.url = await removeBeforeSecondSlash(config.url) + } + // 取消重复请求 if ( @@ -148,7 +165,7 @@ function createAxios>( }) }) } - } else if (response.data.code == 'A0024'||response.data.code == 'null') { + } else if (response.data.code == 'A0024' || response.data.code == 'null') { // // 登录失效 ElNotification({ type: 'error', diff --git a/src/views/pqs/runManage/cleaning/components/abnormal.vue b/src/views/pqs/runManage/cleaning/components/abnormal.vue index d0017e17..0b3a8035 100644 --- a/src/views/pqs/runManage/cleaning/components/abnormal.vue +++ b/src/views/pqs/runManage/cleaning/components/abnormal.vue @@ -18,13 +18,7 @@ - +