Kaynağa Gözat

日志结构修改

zhongxiaoyu 3 yıl önce
ebeveyn
işleme
394fb2553a
3 değiştirilmiş dosya ile 23 ekleme ve 6 silme
  1. 3 1
      src/store/modules/user.js
  2. 12 0
      src/utils/auth.js
  3. 8 5
      src/utils/request.js

+ 3 - 1
src/store/modules/user.js

@@ -1,5 +1,5 @@
 import { login, loginUp, getInfo } from '@/api/login'
-import { getToken, setToken, removeToken, setUserId, TokenKey } from '@/utils/auth'
+import { getToken, setToken, removeToken, setUserId, TokenKey, setLogId, removeLogId } from '@/utils/auth'
 import { resetRouter } from '@/router'
 import { wsSocketClose } from '@/utils/socket'
 const getDefaultState = () => {
@@ -63,6 +63,7 @@ const actions = {
           sessionStorage.setItem("token", returnData.Token);
           setToken(TokenKey, returnData.Token);
           setToken('FirstLogin', returnData.FirstLogin);
+          setLogId(returnData.LogId)
           setUserId(returnData.UserId)
           let nowDate = new Date();
           let oldDate = new Date(returnData.ValidTime);
@@ -118,6 +119,7 @@ const actions = {
         removeToken('systemSet');
         removeToken('FirstLogin');
         removeToken('userAuthList');
+        removeLogId()
         resetRouter();
         commit('RESET_STATE');
         commit('SET_ROLES', []);

+ 12 - 0
src/utils/auth.js

@@ -29,3 +29,15 @@ export function setCodeToken (token) {
 export function getCodeToken () {
   return Cookies.get('codeToken')
 }
+
+export function setLogId(id) {
+  sessionStorage.setItem('LogId', id)
+}
+
+export function getLogId() {
+  return sessionStorage.getItem('LogId')
+}
+
+export function removeLogId() {
+  sessionStorage.removeItem('LogId')
+}

+ 8 - 5
src/utils/request.js

@@ -1,14 +1,14 @@
 /*
  * @Author: your name
  * @Date: 2022-01-06 09:45:17
- * @LastEditTime: 2022-04-14 16:15:03
+ * @LastEditTime: 2022-04-15 11:39:57
  * @LastEditors: your name
  * @Description: axios封装
  */
 import axios from 'axios'
 import { MessageBox, Message } from 'element-ui'
 import store from '@/store'
-import { getToken, getUserId, getCodeToken } from '@/utils/auth'
+import { getToken, getUserId, getCodeToken, getLogId } from '@/utils/auth'
 import { parseTime } from '@/utils'
 import { Loading } from 'element-ui'
 // create an axios instance
@@ -97,15 +97,18 @@ service.interceptors.response.use(
           Type: '2',
           BeginTime,
           EndTime,
-          OperateResult
+          OperateResult,
+          Ident: Ident ?? ''
         }
       }
       if (islogin) {
         if (res.returnData) {
-          config.data.OperatorId = config.data.Operator = res.returnData.UserId.toString()
+          config.data.OperatorId = res.returnData.UserId.toString()
+          config.data.LogId = res.returnData.LogId?.toString() ?? ''
         }
       } else {
-        config.data.OperatorId = config.data.Operator = getUserId()
+        config.data.OperatorId = getUserId()
+        config.data.LogId = getLogId() ?? ''
       }
       service(config)
     }