Skip to content

Commit 7da4d68

Browse files
authored
optimize(book): handle no data situation (#154)
1 parent 13ebdac commit 7da4d68

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/config/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const Config = {
2-
baseUrl: 'http://localhost:5000/',
2+
baseUrl: 'http://dev.koa.7yue.pro/',
33
stagnateTime: 1 * 60 * 60 * 1000, // 无操作停滞时间 默认1小时
44
openAutoJumpOut: true, // 是否开启无操作跳出
55
notLoginRoute: ['login'], // 无需登录即可访问的路由 name,

src/views/book/BookList.vue

+12-4
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,23 @@ export default {
4545
this.loading = true
4646
this.getBooks()
4747
this.operate = [{ name: '编辑', func: 'handleEdit', type: 'primary' }, {
48-
name: '删除', func: 'handleDelete', type: 'danger', auth: '删除图书',
48+
name: '删除',
49+
func: 'handleDelete',
50+
type: 'danger',
51+
auth: '删除图书',
4952
}]
5053
this.loading = false
5154
},
5255
methods: {
5356
async getBooks() {
54-
const books = await book.getBooks()
55-
this.tableData = books
57+
try {
58+
const books = await book.getBooks()
59+
this.tableData = books
60+
} catch (error) {
61+
if (error.error_code === 10020) {
62+
this.tableData = []
63+
}
64+
}
5665
},
5766
handleEdit(val) {
5867
console.log('val', val)
@@ -87,7 +96,6 @@ export default {
8796
</script>
8897

8998
<style lang="scss" scoped>
90-
9199
.container {
92100
padding: 0 30px;
93101

0 commit comments

Comments
 (0)