Compare commits

..

2 Commits

6 changed files with 33 additions and 30 deletions

View File

@@ -1,3 +1,4 @@
// oxlint-disable no-unused-expressions
<script setup lang="ts"> <script setup lang="ts">
import type { FetcherStatisticData } from './data/models' import type { FetcherStatisticData } from './data/models'
@@ -169,7 +170,6 @@ async function setCookieCloud() {
let uptimeTimer: number | undefined let uptimeTimer: number | undefined
let epsTimer: number | undefined let epsTimer: number | undefined
let lastEventCount = 0 let lastEventCount = 0
let networkPollTimer: number | undefined
// --- Computed Properties --- // --- Computed Properties ---
const isConnected = computed(() => webfetcher.state === 'connected') const isConnected = computed(() => webfetcher.state === 'connected')
@@ -544,7 +544,6 @@ onMounted(async () => {
onUnmounted(() => { onUnmounted(() => {
clearInterval(uptimeTimer) clearInterval(uptimeTimer)
clearInterval(epsTimer) clearInterval(epsTimer)
clearInterval(networkPollTimer)
// Clean up login timers if component unmounts during login // Clean up login timers if component unmounts during login
clearInterval(timer.value) clearInterval(timer.value)
clearTimeout(expiredTimer.value) clearTimeout(expiredTimer.value)

9
src/components.d.ts vendored
View File

@@ -19,13 +19,22 @@ declare module 'vue' {
LiveInfoContainer: typeof import('./components/LiveInfoContainer.vue')['default'] LiveInfoContainer: typeof import('./components/LiveInfoContainer.vue')['default']
MonacoEditorComponent: typeof import('./components/MonacoEditorComponent.vue')['default'] MonacoEditorComponent: typeof import('./components/MonacoEditorComponent.vue')['default']
NAlert: typeof import('naive-ui')['NAlert'] NAlert: typeof import('naive-ui')['NAlert']
NAvatar: typeof import('naive-ui')['NAvatar']
NButton: typeof import('naive-ui')['NButton']
NCard: typeof import('naive-ui')['NCard']
NEllipsis: typeof import('naive-ui')['NEllipsis']
NEmpty: typeof import('naive-ui')['NEmpty']
NFlex: typeof import('naive-ui')['NFlex'] NFlex: typeof import('naive-ui')['NFlex']
NFormItemGi: typeof import('naive-ui')['NFormItemGi'] NFormItemGi: typeof import('naive-ui')['NFormItemGi']
NGridItem: typeof import('naive-ui')['NGridItem'] NGridItem: typeof import('naive-ui')['NGridItem']
NIcon: typeof import('naive-ui')['NIcon'] NIcon: typeof import('naive-ui')['NIcon']
NImage: typeof import('naive-ui')['NImage']
NPopconfirm: typeof import('naive-ui')['NPopconfirm']
NScrollbar: typeof import('naive-ui')['NScrollbar'] NScrollbar: typeof import('naive-ui')['NScrollbar']
NSpace: typeof import('naive-ui')['NSpace']
NTag: typeof import('naive-ui')['NTag'] NTag: typeof import('naive-ui')['NTag']
NText: typeof import('naive-ui')['NText'] NText: typeof import('naive-ui')['NText']
NTime: typeof import('naive-ui')['NTime']
PointGoodsItem: typeof import('./components/manage/PointGoodsItem.vue')['default'] PointGoodsItem: typeof import('./components/manage/PointGoodsItem.vue')['default']
PointHistoryCard: typeof import('./components/manage/PointHistoryCard.vue')['default'] PointHistoryCard: typeof import('./components/manage/PointHistoryCard.vue')['default']
PointOrderCard: typeof import('./components/manage/PointOrderCard.vue')['default'] PointOrderCard: typeof import('./components/manage/PointOrderCard.vue')['default']

View File

@@ -5,7 +5,7 @@ const debugAPI
= import.meta.env.VITE_API == 'dev' = import.meta.env.VITE_API == 'dev'
? import.meta.env.VITE_DEBUG_DEV_API ? import.meta.env.VITE_DEBUG_DEV_API
: import.meta.env.VITE_DEBUG_RELEASE_API : import.meta.env.VITE_DEBUG_RELEASE_API
const releseAPI = `https://vtsuru.suki.club/` const releseAPI = `https://api.vtsuru.suki.club/`
const failoverAPI = `https://failover-api.vtsuru.suki.club/` const failoverAPI = `https://failover-api.vtsuru.suki.club/`
export const isBackendUsable = ref(true) export const isBackendUsable = ref(true)

View File

@@ -65,10 +65,10 @@ const obsScrollSpeedMultiplierRef = ref(1)
const volumn = useStorage('Settings.Volumn', 0.5) const volumn = useStorage('Settings.Volumn', 0.5)
// 使用composable管理歌曲请求核心逻辑 // 使用composable管理歌曲请求核心逻辑
const songRequest = useLiveRequest() const liveRequest = useLiveRequest()
// 提供activeSongs给子组件 // 提供activeSongs给子组件
provide('activeSongs', songRequest.activeSongs) provide('activeSongs', liveRequest.activeSongs)
// 控制歌曲请求功能开关 // 控制歌曲请求功能开关
async function onUpdateFunctionEnable() { async function onUpdateFunctionEnable() {
@@ -82,7 +82,7 @@ async function onUpdateFunctionEnable() {
accountInfo.value.settings.enableFunctions.push(FunctionTypes.LiveRequest) 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 = liveRequest.defaultPrefix
} }
await SaveEnableFunctions(accountInfo.value?.settings.enableFunctions) await SaveEnableFunctions(accountInfo.value?.settings.enableFunctions)
.then((data) => { .then((data) => {
@@ -110,7 +110,7 @@ async function onUpdateFunctionEnable() {
// 更新歌曲请求设置 // 更新歌曲请求设置
async function updateSettings() { async function updateSettings() {
if (accountInfo.value.id) { if (accountInfo.value.id) {
songRequest.isLoading = true liveRequest.isLoading = true
await SaveSetting('SongRequest', accountInfo.value.settings.songRequest) await SaveSetting('SongRequest', accountInfo.value.settings.songRequest)
.then((msg) => { .then((msg) => {
if (msg) { if (msg) {
@@ -121,7 +121,7 @@ async function updateSettings() {
} }
}) })
.finally(() => { .finally(() => {
songRequest.isLoading = false liveRequest.isLoading = false
}) })
} else { } else {
message.success('完成') message.success('完成')
@@ -130,26 +130,23 @@ async function updateSettings() {
// 生命周期钩子 // 生命周期钩子
onMounted(() => { onMounted(() => {
if (accountInfo.value.id) { client.onEvent('danmaku', liveRequest.onGetDanmaku)
accountInfo.value.settings.songRequest = accountInfo.value.settings.songRequest client.onEvent('sc', liveRequest.onGetSC)
} liveRequest.init()
client.onEvent('danmaku', songRequest.onGetDanmaku)
client.onEvent('sc', songRequest.onGetSC)
songRequest.init()
}) })
onActivated(() => { onActivated(() => {
songRequest.init() liveRequest.init()
}) })
onDeactivated(() => { onDeactivated(() => {
songRequest.dispose() liveRequest.dispose()
}) })
onUnmounted(() => { onUnmounted(() => {
client.offEvent('danmaku', songRequest.onGetDanmaku) client.offEvent('danmaku', liveRequest.onGetDanmaku)
client.offEvent('sc', songRequest.onGetSC) client.offEvent('sc', liveRequest.onGetSC)
songRequest.dispose() liveRequest.dispose()
}) })
</script> </script>
@@ -206,7 +203,7 @@ onUnmounted(() => {
OBS 组件 OBS 组件
</NButton> </NButton>
</template> </template>
{{ songRequest.configCanEdit ? '' : '登陆后才可以使用此功能' }} {{ liveRequest.configCanEdit ? '' : '登陆后才可以使用此功能' }}
</NTooltip> </NTooltip>
</NSpace> </NSpace>
</NCard> </NCard>
@@ -224,12 +221,12 @@ onUnmounted(() => {
<!-- 歌曲播放器 --> <!-- 歌曲播放器 -->
<Transition> <Transition>
<div <div
v-if="songRequest.selectedSong" v-if="liveRequest.selectedSong"
class="song-list" class="song-list"
> >
<SongPlayer <SongPlayer
v-model:is-lrc-loading="songRequest.isLrcLoading" v-model:is-lrc-loading="liveRequest.isLrcLoading"
:song="songRequest.selectedSong" :song="liveRequest.selectedSong"
/> />
<NDivider style="margin: 15px 0 15px 0" /> <NDivider style="margin: 15px 0 15px 0" />
</div> </div>
@@ -239,12 +236,12 @@ onUnmounted(() => {
<SongRequestList <SongRequestList
@update:sort-type="(value: any) => { accountInfo.settings.songRequest.sortType = value; updateSettings() }" @update:sort-type="(value: any) => { accountInfo.settings.songRequest.sortType = value; updateSettings() }"
@update:is-reverse="(value: any) => { @update:is-reverse="(value: any) => {
if (songRequest.configCanEdit) { if (liveRequest.configCanEdit) {
accountInfo.settings.songRequest.isReverse = value accountInfo.settings.songRequest.isReverse = value
updateSettings() updateSettings()
} }
else { else {
songRequest.isReverse = value liveRequest.isReverse = value
} }
}" }"
/> />

View File

@@ -314,7 +314,7 @@ async function add(danmaku: EventModel) {
} as DanmakuUserInfo, } as DanmakuUserInfo,
createAt: Date.now(), createAt: Date.now(),
isInLocal: true, isInLocal: true,
id: localQueues.value.length == 0 ? 1 : new List(localQueues.value).Max(s => s.id) + 1, // 本地 ID id: localQueues.value.length == 0 ? 1 : (new List(localQueues.value).Max(s => s.id) ?? 0) + 1, // 本地 ID
} as ResponseQueueModel } as ResponseQueueModel
localQueues.value.unshift(songData) // 添加到本地队列开头 localQueues.value.unshift(songData) // 添加到本地队列开头
message.success(`[${danmaku.uname}] 添加至本地队列`) message.success(`[${danmaku.uname}] 添加至本地队列`)
@@ -352,7 +352,7 @@ async function addManual() {
user: { name: newQueueName.value } as DanmakuUserInfo, user: { name: newQueueName.value } as DanmakuUserInfo,
createAt: Date.now(), createAt: Date.now(),
isInLocal: true, isInLocal: true,
id: localQueues.value.length == 0 ? 1 : new List(localQueues.value).Max(s => s.id) + 1, id: localQueues.value.length == 0 ? 1 : (new List(localQueues.value).Max(s => s.id) ?? 0) + 1,
} as ResponseQueueModel } as ResponseQueueModel
localQueues.value.unshift(songData) localQueues.value.unshift(songData)
message.success(`已手动添加用户至队列: ${newQueueName.value}`) message.success(`已手动添加用户至队列: ${newQueueName.value}`)

View File

@@ -101,7 +101,7 @@ export default defineConfig({
build: { build: {
sourcemap: true, sourcemap: true,
target: 'esnext', target: 'esnext',
minify: 'esbuild', minify: 'oxc',
chunkSizeWarningLimit: 1000, chunkSizeWarningLimit: 1000,
rollupOptions: { rollupOptions: {
output: { // @ts-ignore output: { // @ts-ignore
@@ -111,13 +111,11 @@ export default defineConfig({
name: 'vue-vendor', name: 'vue-vendor',
test: /[\\/]node_modules[\\/](vue|vue-router|pinia)[\\/]/, test: /[\\/]node_modules[\\/](vue|vue-router|pinia)[\\/]/,
priority: -10, priority: -10,
enforce: true,
}, },
{ {
name: 'ui-vendor', name: 'ui-vendor',
test: /[\\/]node_modules[\\/](naive-ui|@vueuse[\\/]core)[\\/]/, test: /[\\/]node_modules[\\/](naive-ui|@vueuse[\\/]core)[\\/]/,
priority: -10, priority: -10,
enforce: true,
}, },
], ],
}, },