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 // 最大奖励积分
|
maxBonusPoints: number // 最大奖励积分
|
||||||
allowSelfCheckIn: boolean // 是否允许自己签到
|
allowSelfCheckIn: boolean // 是否允许自己签到
|
||||||
requireAuth: boolean // 是否需要认证
|
requireAuth: boolean // 是否需要认证
|
||||||
allowCheckInRanking: boolean // 是否允许查询签到排行
|
|
||||||
}
|
}
|
||||||
export interface Setting_QuestionDisplay {
|
export interface Setting_QuestionDisplay {
|
||||||
font?: string // Optional string, with a maximum length of 30 characters
|
font?: string // Optional string, with a maximum length of 30 characters
|
||||||
@@ -293,10 +292,11 @@ export enum FunctionTypes {
|
|||||||
SongList,
|
SongList,
|
||||||
QuestionBox,
|
QuestionBox,
|
||||||
Schedule,
|
Schedule,
|
||||||
SongRequest,
|
LiveRequest,
|
||||||
Queue,
|
Queue,
|
||||||
Point,
|
Point,
|
||||||
VideoCollect
|
VideoCollect,
|
||||||
|
CheckInRanking,
|
||||||
}
|
}
|
||||||
export interface SongAuthorInfo {
|
export interface SongAuthorInfo {
|
||||||
name: string
|
name: string
|
||||||
|
|||||||
@@ -148,8 +148,8 @@
|
|||||||
|
|
||||||
<NFormItem label="允许查看签到排行">
|
<NFormItem label="允许查看签到排行">
|
||||||
<NSwitch
|
<NSwitch
|
||||||
v-model:value="serverSetting.allowCheckInRanking"
|
:value="accountInfo.settings.enableFunctions.includes(FunctionTypes.CheckInRanking)"
|
||||||
@update:value="updateServerSettings"
|
@update:value="updateCheckInRanking"
|
||||||
/>
|
/>
|
||||||
<template #feedback>
|
<template #feedback>
|
||||||
启用后,用户可以查看签到排行榜
|
启用后,用户可以查看签到排行榜
|
||||||
@@ -381,8 +381,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { SaveSetting, useAccount } from '@/api/account';
|
import { SaveEnableFunctions, SaveSetting, useAccount } from '@/api/account';
|
||||||
import { CheckInRankingInfo, CheckInResult } from '@/api/api-models';
|
import { CheckInRankingInfo, CheckInResult, FunctionTypes } from '@/api/api-models';
|
||||||
import { QueryGetAPI } from '@/api/query';
|
import { QueryGetAPI } from '@/api/query';
|
||||||
import { useAutoAction } from '@/client/store/useAutoAction';
|
import { useAutoAction } from '@/client/store/useAutoAction';
|
||||||
import { CHECKIN_API_URL } from '@/data/constants';
|
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(() => {
|
onMounted(() => {
|
||||||
|
|||||||
@@ -156,7 +156,6 @@ function getScoreColor(score: number | undefined): string {
|
|||||||
lazy
|
lazy
|
||||||
/>
|
/>
|
||||||
</NSpace>
|
</NSpace>
|
||||||
<NDivider style="margin: 10px 0;" />
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<NText
|
<NText
|
||||||
|
|||||||
@@ -121,7 +121,7 @@
|
|||||||
{
|
{
|
||||||
label: () => h(RouterLink, { to: { name: 'user-checkin' } }, { default: () => '签到排行' }),
|
label: () => h(RouterLink, { to: { name: 'user-checkin' } }, { default: () => '签到排行' }),
|
||||||
key: 'user-checkin', icon: renderIcon(CheckmarkCircle24Filled),
|
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 的菜单项
|
].filter(option => option.show !== false) as MenuOption[]; // 过滤掉 show 为 false 的菜单项
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -633,12 +633,15 @@
|
|||||||
<NCheckbox :value="FunctionTypes.Schedule">
|
<NCheckbox :value="FunctionTypes.Schedule">
|
||||||
日程
|
日程
|
||||||
</NCheckbox>
|
</NCheckbox>
|
||||||
<NCheckbox :value="FunctionTypes.SongRequest">
|
<NCheckbox :value="FunctionTypes.LiveRequest">
|
||||||
点歌
|
点歌
|
||||||
</NCheckbox>
|
</NCheckbox>
|
||||||
<NCheckbox :value="FunctionTypes.Queue">
|
<NCheckbox :value="FunctionTypes.Queue">
|
||||||
排队
|
排队
|
||||||
</NCheckbox>
|
</NCheckbox>
|
||||||
|
<NCheckbox :value="FunctionTypes.CheckInRanking">
|
||||||
|
签到排行
|
||||||
|
</NCheckbox>
|
||||||
</NCheckboxGroup>
|
</NCheckboxGroup>
|
||||||
|
|
||||||
<NDivider> 通知 </NDivider>
|
<NDivider> 通知 </NDivider>
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ const defaultSettingPoint: Setting_Point = {
|
|||||||
maxBonusPoints: 0,
|
maxBonusPoints: 0,
|
||||||
allowSelfCheckIn: false,
|
allowSelfCheckIn: false,
|
||||||
requireAuth: false,
|
requireAuth: false,
|
||||||
allowCheckInRanking: false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 响应式设置对象
|
// 响应式设置对象
|
||||||
|
|||||||
@@ -76,12 +76,12 @@ const props = defineProps<{
|
|||||||
async function onUpdateFunctionEnable() {
|
async function onUpdateFunctionEnable() {
|
||||||
if (accountInfo.value.id) {
|
if (accountInfo.value.id) {
|
||||||
const oldValue = JSON.parse(JSON.stringify(accountInfo.value.settings.enableFunctions))
|
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(
|
accountInfo.value.settings.enableFunctions = accountInfo.value.settings.enableFunctions.filter(
|
||||||
(f) => f != FunctionTypes.SongRequest,
|
(f) => f != FunctionTypes.LiveRequest,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
accountInfo.value.settings.enableFunctions.push(FunctionTypes.SongRequest)
|
accountInfo.value.settings.enableFunctions.push(FunctionTypes.LiveRequest)
|
||||||
}
|
}
|
||||||
if (!accountInfo.value.settings.songRequest.orderPrefix) {
|
if (!accountInfo.value.settings.songRequest.orderPrefix) {
|
||||||
accountInfo.value.settings.songRequest.orderPrefix = songRequest.defaultPrefix
|
accountInfo.value.settings.songRequest.orderPrefix = songRequest.defaultPrefix
|
||||||
@@ -90,20 +90,20 @@ async function onUpdateFunctionEnable() {
|
|||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (data.code == 200) {
|
if (data.code == 200) {
|
||||||
message.success(
|
message.success(
|
||||||
`已${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.SongRequest) ? '启用' : '禁用'}点播功能`,
|
`已${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.LiveRequest) ? '启用' : '禁用'}点播功能`,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
if (accountInfo.value.id) {
|
if (accountInfo.value.id) {
|
||||||
accountInfo.value.settings.enableFunctions = oldValue
|
accountInfo.value.settings.enableFunctions = oldValue
|
||||||
}
|
}
|
||||||
message.error(
|
message.error(
|
||||||
`点播功能${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.SongRequest) ? '启用' : '禁用'}失败: ${data.message}`,
|
`点播功能${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.LiveRequest) ? '启用' : '禁用'}失败: ${data.message}`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
message.error(
|
message.error(
|
||||||
`点播功能${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.SongRequest) ? '启用' : '禁用'}失败: ${err}`,
|
`点播功能${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.LiveRequest) ? '启用' : '禁用'}失败: ${err}`,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -158,11 +158,11 @@ onUnmounted(() => {
|
|||||||
<template>
|
<template>
|
||||||
<NAlert
|
<NAlert
|
||||||
v-if="accountInfo.id"
|
v-if="accountInfo.id"
|
||||||
:type="accountInfo.settings.enableFunctions.includes(FunctionTypes.SongRequest) ? 'success' : 'warning'"
|
:type="accountInfo.settings.enableFunctions.includes(FunctionTypes.LiveRequest) ? 'success' : 'warning'"
|
||||||
>
|
>
|
||||||
启用弹幕点播功能
|
启用弹幕点播功能
|
||||||
<NSwitch
|
<NSwitch
|
||||||
:value="accountInfo?.settings.enableFunctions.includes(FunctionTypes.SongRequest)"
|
:value="accountInfo?.settings.enableFunctions.includes(FunctionTypes.LiveRequest)"
|
||||||
@update:value="onUpdateFunctionEnable"
|
@update:value="onUpdateFunctionEnable"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -215,7 +215,7 @@ onUnmounted(() => {
|
|||||||
<br>
|
<br>
|
||||||
<NCard>
|
<NCard>
|
||||||
<NTabs
|
<NTabs
|
||||||
v-if="!accountInfo || accountInfo.settings.enableFunctions.includes(FunctionTypes.SongRequest)"
|
v-if="!accountInfo || accountInfo.settings.enableFunctions.includes(FunctionTypes.LiveRequest)"
|
||||||
animated
|
animated
|
||||||
display-directive="show:lazy"
|
display-directive="show:lazy"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ const message = useMessage()
|
|||||||
|
|
||||||
const enableSongRequest = computed({
|
const enableSongRequest = computed({
|
||||||
get: () => {
|
get: () => {
|
||||||
return accountInfo.value?.settings?.enableFunctions?.includes(FunctionTypes.SongRequest) || false
|
return accountInfo.value?.settings?.enableFunctions?.includes(FunctionTypes.LiveRequest) || false
|
||||||
},
|
},
|
||||||
set: async () => {
|
set: async () => {
|
||||||
await updateEnableFunctions()
|
await updateEnableFunctions()
|
||||||
@@ -35,12 +35,12 @@ const enableSongRequest = computed({
|
|||||||
async function updateEnableFunctions() {
|
async function updateEnableFunctions() {
|
||||||
if (accountInfo.value.id) {
|
if (accountInfo.value.id) {
|
||||||
const oldValue = JSON.parse(JSON.stringify(accountInfo.value.settings.enableFunctions))
|
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(
|
accountInfo.value.settings.enableFunctions = accountInfo.value.settings.enableFunctions.filter(
|
||||||
(f: number) => f != FunctionTypes.SongRequest,
|
(f: number) => f != FunctionTypes.LiveRequest,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
accountInfo.value.settings.enableFunctions.push(FunctionTypes.SongRequest)
|
accountInfo.value.settings.enableFunctions.push(FunctionTypes.LiveRequest)
|
||||||
}
|
}
|
||||||
if (!accountInfo.value.settings.songRequest.orderPrefix) {
|
if (!accountInfo.value.settings.songRequest.orderPrefix) {
|
||||||
accountInfo.value.settings.songRequest.orderPrefix = liveRequest.defaultPrefix
|
accountInfo.value.settings.songRequest.orderPrefix = liveRequest.defaultPrefix
|
||||||
@@ -49,20 +49,20 @@ async function updateEnableFunctions() {
|
|||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (data.code == 200) {
|
if (data.code == 200) {
|
||||||
message.success(
|
message.success(
|
||||||
`已${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.SongRequest) ? '启用' : '禁用'}点播功能`,
|
`已${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.LiveRequest) ? '启用' : '禁用'}点播功能`,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
if (accountInfo.value.id) {
|
if (accountInfo.value.id) {
|
||||||
accountInfo.value.settings.enableFunctions = oldValue
|
accountInfo.value.settings.enableFunctions = oldValue
|
||||||
}
|
}
|
||||||
message.error(
|
message.error(
|
||||||
`点播功能${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.SongRequest) ? '启用' : '禁用'}失败: ${data.message}`,
|
`点播功能${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.LiveRequest) ? '启用' : '禁用'}失败: ${data.message}`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
message.error(
|
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
|
clearable
|
||||||
/>
|
/>
|
||||||
<NDivider />
|
<NDivider />
|
||||||
<LiveRequestOBS v-if="userInfo?.extra?.enableFunctions.includes(FunctionTypes.SongRequest)" />
|
<LiveRequestOBS v-if="userInfo?.extra?.enableFunctions.includes(FunctionTypes.LiveRequest)" />
|
||||||
</NSpace>
|
</NSpace>
|
||||||
</NCard>
|
</NCard>
|
||||||
<NEmpty
|
<NEmpty
|
||||||
|
|||||||
Reference in New Issue
Block a user