From bd5a7ca6133eeddb8fed41ee2eb1c0c0874db91d Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期六, 11 四月 2026 16:15:10 +0800
Subject: [PATCH] 中兴实强app 1.部署修改
---
src/store/modules/user.ts | 59 +++++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 39 insertions(+), 20 deletions(-)
diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts
index b63c5f5..64ada0b 100644
--- a/src/store/modules/user.ts
+++ b/src/store/modules/user.ts
@@ -1,62 +1,65 @@
-import { login, logout, getInfo } from "@/api/login";
+import { logout, getInfo, loginCheckFactory } from "@/api/login";
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;
- code: string;
- uuid: string;
}
const useUserStore = defineStore("user", {
state: () => ({
token: getToken(),
+ id: "",
name: "",
avatar: "",
+ currentFactoryName: "",
+ nickName: "",
+ roleName: "",
+ currentDeptId: "",
+ currentLoginTime: "",
roles: Array(),
permissions: [],
+ routers: [],
}),
actions: {
- // 鐧诲綍
- login(userInfo: LoginForm) {
- const username = userInfo.username.trim();
+ loginCheckFactory(userInfo: any) {
+ const userName = userInfo.userName;
const password = userInfo.password;
- const code = userInfo.code;
- const uuid = userInfo.uuid;
return new Promise((resolve, reject) => {
- login(username, password, code, uuid)
+ loginCheckFactory(userName, password)
.then((res: any) => {
setToken(res.token);
this.token = res.token;
resolve(null);
})
- .catch((error) => {
+ .catch((error: any) => {
reject(error);
});
});
},
- // 鑾峰彇鐢ㄦ埛淇℃伅
getInfo() {
return new Promise((resolve, reject) => {
getInfo()
.then((res: any) => {
const user = res.user;
- const avatar =
- user.avatar == "" || user.avatar == null
- ? defAva
- : import.meta.env.VITE_APP_BASE_API + user.avatar;
-
+ let avatar = user.avatar || "";
+ avatar = config.baseUrl + "/profile/" + avatar;
if (res.roles && res.roles.length > 0) {
- // 楠岃瘉杩斿洖鐨剅oles鏄惁鏄竴涓潪绌烘暟缁�
this.roles = res.roles;
this.permissions = res.permissions;
} else {
this.roles = ["ROLE_DEFAULT"];
}
+ this.id = user.userId;
this.name = user.userName;
this.avatar = avatar;
+ this.currentFactoryName = user.currentFactoryName;
+ this.nickName = user.nickName;
+ this.roleName = user.roles[0].roleName;
+ this.currentDeptId = user.tenantId;
+ this.currentLoginTime = this.getCurrentTime();
resolve(res);
})
.catch((error) => {
@@ -64,7 +67,6 @@
});
});
},
- // 閫�鍑虹郴缁�
logOut() {
return new Promise<null>((resolve, reject) => {
logout()
@@ -72,6 +74,7 @@
this.token = "";
this.roles = [];
this.permissions = [];
+ this.routers = [];
this.name = "";
this.avatar = "";
removeToken();
@@ -82,6 +85,22 @@
});
});
},
+ getCurrentTime() {
+ const now = new Date();
+ const year = now.getFullYear();
+ const month = String(now.getMonth() + 1).padStart(2, "0");
+ const day = String(now.getDate()).padStart(2, "0");
+ const hours = String(now.getHours()).padStart(2, "0");
+ const minutes = String(now.getMinutes()).padStart(2, "0");
+ const seconds = String(now.getSeconds()).padStart(2, "0");
+ return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
+ },
+ getRouters() {
+ return new Promise((resolve) => {
+ this.routers = [];
+ resolve({ data: [] });
+ });
+ },
},
});
--
Gitblit v1.9.3