From 137910cf4fc73a3a2787a3a02718f1e1f637c368 Mon Sep 17 00:00:00 2001
From: zhouwx <1175765986@qq.com>
Date: 星期五, 14 六月 2024 16:01:17 +0800
Subject: [PATCH] bug修改

---
 src/components/Tinymce/Tinymce.vue |   49 ++++++++++++++++++++++++++++++++++---------------
 1 files changed, 34 insertions(+), 15 deletions(-)

diff --git a/src/components/Tinymce/Tinymce.vue b/src/components/Tinymce/Tinymce.vue
index a4ab141..830a531 100644
--- a/src/components/Tinymce/Tinymce.vue
+++ b/src/components/Tinymce/Tinymce.vue
@@ -46,16 +46,18 @@
         },
         toolbar: {
             type: [String, Array],
-            default: "undo redo |  formatselect  | upfile image  bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | lists  insertfile  table | removeformat fullscreen  "
+            default: " styleselect fontsizeselect | undo redo |  upfile image  bold italic | fontselect |alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | lists  insertfile  table | removeformat fullscreen  "
         }
     },
     data() {
         return {
+            loading: false,
             // 初始化配置
             init: {
                 language_url: "/tinymce/langs/zh_CN.js",
                 language: "zh_CN",
                 skin_url: "/tinymce/skins/ui/oxide", // skin路径
+                content_css: '/tinymce/skins/content/default/content.css',
                 height: 500, // 编辑器高度
                 branding: false, // 是否禁用“Powered by TinyMCE”
                 menubar: true, // 顶部菜单栏显示
@@ -64,10 +66,6 @@
                 relative_urls: false,
                 remove_script_host: true,
                 statusbar: false,
-                // images_upload_handler: (blobInfo, success, failure) => {
-                //     console.log(blobInfo);
-                //     this.handleImgUpload(blobInfo, success, failure);
-                // },
                 images_upload_handler: async (blobInfo, success, failure) => {
                     const formData = new FormData(); // 和后端协商后用formData格式进行传参
                     formData.append("file", blobInfo.blob());// 传递的参数
@@ -75,7 +73,15 @@
                     let res = await upload(formData); // 调取 接口
                     console.log(res);
                     if (res.code == 200) {
-                        const path = import.meta.env.VITE_APP_BASE_API + '/' + res.data.path
+
+                        // const path = import.meta.env.VITE_APP_BASE_API + '/' + res.data.path
+                        let path = "";
+                        if(import.meta.env.VITE_APP_ENV == 'development') {
+                            path = import.meta.env.VITE_APP_BASE_API + '/' + res.data.path
+                        }else {
+                            path = 'http://106.15.95.149:8088/api/' + res.data.path
+                        }
+
                         success(path);
                     } else {
                         failure("上传失败");
@@ -85,18 +91,30 @@
                     const formData = new FormData(); // 和后端协商后用formData格式进行传参
                     formData.append("file", file);// 传递的参数
                     formData.append("Authorization", getToken());// token值
-                    let res = await upload(formData); // 调取 接口
-                    console.log(res);
-                    if (res.code == 200) {
-                        const path = import.meta.env.VITE_APP_BASE_API + '/' + res.data.path
-                        success(path);
-                    } else {
-                        failure("上传失败");
-                    }
+                    await upload(formData).then(res => {
+                        console.log(res);
+                        if (res.code == 200) {
+                          // const path = import.meta.env.VITE_APP_BASE_API + '/' + res.data.path
+                            let path = "";
+                            if(import.meta.env.VITE_APP_ENV == 'development') {
+                                path = import.meta.env.VITE_APP_BASE_API + '/' + res.data.path
+                            }else {
+                                path = 'http://106.15.95.149:8088/api/' + res.data.path
+                            }
+
+                            success(path,res.data);
+                        } else {
+                            console.log("上传失败");
+                        }
+                    }).catch(err => {
+                        success('失败');
+                              console.log('err',err)
+                    })
                 }
             },
             myValue: this.value,
-            // content_css: '/tinymce/skins/content/default/content.css',
+
+
 
         };
     },
@@ -112,6 +130,7 @@
         },
         // 可以添加一些自己的自定义事件,如清空内容
         clear() {
+
             this.myValue = "";
         },
     },

--
Gitblit v1.9.2