Skip to content

Commit

Permalink
管理端支持拉黑上传ip;管理端批量操作支持按照用户选择的顺序进行;random接口优化
Browse files Browse the repository at this point in the history
  • Loading branch information
MarSeventh committed Dec 20, 2024
1 parent 397facf commit 6a151ad
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/UploadForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</el-icon>
<div class="el-upload__text"><em>拖拽</em> <em>点击</em> 或 <em>Ctrl + V</em> 粘贴上传</div>
<template #tip>
<div class="el-upload__tip">支持多文件上传,支持大多数常见文件格式,Telegram渠道不支持超过20MB</div>
<div class="el-upload__tip">支持多文件上传,支持所有常见文件格式,Telegram渠道不支持超过20MB</div>
</template>
</el-upload>
<el-card class="upload-list-card" :class="{'upload-list-busy': fileList.length}">
Expand Down
5 changes: 4 additions & 1 deletion src/views/AdminDashBoard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,10 @@ computed: {
watch: {
tableData: {
handler(newData) {
this.selectedFiles = newData.filter(file => file.selected);
// selectedFiles 增加 newData中新选中,不包含在 selectedFiles 中的文件
this.selectedFiles = this.selectedFiles.concat(newData.filter(file => file.selected && !this.selectedFiles.includes(file)));
// selectedFiles 删掉 newData 中已取消选中的文件
this.selectedFiles = this.selectedFiles.filter(file => file.selected);
},
deep: true
},
Expand Down
45 changes: 43 additions & 2 deletions src/views/CustomerConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@
</el-table-column>
<el-table-column prop="ip" label="IP地址"></el-table-column>
<el-table-column prop="count" label="上传次数" sortable></el-table-column>
<el-table-column label="允许上传">
<template v-slot="{ row }">
<el-switch
v-model="row.enable"
active-color="#13ce66"
inactive-color="#ff4949"
active-text="允许"
inactive-text="禁止"
@change="handleSwitchEnable(row)"
>
</el-switch>
</template>
</el-table-column>
</el-table>
</div>
</div>
Expand All @@ -60,6 +73,7 @@ export default {
return {
tableData: [],
dealedData: [], // 根据IP地址处理后的数据,格式为 {ip, count, [data]}
blockipList: [], // 禁止上传的IP列表
}
},
computed: {
Expand Down Expand Up @@ -104,7 +118,8 @@ export default {
ipSet.forEach(ip => {
let ipData = data.filter(item => item.metadata?.UploadIP === ip);
let count = ipData.length;
dealedData.push({ip, count, data: ipData});
let enable = !this.blockipList.includes(ip);
dealedData.push({ip, count, data: ipData, enable});
});
return dealedData;
},
Expand All @@ -123,6 +138,27 @@ export default {
},
sortByTimestamp(a, b) {
return new Date(a.metadata.TimeStamp) - new Date(b.metadata.TimeStamp);
},
async handleSwitchEnable(row) {
const ip = row.ip;
const enable = row.enable;
if (enable) {
// 从 blockipList 中移除
this.blockipList = this.blockipList.filter(item => item !== ip);
// 更新 blockipList
await this.fetchWithAuth("/api/manage/cusConfig/whiteip", {
method: 'POST',
body: ip
});
} else {
// 添加到 blockipList 中
this.blockipList.push(ip);
// 更新 blockipList
await this.fetchWithAuth("/api/manage/cusConfig/blockip", {
method: 'POST',
body: ip
});
}
}
},
mounted() {
Expand All @@ -140,7 +176,10 @@ export default {
}
})
.then(response => response.json())
.then(result => {
.then(async result => {
// 读取blockipList, 接口返回格式为 'ip1,ip2,ip3',需要转换为数组
const blockipList = await this.fetchWithAuth("/api/manage/cusConfig/blockipList", { method: 'GET' });
this.blockipList = (await blockipList.text()).split(',');
this.tableData = result;
this.dealedData = this.dealByIP(result); // 根据IP地址处理数据
})
Expand All @@ -156,6 +195,8 @@ export default {
<style scoped>
.main-table {
width: 90%;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.container {
Expand Down
2 changes: 1 addition & 1 deletion src/views/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default {
} else {
this.writtenPass = this.password
}
axios.post('/login', {
axios.post('/api/login', {
authCode: this.password
}).then(res => {
if (res.status !== 200) {
Expand Down

0 comments on commit 6a151ad

Please sign in to comment.