Commit 624aad7f authored by 刘怀志's avatar 刘怀志

67332 文章管理,富文本编辑器在登录失效情况上传图片问题

parent abbed9b5
...@@ -22,6 +22,8 @@ import 'quill/dist/quill.core.css' ...@@ -22,6 +22,8 @@ import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css' import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css' import 'quill/dist/quill.bubble.css'
import { getToken } from '@/utils/auth' import { getToken } from '@/utils/auth'
import { MessageBox } from 'element-ui'
import store from '@/store'
export default { export default {
name: 'Editor', name: 'Editor',
...@@ -186,12 +188,34 @@ export default { ...@@ -186,12 +188,34 @@ export default {
const quill = this.Quill const quill = this.Quill
// 如果上传成功 // 如果上传成功
if (res) { if (res) {
// 获取光标所在位置 if (res.code === 401) {
const length = quill.getSelection().index if (!sessionStorage.getItem('isRelogin')) {
// 插入图片 res.url为服务器返回的图片地址 sessionStorage.setItem('isRelogin', 'true')
quill.insertEmbed(length, 'image', process.env.VUE_APP_TEST_API + res) MessageBox.confirm(
// 调整光标到最后 '登录状态已过期,您可以继续留在该页面,或者重新登录',
quill.setSelection(length + 1) '系统提示',
{
confirmButtonText: '重新登录',
cancelButtonText: '取消',
closeOnClickModal: false,
cancelButtonClass: 'resetBtn',
confirmButtonClass: 'queryBtn', type: 'warning' }).then(() => {
sessionStorage.setItem('isRelogin', '')
store.dispatch('LogOut').then(() => {
location.href = '/index'
})
}).catch(() => {
sessionStorage.setItem('isRelogin', '')
})
}
} else {
// 获取光标所在位置
const length = quill.getSelection().index
// 插入图片 res.url为服务器返回的图片地址
quill.insertEmbed(length, 'image', process.env.VUE_APP_TEST_API + res)
// 调整光标到最后
quill.setSelection(length + 1)
}
} else { } else {
this.$message.error('图片插入失败') this.$message.error('图片插入失败')
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment