log
Former-commit-id: 067af1ad15588da779f6fdb52d8dd5e4d5337a83 [formerly 067af1ad15588da779f6fdb52d8dd5e4d5337a83 [formerly 067af1ad15588da779f6fdb52d8dd5e4d5337a83 [formerly 067af1ad15588da779f6fdb52d8dd5e4d5337a83 [formerly 26bff908e7e98cdecb3942975cb8dac912d22760 [formerly 5394d813fcdce16e699ff3d54fca956c87f1b56b]]]]] Former-commit-id: 4d70ea535fa6b135fd63ef83fc090e9a9d851e39 Former-commit-id: faec9e738fabb0225ec9ed61b86c30f269c02486 Former-commit-id: 9b54c495f13d810d67fa85e2129c05eec4a99324 [formerly 46471134b136a5df475c7787b5694052aca6b8ae] Former-commit-id: 0eb56ebbfa256ce1c2d3c1d99994ec7236c7ad5f Former-commit-id: 68c0847f64453808a6afc906ffc110654ccf84a4 Former-commit-id: 93c3b439339c575b5d7a085262817b295a852058 Former-commit-id: 32ccde3e80c1ec1a1dc8bc335082eb6ac80ea3e1 Former-commit-id: b8e2a549af61ff83b566fd961085ad7414d21b2d
This commit is contained in:
@@ -1 +1 @@
|
||||
e2e9f9e3f236b74d6b87a1b9a3865b19b4afc9fb
|
||||
2eb4adc620a4ffb94292cc6c574b7290fccf8356
|
||||
75
src/store/modules/d2admin/modules/log.js
Normal file
75
src/store/modules/d2admin/modules/log.js
Normal file
@@ -0,0 +1,75 @@
|
||||
import dayjs from 'dayjs'
|
||||
import get from 'lodash.get'
|
||||
import util from '@/libs/util.js'
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
// 错误日志
|
||||
list: []
|
||||
},
|
||||
getters: {
|
||||
/**
|
||||
* @description 返回现存 log (all) 的条数
|
||||
* @param {*} state vuex state
|
||||
*/
|
||||
length (state) {
|
||||
return state.list.length
|
||||
},
|
||||
/**
|
||||
* @description 返回现存 log (error) 的条数
|
||||
* @param {*} state vuex state
|
||||
*/
|
||||
lengthError (state) {
|
||||
return state.list.filter(l => l.type === 'error').length
|
||||
}
|
||||
},
|
||||
mutations: {
|
||||
/**
|
||||
* @description 清空日志
|
||||
* @param {Object} state vuex state
|
||||
*/
|
||||
clean (state) {
|
||||
// store 赋值
|
||||
state.list = []
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
/**
|
||||
* @description 添加一个日志
|
||||
* @param {Object} state vuex state
|
||||
* @param {Object} param type {String}: 类型
|
||||
* @param {Object} param err {Error}: 错误对象
|
||||
* @param {Object} param vm {Object}: vue 实例
|
||||
* @param {Object} param info {String}: 信息
|
||||
*/
|
||||
add ({ state, rootState }, { type, err, vm, info }) {
|
||||
// store 赋值
|
||||
state.list.push(Object.assign({
|
||||
// 记录类型
|
||||
type: 'log', // or error
|
||||
// 信息
|
||||
info: '',
|
||||
// 错误对象
|
||||
err: '',
|
||||
// vue 实例
|
||||
vm: '',
|
||||
// 当前用户信息
|
||||
user: rootState.d2admin.user.info,
|
||||
// 当前用户的 uuid
|
||||
uuid: util.cookies.get('uuid'),
|
||||
// 当前的 token
|
||||
token: util.cookies.get('token'),
|
||||
// 当前地址
|
||||
url: get(window, 'location.href', ''),
|
||||
// 当前时间
|
||||
time: dayjs().format('YYYY-M-D HH:mm:ss')
|
||||
}, {
|
||||
type,
|
||||
err,
|
||||
vm,
|
||||
info
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user