From a492eb0a7dfcfd545613f70ada9e91fe018a3bc5 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:48:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=B7=E6=B1=82=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/common.ts | 17 +++++++++++++---- src/api/upload.ts | 20 ++++++++++---------- src/utils/api-request.ts | 7 +++---- src/utils/common.ts | 1 - src/utils/request.ts | 7 +++---- 5 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/api/common.ts b/src/api/common.ts index a0ea1d8d..ea43a9fc 100644 --- a/src/api/common.ts +++ b/src/api/common.ts @@ -1,13 +1,22 @@ +import { get_type } from '@/utils/common'; import request from '@/utils/request'; import { isEmpty } from 'lodash'; class CommonAPI { /** 链接初始化接口 */ static getInit() { - return request({ - url: `diyapi/init`, - method: 'post', - }); + if (get_type() == 'shop') { + return request({ + url: `?s=plugins/index/pluginsname/shop/pluginscontrol/diyapi/pluginsaction/init.html`, + method: 'post', + }); + } else { + return request({ + url: `diyapi/init`, + method: 'post', + }); + } + } /** 动态接口 */ static getDynamicApi(url: string, data: any, is_header: boolean = false) { diff --git a/src/api/upload.ts b/src/api/upload.ts index 7f9b7a44..fa900e97 100644 --- a/src/api/upload.ts +++ b/src/api/upload.ts @@ -4,14 +4,14 @@ class UploadAPI { /** 分类查询接口*/ static getTree() { return api_request({ - url: `?s=attachmentapi/attachmentcategory`, + url: `?s=attachmentapi/category`, method: 'post', }); } /** 分类新增,修改接口 */ static saveTree(data: any) { return api_request({ - url: `?s=attachmentapi/attachmentcategorysave`, + url: `?s=attachmentapi/categorysave`, method: 'post', data, }); @@ -19,7 +19,7 @@ class UploadAPI { /** 分类删除接口 */ static delTree(data: any) { return api_request({ - url: `?s=attachmentapi/attachmentcategorydelete`, + url: `?s=attachmentapi/categorydelete`, method: 'post', data, }); @@ -27,7 +27,7 @@ class UploadAPI { /** 附件移动分类 */ static moveTree(data: any) { return api_request({ - url: `?s=attachmentapi/attachmentmovecategory`, + url: `?s=attachmentapi/movecategory`, method: 'post', data, }); @@ -36,7 +36,7 @@ class UploadAPI { // 附件列表 static getAttachmentList(data: any) { return api_request({ - url: `?s=attachmentapi/attachmentlist`, + url: `?s=attachmentapi/list`, method: 'post', data, }); @@ -44,7 +44,7 @@ class UploadAPI { // 附件名称修改 static saveAttachmentName(data: any) { return api_request({ - url: `?s=attachmentapi/attachmentsave`, + url: `?s=attachmentapi/save`, method: 'post', data, }); @@ -52,7 +52,7 @@ class UploadAPI { // 附件删除 static delAttachment(data: any) { return api_request({ - url: `?s=attachmentapi/attachmentdelete`, + url: `?s=attachmentapi/delete`, method: 'post', data, }); @@ -60,7 +60,7 @@ class UploadAPI { // 附件上传 static uploadAttachment(data: any, progress: any) { return api_request({ - url: `?s=attachmentapi/attachmentupload`, + url: `?s=attachmentapi/upload`, method: 'post', data, headers: { @@ -72,7 +72,7 @@ class UploadAPI { // 扫码上传 static uploadQrcode(data: any) { return api_request({ - url: `?s=attachmentapi/attachmentscanuploaddata`, + url: `?s=attachmentapi/scanuploaddata`, method: 'post', data, }); @@ -80,7 +80,7 @@ class UploadAPI { // 提取链接 --------附件远程下载 static getAttachmentCatch(data: any) { return api_request({ - url: `?s=attachmentapi/attachmentcatch`, + url: `?s=attachmentapi/catch`, method: 'post', data, }); diff --git a/src/utils/api-request.ts b/src/utils/api-request.ts index 59767642..c5a950e5 100644 --- a/src/utils/api-request.ts +++ b/src/utils/api-request.ts @@ -39,17 +39,16 @@ 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 = new_url?.includes('?') ? '&' : '?'; + const symbol = config.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 = new_url + symbol + 'token=' + temp_data.default.temp_token; + config.url = config.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 = new_url + '&token=' + (JSON.parse(cookie) !== 'null' ? JSON.parse(cookie)?.token : ''); + config.url = config.url + '&token=' + (JSON.parse(cookie) !== 'null' ? JSON.parse(cookie)?.token : ''); } } // 判断是否是包含不需要认证的接口 diff --git a/src/utils/common.ts b/src/utils/common.ts index dd98671f..aaeccb8f 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -49,7 +49,6 @@ export const get_type = () => { if (url.indexOf('type/') != -1) { new_type = url.substring(url.indexOf('type/') + 5); // 去除字符串的.html - // 去除字符串的.html const dot_data = new_type.split('.')[0]; if (dot_data != '') { new_type = dot_data.split('/')[0]; diff --git a/src/utils/request.ts b/src/utils/request.ts index 2f5eadb2..badda36a 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -35,16 +35,15 @@ 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; - const symbol = new_url ?.includes('?') ? '&' : '?'; + const symbol = config.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 = new_url + symbol + 'token=' + temp_data.default.temp_token; + config.url = config.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 = new_url + '&token=' + (JSON.parse(cookie) !== 'null' ? JSON.parse(cookie)?.token : ''); + config.url = config.url + '&token=' + (JSON.parse(cookie) !== 'null' ? JSON.parse(cookie)?.token : ''); } } // 判断是否是包含不需要认证的接口