From cb03299a994a4c460ceb50d6dbeb0eba0308239e Mon Sep 17 00:00:00 2001 From: Megghy Date: Fri, 17 Nov 2023 22:18:27 +0800 Subject: [PATCH] add song request --- index.html | 4 +- src/api/account.ts | 8 +- src/api/api-models.ts | 81 +- src/data/DanmakuClient.ts | 1 + src/data/constants.ts | 2 + src/data/notifactions.ts | 4 +- src/router/index.ts | 8 + src/views/IndexView.vue | 1 - src/views/OpenLiveLayout.vue | 22 +- src/views/manage/SettingsManageView.vue | 8 +- src/views/obs/SongRequestOBS.vue | 323 ++++++++ src/views/open_live/MusicRequest.vue | 953 +++++++++++++++++++++++- src/views/open_live/OpenLottery.vue | 361 ++++----- vite.config.ts | 7 +- yarn.lock | 372 +++++---- 15 files changed, 1737 insertions(+), 418 deletions(-) create mode 100644 src/views/obs/SongRequestOBS.vue diff --git a/index.html b/index.html index f6e5246..ccec625 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,9 @@ vtsuru.live - + + + diff --git a/src/api/account.ts b/src/api/account.ts index 6680014..3af0163 100644 --- a/src/api/account.ts +++ b/src/api/account.ts @@ -1,5 +1,5 @@ import { ACCOUNT_API_URL, BASE_API } from '@/data/constants' -import { APIRoot, AccountInfo } from './api-models' +import { APIRoot, AccountInfo, FunctionTypes } from './api-models' import { QueryPostAPI } from '@/api/query' import { ref } from 'vue' import { useLocalStorage } from '@vueuse/core' @@ -47,6 +47,12 @@ function refreshCookie() { } }) } +export async function SaveAccountSettings() { + return await QueryPostAPI(ACCOUNT_API_URL + 'update-setting', ACCOUNT.value?.settings) +} +export async function SaveEnableFunctions(functions: FunctionTypes[]) { + return await QueryPostAPI(ACCOUNT_API_URL + 'update-enable-functions', functions) +} export function useAccount() { return ACCOUNT } diff --git a/src/api/api-models.ts b/src/api/api-models.ts index 32e56de..1930a4e 100644 --- a/src/api/api-models.ts +++ b/src/api/api-models.ts @@ -60,16 +60,39 @@ export interface Setting_QuestionBox { export interface UserSetting { sendEmail: Setting_SendEmail questionBox: Setting_QuestionBox + songRequest: Setting_SongRequest enableFunctions: FunctionTypes[] - indexTemplate: string | null, + indexTemplate: string | null songListTemplate: string | null scheduleTemplate: string | null } +export interface Setting_SongRequest { + orderPrefix: string + onlyAllowSongList: boolean + queueMaxSize: number + allowAllDanmaku: boolean + allowFromWeb: boolean + needWearFanMedal: boolean + needJianzhang: boolean + needTidu: boolean + needZongdu: boolean + allowSC: boolean + scIgnoreLimit: boolean + scMinPrice: number + fanMedalMinLevel: number + allowReorderSong: boolean + enableCooldown: boolean + cooldownSecond: number + zongduCooldownSecond: number + tiduCooldownSecond: number + jianzhangCooldownSecond: number +} export enum FunctionTypes { SongList, QuestionBox, Schedule, + SongRequest, } export interface SongAuthorInfo { name: string @@ -167,7 +190,7 @@ export interface VideoCollectCreateModel { endAt: number maxVideoCount: number } -export interface VideoCollectTable{ +export interface VideoCollectTable { id: string shortId: string name: string @@ -190,17 +213,16 @@ export interface VideoCollectVideo { length: number watched?: boolean } -export enum VideoFrom{ +export enum VideoFrom { Collect, - Spam + Spam, } -export enum VideoStatus -{ - Pending, - Accepted, - Rejected, +export enum VideoStatus { + Pending, + Accepted, + Rejected, } -export interface VideoSender{ +export interface VideoSender { sendAt: number sender?: string senderId?: number @@ -247,9 +269,9 @@ export interface OpenLiveLotteryUserInfo { fans_medal_wearing_status: boolean //该房间粉丝勋章佩戴情况 guard_level: number } -export enum OpenLiveLotteryType{ +export enum OpenLiveLotteryType { Waiting, - Result + Result, } export interface UpdateLiveLotteryUsersModel { users: OpenLiveLotteryUserInfo[] @@ -257,6 +279,7 @@ export interface UpdateLiveLotteryUsersModel { type: OpenLiveLotteryType } export interface SongRequestInfo { + id: number songName: string song?: SongsInfo status: SongRequestStatus @@ -264,14 +287,16 @@ export interface SongRequestInfo { scPrice?: number user?: SongRequestUserInfo createAt: number + finishAt?:number + isInLocal?: boolean } export interface SongRequestUserInfo { name: string - uId: number - guardLevel: number - fansMedalLevel: number - fansMedalName: string - fansMedalWearingStatus: boolean + uid: number + guard_level: number + fans_medal_level: number + fans_medal_name: string + fans_medal_wearing_status: boolean } export enum SongRequestFrom { @@ -286,4 +311,24 @@ export enum SongRequestStatus { Singing, Finish, Cancel, -} \ No newline at end of file +} +export interface EventModel { + type: EventDataTypes + name: string + avatar: string + uid: number + msg: string + time: number + num: number + price: number + guard_level: number + fans_medal_level: number + fans_medal_name: string + fans_medal_wearing_status: boolean +} +export enum EventDataTypes { + Guard, + SC, + Gift, + Message, +} diff --git a/src/data/DanmakuClient.ts b/src/data/DanmakuClient.ts index 645e3fe..76e3d0f 100644 --- a/src/data/DanmakuClient.ts +++ b/src/data/DanmakuClient.ts @@ -245,6 +245,7 @@ export default class DanmakuClient { chatClient.start() console.log('[OPEN-LIVE] 已连接房间: ' + auth.anchor_info.room_id) this.roomAuthInfo.value = auth + this.client = chatClient return true } else { console.log('[OPEN-LIVE] 无法开启场次') diff --git a/src/data/constants.ts b/src/data/constants.ts index e541e04..1a5027f 100644 --- a/src/data/constants.ts +++ b/src/data/constants.ts @@ -23,6 +23,8 @@ export const HISTORY_API_URL = `${BASE_API}history/` export const SCHEDULE_API_URL = `${BASE_API}schedule/` export const VIDEO_COLLECT_API_URL = `${BASE_API}video-collect/` export const OPEN_LIVE_API_URL = `${BASE_API}open-live/` +export const SONG_REQUEST_API_URL = `${BASE_API}song-request/` +export const EVENT_API_URL = `${BASE_API}event/` export const ScheduleTemplateMap = { '': { name: '默认', compoent: defineAsyncComponent(() => import('@/views/view/scheduleTemplate/DefaultScheduleTemplate.vue')) }, diff --git a/src/data/notifactions.ts b/src/data/notifactions.ts index 4f36b45..21eba69 100644 --- a/src/data/notifactions.ts +++ b/src/data/notifactions.ts @@ -1,6 +1,6 @@ import { QueryGetAPI } from '@/api/query' import { useRequest } from 'vue-request' -import { NOTIFACTION_API_URL, isBackendUsable } from './constants' +import { NOTIFACTION_API_URL, SONG_REQUEST_API_URL, isBackendUsable } from './constants' import { NotifactionInfo } from '@/api/api-models' import { useAccount } from '@/api/account' import { ref } from 'vue' @@ -10,7 +10,7 @@ const n = ref() let isLoading = false function get() { if (isLoading) return - QueryGetAPI(NOTIFACTION_API_URL + 'get') + QueryGetAPI(SONG_REQUEST_API_URL + 'get-active') .then((data) => { if (data.code == 200) { n.value = data.data diff --git a/src/router/index.ts b/src/router/index.ts index 3366ef9..7f2a089 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -233,6 +233,14 @@ const routes: Array = [ title: '直播抽奖', }, }, + { + path: 'song-request', + name: 'obs-song-request', + component: () => import('@/views/obs/SongRequestOBS.vue'), + meta: { + title: '弹幕点歌', + }, + }, ], }, { diff --git a/src/views/IndexView.vue b/src/views/IndexView.vue index 1ba4946..0d45acf 100644 --- a/src/views/IndexView.vue +++ b/src/views/IndexView.vue @@ -72,7 +72,6 @@ const iconColor = 'white'
- { message.error('你不是从幻星平台访问此页面, 或未提供对应参数, 无法使用此功能') } }) +onUnmounted(() => { + client.value?.Stop() +})