Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pet-business-web
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘怀志
pet-business-web
Commits
624aad7f
Commit
624aad7f
authored
Sep 06, 2023
by
刘怀志
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
67332 文章管理,富文本编辑器在登录失效情况上传图片问题
parent
abbed9b5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
6 deletions
+30
-6
index.vue
src/components/Editor/index.vue
+30
-6
No files found.
src/components/Editor/index.vue
View file @
624aad7f
...
@@ -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
(
'图片插入失败'
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment