D2ErrorLogList 放在了 layout 文件夹内

Former-commit-id: e7c5073e750de6659873bf827575e67d60fda6cc [formerly e7c5073e750de6659873bf827575e67d60fda6cc [formerly e7c5073e750de6659873bf827575e67d60fda6cc [formerly e7c5073e750de6659873bf827575e67d60fda6cc [formerly 73408af989e90a4f3fb9d7dcf87115d115784a85 [formerly 25c75956a932431724fc33b1076e72edd3bad64a]]]]]
Former-commit-id: efb244c3b1729ce3ce80fefcc2116b5682c544f8
Former-commit-id: 33cbec8cac3b464ba50691a0301816a14c92c507
Former-commit-id: 0d402138f2324a28d52f685049c3299197c2292d [formerly 715be3a1af8c720d3102a7556dd709dbb106f102]
Former-commit-id: 574cfa22abbb883db5a1bb9d83abbb59ccc15d21
Former-commit-id: 0f2ed4796206d30f827600b14603972a9a6db594
Former-commit-id: 1d1543d63a76cff518a8a6122b489395c5de8052
Former-commit-id: 10202d438c9adfa300ba3603895bab17f17d2372
Former-commit-id: 5a4bc16655a86dabed9a235699ed945466895032
This commit is contained in:
liyang
2018-08-22 11:12:52 +08:00
parent 42fd3dcb9c
commit 2d17d09d61
5 changed files with 18 additions and 13 deletions

View File

@@ -1,30 +0,0 @@
<template>
<div
class="d2-error-log-list__expand"
:class="className">
<p class="d2-error-log-list__expand-title">{{title}}</p>
<p class="d2-error-log-list__expand-value">{{value === '' ? '无数据' : value}}</p>
<slot/>
</div>
</template>
<script>
export default {
props: {
type: {
default: 'log'
},
title: {
default: ''
},
value: {
default: ''
}
},
computed: {
className () {
return this.type === 'log' ? 'd2-error-log-list__expand--log' : 'd2-error-log-list__expand--error'
}
}
}
</script>

View File

@@ -1,195 +0,0 @@
<template>
<el-table
:data="logReverse"
border
stripe
style="width: 100%"
size="mini">
<el-table-column type="expand">
<div slot-scope="props" class="d2-error-log-list__expand-group">
<expand-item
:type="props.row.type"
title="类型"
:value="props.row.type === 'log' ? '日志' : '异常'"/>
<expand-item
:type="props.row.type"
title="内容"
:value="props.row.info"/>
<expand-item
v-if="props.row.type === 'error'"
type="error"
title="报错组件"
:value="get(props.row.vm, '$vnode.tag', '')"/>
<expand-item
v-if="props.row.type === 'error'"
type="error"
title="错误名称"
:value="get(props.row.err, 'name', '')"/>
<expand-item
v-if="props.row.type === 'error'"
type="error"
title="错误信息"
:value="get(props.row.err, 'message', '')"/>
<expand-item
v-if="props.row.type === 'error'"
type="error"
title="错误堆栈"
value="见下">
<div style="overflow: auto;">
<pre>{{stackBeautify(props.row.err)}}</pre>
</div>
</expand-item>
<expand-item
:type="props.row.type"
title="用户名"
:value="get(props.row.user, 'name', '')"/>
<expand-item
:type="props.row.type"
title="uuid"
:value="props.row.uuid"/>
<expand-item
:type="props.row.type"
title="token"
:value="props.row.token"/>
<expand-item
:type="props.row.type"
title="页面地址"
:value="props.row.url"/>
<expand-item
:type="props.row.type"
title="时间"
:value="props.row.time"/>
</div>
</el-table-column>
<el-table-column
prop="type"
label="类型"
width="80px"
align="center"
:filters="[
{ text: '日志', value: 'log' },
{ text: '异常', value: 'error' }
]"
:filter-multiple="false"
:filter-method="filterType"
filter-placement="bottom">
<template slot-scope="scope">
<el-tag
v-if="scope.row.type === 'error'"
size="mini"
type="danger">
<d2-icon name="bug"/> Bug
</el-tag>
<el-tag
v-else
size="mini"
type="info">
<d2-icon name="dot-circle-o"/> Log
</el-tag>
</template>
</el-table-column>
<el-table-column
label="地址"
prop="url"
width="140px"
:show-overflow-tooltip="true">
</el-table-column>
<el-table-column
label="内容"
prop="info"
:show-overflow-tooltip="true">
</el-table-column>
<el-table-column
label="错误类型"
width="140px"
:show-overflow-tooltip="true">
<template
slot-scope="scope">
{{get(scope.row.err, 'name', '')}}
</template>
</el-table-column>
<el-table-column
label="错误信息"
width="300px">
<template
slot-scope="scope">
{{get(scope.row.err, 'message', '')}}
</template>
</el-table-column>
</el-table>
</template>
<script>
import { mapState } from 'vuex'
import { get } from 'lodash'
import ExpandItem from './components/ExpandItem'
export default {
name: 'd2-error-log-list',
components: {
ExpandItem
},
computed: {
...mapState('d2admin', {
logList: state => state.log.list
}),
logReverse () {
// 直接 reverse 的话有点问题
const res = []
const loglength = this.logList.length
this.logList.forEach((log, index) => {
res.push(this.logList[loglength - 1 - index])
})
return res
}
},
methods: {
get,
filterType (value, row) {
return row.type === value
},
stackBeautify (err) {
if (!err) {
return ''
}
return err.stack
}
}
}
</script>
<style lang="scss">
@import '~@/assets/style/public.scss';
.d2-error-log-list__expand-group {
.d2-error-log-list__expand {
padding-left: 20px;
margin-bottom: 10px;
&:last-child {
margin-bottom: 0px;
}
.d2-error-log-list__expand-title {
font-size: 16px;
font-weight: bold;
margin-top: 0px;
margin-bottom: 10px;
}
.d2-error-log-list__expand-value {
font-size: 12px;
margin-top: 0px;
margin-bottom: 0px;
}
}
.d2-error-log-list__expand--log {
border-left: 4px solid $color-info;
}
.d2-error-log-list__expand--error {
border-left: 4px solid $color-danger;
}
}
</style>

View File

@@ -1,22 +1,13 @@
import Vue from 'vue'
import { GridLayout, GridItem } from 'vue-grid-layout'
import SplitPane from 'vue-splitpane'
import d2Container from './d2-container'
import d2LinkBtn from './d2-link-btn'
// 注意 有些组件使用异步加载会有影响
Vue.component('d2-grid-layout', GridLayout)
Vue.component('d2-grid-item', GridItem)
Vue.component('SplitPane', SplitPane)
Vue.component('d2-container', d2Container)
Vue.component('d2-link-btn', d2LinkBtn)
Vue.component('d2-page-cover', () => import('./d2-page-cover'))
Vue.component('d2-count-up', () => import('./d2-count-up'))
Vue.component('d2-error-log-list', () => import('./d2-error-log-list'))
Vue.component('d2-help', () => import('./d2-help'))
Vue.component('d2-highlight', () => import('./d2-highlight'))
Vue.component('d2-icon', () => import('./d2-icon'))