From c11a5bdbc5a6476109f551cd2e811553bbda8eba Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Wed, 13 Aug 2025 17:34:55 +0800 Subject: [PATCH] 122 --- src/components/business/ueditor.vue | 40 +++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/components/business/ueditor.vue b/src/components/business/ueditor.vue index 748e8ee..0758788 100644 --- a/src/components/business/ueditor.vue +++ b/src/components/business/ueditor.vue @@ -424,6 +424,8 @@ onMounted(() => { // 强制设置UEditor的全局路径配置 const currentUeditorBasePath = ueditorBasePath.value + console.log('=== UEditor路径配置开始 ===') + console.log('当前环境:', isProduction.value ? '线上' : '本地') console.log('设置UEditor全局路径:', currentUeditorBasePath) // 在UEditor加载前设置全局配置,避免路径问题 @@ -437,6 +439,25 @@ window.UEDITOR_CONFIG.UEDITOR_HOME_URL = currentUeditorBasePath; window.UEDITOR_CONFIG.UEDITOR_CORS_URL = currentUeditorBasePath; + // 添加路径保护,防止被覆盖 + Object.defineProperty(window, 'UEDITOR_HOME_URL', { + get: () => currentUeditorBasePath, + set: (value) => { + console.warn('尝试修改UEDITOR_HOME_URL:', value, ',强制保持为:', currentUeditorBasePath) + }, + configurable: false + }) + + Object.defineProperty(window, 'UEDITOR_CORS_URL', { + get: () => currentUeditorBasePath, + set: (value) => { + console.warn('尝试修改UEDITOR_CORS_URL:', value, ',强制保持为:', currentUeditorBasePath) + }, + configurable: false + }) + + console.log('=== UEditor路径配置完成 ===') + // 图片上传成功后的处理 - 关键配置 window.UEDITOR_CONFIG.onImageUploadSuccess = function(result) { console.log('=== 图片上传成功回调开始 ==='); @@ -528,10 +549,29 @@ // 延迟强制刷新编辑器配置 setTimeout(() => { + console.log('=== 延迟刷新UEditor配置开始 ===') + + // 检查并强制设置路径 + if (window.UEDITOR_HOME_URL !== currentUeditorBasePath) { + console.warn('检测到UEDITOR_HOME_URL被修改:', window.UEDITOR_HOME_URL, ',强制恢复为:', currentUeditorBasePath) + window.UEDITOR_HOME_URL = currentUeditorBasePath + } + + if (window.UEDITOR_CORS_URL !== currentUeditorBasePath) { + console.warn('检测到UEDITOR_CORS_URL被修改:', window.UEDITOR_CORS_URL, ',强制恢复为:', currentUeditorBasePath) + window.UEDITOR_CORS_URL = currentUeditorBasePath + } + if (window.UE && window.UEDITOR_CONFIG) { // 强制覆盖配置 Object.assign(window.UEDITOR_CONFIG, editorConfig); + // 再次确保路径正确 + window.UEDITOR_CONFIG.UEDITOR_HOME_URL = currentUeditorBasePath; + window.UEDITOR_CONFIG.UEDITOR_CORS_URL = currentUeditorBasePath; + + console.log('=== 延迟刷新UEditor配置完成 ===') + // 确保上传成功回调被正确设置 if (window.UEDITOR_CONFIG.onImageUploadSuccess) { console.log('UEditor图片上传成功回调已设置');