zhouwenxuan
2023-12-15 07ca2d96c6f38a2a38f958d1771b6b9848f0ce0d
src/components/Tinymce/Tinymce.vue
@@ -51,6 +51,7 @@
    },
    data() {
        return {
            loading: false,
            // 初始化配置
            init: {
                language_url: "/tinymce/langs/zh_CN.js",
@@ -72,7 +73,14 @@
                    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 = '/api/' + res.data.path
                        }
                        success(path);
                    } else {
                        failure("上传失败");
@@ -82,19 +90,32 @@
                    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) {
                            let path = "";
                            if(import.meta.env.VITE_APP_ENV == 'development') {
                                path = import.meta.env.VITE_APP_BASE_API + '/' + res.data.path
                            }else {
                                path = '/api/' + res.data.path
                            }
                            // const path = import.meta.env.VITE_APP_BASE_API + '/' + res.data.path
                            // const path = '/api/' + res.data.path
                            success(path,res.data);
                        } else {
                            console.log("上传失败");
                        }
                    }).catch(err => {
                        success('失败');
                              console.log('err',err)
                    })
                }
            },
            myValue: this.value,
        };
    },
    mounted() {