From 836e147e8be6b84affd69f8189054a46532177ce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=91=A3=E5=93=B2=E5=A5=87?= <13840175730@139.com>
Date: Wed, 27 Mar 2024 10:03:56 +0800
Subject: [PATCH] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E7=99=BB=E5=BD=95=E6=97=A5?=
=?UTF-8?q?=E5=BF=97=E5=92=8C=E8=8F=9C=E5=8D=95=E6=93=8D=E4=BD=9C=E6=97=A5?=
=?UTF-8?q?=E5=BF=97=E8=AE=B0=E5=BD=95=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/user.js | 11 +++++++-
src/layout/components/Sidebar/SidebarItem.vue | 20 ++++++++------
src/layout/components/Sidebar/index.vue | 3 +--
src/permission.js | 1 -
src/store/getters.js | 1 +
src/store/modules/page.js | 26 +++++++++++++++++++
src/store/modules/permission.js | 1 -
src/utils/request.js | 5 ++--
src/views/login/index.vue | 16 ++++++++++++
9 files changed, 69 insertions(+), 15 deletions(-)
create mode 100644 src/store/modules/page.js
diff --git a/src/api/user.js b/src/api/user.js
index 6c49f51..036e577 100644
--- a/src/api/user.js
+++ b/src/api/user.js
@@ -1,12 +1,21 @@
import request from '@/utils/request'
+export function saveLog(data) {
+ return request({
+ url: '/userLog/save',
+ method: 'post',
+ data
+ })
+}
+
export function login(data) {
return request({
url: '/api/login',
method: 'post',
data
})
-}export function updatePassword(data) {
+}
+export function updatePassword(data) {
return request({
url: '/api/updatePassword',
method: 'post',
diff --git a/src/layout/components/Sidebar/SidebarItem.vue b/src/layout/components/Sidebar/SidebarItem.vue
index 4fafd19..1fc1454 100644
--- a/src/layout/components/Sidebar/SidebarItem.vue
+++ b/src/layout/components/Sidebar/SidebarItem.vue
@@ -31,6 +31,7 @@ import { isExternal } from '@/utils/validate'
import Item from './Item'
import AppLink from './Link'
import FixiOSBug from './FixiOSBug'
+import {saveLog} from "@/api/user";
export default {
@@ -60,14 +61,17 @@ export default {
},
methods: {
insertLog(a) {
- //
- console.log(a)
- const syLog = {}
- // syLog.systemCode = a.system_code
- // syLog.content = a.menu_name
- // syLogAdd(syLog).then(res => {
- //
- // })
+ //启用静默方式,操作日志
+ this.$store.dispatch('page/handler', true).then(()=>{
+ saveLog({
+ type:'REDIRECT',
+ result:'打开菜单',
+ content:'',
+ path:this.basePath+'/'+a.path
+ }).then(()=>{
+ this.$store.dispatch('page/handler', false)
+ })
+ })
},
hasOneShowingChild(children = [], parent) {
const showingChildren = children.filter(item => {
diff --git a/src/layout/components/Sidebar/index.vue b/src/layout/components/Sidebar/index.vue
index 65c9ef1..8de14ca 100644
--- a/src/layout/components/Sidebar/index.vue
+++ b/src/layout/components/Sidebar/index.vue
@@ -14,8 +14,7 @@
>
-
-
+
diff --git a/src/permission.js b/src/permission.js
index a563347..4c7305d 100644
--- a/src/permission.js
+++ b/src/permission.js
@@ -54,7 +54,6 @@ router.beforeEach(async(to, from, next) => {
// note: roles must be a object array! such as: ['admin'] or ,['developer','editor']
// const { roles } = await store.dispatch('user/getInfo')
const {menu} = await store.dispatch('user/getInfo')
- console.log(menu)
if (menu.length === 0) {
throw new Error('没有任何菜单信息!getInfo')
}
diff --git a/src/store/getters.js b/src/store/getters.js
index 46e7a6f..a89ef88 100644
--- a/src/store/getters.js
+++ b/src/store/getters.js
@@ -19,5 +19,6 @@ const getters = {
dictMapList: state => state.dict.dictMapList,
zone: state=>state.user.zone,//责任区域
title: state=>state.user.title,//职称
+ noLoading:state=>state.page.noLoading,
}
export default getters
diff --git a/src/store/modules/page.js b/src/store/modules/page.js
new file mode 100644
index 0000000..f19c6ab
--- /dev/null
+++ b/src/store/modules/page.js
@@ -0,0 +1,26 @@
+
+const state = {
+ noLoading: false,
+}
+
+const mutations = {
+ SET_LOADING: (state, loading) => {
+ state.noLoading = loading
+ },
+}
+
+const actions = {
+ handler({ commit }, loading){
+ return new Promise((resolve, reject) => {
+ commit('SET_LOADING', loading)
+ resolve()
+ })
+ }
+}
+
+export default {
+ namespaced: true,
+ state,
+ actions,
+ mutations
+}
diff --git a/src/store/modules/permission.js b/src/store/modules/permission.js
index a2f0ba4..ac57130 100644
--- a/src/store/modules/permission.js
+++ b/src/store/modules/permission.js
@@ -90,7 +90,6 @@ const actions = {
}
return !node.parent_id
})
- console.log(result)
commit('SET_ROUTES', result)
resolve(result)
})
diff --git a/src/utils/request.js b/src/utils/request.js
index 712d805..3308846 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -20,7 +20,8 @@ function endLoading() { // 使用Element loading-close 方法
// 声明一个变量 needLoadingRequestCount,每次调用showFullScreenLoading方法 needLoadingRequestCount + 1。
// 调用tryHideFullScreenLoading()方法,needLoadingRequestCount - 1。needLoadingRequestCount为 0 时,结束 loading。
let needLoadingRequestCount = 0
-export function showFullScreenLoading() {
+export function showFullScreenLoading(noLoading=false) {
+ if (noLoading)return;
if (needLoadingRequestCount === 0) {
startLoading()
}
@@ -54,7 +55,7 @@ service.interceptors.request.use(
config.headers['token'] = getToken()
}
- showFullScreenLoading()
+ showFullScreenLoading(store.getters.noLoading)
return config
},
error => {
diff --git a/src/views/login/index.vue b/src/views/login/index.vue
index b9b7dcb..9388bec 100644
--- a/src/views/login/index.vue
+++ b/src/views/login/index.vue
@@ -75,6 +75,7 @@