Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
Vue-Dashboard
Project
Overview
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
高源
Vue-Dashboard
Commits
6b244022
Commit
6b244022
authored
Feb 20, 2025
by
高源
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
加入退出登录接口
parent
33d487e1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
10 deletions
+36
-10
index.html
dist/index.html
+2
-2
auth.ts
src/service/api/auth.ts
+8
-0
index.ts
src/store/modules/auth/index.ts
+26
-8
No files found.
dist/index.html
View file @
6b244022
<!doctype html>
<html
lang=
"zh-cmn-Hans"
>
<head>
<meta
name=
"buildTime"
content=
"2025-02-20
09:28:5
8"
>
<meta
name=
"buildTime"
content=
"2025-02-20
16:06:4
8"
>
<meta
charset=
"UTF-8"
/>
<link
rel=
"icon"
href=
"/favicon.svg"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
/>
<meta
name=
"color-scheme"
content=
"light dark"
/>
<title>
VueDashboard
</title>
<script
type=
"module"
crossorigin
src=
"/Content/VueDashboardUi/VueDashboard1/assets/index-
u5iQYcYA
.js"
></script>
<script
type=
"module"
crossorigin
src=
"/Content/VueDashboardUi/VueDashboard1/assets/index-
BTK4dlWY
.js"
></script>
<link
rel=
"stylesheet"
crossorigin
href=
"/Content/VueDashboardUi/VueDashboard1/assets/index-9k_B1ZU8.css"
>
</head>
<body>
...
...
src/service/api/auth.ts
View file @
6b244022
...
...
@@ -46,3 +46,11 @@ export function fetchRefreshToken(refreshToken: string) {
export
function
fetchCustomBackendError
(
code
:
string
,
msg
:
string
)
{
return
request
({
url
:
'/auth/error'
,
params
:
{
code
,
msg
}
});
}
/** 退出登录 */
export
function
fetchLogout
()
{
return
request
({
url
:
'/auth/logout.json'
,
method
:
'post'
});
}
src/store/modules/auth/index.ts
View file @
6b244022
...
...
@@ -4,7 +4,7 @@ import { defineStore } from 'pinia';
import
{
useLoading
}
from
'@sa/hooks'
;
import
{
SetupStoreId
}
from
'@/enum'
;
import
{
useRouterPush
}
from
'@/hooks/common/router'
;
import
{
fetchGetUserInfo
,
fetchLogin
}
from
'@/service/api'
;
import
{
fetchGetUserInfo
,
fetchLogin
,
fetchLogout
}
from
'@/service/api'
;
import
{
localStg
}
from
'@/utils/storage'
;
import
{
$t
}
from
'@/locales'
;
import
{
useRouteStore
}
from
'../route'
;
...
...
@@ -43,16 +43,34 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
async
function
resetStore
()
{
const
authStore
=
useAuthStore
();
clearAuthStorage
();
try
{
// 调用退出接口
const
{
error
}
=
await
fetchLogout
();
if
(
!
error
)
{
// 清除存储
clearAuthStorage
();
// 重置store
authStore
.
$reset
();
if
(
!
route
.
meta
.
constant
)
{
await
toLogin
();
}
authStore
.
$reset
();
tabStore
.
cacheTabs
();
routeStore
.
resetStore
();
}
}
catch
(
err
)
{
// 即使退出接口失败,也要清除本地状态
clearAuthStorage
();
authStore
.
$reset
();
if
(
!
route
.
meta
.
constant
)
{
await
toLogin
();
}
if
(
!
route
.
meta
.
constant
)
{
await
toLogin
();
}
tabStore
.
cacheTabs
();
routeStore
.
resetStore
();
tabStore
.
cacheTabs
();
routeStore
.
resetStore
();
}
}
/**
...
...
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