From e181f04c642204e79749af93fa921875ff6c21ba Mon Sep 17 00:00:00 2001 From: baoshiwei <baoshiwei@shlanbao.cn> Date: 星期二, 20 五月 2025 10:46:35 +0800 Subject: [PATCH] refactor(qms): 重构趋势图展示逻辑 --- src/components/Editor/index.vue | 45 +++++++++++++++++++++++++++++---------------- 1 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/components/Editor/index.vue b/src/components/Editor/index.vue index d2467f1..ba70fbb 100644 --- a/src/components/Editor/index.vue +++ b/src/components/Editor/index.vue @@ -2,7 +2,6 @@ <div> <el-upload v-if="type === 'url'" - ref="uploadRef" :action="upload.url" :before-upload="handleBeforeUpload" :on-success="handleUploadSuccess" @@ -12,6 +11,7 @@ :show-file-list="false" :headers="upload.headers" > + <i ref="uploadRef"></i> </el-upload> </div> <div class="editor"> @@ -57,6 +57,7 @@ url: import.meta.env.VITE_APP_BASE_API + '/resource/oss/upload' }); const quillEditorRef = ref(); +const uploadRef = ref<HTMLDivElement>(); const options = ref<any>({ theme: 'snow', @@ -64,18 +65,30 @@ debug: 'warn', modules: { // 宸ュ叿鏍忛厤缃� - toolbar: [ - ['bold', 'italic', 'underline', 'strike'], // 鍔犵矖 鏂滀綋 涓嬪垝绾� 鍒犻櫎绾� - ['blockquote', 'code-block'], // 寮曠敤 浠g爜鍧� - [{ list: 'ordered' }, { list: 'bullet' }], // 鏈夊簭銆佹棤搴忓垪琛� - [{ indent: '-1' }, { indent: '+1' }], // 缂╄繘 - [{ size: ['small', false, 'large', 'huge'] }], // 瀛椾綋澶у皬 - [{ header: [1, 2, 3, 4, 5, 6, false] }], // 鏍囬 - [{ color: [] }, { background: [] }], // 瀛椾綋棰滆壊銆佸瓧浣撹儗鏅鑹� - [{ align: [] }], // 瀵归綈鏂瑰紡 - ['clean'], // 娓呴櫎鏂囨湰鏍煎紡 - ['link', 'image', 'video'] // 閾炬帴銆佸浘鐗囥�佽棰� - ] + toolbar: { + container: [ + ['bold', 'italic', 'underline', 'strike'], // 鍔犵矖 鏂滀綋 涓嬪垝绾� 鍒犻櫎绾� + ['blockquote', 'code-block'], // 寮曠敤 浠g爜鍧� + [{ list: 'ordered' }, { list: 'bullet' }], // 鏈夊簭銆佹棤搴忓垪琛� + [{ indent: '-1' }, { indent: '+1' }], // 缂╄繘 + [{ size: ['small', false, 'large', 'huge'] }], // 瀛椾綋澶у皬 + [{ header: [1, 2, 3, 4, 5, 6, false] }], // 鏍囬 + [{ color: [] }, { background: [] }], // 瀛椾綋棰滆壊銆佸瓧浣撹儗鏅鑹� + [{ align: [] }], // 瀵归綈鏂瑰紡 + ['clean'], // 娓呴櫎鏂囨湰鏍煎紡 + ['link', 'image', 'video'] // 閾炬帴銆佸浘鐗囥�佽棰� + ], + handlers: { + image: (value: boolean) => { + if (value) { + // 璋冪敤element鍥剧墖涓婁紶 + uploadRef.value.click(); + } else { + Quill.format('image', true); + } + } + } + } }, placeholder: '璇疯緭鍏ュ唴瀹�', readOnly: props.readOnly @@ -95,9 +108,9 @@ const content = ref(''); watch( () => props.modelValue, - (v) => { + (v: string) => { if (v !== content.value) { - content.value = v === undefined ? '<p></p>' : v; + content.value = v || '<p></p>'; } }, { immediate: true } @@ -117,7 +130,7 @@ quill.setSelection(length + 1); proxy?.$modal.closeLoading(); } else { - proxy?.$modal.msgError("鍥剧墖鎻掑叆澶辫触"); + proxy?.$modal.msgError('鍥剧墖鎻掑叆澶辫触'); proxy?.$modal.closeLoading(); } }; -- Gitblit v1.9.3