Commit 94b4cef2 authored by wends's avatar wends

remove errorlog

parent 7fede577
...@@ -216,28 +216,6 @@ Object.keys(filters).forEach(key => { ...@@ -216,28 +216,6 @@ Object.keys(filters).forEach(key => {
}) })
``` ```
### moment
moment 时间格式化工具
```javascript
export function momentFilter(value, formatString) {
formatString = formatString || 'YYYY-MM-DD HH:mm:ss'
if (value === undefined) {
return null
}
return moment(value).format(formatString)
}
```
用在展示数据时把时间戳转换为带有固定格式的日期
```javascript
{{ 1587712722637 | momentFilter }}
```
除了 moment 之外还有 pluralize、timeAgo这些可以全局使用的过滤器
## 全局方法 ## 全局方法
在 main.js 中 Mixin 全局方法,全局混入的方法名加 $前缀,以便与实例内方法区分开 在 main.js 中 Mixin 全局方法,全局混入的方法名加 $前缀,以便与实例内方法区分开
...@@ -250,8 +228,10 @@ export function momentFilter(value, formatString) { ...@@ -250,8 +228,10 @@ export function momentFilter(value, formatString) {
Vue.mixin({ Vue.mixin({
methods: { methods: {
$moment(row, column, cellValue) { $moment(row, column, cellValue) {
const m = moment(cellValue, 'x') const val = cellValue || row
return m.isValid() ? moment(cellValue).format('YYYY-MM-DD HH:mm:ss') : null const m = moment(val, 'x')
const formatText = cellValue ? (format || 'YYYY-MM-DD HH:mm:ss') : column
return m.isValid() ? moment(cellValue).format(formatText) : null
} }
} }
}) })
......
<template>
<div v-if="errorLogs.length>0">
<el-badge :is-dot="true" style="line-height: 25px;margin-top: -5px;" @click.native="dialogTableVisible=true">
<el-button style="padding: 8px 10px;" size="small" type="danger">
<svg-icon icon-class="bug" />
</el-button>
</el-badge>
<el-dialog :visible.sync="dialogTableVisible" width="80%" append-to-body>
<div slot="title">
<span style="padding-right: 10px;">Error Log</span>
<el-button size="mini" type="primary" icon="el-icon-delete" @click="clearAll">Clear All</el-button>
</div>
<el-table :data="errorLogs" border>
<el-table-column label="Message">
<template slot-scope="{row}">
<div>
<span class="message-title">Msg:</span>
<el-tag type="danger">
{{ row.err.message }}
</el-tag>
</div>
<br>
<div>
<span class="message-title" style="padding-right: 10px;">Info: </span>
<el-tag type="warning">
{{ row.vm.$vnode.tag }} error in {{ row.info }}
</el-tag>
</div>
<br>
<div>
<span class="message-title" style="padding-right: 16px;">Url: </span>
<el-tag type="success">
{{ row.url }}
</el-tag>
</div>
</template>
</el-table-column>
<el-table-column label="Stack">
<template slot-scope="scope">
{{ scope.row.err.stack }}
</template>
</el-table-column>
</el-table>
</el-dialog>
</div>
</template>
<script>
export default {
name: 'ErrorLog',
data() {
return {
dialogTableVisible: false
}
},
computed: {
errorLogs() {
return this.$store.getters.errorLogs
}
},
methods: {
clearAll() {
this.dialogTableVisible = false
this.$store.dispatch('errorLog/clearErrorLog')
}
}
}
</script>
<style scoped>
.message-title {
font-size: 16px;
color: #333;
font-weight: bold;
padding-right: 8px;
}
</style>
...@@ -25,12 +25,5 @@ module.exports = { ...@@ -25,12 +25,5 @@ module.exports = {
*/ */
sidebarLogo: true, sidebarLogo: true,
/**
* @type {string | array} 'production' | ['production', 'development']
* @description Need show err logs component.
* The default is only used in the production env
* If you want to also use it in dev, you can pass ['production', 'development']
*/
errorLog: 'production',
overview: true overview: true
} }
...@@ -9,15 +9,9 @@ const getters = { ...@@ -9,15 +9,9 @@ const getters = {
roles: state => state.user.roles, roles: state => state.user.roles,
permission_routes: state => state.permission.routes, permission_routes: state => state.permission.routes,
add_routes: state => state.permission.addRoutes, add_routes: state => state.permission.addRoutes,
errorLogs: state => state.errorLog.logs,
permissions: state => state.permission.permissions, permissions: state => state.permission.permissions,
tokenValid: state => state.user.tokenValid, tokenValid: state => state.user.tokenValid,
userInfo: state => state.user.userInfo, userInfo: state => state.user.userInfo,
currentMenuId: state => state.permission.currentMenuId, currentMenuId: state => state.permission.currentMenuId
dictionary: state => state.app.dictionary,
regions: state => state.app.regions,
originalRegions: state => state.app.originalRegions,
goodsType: state => state.app.goodsType,
vehicleType: state => state.app.vehicleType
} }
export default getters export default getters
...@@ -6,12 +6,7 @@ const state = { ...@@ -6,12 +6,7 @@ const state = {
withoutAnimation: false withoutAnimation: false
}, },
device: 'desktop', device: 'desktop',
size: Cookies.get('size') || 'medium', size: Cookies.get('size') || 'medium'
dictionary: {},
regions: [],
originalRegions: [],
goodsType: [],
vehicleType: []
} }
const mutations = { const mutations = {
...@@ -35,21 +30,6 @@ const mutations = { ...@@ -35,21 +30,6 @@ const mutations = {
SET_SIZE: (state, size) => { SET_SIZE: (state, size) => {
state.size = size state.size = size
Cookies.set('size', size) Cookies.set('size', size)
},
SET_DIST: (state, dictionary) => {
state.dictionary = dictionary
},
SET_REGIONS: (state, regions) => {
state.regions = regions
},
SET_ORIGINAL_REGIONS: (state, originalRegions) => {
state.originalRegions = originalRegions
},
SET_GOODSTYPE: (state, goodsType) => {
state.goodsType = goodsType
},
SET_VEHICLETYPE: (state, vehicleType) => {
state.vehicleType = vehicleType
} }
} }
......
const state = {
logs: []
}
const mutations = {
ADD_ERROR_LOG: (state, log) => {
state.logs.push(log)
},
CLEAR_ERROR_LOG: (state) => {
state.logs.splice(0)
}
}
const actions = {
addErrorLog({ commit }, log) {
commit('ADD_ERROR_LOG', log)
},
clearErrorLog({ commit }) {
commit('CLEAR_ERROR_LOG')
}
}
export default {
namespaced: true,
state,
mutations,
actions
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment