diff --git a/src/components/business/ueditor.vue b/src/components/business/ueditor.vue index d1814e2..748e8ee 100644 --- a/src/components/business/ueditor.vue +++ b/src/components/business/ueditor.vue @@ -101,11 +101,11 @@ // UEditor依赖文件配置 const editorDependencies = computed(() => { if (isProduction.value) { - // 线上环境:使用完整路径 + // 线上环境:使用相对路径,让UEDITOR_HOME_URL处理基础路径 return [ - '/admin/web/UEditorPlus/ueditor.config.js', - '/admin/web/UEditorPlus/ueditor.all.js', - '/admin/web/UEditorPlus/lang/zh-cn/zh-cn.js' + 'ueditor.config.js', + 'ueditor.all.js', + 'lang/zh-cn/zh-cn.js' ] } // 本地环境:使用相对路径 @@ -118,8 +118,12 @@ const editorConfig = reactive({ // 基础路径配置 - 必须正确设置,避免路径拼接问题 - UEDITOR_HOME_URL: ueditorBasePath.value, - UEDITOR_CORS_URL: ueditorBasePath.value, + get UEDITOR_HOME_URL() { + return ueditorBasePath.value + }, + get UEDITOR_CORS_URL() { + return ueditorBasePath.value + }, // 不从服务器加载配置,使用本地配置 loadConfigFromServer: false, @@ -418,13 +422,21 @@ // 组件挂载后的处理 onMounted(() => { + // 强制设置UEditor的全局路径配置 + const currentUeditorBasePath = ueditorBasePath.value + console.log('设置UEditor全局路径:', currentUeditorBasePath) + // 在UEditor加载前设置全局配置,避免路径问题 - window.UEDITOR_HOME_URL = ueditorBasePath.value; - window.UEDITOR_CORS_URL = ueditorBasePath.value; + window.UEDITOR_HOME_URL = currentUeditorBasePath; + window.UEDITOR_CORS_URL = currentUeditorBasePath; // 设置UEditor的全局上传成功回调 window.UEDITOR_CONFIG = window.UEDITOR_CONFIG || {}; + // 强制覆盖全局配置中的路径 + window.UEDITOR_CONFIG.UEDITOR_HOME_URL = currentUeditorBasePath; + window.UEDITOR_CONFIG.UEDITOR_CORS_URL = currentUeditorBasePath; + // 图片上传成功后的处理 - 关键配置 window.UEDITOR_CONFIG.onImageUploadSuccess = function(result) { console.log('=== 图片上传成功回调开始 ===');