diff --git a/src/components/business/ueditor.vue b/src/components/business/ueditor.vue index 0e1485f..bb1a3c3 100644 --- a/src/components/business/ueditor.vue +++ b/src/components/business/ueditor.vue @@ -46,6 +46,18 @@ // 获取用户store实例 const userStore = useUserStore() + // 根据环境动态设置UEditor路径 + const isProduction = computed(() => { + return apiBase.includes('dev-casedata.igandan.com') || apiBase.includes('casedata.igandan.com') + }) + + const ueditorBasePath = computed(() => { + if (isProduction.value) { + return '/admin/web/UEditorPlus/' + } + return '/UEditorPlus/' + }) + const props = defineProps({ // 内容 modelValue: { @@ -86,8 +98,8 @@ const editorConfig = reactive({ // 基础路径配置 - 必须正确设置,避免路径拼接问题 - UEDITOR_HOME_URL: '/UEditorPlus/', - UEDITOR_CORS_URL: '/UEditorPlus/', + UEDITOR_HOME_URL: ueditorBasePath.value, + UEDITOR_CORS_URL: ueditorBasePath.value, // 不从服务器加载配置,使用本地配置 loadConfigFromServer: false, @@ -387,8 +399,8 @@ // 组件挂载后的处理 onMounted(() => { // 在UEditor加载前设置全局配置,避免路径问题 - window.UEDITOR_HOME_URL = '/UEditorPlus/'; - window.UEDITOR_CORS_URL = '/UEditorPlus/'; + window.UEDITOR_HOME_URL = ueditorBasePath.value; + window.UEDITOR_CORS_URL = ueditorBasePath.value; // 设置UEditor的全局上传成功回调 window.UEDITOR_CONFIG = window.UEDITOR_CONFIG || {};