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
849d0456
Commit
849d0456
authored
Feb 06, 2025
by
高源
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
登录权限优化
parent
b094eedf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
20 deletions
+31
-20
dist.zip
dist.zip
+0
-0
index.html
dist/index.html
+2
-2
main.ts
src/main.ts
+29
-18
No files found.
dist.zip
View file @
849d0456
No preview for this file type
dist/index.html
View file @
849d0456
<!doctype html>
<!doctype html>
<html
lang=
"zh-cmn-Hans"
>
<html
lang=
"zh-cmn-Hans"
>
<head>
<head>
<meta
name=
"buildTime"
content=
"202
4-12-10 17:34:19
"
>
<meta
name=
"buildTime"
content=
"202
5-02-06 10:11:28
"
>
<meta
charset=
"UTF-8"
/>
<meta
charset=
"UTF-8"
/>
<link
rel=
"icon"
href=
"/favicon.svg"
/>
<link
rel=
"icon"
href=
"/favicon.svg"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
/>
<meta
name=
"color-scheme"
content=
"light dark"
/>
<meta
name=
"color-scheme"
content=
"light dark"
/>
<title>
VueDashboard
</title>
<title>
VueDashboard
</title>
<script
type=
"module"
crossorigin
src=
"/Content/VueDashboardUi/VueDashboard1/assets/index-
BMlV-6Dx
.js"
></script>
<script
type=
"module"
crossorigin
src=
"/Content/VueDashboardUi/VueDashboard1/assets/index-
DpYjMZ_w
.js"
></script>
<link
rel=
"stylesheet"
crossorigin
href=
"/Content/VueDashboardUi/VueDashboard1/assets/index-9k_B1ZU8.css"
>
<link
rel=
"stylesheet"
crossorigin
href=
"/Content/VueDashboardUi/VueDashboard1/assets/index-9k_B1ZU8.css"
>
</head>
</head>
<body>
<body>
...
...
src/main.ts
View file @
849d0456
...
@@ -2,7 +2,7 @@ import { createApp } from 'vue';
...
@@ -2,7 +2,7 @@ import { createApp } from 'vue';
import
'./plugins/assets'
;
import
'./plugins/assets'
;
import
{
localStg
}
from
'@/utils/storage'
;
import
{
localStg
}
from
'@/utils/storage'
;
// main.js or main.ts
// main.js or main.ts
import
'font-awesome/css/font-awesome.css'
;
// 导入所有的 Font Awesome 样式
import
'font-awesome/css/font-awesome.css'
;
import
{
setupDayjs
,
setupIconifyOffline
,
setupLoading
,
setupNProgress
}
from
'./plugins'
;
import
{
setupDayjs
,
setupIconifyOffline
,
setupLoading
,
setupNProgress
}
from
'./plugins'
;
import
{
setupStore
}
from
'./store'
;
import
{
setupStore
}
from
'./store'
;
import
{
setupRouter
}
from
'./router'
;
import
{
setupRouter
}
from
'./router'
;
...
@@ -10,18 +10,29 @@ import { setupI18n } from './locales';
...
@@ -10,18 +10,29 @@ import { setupI18n } from './locales';
import
App
from
'./App.vue'
;
import
App
from
'./App.vue'
;
let
timeoutHandle
:
string
|
number
|
NodeJS
.
Timeout
|
undefined
;
let
timeoutHandle
:
string
|
number
|
NodeJS
.
Timeout
|
undefined
;
const
INACTIVITY_TIMEOUT
=
20
*
60
*
1000
;
function
handleLogout
(
app
:
any
)
{
localStg
.
remove
(
'token'
);
localStg
.
remove
(
'refreshToken'
);
localStg
.
remove
(
'userInfo'
);
app
.
config
.
globalProperties
.
$router
.
push
(
'/login/pwd-login'
);
}
function
checkLastActivity
(
app
:
any
)
{
const
lastActivity
=
localStorage
.
getItem
(
'lastActivityTime'
);
if
(
lastActivity
)
{
const
timeDiff
=
Date
.
now
()
-
Number
.
parseInt
(
lastActivity
,
10
);
if
(
timeDiff
>
INACTIVITY_TIMEOUT
)
{
handleLogout
(
app
);
}
}
}
function
startInactivityTimer
(
app
:
any
)
{
function
startInactivityTimer
(
app
:
any
)
{
clearTimeout
(
timeoutHandle
);
clearTimeout
(
timeoutHandle
);
timeoutHandle
=
setTimeout
(
localStorage
.
setItem
(
'lastActivityTime'
,
Date
.
now
().
toString
());
()
=>
{
timeoutHandle
=
setTimeout
(()
=>
handleLogout
(
app
),
INACTIVITY_TIMEOUT
);
localStg
.
remove
(
'token'
);
localStg
.
remove
(
'refreshToken'
);
localStg
.
remove
(
'userInfo'
);
app
.
config
.
globalProperties
.
$router
.
push
(
'/login/pwd-login'
);
},
29
*
60
*
1000
);
// 30分钟 = 30 * 60 * 1000 毫秒
}
}
function
resetInactivityTimer
(
app
:
any
)
{
function
resetInactivityTimer
(
app
:
any
)
{
...
@@ -30,22 +41,17 @@ function resetInactivityTimer(app: any) {
...
@@ -30,22 +41,17 @@ function resetInactivityTimer(app: any) {
async
function
setupApp
()
{
async
function
setupApp
()
{
setupLoading
();
setupLoading
();
setupNProgress
();
setupNProgress
();
setupIconifyOffline
();
setupIconifyOffline
();
setupDayjs
();
setupDayjs
();
const
app
=
createApp
(
App
);
const
app
=
createApp
(
App
);
setupStore
(
app
);
setupStore
(
app
);
await
setupRouter
(
app
);
await
setupRouter
(
app
);
setupI18n
(
app
);
setupI18n
(
app
);
// 系统更新提示
// setupAppVersionNotification();
// 检查上次活动时间
checkLastActivity
(
app
);
// 监听用户的操作
// 监听用户的操作
window
.
addEventListener
(
'mousemove'
,
()
=>
resetInactivityTimer
(
app
));
window
.
addEventListener
(
'mousemove'
,
()
=>
resetInactivityTimer
(
app
));
...
@@ -59,6 +65,11 @@ async function setupApp() {
...
@@ -59,6 +65,11 @@ async function setupApp() {
app
.
mount
(
'#app'
);
app
.
mount
(
'#app'
);
}
}
// 页面卸载时保存最后活动时间
window
.
addEventListener
(
'beforeunload'
,
()
=>
{
localStorage
.
setItem
(
'lastActivityTime'
,
Date
.
now
().
toString
());
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
setupApp
();
setupApp
();
},
200
);
},
200
);
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