mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-07 02:46:55 +08:00
update songrequest settings
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useAccount } from '@/api/account'
|
import { useAccount } from '@/api/account'
|
||||||
import DanmakuClient from '@/data/DanmakuClient'
|
import DanmakuClient from '@/data/DanmakuClient'
|
||||||
import { onMounted, onUnmounted } from 'vue'
|
import { onActivated, onDeactivated, onMounted, onUnmounted } from 'vue'
|
||||||
import MusicRequest from '../open_live/MusicRequest.vue'
|
import MusicRequest from '../open_live/MusicRequest.vue'
|
||||||
import { NAlert } from 'naive-ui'
|
import { NAlert } from 'naive-ui'
|
||||||
|
|
||||||
@@ -9,9 +9,7 @@ const accountInfo = useAccount()
|
|||||||
let client = new DanmakuClient(null)
|
let client = new DanmakuClient(null)
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if(accountInfo.value?.eventFetcherOnline != true){
|
client.Start()
|
||||||
client.Start()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
client.Stop()
|
client.Stop()
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ import {
|
|||||||
useMessage,
|
useMessage,
|
||||||
useNotification,
|
useNotification,
|
||||||
} from 'naive-ui'
|
} from 'naive-ui'
|
||||||
import { computed, h, onMounted, onUnmounted, ref } from 'vue'
|
import { computed, h, onActivated, onDeactivated, onMounted, onUnmounted, ref } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import SongRequestOBS from '../obs/SongRequestOBS.vue'
|
import SongRequestOBS from '../obs/SongRequestOBS.vue'
|
||||||
import APlayer from 'vue3-aplayer'
|
import APlayer from 'vue3-aplayer'
|
||||||
@@ -211,7 +211,7 @@ async function addSong(danmaku: EventModel) {
|
|||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (data.code == 200) {
|
if (data.code == 200) {
|
||||||
message.success(`[${danmaku.name}] 添加曲目: ${data.data.songName}`)
|
message.success(`[${danmaku.name}] 添加曲目: ${data.data.songName}`)
|
||||||
originSongs.value.unshift(data.data)
|
if (data.message != 'EventFetcher') originSongs.value.unshift(data.data)
|
||||||
} else {
|
} else {
|
||||||
//message.error(`[${danmaku.name}] 添加曲目失败: ${data.message}`)
|
//message.error(`[${danmaku.name}] 添加曲目失败: ${data.message}`)
|
||||||
const time = Date.now()
|
const time = Date.now()
|
||||||
@@ -791,22 +791,33 @@ onMounted(() => {
|
|||||||
if (accountInfo.value) {
|
if (accountInfo.value) {
|
||||||
settings.value = accountInfo.value.settings.songRequest
|
settings.value = accountInfo.value.settings.songRequest
|
||||||
}
|
}
|
||||||
if (accountInfo.value?.eventFetcherOnline != true) {
|
init()
|
||||||
props.client.on('danmaku', onGetDanmaku)
|
})
|
||||||
props.client.on('sc', onGetSC)
|
onActivated(() => {
|
||||||
}
|
init()
|
||||||
|
})
|
||||||
|
function init() {
|
||||||
|
dispose()
|
||||||
|
props.client.on('danmaku', onGetDanmaku)
|
||||||
|
props.client.on('sc', onGetSC)
|
||||||
timer = setInterval(() => {
|
timer = setInterval(() => {
|
||||||
updateKey.value++
|
updateKey.value++
|
||||||
}, 1000)
|
}, 1000)
|
||||||
updateActiveTimer = setInterval(() => {
|
updateActiveTimer = setInterval(() => {
|
||||||
updateActive()
|
updateActive()
|
||||||
}, 3000)
|
}, 2000)
|
||||||
})
|
}
|
||||||
onUnmounted(() => {
|
function dispose() {
|
||||||
props.client.off('danmaku', onGetDanmaku)
|
props.client.off('danmaku', onGetDanmaku)
|
||||||
props.client.off('sc', onGetSC)
|
props.client.off('sc', onGetSC)
|
||||||
clearInterval(timer)
|
clearInterval(timer)
|
||||||
clearInterval(updateActiveTimer)
|
clearInterval(updateActiveTimer)
|
||||||
|
}
|
||||||
|
onDeactivated(() => {
|
||||||
|
dispose()
|
||||||
|
})
|
||||||
|
onUnmounted(() => {
|
||||||
|
dispose()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user