From a2fb35f6e7a161f080734acbc18ebca337692148 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期三, 11 二月 2026 14:23:51 +0800
Subject: [PATCH] 打卡添加防抖
---
src/store/modules/user.ts | 25 ++++++++++++++++++++-----
1 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts
index 7b9c873..140e0a3 100644
--- a/src/store/modules/user.ts
+++ b/src/store/modules/user.ts
@@ -1,13 +1,13 @@
import {logout, getInfo, loginCheckFactory} from "@/api/login";
+import { getRouters as getRoutersApi } from "@/api/menu";
import { getToken, setToken, removeToken } from "@/utils/auth";
import defAva from "@/static/images/profile.jpg";
import { defineStore } from "pinia";
import config from '@/config.js'
export interface LoginForm {
- username: string;
+ userName: string;
password: string;
- factoryId: string;
}
const useUserStore = defineStore("user", {
@@ -23,15 +23,15 @@
currentLoginTime: "",
roles: Array(),
permissions: [],
+ routers: [], // 璺敱鏉冮檺鏁版嵁
}),
actions: {
// 閮ㄩ棬鐧诲綍
loginCheckFactory(userInfo: any) {
- const username = userInfo.username.trim()
+ const userName = userInfo.userName
const password = userInfo.password
- const factoryId = userInfo.factoryId
return new Promise((resolve, reject) => {
- loginCheckFactory(username, password, factoryId).then((res: any) => {
+ loginCheckFactory(userName, password).then((res: any) => {
setToken(res.token)
this.token = res.token
resolve(null)
@@ -77,6 +77,7 @@
this.token = "";
this.roles = [];
this.permissions = [];
+ this.routers = [];
this.name = "";
this.avatar = "";
removeToken();
@@ -97,6 +98,20 @@
const seconds = String(now.getSeconds()).padStart(2, '0'); // 绉掓暟琛ラ浂
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
},
+ // 鑾峰彇璺敱鏉冮檺
+ getRouters() {
+ return new Promise((resolve, reject) => {
+ getRoutersApi()
+ .then((res: any) => {
+ // 瀛樺偍璺敱鏉冮檺鏁版嵁
+ this.routers = res.data || [];
+ resolve(res);
+ })
+ .catch((error) => {
+ reject(error);
+ });
+ });
+ },
},
});
--
Gitblit v1.9.3