vben
authored
|
1
2
|
<template>
<div class="p-4">
|
vben
authored
|
3
|
<template v-for="src in imgList" :key="src">
|
|
4
|
<img :src="src" v-show="false" alt="" />
|
vben
authored
|
5
|
</template>
|
vben
authored
|
6
|
<DetailModal :info="rowInfo" @register="registerModal" />
|
vben
authored
|
7
8
|
<BasicTable @register="register" class="error-handle-table">
<template #toolbar>
|
vben
authored
|
9
10
11
12
13
14
15
16
17
|
<a-button @click="fireVueError" type="primary">
{{ t('sys.errorLog.fireVueError') }}
</a-button>
<a-button @click="fireResourceError" type="primary">
{{ t('sys.errorLog.fireResourceError') }}
</a-button>
<a-button @click="fireAjaxError" type="primary">
{{ t('sys.errorLog.fireAjaxError') }}
</a-button>
|
vben
authored
|
18
|
</template>
|
|
19
20
21
22
23
24
25
26
27
28
29
|
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{
label: t('sys.errorLog.tableActionDesc'),
onClick: handleDetail.bind(null, record),
},
]"
/>
</template>
|
vben
authored
|
30
31
32
33
34
|
</template>
</BasicTable>
</div>
</template>
|
vben
authored
|
35
|
<script lang="ts" setup>
|
Vben
authored
|
36
|
import type { ErrorLogInfo } from '/#/store';
|
vben
authored
|
37
|
import { watch, ref, nextTick } from 'vue';
|
vben
authored
|
38
|
import DetailModal from './DetailModal.vue';
|
vben
authored
|
39
|
import { BasicTable, useTable, TableAction } from '/@/components/Table/index';
|
|
40
|
import { useModal } from '/@/components/Modal';
|
vben
authored
|
41
|
import { useMessage } from '/@/hooks/web/useMessage';
|
vben
authored
|
42
|
import { useI18n } from '/@/hooks/web/useI18n';
|
Vben
authored
|
43
|
import { useErrorLogStore } from '/@/store/modules/errorLog';
|
vben
authored
|
44
45
46
47
|
import { fireErrorApi } from '/@/api/demo/error';
import { getColumns } from './data';
import { cloneDeep } from 'lodash-es';
|
vben
authored
|
48
49
|
const rowInfo = ref<ErrorLogInfo>();
const imgList = ref<string[]>([]);
|
vben
authored
|
50
|
|
vben
authored
|
51
52
53
54
55
56
57
58
59
|
const { t } = useI18n();
const errorLogStore = useErrorLogStore();
const [register, { setTableData }] = useTable({
title: t('sys.errorLog.tableTitle'),
columns: getColumns(),
actionColumn: {
width: 80,
title: 'Action',
dataIndex: 'action',
|
|
60
|
// slots: { customRender: 'action' },
|
vben
authored
|
61
62
63
|
},
});
const [registerModal, { openModal }] = useModal();
|
vben
authored
|
64
|
|
vben
authored
|
65
66
67
68
69
70
71
72
73
|
watch(
() => errorLogStore.getErrorLogInfoList,
(list) => {
nextTick(() => {
setTableData(cloneDeep(list));
});
},
{
immediate: true,
|
vben
authored
|
74
|
},
|
vben
authored
|
75
76
77
78
79
80
81
82
83
84
|
);
const { createMessage } = useMessage();
if (import.meta.env.DEV) {
createMessage.info(t('sys.errorLog.enableMessage'));
}
// 查看详情
function handleDetail(row: ErrorLogInfo) {
rowInfo.value = row;
openModal(true);
}
|
vben
authored
|
85
|
|
vben
authored
|
86
87
88
|
function fireVueError() {
throw new Error('fire vue error!');
}
|
vben
authored
|
89
|
|
vben
authored
|
90
91
92
|
function fireResourceError() {
imgList.value.push(`${new Date().getTime()}.png`);
}
|
vben
authored
|
93
|
|
vben
authored
|
94
95
96
|
async function fireAjaxError() {
await fireErrorApi();
}
|
vben
authored
|
97
|
</script>
|