From e6a899cbf6d9cdf709d0f1deef91ff4d3f36abe8 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 10 二月 2026 11:01:14 +0800
Subject: [PATCH] 进销存升级app: 1.添加菜单权限

---
 src/store/modules/user.ts |   21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts
index 969943c..140e0a3 100644
--- a/src/store/modules/user.ts
+++ b/src/store/modules/user.ts
@@ -1,4 +1,5 @@
 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";
@@ -7,7 +8,6 @@
 export interface LoginForm {
   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
       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