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">
|
||||
import { useAccount } from '@/api/account'
|
||||
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 { NAlert } from 'naive-ui'
|
||||
|
||||
@@ -9,9 +9,7 @@ const accountInfo = useAccount()
|
||||
let client = new DanmakuClient(null)
|
||||
|
||||
onMounted(() => {
|
||||
if(accountInfo.value?.eventFetcherOnline != true){
|
||||
client.Start()
|
||||
}
|
||||
client.Start()
|
||||
})
|
||||
onUnmounted(() => {
|
||||
client.Stop()
|
||||
|
||||
@@ -58,7 +58,7 @@ import {
|
||||
useMessage,
|
||||
useNotification,
|
||||
} 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 SongRequestOBS from '../obs/SongRequestOBS.vue'
|
||||
import APlayer from 'vue3-aplayer'
|
||||
@@ -211,7 +211,7 @@ async function addSong(danmaku: EventModel) {
|
||||
.then((data) => {
|
||||
if (data.code == 200) {
|
||||
message.success(`[${danmaku.name}] 添加曲目: ${data.data.songName}`)
|
||||
originSongs.value.unshift(data.data)
|
||||
if (data.message != 'EventFetcher') originSongs.value.unshift(data.data)
|
||||
} else {
|
||||
//message.error(`[${danmaku.name}] 添加曲目失败: ${data.message}`)
|
||||
const time = Date.now()
|
||||
@@ -791,22 +791,33 @@ onMounted(() => {
|
||||
if (accountInfo.value) {
|
||||
settings.value = accountInfo.value.settings.songRequest
|
||||
}
|
||||
if (accountInfo.value?.eventFetcherOnline != true) {
|
||||
props.client.on('danmaku', onGetDanmaku)
|
||||
props.client.on('sc', onGetSC)
|
||||
}
|
||||
init()
|
||||
})
|
||||
onActivated(() => {
|
||||
init()
|
||||
})
|
||||
function init() {
|
||||
dispose()
|
||||
props.client.on('danmaku', onGetDanmaku)
|
||||
props.client.on('sc', onGetSC)
|
||||
timer = setInterval(() => {
|
||||
updateKey.value++
|
||||
}, 1000)
|
||||
updateActiveTimer = setInterval(() => {
|
||||
updateActive()
|
||||
}, 3000)
|
||||
})
|
||||
onUnmounted(() => {
|
||||
}, 2000)
|
||||
}
|
||||
function dispose() {
|
||||
props.client.off('danmaku', onGetDanmaku)
|
||||
props.client.off('sc', onGetSC)
|
||||
clearInterval(timer)
|
||||
clearInterval(updateActiveTimer)
|
||||
}
|
||||
onDeactivated(() => {
|
||||
dispose()
|
||||
})
|
||||
onUnmounted(() => {
|
||||
dispose()
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user