File tree Expand file tree Collapse file tree 4 files changed +19
-10
lines changed Expand file tree Collapse file tree 4 files changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -94,11 +94,15 @@ export default {
9494 }
9595 } ,
9696 actions : {
97- addErrorLog ( { commit } , info ) {
97+ addErrorLog ( { commit, rootState } , info ) {
9898 if ( ! window . location . href . includes ( 'error_logger_page' ) ) commit ( 'setHasReadErrorLoggerStatus' , false )
99+ const { user : { token, userId, userName } } = rootState
99100 let data = {
100101 ...info ,
101- time : Date . parse ( new Date ( ) )
102+ time : Date . parse ( new Date ( ) ) ,
103+ token,
104+ userId,
105+ userName
102106 }
103107 saveErrorLogger ( info ) . then ( ( ) => {
104108 commit ( 'addError' , data )
Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ export default {
7171 getUserInfo ( state . token ) . then ( res => {
7272 const data = res . data
7373 commit ( 'setAvator' , data . avator )
74- commit ( 'setUserName' , data . user_name )
74+ commit ( 'setUserName' , data . name )
7575 commit ( 'setUserId' , data . user_id )
7676 commit ( 'setAccess' , data . access )
7777 commit ( 'setHasGetInfo' , true )
Original file line number Diff line number Diff line change 77 </Card >
88 <Card style =" margin-top : 20px ;" >
99 <Row >
10- <i-col span =" 4" >
11- <Button @click =" click" >点击测试触发程序错误</Button >
12- </i-col >
13- <i-col span =" 4" >
14- <Button @click =" ajaxClick" >点击测试触发ajax接口请求错误</Button >
10+ <i-col span =" 8" >
11+ <Button @click =" click" style =" display : block " >点击测试触发程序错误</Button >
12+ <Button @click =" ajaxClick" style =" margin-top :10px ;" >点击测试触发ajax接口请求错误</Button >
1513 </i-col >
1614 <i-col span =" 16" >
1715 ajax接口请求是请求easy-mock的一个不存在接口,所以服务端会报404错误,错误收集机制会收集这个错误,测试的时候有一定网络延迟,所以点击按钮之后稍等一会才会收集到错误。
Original file line number Diff line number Diff line change 11<template >
22 <div >
3- <Table :columns =" columns" :data =" errorList" ></Table >
3+ <Button @click =" exportData" type =" primary" style =" margin : 0 10px 10px 0 ;" >导出日志记录</Button >
4+ <b >注:这里只会显示成功保存到服务端的错误日志,而且页面错误日志不会在浏览器持久化存储,刷新页面即会丢失</b >
5+ <Table ref =" table" :columns =" columns" :data =" errorList" ></Table >
46 </div >
57</template >
68
@@ -68,7 +70,12 @@ export default {
6870 methods: {
6971 ... mapMutations ([
7072 ' setHasReadErrorLoggerStatus'
71- ])
73+ ]),
74+ exportData () {
75+ this .$refs .table .exportCsv ({
76+ filename: ' 错误日志.csv'
77+ })
78+ }
7279 },
7380 activated () {
7481 this .setHasReadErrorLoggerStatus ()
You can’t perform that action at this time.
0 commit comments