zhongxiaoyu пре 3 година
родитељ
комит
09d39d5bbb
4 измењених фајлова са 48 додато и 12 уклоњено
  1. 1 0
      public/index.html
  2. 6 2
      src/api/Account.js
  3. 4 2
      src/api/apiAuthority.js
  4. 37 8
      src/utils/request.js

+ 1 - 0
public/index.html

@@ -14,5 +14,6 @@
     </noscript>
     <div id="app"></div>
     <!-- built files will be auto injected -->
+    <script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
   </body>
 </html>

+ 6 - 2
src/api/Account.js

@@ -1,8 +1,8 @@
 /*
  * @Author: Badguy
  * @Date: 2022-02-14 09:37:11
- * @LastEditTime: 2022-02-28 15:36:37
- * @LastEditors: Please set LastEditors
+ * @LastEditTime: 2022-03-29 18:15:11
+ * @LastEditors: your name
  * @Description: 账户管理api
  * have a nice day!
  */
@@ -24,6 +24,7 @@ export function ChangeUserStatus (params) {
     url: '/api/fs4a/ChangeUserStatus/v1',
     method: 'post',
     data: params,
+    msg: '账号状态变更',
     proxy: true
   })
 }
@@ -34,6 +35,7 @@ export function delAccount (params) {
     url: '/api/fs4a/DeleteUser/v1',
     method: 'post',
     data: params,
+    msg: '账号删除',
     proxy: true
   })
 }
@@ -44,6 +46,7 @@ export function addAccount (params) {
     url: '/api/fs4a/SaveUser/v1',
     method: 'post',
     data: params,
+    msg: '账号新增',
     proxy: true
   })
 }
@@ -64,6 +67,7 @@ export function editAccount (params) {
     url: '/api/fs4a/EditUser/v1',
     method: 'post',
     data: params,
+    msg: '账号编辑',
     proxy: true
   })
 }

+ 4 - 2
src/api/apiAuthority.js

@@ -1,8 +1,8 @@
 /*
  * @Author: your name
  * @Date: 2021-12-21 09:22:04
- * @LastEditTime: 2021-12-27 11:56:24
- * @LastEditors: Please set LastEditors
+ * @LastEditTime: 2022-03-29 18:17:52
+ * @LastEditors: your name
  * @Description: 权限项管理
  * @FilePath: \Foshan4A2.0\src\api\apiAuthority.js
  */
@@ -54,6 +54,7 @@ export function UpdateAppStatus (params) {
     url: '/api/fs4a/UpdateAppStatus/v1',
     method: 'post',
     data: params,
+    msg: '应用状态变更',
     proxy: true
   })
 }
@@ -125,6 +126,7 @@ export function UpdateAuthStatus (params) {
     url: '/api/fs4a/UpdateAuthStatus/v1',
     method: 'post',
     data: params,
+    msg: '权限状态变更',
     proxy: true
   })
 }

+ 37 - 8
src/utils/request.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2022-01-06 09:45:17
- * @LastEditTime: 2022-03-16 09:17:41
+ * @LastEditTime: 2022-03-29 18:11:10
  * @LastEditors: your name
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: \vue-admin-template\src\utils\request.js
@@ -20,9 +20,10 @@ const service = axios.create({
   timeout: 30000, // request timeout
   headers: {
     'Content-Type': 'application/json'
-  },
+  }
 })
-let loadingInstance, flag = false
+let loadingInstance,
+  flag = false
 // request interceptor
 service.interceptors.request.use(
   config => {
@@ -45,6 +46,15 @@ service.interceptors.request.use(
         text: '数据加载中'
       })
     }
+    if (!config.url.includes('/api/fs4a/sendLog') && config.msg) {
+      config.metaData = {
+        beginTime: new Date(),
+        browserTag: navigator.userAgent,
+        logType: config.msg ?? '未定义操作',
+        operateIP: returnCitySN.cip,
+        operator: getUserId()
+      }
+    }
     return config
   },
   error => {
@@ -59,7 +69,7 @@ service.interceptors.response.use(
   /**
    * If you want to get http information such as headers or status
    * Please return  response => response
-  */
+   */
 
   /**
    * Determine the request status by custom code
@@ -68,6 +78,25 @@ service.interceptors.response.use(
    */
   response => {
     const res = response.data
+    const config = response.config
+    if (!config.url.includes('/api/fs4a/sendLog') && config.msg) {
+      config.metaData = {
+        ...config.metaData,
+        endTime: new Date(),
+        data: config.data,
+        operateResult: res.returnData
+      }
+      service({
+        url: '/api/fs4a/sendLog',
+        method: 'post',
+        data: {
+          data: [config.metaData],
+          msg: config.msg,
+          type: '2'
+        },
+        proxy: true
+      })
+    }
     if (res.code == 0 || res.code == -1) {
       flag = false
       loadingInstance.close()
@@ -79,7 +108,7 @@ service.interceptors.response.use(
           type: 'error',
           duration: 5 * 1000,
           onClose: () => {
-            store.dispatch('tagsView/delAllViews').then(() => { })
+            store.dispatch('tagsView/delAllViews').then(() => {})
             store.dispatch('user/resetToken').then(() => {
               location.reload()
             })
@@ -121,15 +150,15 @@ service.interceptors.response.use(
   },
   error => {
     // console.log('err', error) // for debug
-    const des = `${error}`.split(" ").includes('500')
+    const des = `${error}`.split(' ').includes('500')
     if (des) {
       Message({
         message: '身份令牌过期或失效,即将重新登录',
         type: 'error',
         duration: 5 * 1000,
         onClose: () => {
-          store.dispatch("app/toggleDialog", false)
-          store.dispatch('tagsView/delAllViews').then(() => { })
+          store.dispatch('app/toggleDialog', false)
+          store.dispatch('tagsView/delAllViews').then(() => {})
           store.dispatch('user/resetToken').then(() => {
             location.reload()
           })