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 @@