From 07f9f8657d057a38792c3822acc9b08d83478967 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 07 五月 2026 14:23:10 +0800
Subject: [PATCH] 合并代码

---
 src/store/modules/user.js |   57 ++++++++++++++++++++++++++++++---------------------------
 1 files changed, 30 insertions(+), 27 deletions(-)

diff --git a/src/store/modules/user.js b/src/store/modules/user.js
index d52efa6..ea358d1 100644
--- a/src/store/modules/user.js
+++ b/src/store/modules/user.js
@@ -2,17 +2,19 @@
 import { getToken, setToken, removeToken } from '@/utils/auth'
 import { isHttp, isEmpty } from "@/utils/validate"
 import defAva from '@/assets/images/profile.jpg'
+import { defineStore } from 'pinia'
 
 const useUserStore = defineStore(
   'user',
   {
-    state: () => ({
-      token: getToken(),
-      id: '',
-      name: '',
-      avatar: '',
-      roles: [],
-      permissions: []
+    state: () => ({
+      token: getToken(),
+      id: '',
+      name: '',
+      avatar: '',
+      roles: [],
+      permissions: [],
+      aiEnabled: 0
     }),
     actions: {
       // 鐧诲綍
@@ -57,29 +59,31 @@
             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 => {
-            reject(error)
-          })
-        })
+            this.currentFactoryName = user.currentFactoryName
+            this.nickName = user.nickName
+            this.roleName = user.roles[0].roleName
+            this.currentDeptId = user.tenantId
+            this.currentLoginTime = this.getCurrentTime()
+            this.aiEnabled = Number(res.aiEnabled) === 1 ? 1 : 0
+            resolve(res)
+          }).catch(error => {
+            reject(error)
+          })
+        })
       },
       // 閫�鍑虹郴缁�
       logOut() {
         return new Promise((resolve, reject) => {
           logout(this.token).then(() => {
-            this.token = ''
-            this.roles = []
-            this.permissions = []
-            removeToken()
-            resolve()
-          }).catch(error => {
-            reject(error)
-          })
+            this.token = ''
+            this.roles = []
+            this.permissions = []
+            this.aiEnabled = 0
+            removeToken()
+            resolve()
+          }).catch(error => {
+            reject(error)
+          })
         })
       },
       // 鐧诲綍鏍¢獙
@@ -98,9 +102,8 @@
       loginCheckFactory(userInfo) {
         const username = userInfo.username.trim()
         const password = userInfo.password
-        const factoryId = userInfo.currentFatoryId
         return new Promise((resolve, reject) => {
-          loginCheckFactory(username, password, factoryId).then(res => {
+          loginCheckFactory(username, password).then(res => {
             setToken(res.token)
             this.token = res.token
             resolve()

--
Gitblit v1.9.3