mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-06 18:36:55 +08:00
feat: 更新API模型和组件以支持签到排行开关功能
- 在api-models.ts中将SongRequest更改为LiveRequest,并添加CheckInRanking - 更新CheckInSettings.vue以支持签到排行的开关 - 在多个视图中调整签到排行的显示逻辑 - 移除不再使用的allowCheckInRanking字段
This commit is contained in:
@@ -239,7 +239,6 @@ export interface Setting_Point {
|
||||
maxBonusPoints: number // 最大奖励积分
|
||||
allowSelfCheckIn: boolean // 是否允许自己签到
|
||||
requireAuth: boolean // 是否需要认证
|
||||
allowCheckInRanking: boolean // 是否允许查询签到排行
|
||||
}
|
||||
export interface Setting_QuestionDisplay {
|
||||
font?: string // Optional string, with a maximum length of 30 characters
|
||||
@@ -293,10 +292,11 @@ export enum FunctionTypes {
|
||||
SongList,
|
||||
QuestionBox,
|
||||
Schedule,
|
||||
SongRequest,
|
||||
LiveRequest,
|
||||
Queue,
|
||||
Point,
|
||||
VideoCollect
|
||||
VideoCollect,
|
||||
CheckInRanking,
|
||||
}
|
||||
export interface SongAuthorInfo {
|
||||
name: string
|
||||
|
||||
@@ -148,8 +148,8 @@
|
||||
|
||||
<NFormItem label="允许查看签到排行">
|
||||
<NSwitch
|
||||
v-model:value="serverSetting.allowCheckInRanking"
|
||||
@update:value="updateServerSettings"
|
||||
:value="accountInfo.settings.enableFunctions.includes(FunctionTypes.CheckInRanking)"
|
||||
@update:value="updateCheckInRanking"
|
||||
/>
|
||||
<template #feedback>
|
||||
启用后,用户可以查看签到排行榜
|
||||
@@ -381,8 +381,8 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { SaveSetting, useAccount } from '@/api/account';
|
||||
import { CheckInRankingInfo, CheckInResult } from '@/api/api-models';
|
||||
import { SaveEnableFunctions, SaveSetting, useAccount } from '@/api/account';
|
||||
import { CheckInRankingInfo, CheckInResult, FunctionTypes } from '@/api/api-models';
|
||||
import { QueryGetAPI } from '@/api/query';
|
||||
import { useAutoAction } from '@/client/store/useAutoAction';
|
||||
import { CHECKIN_API_URL } from '@/data/constants';
|
||||
@@ -791,6 +791,10 @@ async function handleTestCheckIn() {
|
||||
});
|
||||
}
|
||||
}
|
||||
function updateCheckInRanking(value: boolean) {
|
||||
accountInfo.value.settings.enableFunctions = value ? [...accountInfo.value.settings.enableFunctions, FunctionTypes.CheckInRanking] : accountInfo.value.settings.enableFunctions.filter(f => f !== FunctionTypes.CheckInRanking);
|
||||
SaveEnableFunctions(accountInfo.value.settings.enableFunctions);
|
||||
}
|
||||
|
||||
// 组件挂载时加载排行榜
|
||||
onMounted(() => {
|
||||
|
||||
@@ -156,7 +156,6 @@ function getScoreColor(score: number | undefined): string {
|
||||
lazy
|
||||
/>
|
||||
</NSpace>
|
||||
<NDivider style="margin: 10px 0;" />
|
||||
</template>
|
||||
|
||||
<NText
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
{
|
||||
label: () => h(RouterLink, { to: { name: 'user-checkin' } }, { default: () => '签到排行' }),
|
||||
key: 'user-checkin', icon: renderIcon(CheckmarkCircle24Filled),
|
||||
show: userInfo.value?.extra?.allowCheckInRanking
|
||||
show: userInfo.value?.extra?.enableFunctions.includes(FunctionTypes.CheckInRanking)
|
||||
},
|
||||
].filter(option => option.show !== false) as MenuOption[]; // 过滤掉 show 为 false 的菜单项
|
||||
}
|
||||
|
||||
@@ -633,12 +633,15 @@
|
||||
<NCheckbox :value="FunctionTypes.Schedule">
|
||||
日程
|
||||
</NCheckbox>
|
||||
<NCheckbox :value="FunctionTypes.SongRequest">
|
||||
<NCheckbox :value="FunctionTypes.LiveRequest">
|
||||
点歌
|
||||
</NCheckbox>
|
||||
<NCheckbox :value="FunctionTypes.Queue">
|
||||
排队
|
||||
</NCheckbox>
|
||||
<NCheckbox :value="FunctionTypes.CheckInRanking">
|
||||
签到排行
|
||||
</NCheckbox>
|
||||
</NCheckboxGroup>
|
||||
|
||||
<NDivider> 通知 </NDivider>
|
||||
|
||||
@@ -54,7 +54,6 @@ const defaultSettingPoint: Setting_Point = {
|
||||
maxBonusPoints: 0,
|
||||
allowSelfCheckIn: false,
|
||||
requireAuth: false,
|
||||
allowCheckInRanking: false
|
||||
}
|
||||
|
||||
// 响应式设置对象
|
||||
|
||||
@@ -76,12 +76,12 @@ const props = defineProps<{
|
||||
async function onUpdateFunctionEnable() {
|
||||
if (accountInfo.value.id) {
|
||||
const oldValue = JSON.parse(JSON.stringify(accountInfo.value.settings.enableFunctions))
|
||||
if (accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.SongRequest)) {
|
||||
if (accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.LiveRequest)) {
|
||||
accountInfo.value.settings.enableFunctions = accountInfo.value.settings.enableFunctions.filter(
|
||||
(f) => f != FunctionTypes.SongRequest,
|
||||
(f) => f != FunctionTypes.LiveRequest,
|
||||
)
|
||||
} else {
|
||||
accountInfo.value.settings.enableFunctions.push(FunctionTypes.SongRequest)
|
||||
accountInfo.value.settings.enableFunctions.push(FunctionTypes.LiveRequest)
|
||||
}
|
||||
if (!accountInfo.value.settings.songRequest.orderPrefix) {
|
||||
accountInfo.value.settings.songRequest.orderPrefix = songRequest.defaultPrefix
|
||||
@@ -90,20 +90,20 @@ async function onUpdateFunctionEnable() {
|
||||
.then((data) => {
|
||||
if (data.code == 200) {
|
||||
message.success(
|
||||
`已${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.SongRequest) ? '启用' : '禁用'}点播功能`,
|
||||
`已${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.LiveRequest) ? '启用' : '禁用'}点播功能`,
|
||||
)
|
||||
} else {
|
||||
if (accountInfo.value.id) {
|
||||
accountInfo.value.settings.enableFunctions = oldValue
|
||||
}
|
||||
message.error(
|
||||
`点播功能${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.SongRequest) ? '启用' : '禁用'}失败: ${data.message}`,
|
||||
`点播功能${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.LiveRequest) ? '启用' : '禁用'}失败: ${data.message}`,
|
||||
)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
message.error(
|
||||
`点播功能${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.SongRequest) ? '启用' : '禁用'}失败: ${err}`,
|
||||
`点播功能${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.LiveRequest) ? '启用' : '禁用'}失败: ${err}`,
|
||||
)
|
||||
})
|
||||
}
|
||||
@@ -158,11 +158,11 @@ onUnmounted(() => {
|
||||
<template>
|
||||
<NAlert
|
||||
v-if="accountInfo.id"
|
||||
:type="accountInfo.settings.enableFunctions.includes(FunctionTypes.SongRequest) ? 'success' : 'warning'"
|
||||
:type="accountInfo.settings.enableFunctions.includes(FunctionTypes.LiveRequest) ? 'success' : 'warning'"
|
||||
>
|
||||
启用弹幕点播功能
|
||||
<NSwitch
|
||||
:value="accountInfo?.settings.enableFunctions.includes(FunctionTypes.SongRequest)"
|
||||
:value="accountInfo?.settings.enableFunctions.includes(FunctionTypes.LiveRequest)"
|
||||
@update:value="onUpdateFunctionEnable"
|
||||
/>
|
||||
|
||||
@@ -215,7 +215,7 @@ onUnmounted(() => {
|
||||
<br>
|
||||
<NCard>
|
||||
<NTabs
|
||||
v-if="!accountInfo || accountInfo.settings.enableFunctions.includes(FunctionTypes.SongRequest)"
|
||||
v-if="!accountInfo || accountInfo.settings.enableFunctions.includes(FunctionTypes.LiveRequest)"
|
||||
animated
|
||||
display-directive="show:lazy"
|
||||
>
|
||||
|
||||
@@ -24,7 +24,7 @@ const message = useMessage()
|
||||
|
||||
const enableSongRequest = computed({
|
||||
get: () => {
|
||||
return accountInfo.value?.settings?.enableFunctions?.includes(FunctionTypes.SongRequest) || false
|
||||
return accountInfo.value?.settings?.enableFunctions?.includes(FunctionTypes.LiveRequest) || false
|
||||
},
|
||||
set: async () => {
|
||||
await updateEnableFunctions()
|
||||
@@ -35,12 +35,12 @@ const enableSongRequest = computed({
|
||||
async function updateEnableFunctions() {
|
||||
if (accountInfo.value.id) {
|
||||
const oldValue = JSON.parse(JSON.stringify(accountInfo.value.settings.enableFunctions))
|
||||
if (accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.SongRequest)) {
|
||||
if (accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.LiveRequest)) {
|
||||
accountInfo.value.settings.enableFunctions = accountInfo.value.settings.enableFunctions.filter(
|
||||
(f: number) => f != FunctionTypes.SongRequest,
|
||||
(f: number) => f != FunctionTypes.LiveRequest,
|
||||
)
|
||||
} else {
|
||||
accountInfo.value.settings.enableFunctions.push(FunctionTypes.SongRequest)
|
||||
accountInfo.value.settings.enableFunctions.push(FunctionTypes.LiveRequest)
|
||||
}
|
||||
if (!accountInfo.value.settings.songRequest.orderPrefix) {
|
||||
accountInfo.value.settings.songRequest.orderPrefix = liveRequest.defaultPrefix
|
||||
@@ -49,20 +49,20 @@ async function updateEnableFunctions() {
|
||||
.then((data) => {
|
||||
if (data.code == 200) {
|
||||
message.success(
|
||||
`已${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.SongRequest) ? '启用' : '禁用'}点播功能`,
|
||||
`已${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.LiveRequest) ? '启用' : '禁用'}点播功能`,
|
||||
)
|
||||
} else {
|
||||
if (accountInfo.value.id) {
|
||||
accountInfo.value.settings.enableFunctions = oldValue
|
||||
}
|
||||
message.error(
|
||||
`点播功能${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.SongRequest) ? '启用' : '禁用'}失败: ${data.message}`,
|
||||
`点播功能${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.LiveRequest) ? '启用' : '禁用'}失败: ${data.message}`,
|
||||
)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
message.error(
|
||||
`点播功能${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.SongRequest) ? '启用' : '禁用'}失败: ${err}`,
|
||||
`点播功能${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.LiveRequest) ? '启用' : '禁用'}失败: ${err}`,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ function loadMore() {
|
||||
clearable
|
||||
/>
|
||||
<NDivider />
|
||||
<LiveRequestOBS v-if="userInfo?.extra?.enableFunctions.includes(FunctionTypes.SongRequest)" />
|
||||
<LiveRequestOBS v-if="userInfo?.extra?.enableFunctions.includes(FunctionTypes.LiveRequest)" />
|
||||
</NSpace>
|
||||
</NCard>
|
||||
<NEmpty
|
||||
|
||||
Reference in New Issue
Block a user