Просмотр исходного кода

隐藏富文本上传附件功能

Xiao_123 4 месяцев назад
Родитель
Сommit
0c6aacc8e0

+ 21 - 20
src/components/Editor/src/Editor.vue

@@ -7,7 +7,7 @@ import { isNumber } from '@/utils/is'
 import { ElMessage } from 'element-plus'
 import { useLocaleStore } from '@/store/modules/locale'
 import { getAccessToken, getTenantId } from '@/utils/auth'
-import { updateFile } from '@/api/infra/file/index.ts'
+// import { updateFile } from '@/api/infra/file/index.ts'
 
 defineOptions({ name: 'Editor' })
 
@@ -62,7 +62,8 @@ const handleCreated = (editor: IDomEditor) => {
 
 // 编辑器配置
 import { getExcludeKeys } from './util/toolbarConfig'
-const toolbarConfig = reactive({  insertKeys: {index: 0, keys: ['uploadAttachment']}, excludeKeys: getExcludeKeys() })
+// const toolbarConfig = reactive({  insertKeys: {index: 0, keys: ['uploadAttachment']}, excludeKeys: getExcludeKeys() })
+const toolbarConfig = reactive({  excludeKeys: getExcludeKeys() })
 
 // 编辑器配置
 const editorConfig = computed((): IEditorConfig => {
@@ -149,25 +150,25 @@ const editorConfig = computed((): IEditorConfig => {
           }
         },
         // 上传附件
-        uploadAttachment: {
-          allowedFileTypes: ['.doc', '.docx', '.xls', '.xlsx', '.ppt', '.pptx', '.pdf', '.txt'],
-          customUpload(file: File, insertFn: Function) {
-            let formData = new FormData()
-            formData.append("file", file)
-            const name = file.name.split('.')[0]
-            updateFile(formData).then(res => {
-              if (res.code === 0) {
-                insertFn(name, res.data)
-              }
-            })
-          }
-        }
-      },
-      hoverbarKeys: {
-        attachment: {
-          menuKeys: ['downloadAttachment']
-        }
+        // uploadAttachment: {
+        //   allowedFileTypes: ['.doc', '.docx', '.xls', '.xlsx', '.ppt', '.pptx', '.pdf', '.txt'],
+        //   customUpload(file: File, insertFn: Function) {
+        //     let formData = new FormData()
+        //     formData.append("file", file)
+        //     const name = file.name.split('.')[0]
+        //     updateFile(formData).then(res => {
+        //       if (res.code === 0) {
+        //         insertFn(name, res.data)
+        //       }
+        //     })
+        //   }
+        // }
       },
+      // hoverbarKeys: {
+      //   attachment: {
+      //     menuKeys: ['downloadAttachment']
+      //   }
+      // },
       uploadImgShowBase64: true
     },
     props.editorConfig || {}

+ 3 - 3
src/main.ts

@@ -42,9 +42,9 @@ import Logger from '@/utils/Logger'
 
 import VueDOMPurifyHTML from 'vue-dompurify-html' // 解决v-html 的安全隐患
 
-import { Boot } from '@wangeditor/editor'
-import attachmentModule from '@wangeditor/plugin-upload-attachment'
-Boot.registerModule(attachmentModule)
+// import { Boot } from '@wangeditor/editor'
+// import attachmentModule from '@wangeditor/plugin-upload-attachment'
+// Boot.registerModule(attachmentModule)
 
 // 创建实例
 const setupAll = async () => {

+ 5 - 3
src/views/mall/product/spu/components/SkuList.vue

@@ -165,7 +165,7 @@
     </el-table-column>
     <el-table-column v-if="productType !== '0'" align="center" label="文件" min-width="90">
       <template #default="{ row }">
-        <el-button v-if="row?.extend?.fileUrls?.length" type="primary" link @click.stop="handleUpload(row)">已上传</el-button>
+        <el-button v-if="row?.extend?.fileUrls?.length" type="primary" link>已上传</el-button>
         <div v-else>未上传</div>
       </template>
     </el-table-column>
@@ -377,12 +377,14 @@ const fileUrl = ref('')
 const itemData = ref({})
 const handleUpload = (row) => {
   itemData.value = row
-  if (row.extend.fileUrls?.length) fileUrl.value = row.extend.fileUrls[0]
+  if (row.extend?.fileUrls?.length) fileUrl.value = row.extend.fileUrls[0]
   dialogVisible.value = true
 }
 const handleUploadSubmit = () => {
   if (!fileUrl.value) return message.warning('请上传文件')
-  itemData.value.extend.fileUrls = [fileUrl.value]
+  itemData.value.extend = {
+    fileUrls: [fileUrl.value]
+  }
   dialogVisible.value = false
   fileUrl.value = ''
 }