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

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

@ -1,12 +1,21 @@
import request from '@/utils/request' import request from '@/utils/request'
export function saveLog(data) {
return request({
url: '/userLog/save',
method: 'post',
data
})
}
export function login(data) { export function login(data) {
return request({ return request({
url: '/api/login', url: '/api/login',
method: 'post', method: 'post',
data data
}) })
}export function updatePassword(data) { }
export function updatePassword(data) {
return request({ return request({
url: '/api/updatePassword', url: '/api/updatePassword',
method: 'post', method: 'post',

@ -31,6 +31,7 @@ import { isExternal } from '@/utils/validate'
import Item from './Item' import Item from './Item'
import AppLink from './Link' import AppLink from './Link'
import FixiOSBug from './FixiOSBug' import FixiOSBug from './FixiOSBug'
import {saveLog} from "@/api/user";
export default { export default {
@ -60,14 +61,17 @@ export default {
}, },
methods: { methods: {
insertLog(a) { insertLog(a) {
// //,
console.log(a) this.$store.dispatch('page/handler', true).then(()=>{
const syLog = {} saveLog({
// syLog.systemCode = a.system_code type:'REDIRECT',
// syLog.content = a.menu_name result:'打开菜单',
// syLogAdd(syLog).then(res => { content:'',
// path:this.basePath+'/'+a.path
// }) }).then(()=>{
this.$store.dispatch('page/handler', false)
})
})
}, },
hasOneShowingChild(children = [], parent) { hasOneShowingChild(children = [], parent) {
const showingChildren = children.filter(item => { const showingChildren = children.filter(item => {

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

@ -54,7 +54,6 @@ router.beforeEach(async(to, from, next) => {
// note: roles must be a object array! such as: ['admin'] or ,['developer','editor'] // note: roles must be a object array! such as: ['admin'] or ,['developer','editor']
// const { roles } = await store.dispatch('user/getInfo') // const { roles } = await store.dispatch('user/getInfo')
const {menu} = await store.dispatch('user/getInfo') const {menu} = await store.dispatch('user/getInfo')
console.log(menu)
if (menu.length === 0) { if (menu.length === 0) {
throw new Error('没有任何菜单信息getInfo') throw new Error('没有任何菜单信息getInfo')
} }

@ -19,5 +19,6 @@ const getters = {
dictMapList: state => state.dict.dictMapList, dictMapList: state => state.dict.dictMapList,
zone: state=>state.user.zone,//责任区域 zone: state=>state.user.zone,//责任区域
title: state=>state.user.title,//职称 title: state=>state.user.title,//职称
noLoading:state=>state.page.noLoading,
} }
export default getters 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 return !node.parent_id
}) })
console.log(result)
commit('SET_ROUTES', result) commit('SET_ROUTES', result)
resolve(result) resolve(result)
}) })

@ -20,7 +20,8 @@ function endLoading() { // 使用Element loading-close 方法
// 声明一个变量 needLoadingRequestCount每次调用showFullScreenLoading方法 needLoadingRequestCount + 1。 // 声明一个变量 needLoadingRequestCount每次调用showFullScreenLoading方法 needLoadingRequestCount + 1。
// 调用tryHideFullScreenLoading()方法needLoadingRequestCount - 1。needLoadingRequestCount为 0 时,结束 loading。 // 调用tryHideFullScreenLoading()方法needLoadingRequestCount - 1。needLoadingRequestCount为 0 时,结束 loading。
let needLoadingRequestCount = 0 let needLoadingRequestCount = 0
export function showFullScreenLoading() { export function showFullScreenLoading(noLoading=false) {
if (noLoading)return;
if (needLoadingRequestCount === 0) { if (needLoadingRequestCount === 0) {
startLoading() startLoading()
} }
@ -54,7 +55,7 @@ service.interceptors.request.use(
config.headers['token'] = getToken() config.headers['token'] = getToken()
} }
showFullScreenLoading() showFullScreenLoading(store.getters.noLoading)
return config return config
}, },
error => { error => {

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

Loading…
Cancel
Save