From 46d65c4ca59ffb1e7e8f7d2cf7c15c8e0630c4a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E8=82=96=E7=A3=8A?= <18851179580@163.com> Date: Fri, 8 Aug 2025 18:23:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/api-request.ts | 7 ++++--- src/utils/request.ts | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/utils/api-request.ts b/src/utils/api-request.ts index c5a950e5..59767642 100644 --- a/src/utils/api-request.ts +++ b/src/utils/api-request.ts @@ -39,16 +39,17 @@ const service = axios.create({ // 请求拦截器 service.interceptors.request.use( async (config: InternalAxiosRequestConfig) => { + const new_url = get_type() == 'shop' && config.url?.includes('diyapi/init') ? '?s=plugins/index/pluginsname/shop/pluginscontrol/diyapi/pluginsaction/init.html' : config.url; // 如果是本地则使用静态tonken如果是线上则使用cookie的token - const symbol = config.url?.includes('?') ? '&' : '?'; + const symbol = new_url?.includes('?') ? '&' : '?'; if (import.meta.env.VITE_APP_BASE_API_PHP == '/dev-api') { let temp_data = await import(import.meta.env.VITE_APP_BASE_API_PHP == '/dev-api' ? '../../temp.d' : '../../temp_pro.d'); - config.url = config.url + symbol + 'token=' + temp_data.default.temp_token; + config.url = new_url + symbol + 'token=' + temp_data.default.temp_token; } else { // 如果是shop认为是多商户插件使用user_info的cookie const cookie = get_type() == 'shop' ? get_cookie('user_info') : get_cookie('admin_info'); if (cookie && cookie !== null && cookie !== 'null') { - config.url = config.url + '&token=' + (JSON.parse(cookie) !== 'null' ? JSON.parse(cookie)?.token : ''); + config.url = new_url + '&token=' + (JSON.parse(cookie) !== 'null' ? JSON.parse(cookie)?.token : ''); } } // 判断是否是包含不需要认证的接口 diff --git a/src/utils/request.ts b/src/utils/request.ts index badda36a..2f5eadb2 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -35,15 +35,16 @@ const service = axios.create({ // 请求拦截器 service.interceptors.request.use( async (config: InternalAxiosRequestConfig) => { - const symbol = config.url?.includes('?') ? '&' : '?'; + const new_url = get_type() == 'shop' && config.url?.includes('diyapi/init') ? '?s=plugins/index/pluginsname/shop/pluginscontrol/diyapi/pluginsaction/init.html' : config.url; + const symbol = new_url ?.includes('?') ? '&' : '?'; if (import.meta.env.VITE_APP_BASE_API == '/dev-admin') { let temp_data = await import(import.meta.env.VITE_APP_BASE_API == '/dev-admin' ? '../../temp.d' : '../../temp_pro.d'); - config.url = config.url + symbol + 'token=' + temp_data.default.temp_token; + config.url = new_url + symbol + 'token=' + temp_data.default.temp_token; } else { // 如果是shop认为是多商户插件使用user_info的cookie const cookie = get_type() == 'shop' ? get_cookie('user_info') : get_cookie('admin_info'); if (cookie && cookie !== null && cookie !== 'null') { - config.url = config.url + '&token=' + (JSON.parse(cookie) !== 'null' ? JSON.parse(cookie)?.token : ''); + config.url = new_url + '&token=' + (JSON.parse(cookie) !== 'null' ? JSON.parse(cookie)?.token : ''); } } // 判断是否是包含不需要认证的接口