Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
Y
yishuju-ui
Project
Project
Details
Activity
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
何远江
yishuju-ui
Commits
e681d845
Commit
e681d845
authored
Mar 28, 2025
by
沈翠玲
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
登录问题处理
parent
dfa18029
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
7 deletions
+20
-7
user.js
src/stores/modules/user.js
+8
-0
websocket.js
src/stores/modules/websocket.js
+3
-1
index.js
src/utils/http/index.js
+5
-4
index.vue
src/views/login/index.vue
+4
-2
No files found.
src/stores/modules/user.js
View file @
e681d845
...
...
@@ -46,6 +46,14 @@ export const useUserStore = defineStore({
this
.
isTenant
=
false
;
this
.
tenant
=
null
;
},
async
logoutPass
()
{
const
socketStore
=
useSocketStore
();
socketStore
.
closeWs
();
this
.
token
=
''
;
this
.
userInfo
=
null
;
this
.
isTenant
=
false
;
this
.
tenant
=
null
;
},
},
persist
:
piniaPersistConfig
(
'admin-user'
),
});
src/stores/modules/websocket.js
View file @
e681d845
...
...
@@ -136,7 +136,9 @@ const useSocketStore = defineStore('socket', {
this
.
handClose
=
true
;
this
.
clearTimer
();
console
.
log
(
'ws'
,
this
.
ws
);
this
.
ws
.
close
();
if
(
this
.
ws
&&
this
.
ws
.
close
)
{
this
.
ws
.
close
();
}
},
},
});
...
...
src/utils/http/index.js
View file @
e681d845
...
...
@@ -78,8 +78,9 @@ class RequestClient {
axiosCanceler
.
removePending
(
config
);
const
userStore
=
useUserStore
();
if
(
data
.
code
===
500
&&
data
.
message
.
includes
(
'token'
))
{
userStore
.
setToken
(
''
);
router
.
replace
(
LOGIN_URL
);
// if (data.code === 200) {
userStore
.
logoutPass
();
window
.
location
.
href
=
LOGIN_URL
ElMessage
({
message
:
'登录失效,请重新登录'
,
type
:
'error'
,
...
...
@@ -89,8 +90,8 @@ class RequestClient {
}
// 登录失效
if
(
data
.
code
===
404
)
{
userStore
.
setToken
(
''
);
router
.
replace
(
LOGIN_URL
);
userStore
.
logoutPass
(
);
window
.
location
.
href
=
LOGIN_URL
ElMessage
({
message
:
'登录失效,请重新登录'
,
type
:
'error'
,
...
...
src/views/login/index.vue
View file @
e681d845
...
...
@@ -115,8 +115,10 @@
keepAliveStore
.
setKeepAliveName
([]);
// 4.跳转到首页
router
.
push
(
HOME_URL
);
loginLoading
.
value
=
false
;
setTimeout
(()
=>
{
router
.
push
(
HOME_URL
);
loginLoading
.
value
=
false
;
},
1000
)
};
/**
...
...
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