From 4634a1369219cb5ba5bf35c4345c1e34bdba4290 Mon Sep 17 00:00:00 2001 From: WUSIJIAN <13825895+wsj0228@user.noreply.gitee.com> Date: Tue, 2 Dec 2025 16:21:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=8A=B6=E6=80=81=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/editor/index.vue | 99 +++++++++++++++++++-- src/utils/request.ts | 3 +- src/views/customerService/account/index.vue | 7 +- 3 files changed, 100 insertions(+), 9 deletions(-) diff --git a/src/components/editor/index.vue b/src/components/editor/index.vue index d9d0f32..bcfc822 100644 --- a/src/components/editor/index.vue +++ b/src/components/editor/index.vue @@ -1,7 +1,7 @@ @@ -32,6 +32,11 @@ export default defineComponent({ type: Boolean, default: () => false, }, + // 是否禁用除表情外的所有功能 + disableExceptEmotion: { + type: Boolean, + default: () => false, + }, // 内容框默认 placeholder placeholder: { type: String, @@ -70,6 +75,11 @@ export default defineComponent({ emit('update:modelValue', editor.getHtml()); }; + // 即使编辑器只读,也允许表情插入 + if (props.disableExceptEmotion) { + editorConfig.readOnly = false; // 允许编辑,但通过CSS禁用其他功能 + } + (editorConfig).MENU_CONF['uploadImage'] = { base64LimitSize: 10 * 1024 * 1024, }; @@ -94,7 +104,6 @@ export default defineComponent({ // 初始化富文本 const initWangeditor = () => { - // 先销毁旧的编辑器 destroyEditor(); nextTick(() => { @@ -115,6 +124,35 @@ export default defineComponent({ }); state.isInitialized = true; + + // 初始化后应用禁用状态 + applyDisableState(); + }); + }; + + // 应用禁用状态 + const applyDisableState = () => { + if (!state.editorToolbar || !props.disableExceptEmotion) return; + + nextTick(() => { + const toolbarItems = state.editorToolbar!.querySelectorAll('.w-e-bar-item'); + toolbarItems.forEach((item: Element) => { + const button = item.querySelector('button'); + if (button) { + const dataTitle = button.getAttribute('data-title') || ''; + const isEmotionButton = dataTitle.includes('表情') || dataTitle.toLowerCase().includes('emotion'); + + if (!isEmotionButton) { + (item as HTMLElement).style.opacity = '0.5'; + (item as HTMLElement).style.pointerEvents = 'none'; + (item as HTMLElement).style.cursor = 'not-allowed'; + } else { + (item as HTMLElement).style.opacity = '1'; + (item as HTMLElement).style.pointerEvents = 'auto'; + (item as HTMLElement).style.cursor = 'pointer'; + } + } + }); }); }; @@ -133,7 +171,6 @@ export default defineComponent({ () => props.modelValue, (value) => { if (state.editor && state.isInitialized) { - // 只有当内容确实改变时才更新 const currentHtml = state.editor.getHtml(); if (currentHtml !== value) { state.editor.setHtml(value || ''); @@ -152,9 +189,61 @@ export default defineComponent({ } ); + // 监听禁用除表情外的状态变化 + watch( + () => props.disableExceptEmotion, + (disabled) => { + if (state.editor && state.isInitialized) { + applyDisableState(); + } + } + ); + return { ...toRefs(state), }; }, }); + + diff --git a/src/utils/request.ts b/src/utils/request.ts index fc3b8de..b41a6f2 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -18,7 +18,8 @@ const service: AxiosInstance = axios.create({ // 配置新建第二个 axios 实例(新功能服务) const newService: AxiosInstance = axios.create({ - baseURL: 'http://192.168.3.95:8000/', // 新后端地址 + // baseURL: 'http://192.168.3.95:8000/', // 新后端地址 + baseURL: 'http://192.168.3.49:8000/', // 后端地址 timeout: 50000, // 50秒超时 headers: { 'Content-Type': 'application/json' }, // 默认JSON格式 paramsSerializer: { diff --git a/src/views/customerService/account/index.vue b/src/views/customerService/account/index.vue index 2905f27..a7714c9 100644 --- a/src/views/customerService/account/index.vue +++ b/src/views/customerService/account/index.vue @@ -33,12 +33,12 @@ 新增客服 - + @@ -195,6 +195,7 @@ const handleSearch = () => { */ const handleReset = () => { // 重新获取数据 + tableData.param = { ...initialParam }; getList(); }; @@ -257,7 +258,7 @@ const handleStatusChange = async (row: TableDataItem) => { await updatestate({ id: row.id, - status: newStatus, // 接口可能需要status字段 + isDisabled: newStatus, // 接口可能需要status字段 }); ElMessage.success(`客服账号已${newStatus == 0 ? '禁用' : '启用'}`);