fix blacklist display

This commit is contained in:
2024-04-27 12:00:40 +08:00
parent 935384c4e6
commit 76e4f473e9
3 changed files with 38 additions and 3 deletions

View File

@@ -140,6 +140,11 @@ export async function DelBiliBlackList(id: number): Promise<APIRoot<unknown>> {
id: id, id: id,
}) })
} }
export async function DelBlackList(id: number): Promise<APIRoot<unknown>> {
return QueryGetAPI<AccountInfo>(`${ACCOUNT_API_URL}black-list/del`, {
id: id,
})
}
export function downloadConfigDirect(name: string) { export function downloadConfigDirect(name: string) {
return QueryGetAPI<string>(VTSURU_API_URL + 'get-config', { return QueryGetAPI<string>(VTSURU_API_URL + 'get-config', {
name: name, name: name,

View File

@@ -67,7 +67,7 @@ export interface AccountInfo extends UserInfo {
nextSendEmailTime?: number nextSendEmailTime?: number
isServerFetcherOnline: boolean isServerFetcherOnline: boolean
blackList: number[] blackList: UserBasicInfo[]
biliBlackList: { [key: number]: string } biliBlackList: { [key: number]: string }
streamerInfo?: StreamerModel streamerInfo?: StreamerModel
biliUserAuthInfo?: BiliAuthModel biliUserAuthInfo?: BiliAuthModel

View File

@@ -1,6 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { import {
DelBiliBlackList, DelBiliBlackList,
DelBlackList,
SaveAccountSettings, SaveAccountSettings,
SaveEnableFunctions, SaveEnableFunctions,
downloadConfigDirect, downloadConfigDirect,
@@ -461,7 +462,7 @@ const buttonGroup = computed(() => {
]) ])
}) })
function unblockUser(id: number) { function unblockBiliUser(id: number) {
DelBiliBlackList(id) DelBiliBlackList(id)
.then((data) => { .then((data) => {
if (data.code == 200) { if (data.code == 200) {
@@ -477,6 +478,22 @@ function unblockUser(id: number) {
message.error(err) message.error(err)
}) })
} }
function unblockUser(id: number) {
DelBlackList(id)
.then((data) => {
if (data.code == 200) {
message.success(`[${id}] 已移除黑名单`)
if (accountInfo.value) {
accountInfo.value.blackList = accountInfo.value.blackList.filter((u) => u.id != id)
}
} else {
message.error(data.message)
}
})
.catch((err) => {
message.error(err)
})
}
async function getIndexInfo() { async function getIndexInfo() {
try { try {
isLoading.value = true isLoading.value = true
@@ -608,7 +625,20 @@ onMounted(async () => {
<NText depth="3"> <NText depth="3">
{{ item[0] }} {{ item[0] }}
</NText> </NText>
<NButton type="error" @click="unblockUser(Number(item[0]))" size="small"> 移除 </NButton> <NButton type="error" @click="unblockBiliUser(Number(item[0]))" size="small"> 移除 </NButton>
</NSpace>
</NListItem>
</NList>
<NList v-if="accountInfo.blackList && accountInfo.blackList.length > 0">
<NListItem v-for="item in accountInfo.blackList" :key="item.id">
<NSpace align="center">
<NText>
{{ item.name }}
</NText>
<NText depth="3">
{{ item.id }}
</NText>
<NButton type="error" @click="unblockUser(Number(item.id))" size="small"> 移除 </NButton>
</NSpace> </NSpace>
</NListItem> </NListItem>
</NList> </NList>