From b5e7d41a0f50b65d3869fe484efedd3adee31233 Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Thu, 18 Jul 2024 11:37:28 +0800 Subject: [PATCH] fix --- public/styles/css/editor.css | 2 +- src/components/editor.js | 16 +++++++++++ src/components/modules/module.vue | 13 +++++++++ src/pages/article/add/editor.js | 45 ++++++++++++++++++++++++++----- src/pages/seo/index.vue | 18 ++++++++++++- src/setting.js | 2 +- src/styles/common.scss | 3 +++ 7 files changed, 90 insertions(+), 9 deletions(-) diff --git a/public/styles/css/editor.css b/public/styles/css/editor.css index 9d3366a..400cff8 100644 --- a/public/styles/css/editor.css +++ b/public/styles/css/editor.css @@ -131,4 +131,4 @@ margin-right: 8px; background: #1583ff; border-radius: 4px; -} +} \ No newline at end of file diff --git a/src/components/editor.js b/src/components/editor.js index 32097fe..19e06d7 100644 --- a/src/components/editor.js +++ b/src/components/editor.js @@ -2,6 +2,7 @@ import Axios from 'axios' import Api from '@/api' import Setting from '@/setting' import Util from '@/libs/util' +import store from '@/store' export default { //skin:'oxide-dark', language: 'zh_CN', @@ -318,6 +319,7 @@ export default { // 自定义上传 images_upload_handler: function (blobInfo, succFun, failFun) { const form = new FormData() + console.log(11, form) form.append('file', blobInfo.blob()), Axios({ method: 'post', @@ -328,6 +330,13 @@ export default { token: Util.local.get(Setting.tokenKey) }, }).then(({ data }) => { + if (data.code === 401) { + Util.errorMsg(data.msg) + setTimeout(() => { + store.dispatch('user/logout') + }, 1000) + return false + } succFun(data.url) }).catch(res => { }) }, @@ -358,6 +367,13 @@ export default { token: Util.local.get(Setting.tokenKey) }, }).then(({ data }) => { + if (data.code === 401) { + Util.errorMsg(data.msg) + setTimeout(() => { + store.dispatch('user/logout') + }, 1000) + return false + } callback(data.url) }).catch(res => { }) } diff --git a/src/components/modules/module.vue b/src/components/modules/module.vue index 1566d39..1ddde13 100644 --- a/src/components/modules/module.vue +++ b/src/components/modules/module.vue @@ -89,6 +89,14 @@ :headers="headers" :action="api.upload"> 上传资源 +
+ + +
+
@@ -560,4 +568,9 @@ export default { margin-left: -40px; } } + +.preview-media { + max-width: 100px; + margin-left: 20px; +} \ No newline at end of file diff --git a/src/pages/article/add/editor.js b/src/pages/article/add/editor.js index 36e6fd1..00c1ded 100644 --- a/src/pages/article/add/editor.js +++ b/src/pages/article/add/editor.js @@ -2,6 +2,8 @@ import Axios from 'axios' import Api from '@/api' import Setting from '@/setting' import Util from '@/libs/util' +import store from '@/store' +import { Loading } from 'element-ui' export default { //skin:'oxide-dark', language: 'zh_CN', @@ -409,6 +411,13 @@ export default { token: Util.local.get(Setting.tokenKey) }, }).then(({ data }) => { + if (data.code === 401) { + Util.errorMsg(data.msg) + setTimeout(() => { + store.dispatch('user/logout') + }, 1000) + return false + } succFun(data.url) }).catch(res => { }) }, @@ -424,12 +433,26 @@ export default { if (meta.filetype === 'media') { // 动态创建上传input,并进行模拟点击上传操作,达到本地上传视频效果。 let input = document.createElement('input');//创建一个隐藏的input - input.setAttribute('type', 'file'); - input.setAttribute("accept", ".mp4"); + input.setAttribute('type', 'file') + input.setAttribute("accept", ".mp4") input.onchange = function () { - let file = this.files[0]; - let fd = new FormData(); - fd.append("file", file); + let file = this.files[0] + let fd = new FormData() + fd.append("file", file) + // const el = document.createElement('div') + // el.className = 'tinymce-loadel' + // el.style.position = 'absolute' + // el.style.width = '100%' + // el.style.height = '100%' + // document.querySelector('.tox-dialog').appendChild(el) + const load = Loading.service({ + lock: true, + text: '正在上传', + spinner: 'el-icon-loading', + background: 'rgba(0, 0, 0, 0.7)', + zIndex: 30000, + customClass: 'tinymce-load' + }) Axios({ method: 'post', url: Api.upload, @@ -439,8 +462,18 @@ export default { token: Util.local.get(Setting.tokenKey) }, }).then(({ data }) => { + if (data.code === 401) { + Util.errorMsg(data.msg) + setTimeout(() => { + store.dispatch('user/logout') + }, 1000) + return false + } + load.close() callback(data.url) - }).catch(res => { }) + }).catch(res => { + load.close() + }) } //触发点击 input.click(); diff --git a/src/pages/seo/index.vue b/src/pages/seo/index.vue index 31fdec2..4adc44d 100644 --- a/src/pages/seo/index.vue +++ b/src/pages/seo/index.vue @@ -1,6 +1,9 @@