diff --git a/components/smallCommon/CusButton.vue b/components/smallCommon/CusButton.vue
index de6252b..6fe6da5 100644
--- a/components/smallCommon/CusButton.vue
+++ b/components/smallCommon/CusButton.vue
@@ -39,6 +39,9 @@ export default {
color: rgba(255, 255, 255, 1);
text-align: left;
vertical-align: top;
+ a {
+ color: rgba(255, 255, 255, 1) !important;
+ }
&.small {
padding: 2px 10px;
background: linear-gradient(180deg, rgba(188, 216, 247, 0.4) 0%, rgba(152, 217, 237, 0.15) 48.61%, rgba(156, 255, 248, 0.4) 100%);
diff --git a/middleware/auth.js b/middleware/auth.js
new file mode 100644
index 0000000..f909bd5
--- /dev/null
+++ b/middleware/auth.js
@@ -0,0 +1,46 @@
+// 在某个适当的时间点检查登录状态是否过期
+function isLoginExpired(loginTimestamp, expirationDuration) {
+ // 获取登录时间戳
+ // 如果没有登录时间戳,说明用户未登录或状态已过期
+ if (!loginTimestamp) {
+ return true;
+ }
+
+ // 计算登录时间和现在的时间差
+ const currentTimestamp = Date.now();
+ const duration = currentTimestamp - loginTimestamp;
+
+ // 如果时间差大于3小时的毫秒数,则登录状态过期
+ return duration > expirationDuration;
+}
+
+
+export default function ({ route, redirect, store }) {
+ if (route.name === 'manager-login') {
+ return
+ }
+ if (localStorage.getItem('userInfo')) {
+ const cache = JSON.parse(localStorage.getItem('userInfo'))
+ const { expire, loginTime } = cache
+ // 在页面加载时检查登录状态
+ if (isLoginExpired(loginTime, expire)) {
+ // 用户登录已过期,执行登录过期的逻辑
+ console.log('登录已过期');
+ return redirect('/manager/login')
+ } else {
+ // 用户登录有效,执行登录有效的逻辑
+ store.dispatch('user/setUserInfo', cache)
+ if (route.path === '/') {
+ return redirect('/home')
+ }
+ }
+ } else {
+ // 假设用户信息存储在 Vuex store 中
+ const user = store.state.user
+ // 检查路由是否需要认证
+ if (!user.isLogin) {
+ return redirect('/manager/login')
+ }
+ }
+
+}
diff --git a/nuxt.config.js b/nuxt.config.js
index 6e46e09..a9e5073 100644
--- a/nuxt.config.js
+++ b/nuxt.config.js
@@ -39,6 +39,10 @@ export default {
'@/assets/styles/mixin.less'
],
+ router: {
+ middleware: 'auth' // 应用全局中间件
+ },
+
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [
'@/plugins/antd-ui',
diff --git a/pages/cleanTravel/home.vue b/pages/cleanTravel/home.vue
index 985e7a3..942f3c0 100644
--- a/pages/cleanTravel/home.vue
+++ b/pages/cleanTravel/home.vue
@@ -87,9 +87,15 @@
- 厂区车辆台账
- 清洁运输趋势
- 磅秤台账
+
+ 厂区车辆台账
+
+
+ 清洁运输趋势
+
+
+ 磅秤台账
+
门禁监控
@@ -346,7 +352,6 @@ body, html, #__nuxt, #__layout {
width: 100%;
height: 100%;
overflow: hidden;
- background: #09151F;
}
.list-enter-active, .list-leave-active {
diff --git a/pages/home/index.vue b/pages/home/index.vue
index 80e0c0a..64a40bf 100644
--- a/pages/home/index.vue
+++ b/pages/home/index.vue
@@ -80,10 +80,18 @@
- 有组织
- 无组织
- 清洁运输
- 视频广场
+
+ 有组织
+
+
+ 无组织
+
+
+ 清洁运输
+
+
+ 视频广场
+
@@ -355,7 +363,6 @@ body, html, #__nuxt, #__layout {
width: 100%;
height: 100%;
overflow: hidden;
- background: #09151F;
}
.list-enter-active, .list-leave-active {
diff --git a/pages/manager/login.vue b/pages/manager/login.vue
index aa12265..2a10971 100644
--- a/pages/manager/login.vue
+++ b/pages/manager/login.vue
@@ -37,6 +37,7 @@