node.vue 1.29 KB
<template>
    <div>
        <Table highlight-row ref="currentRowTable" :columns="columns" :data="logs"></Table>
    </div>
</template>

<script>
    import {LogService} from '../../js/services/logs';

    export default {
        data() {
            return {
                columns: [
                    {
                        title: 'topic_name',
                        key: 'topic_name'
                    },
                    {
                        title: 'topic_id',
                        key: 'topic_id'
                    },
                    {
                        title: '级别',
                        key: 'level'
                    },
                    {
                        title: '内容',
                        key: 'message'
                    },
                    {
                        title: '时间',
                        key: 'timestamp'
                    }
                ],
                logs: []
            }
        },
        methods: {
            searchLog() {
                this.logService.getLogs({limit: 20}).then(res => {
                    this.logs = res.results;
                });
            }
        },
        created() {
            this.logService = new LogService();
            this.searchLog();
        }
    }
</script>