1.增加登录日志和菜单操作日志记录功能

master
董哲奇 1 year ago
parent 1343d0266e
commit 836e147e8b

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

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

@ -14,8 +14,7 @@
>
<sidebar-item v-for="route in permission_routes" :key="route.path" :item="route" :base-path="route.path" />
</el-menu>
</el-scrollbar>
</el-scrollbar>
</div>
</template>

@ -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')
}

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

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

@ -90,7 +90,6 @@ const actions = {
}
return !node.parent_id
})
console.log(result)
commit('SET_ROUTES', result)
resolve(result)
})

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

@ -75,6 +75,7 @@
<script>
import { validUsername } from '@/utils/validate'
import SocialSign from './components/SocialSignin'
import {saveLog} from "@/api/user";
// import { getByCode,getUser } from '@/api/sy/xtgl'
export default {
@ -178,6 +179,11 @@
console.log(this.loginForm)
this.$store.dispatch('user/login', this.loginForm)
.then(() => {
saveLog({
type:'LOGIN',
result:'登录成功',
content:'登录'
})
this.$router.push({ path: this.redirect || '/' })
this.loading = false
})
@ -204,6 +210,16 @@
.then(() => {
this.$router.push({ path: this.redirect || '/' })
this.loading = false
//,
this.$store.dispatch('page/handler', true).then(()=>{
saveLog({
type:'LOGIN',
result:'登录成功',
content:'登录'
}).then(()=>{
this.$store.dispatch('page/handler', false)
})
})
})
.catch(() => {
this.loading = false

Loading…
Cancel
Save