From 1f58dc3648063d1059ded20862225ecd843506e0 Mon Sep 17 00:00:00 2001 From: lion <120344285@qq.com> Date: Mon, 26 Jan 2026 13:39:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=A4=8D=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 4 +- src/views/activity/component/addActivity.vue | 59 ++++++++++++++++++- .../productService/components/addProduct.vue | 2 + 3 files changed, 60 insertions(+), 5 deletions(-) diff --git a/.env.development b/.env.development index 736c06d..40f6a01 100644 --- a/.env.development +++ b/.env.development @@ -2,7 +2,7 @@ ENV = 'development' # base api -VUE_APP_BASE_API = http://yunyubang-test.ali251.langye.net/ -#VUE_APP_BASE_API = https://yunyubang.ali251.langye.net/ +#VUE_APP_BASE_API = http://yunyubang-test.ali251.langye.net/ +VUE_APP_BASE_API = https://yunyubang.ali251.langye.net/ #VUE_APP_BASE_DEV_API = https://yunyubang.ali251.langye.net/ diff --git a/src/views/activity/component/addActivity.vue b/src/views/activity/component/addActivity.vue index fa5aef6..bf0f72c 100644 --- a/src/views/activity/component/addActivity.vue +++ b/src/views/activity/component/addActivity.vue @@ -461,7 +461,6 @@ import {index as indexType} from "@/api/activityType" import { Message } from 'element-ui' import { getparameter,listparameter } from "@/api/system/dictionary"; import xyTinymce from "@/components/XyTinymce/index.vue"; -import {replaceAll} from "@/utils/index" export default { components:{ @@ -893,7 +892,34 @@ export default { active_playbill:this.form.activePlaybill, illustration:this.form.illustration, sort:this.form.sort, - content: replaceAll(this.form.content,'../storage/files',`${process.env.VUE_APP_BASE_API}storage/files`) + content: (() => { + let content = this.form.content || '' + const baseUrl = `${process.env.VUE_APP_BASE_API}storage/files` + // 使用正则表达式,只替换不包含 http:// 或 https:// 的相对路径 + // 替换 ../storage/files(排除已经包含 http:// 或 https:// 的情况) + content = content.replace(/\.\.\/storage\/files/g, (match, offset) => { + // 检查前面是否有 http:// 或 https:// + const before = content.substring(Math.max(0, offset - 50), offset) + if (before.indexOf('http://') !== -1 || before.indexOf('https://') !== -1) { + return match + } + return baseUrl + }) + // 替换 /storage/files(排除已经包含 http:// 或 https:// 的情况,以及已经替换过的) + content = content.replace(/\/storage\/files/g, (match, offset) => { + // 检查前面是否有 http:// 或 https:// + const before = content.substring(Math.max(0, offset - 50), offset) + if (before.indexOf('http://') !== -1 || before.indexOf('https://') !== -1) { + return match + } + // 检查是否已经包含基础URL(避免重复替换) + if (before.indexOf(baseUrl) !== -1) { + return match + } + return baseUrl + }) + return content + })() }).then(res => { Message({ @@ -938,7 +964,34 @@ export default { active_playbill:this.form.activePlaybill, illustration:this.form.illustration, sort:this.form.sort, - content: replaceAll(this.form.content,'../storage/files',`${process.env.VUE_APP_BASE_API}storage/files`), + content: (() => { + let content = this.form.content || '' + const baseUrl = `${process.env.VUE_APP_BASE_API}storage/files` + // 使用正则表达式,只替换不包含 http:// 或 https:// 的相对路径 + // 替换 ../storage/files(排除已经包含 http:// 或 https:// 的情况) + content = content.replace(/\.\.\/storage\/files/g, (match, offset) => { + // 检查前面是否有 http:// 或 https:// + const before = content.substring(Math.max(0, offset - 50), offset) + if (before.indexOf('http://') !== -1 || before.indexOf('https://') !== -1) { + return match + } + return baseUrl + }) + // 替换 /storage/files(排除已经包含 http:// 或 https:// 的情况,以及已经替换过的) + content = content.replace(/\/storage\/files/g, (match, offset) => { + // 检查前面是否有 http:// 或 https:// + const before = content.substring(Math.max(0, offset - 50), offset) + if (before.indexOf('http://') !== -1 || before.indexOf('https://') !== -1) { + return match + } + // 检查是否已经包含基础URL(避免重复替换) + if (before.indexOf(baseUrl) !== -1) { + return match + } + return baseUrl + }) + return content + })(), // audit_status:1 }).then(res => { Message({ diff --git a/src/views/productService/components/addProduct.vue b/src/views/productService/components/addProduct.vue index aa5c092..5f6ce20 100644 --- a/src/views/productService/components/addProduct.vue +++ b/src/views/productService/components/addProduct.vue @@ -770,3 +770,5 @@ left: 4%; } + +