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:
liyang
2018-08-09 01:03:20 +08:00
parent b793604445
commit dd6bcfd94b
9 changed files with 106 additions and 35 deletions

View File

@@ -136,15 +136,15 @@ export default {
ExpandItem
},
computed: {
...mapState('d2admin', [
'log'
]),
...mapState('d2admin', {
logList: state => state.log.list
}),
logReverse () {
// 直接 reverse 的话有点问题
const res = []
const loglength = this.log.length
this.log.forEach((log, index) => {
res.push(this.log[loglength - 1 - index])
const loglength = this.logList.length
this.logList.forEach((log, index) => {
res.push(this.logList[loglength - 1 - index])
})
return res
}

View File

@@ -11,10 +11,10 @@
<el-badge
v-if="logLength > 0"
:max="99"
:value="logErrorLength"
:is-dot="logErrorLength === 0">
:value="logLengthError"
:is-dot="logLengthError === 0">
<d2-icon
:name="logErrorLength === 0 ? 'dot-circle-o' : 'bug'"
:name="logLengthError === 0 ? 'dot-circle-o' : 'bug'"
style="font-size: 20px"/>
</el-badge>
<d2-icon
@@ -49,21 +49,21 @@ export default {
}
},
computed: {
...mapGetters('d2admin', [
'logLength',
'logErrorLength'
]),
...mapGetters('d2admin', {
logLength: 'log/length',
logLengthError: 'log/lengthError'
}),
tooltipContent () {
return this.logLength === 0
? '没有日志或异常'
: `${this.logLength} 条日志${this.logErrorLength > 0
? ` | 包含 ${this.logErrorLength} 个异常`
: `${this.logLength} 条日志${this.logLengthError > 0
? ` | 包含 ${this.logLengthError} 个异常`
: ''}`
}
},
methods: {
...mapMutations('d2admin', [
'logClean'
...mapMutations('d2admin/log', [
'clean'
]),
handleClick () {
if (this.logLength > 0) {
@@ -72,7 +72,7 @@ export default {
},
handleLogClean () {
this.dialogVisible = false
this.logClean()
this.clean()
}
}
}

View File

@@ -1,6 +1,6 @@
<template>
<el-dropdown class="d2-mr">
<span class="btn-text">你好 {{userInfo.name}}</span>
<span class="btn-text">你好 {{info.name}}</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item @click.native="logOff">
<d2-icon name="power-off" class="d2-mr-5"/>
@@ -14,9 +14,9 @@
import { mapState, mapActions } from 'vuex'
export default {
computed: {
...mapState('d2admin', {
userInfo: state => state.user.info
})
...mapState('d2admin/user', [
'info'
])
},
methods: {
...mapActions('d2admin', [

View File

@@ -85,11 +85,9 @@ export default {
...mapState('d2admin/menu', [
'asideCollapse'
]),
...mapGetters('d2admin', [
'keepAliveInclude'
]),
...mapGetters('d2admin/theme', {
themeActiveSetting: 'activeSetting'
...mapGetters('d2admin', {
keepAliveInclude: 'keepAliveInclude',
themeActiveSetting: 'theme/activeSetting'
}),
/**
* @description 最外层容器的背景图片样式

View File

@@ -155,11 +155,9 @@ export default {
'pageCurrent',
'ua'
]),
...mapGetters('d2admin', [
'keepAliveInclude'
]),
...mapGetters('d2admin/theme', {
themeActiveSetting: 'activeSetting'
...mapGetters('d2admin', {
keepAliveInclude: 'keepAliveInclude',
themeActiveSetting: 'theme/activeSetting'
})
}
}

View File

@@ -5,7 +5,7 @@ export default {
install (Vue, options) {
Vue.config.errorHandler = function (err, vm, info) {
Vue.nextTick(() => {
store.commit('d2admin/logAdd', {
store.dispatch('d2admin/log/add', {
type: 'error',
err,
vm,

View File

@@ -7,7 +7,7 @@ export default {
Vue.prototype.$log = util.log
// 快速记录日志
Vue.prototype.$logAdd = function (info) {
store.commit('d2admin/logAdd', {
store.dispatch('d2admin/log/add', {
type: 'log',
info
})

View File

@@ -1 +1 @@
e2e9f9e3f236b74d6b87a1b9a3865b19b4afc9fb
2eb4adc620a4ffb94292cc6c574b7290fccf8356

View 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
}))
}
}
}