diff --git a/frontend/src/components/BanRecordCard.vue b/frontend/src/components/BanRecordCard.vue new file mode 100644 index 0000000..1287ff9 --- /dev/null +++ b/frontend/src/components/BanRecordCard.vue @@ -0,0 +1,73 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/pages/admin.vue b/frontend/src/pages/admin.vue index e890fad..9be4f04 100644 --- a/frontend/src/pages/admin.vue +++ b/frontend/src/pages/admin.vue @@ -44,6 +44,7 @@ 🪪 账号 + 🚫 封禁记录 @@ -77,6 +78,30 @@ + +
+ +
+
+ + + + + 查找 +
+
+ + +
+ +
+
+
import BottomNavBar from '@/components/BottomNavBar.vue'; import AccountCard from '@/components/AccountCard.vue'; +import BanRecordCard from '@/components/BanRecordCard.vue'; export default { components: { @@ -133,6 +159,25 @@ export default { page_size: 10 }, accountPages: 1, + banListFilter: { + uin: -1, + only_valid: true, + page: 1, + page_size: 10, + time_order: -1 + }, + banRecords: [], + banPages: 1 + } + }, + + watch: { + tab() { + if (this.tab === '1') { + this.getAccounts() + } else if (this.tab === '2') { + this.getBanList() + } } }, @@ -209,7 +254,7 @@ export default { if (res.data.code === 0) { this.accounts = res.data.data.list - for (let i = 0; i < this.accounts.length; i++) { + for (let i = 0; this.accounts!=null && i < this.accounts.length; i++) { let date = new Date(this.accounts[i].created_at) this.accounts[i].created_at = date.toLocaleString() @@ -262,6 +307,59 @@ export default { this.toast('封禁失败:' + err) console.error(err) }) + }, + + + getBanList() { + + if (this.banListFilter.uin === '') { + this.banListFilter.uin = -1 + } else { + this.banListFilter.uin = parseInt(this.banListFilter.uin) + } + this.$axios.post('/v1/account/get-ban-list', this.banListFilter) + .then(res => { + if (res.data.code === 0) { + this.banRecords = res.data.data.list + + let now = new Date() + + for (let i = 0; this.banRecords != null && i < this.banRecords.length; i++) { + let startDateTime = new Date(this.banRecords[i].start_time) + let endDateTime = new Date(this.banRecords[i].end_time) + + this.banRecords[i].start_time = startDateTime.toLocaleString() + this.banRecords[i].end_time = endDateTime.toLocaleString() + this.banRecords[i].valid = endDateTime > now + } + + this.banPages = Math.ceil(res.data.data.total / this.banListFilter.page_size) + } else { + this.toast('获取封禁列表失败:' + res.data.msg) + } + }) + .catch(err => { + this.toast('获取封禁列表失败:' + err) + console.error(err) + }) + }, + + unban(uin) { + this.$axios.put('/v1/account/unban-account', { + uin: uin + }) + .then(res => { + if (res.data.code === 0) { + this.toast('解封成功', 'success') + this.getBanList() + } else { + this.toast('解封失败:' + res.data.msg) + } + }) + .catch(err => { + this.toast('解封失败:' + err) + console.error(err) + }) } }