mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-06 18:36:55 +08:00
add allow anonymous user add liverequest
This commit is contained in:
@@ -35,6 +35,8 @@ import { NButton, NCard, NDivider, NLayoutContent, NSpace, NText, NTimeline, NTi
|
||||
height="200" frameborder="0"></iframe>
|
||||
<NDivider title-placement="left"> 更新日志 </NDivider>
|
||||
<NTimeline>
|
||||
<NTimelineItem type="info" title="功能添加" content="点歌允许从网页匿名点歌" time="2025-3-18" />
|
||||
<NTimelineItem type="success" title="功能添加" content="棉花糖添加内容审查功能" time="2025-3-2" />
|
||||
<NTimelineItem type="info" title="功能更新" content="允许棉花糖设置页滚动条进度同步到obs组件" time="2024-11-23" />
|
||||
<NTimelineItem type="info" title="功能更新" content="礼物兑换允许上舰用户免费兑换, 以及仅允许上舰用户兑换" time="2024-4-23" />
|
||||
<NTimelineItem type="info" title="功能更新" content="积分订单添加导出功能, 允许删除积分用户" time="2024-3-22" />
|
||||
|
||||
@@ -1203,6 +1203,10 @@ onUnmounted(() => {
|
||||
:disabled="!configCanEdit">
|
||||
允许通过网页点歌
|
||||
</NCheckbox>
|
||||
<NCheckbox v-if="settings.allowFromWeb" v-model:checked="settings.allowAnonymousFromWeb" @update:checked="updateSettings"
|
||||
:disabled="!configCanEdit">
|
||||
允许匿名通过网页点歌
|
||||
</NCheckbox>
|
||||
</NSpace>
|
||||
<NDivider> 冷却 (单位: 秒) </NDivider>
|
||||
<NCheckbox v-model:checked="settings.enableCooldown" @update:checked="updateSettings"
|
||||
|
||||
@@ -12,10 +12,15 @@ import { Setting_LiveRequest, SongRequestInfo, SongsInfo, UserInfo } from '@/api
|
||||
import { QueryGetAPI, QueryPostAPIWithParams } from '@/api/query'
|
||||
import { TemplateConfig } from '@/data/VTsuruTypes'
|
||||
import { SONG_API_URL, SONG_REQUEST_API_URL, SongListTemplateMap, VTSURU_API_URL } from '@/data/constants'
|
||||
import { useStorage } from '@vueuse/core'
|
||||
import { addSeconds } from 'date-fns'
|
||||
import { NSpin, useMessage } from 'naive-ui'
|
||||
import { computed, onMounted, ref, watch, watchEffect } from 'vue'
|
||||
|
||||
const accountInfo = useAccount()
|
||||
const nextRequestTime = useStorage('SongList.NextRequestTime', new Date())
|
||||
|
||||
const minRequestTime = 30
|
||||
|
||||
const props = defineProps<{
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
@@ -104,15 +109,22 @@ async function getConfig() {
|
||||
})
|
||||
}
|
||||
async function requestSong(song: SongsInfo) {
|
||||
if (song.options || !settings.value.allowFromWeb) {
|
||||
if (song.options || !settings.value.allowFromWeb || (settings.value.allowFromWeb && !settings.value.allowAnonymousFromWeb)) {
|
||||
navigator.clipboard.writeText(`${settings.value.orderPrefix} ${song.name}`)
|
||||
if (!accountInfo.value) {
|
||||
if (!settings.value.allowAnonymousFromWeb) {
|
||||
message.warning('主播不允许匿名点歌, 需要从网页点歌的话请注册登录, 点歌弹幕已复制到剪切板')
|
||||
}
|
||||
else if (!accountInfo.value.id) {
|
||||
message.warning('要从网页点歌请先登录, 点歌弹幕已复制到剪切板')
|
||||
} else {
|
||||
message.success('复制成功')
|
||||
}
|
||||
} else {
|
||||
if (props.userInfo) {
|
||||
if (!accountInfo.value.id && nextRequestTime.value > new Date()) {
|
||||
message.warning('距离点歌冷却还有' + (nextRequestTime.value.getTime() - new Date().getTime()) / 1000 + '秒')
|
||||
return
|
||||
}
|
||||
try {
|
||||
const data = await QueryPostAPIWithParams(SONG_REQUEST_API_URL + 'add-from-web', {
|
||||
target: props.userInfo?.id,
|
||||
@@ -121,6 +133,7 @@ async function requestSong(song: SongsInfo) {
|
||||
|
||||
if (data.code == 200) {
|
||||
message.success('点歌成功')
|
||||
nextRequestTime.value = addSeconds(new Date(), minRequestTime)
|
||||
} else {
|
||||
message.error('点歌失败: ' + data.message)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user