mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-06 18:36:55 +08:00
feat: 优化弹幕动效, 开始自动操作编写
This commit is contained in:
@@ -253,11 +253,11 @@ async function getAllSong() {
|
||||
}
|
||||
async function addSong(danmaku: EventModel) {
|
||||
console.log(
|
||||
`[OPEN-LIVE-LIVE-REQUEST] 收到 [${danmaku.name}] 的点播${danmaku.type == EventDataTypes.SC ? 'SC' : '弹幕'}: ${danmaku.msg}`,
|
||||
`[OPEN-LIVE-LIVE-REQUEST] 收到 [${danmaku.uname}] 的点播${danmaku.type == EventDataTypes.SC ? 'SC' : '弹幕'}: ${danmaku.msg}`,
|
||||
)
|
||||
if (settings.value.enableOnStreaming && accountInfo.value?.streamerInfo?.isStreaming != true) {
|
||||
notice.info({
|
||||
title: `${danmaku.name} 点播失败`,
|
||||
title: `${danmaku.uname} 点播失败`,
|
||||
description: '当前未在直播中, 无法添加点播请求. 或者关闭设置中的仅允许直播时加入',
|
||||
meta: () => h(NTime, { type: 'relative', time: Date.now(), key: updateKey.value }),
|
||||
})
|
||||
@@ -266,18 +266,18 @@ async function addSong(danmaku: EventModel) {
|
||||
if (accountInfo.value) {
|
||||
await QueryPostAPI<SongRequestInfo>(SONG_REQUEST_API_URL + 'try-add', danmaku).then((data) => {
|
||||
if (data.code == 200) {
|
||||
message.success(`[${danmaku.name}] 添加曲目: ${data.data.songName}`)
|
||||
message.success(`[${danmaku.uname}] 添加曲目: ${data.data.songName}`)
|
||||
if (data.message != 'EventFetcher') originSongs.value.unshift(data.data)
|
||||
} else {
|
||||
//message.error(`[${danmaku.name}] 添加曲目失败: ${data.message}`)
|
||||
const time = Date.now()
|
||||
notice.warning({
|
||||
title: danmaku.name + ' 点播失败',
|
||||
title: danmaku.uname + ' 点播失败',
|
||||
description: data.message,
|
||||
duration: isWarnMessageAutoClose.value ? 3000 : 0,
|
||||
meta: () => h(NTime, { type: 'relative', time: time, key: updateKey.value }),
|
||||
})
|
||||
console.log(`[OPEN-LIVE-LIVE-REQUEST] [${danmaku.name}] 添加曲目失败: ${data.message}`)
|
||||
console.log(`[OPEN-LIVE-LIVE-REQUEST] [${danmaku.uname}] 添加曲目失败: ${data.message}`)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
@@ -288,7 +288,7 @@ async function addSong(danmaku: EventModel) {
|
||||
from: danmaku.type == EventDataTypes.Message ? SongRequestFrom.Danmaku : SongRequestFrom.SC,
|
||||
scPrice: danmaku.type == EventDataTypes.SC ? danmaku.price : 0,
|
||||
user: {
|
||||
name: danmaku.name,
|
||||
name: danmaku.uname,
|
||||
uid: danmaku.uid,
|
||||
oid: danmaku.open_id,
|
||||
face: danmaku.uface,
|
||||
@@ -302,7 +302,7 @@ async function addSong(danmaku: EventModel) {
|
||||
id: songs.value.length == 0 ? 1 : new List(songs.value).Max((s) => s.id) + 1,
|
||||
} as SongRequestInfo
|
||||
localActiveSongs.value.unshift(songData)
|
||||
message.success(`[${danmaku.name}] 添加: ${songData.songName}`)
|
||||
message.success(`[${danmaku.uname}] 添加: ${songData.songName}`)
|
||||
}
|
||||
}
|
||||
async function addSongManual() {
|
||||
|
||||
@@ -281,7 +281,7 @@ async function onGetEvent(data: EventModel) {
|
||||
const lastRequest = cooldown.value[data.uid]
|
||||
if (Date.now() - lastRequest < settings.value.orderCooldown * 1000) {
|
||||
message.info(
|
||||
`[${data.name}] 冷却中,距离下次点歌还有 ${((settings.value.orderCooldown * 1000 - (Date.now() - lastRequest)) / 1000).toFixed(1)} 秒`,
|
||||
`[${data.uname}] 冷却中,距离下次点歌还有 ${((settings.value.orderCooldown * 1000 - (Date.now() - lastRequest)) / 1000).toFixed(1)} 秒`,
|
||||
)
|
||||
return
|
||||
}
|
||||
@@ -290,13 +290,13 @@ async function onGetEvent(data: EventModel) {
|
||||
const result = await searchMusic(name)
|
||||
if (result) {
|
||||
if (settings.value.blacklist.includes(result.name)) {
|
||||
message.warning(`[${data.name}] 点歌失败,因为 ${result.name} 在黑名单中`)
|
||||
message.warning(`[${data.uname}] 点歌失败,因为 ${result.name} 在黑名单中`)
|
||||
return
|
||||
}
|
||||
cooldown.value[data.uid] = Date.now()
|
||||
const music = {
|
||||
from: {
|
||||
name: data.name,
|
||||
name: data.uname,
|
||||
uid: data.uid,
|
||||
guard_level: data.guard_level,
|
||||
fans_medal_level: data.fans_medal_level,
|
||||
|
||||
@@ -251,7 +251,7 @@
|
||||
if (!checkMessage(danmaku)) {
|
||||
return;
|
||||
}
|
||||
console.log(`[OPEN-LIVE-QUEUE] 收到 [${danmaku.name}] 的排队请求`);
|
||||
console.log(`[OPEN-LIVE-QUEUE] 收到 [${danmaku.uname}] 的排队请求`);
|
||||
// 检查是否仅直播时允许加入
|
||||
if (settings.value.enableOnStreaming && accountInfo.value?.streamerInfo?.isStreaming != true) {
|
||||
message.info('当前未在直播中, 无法添加排队请求. 或者关闭设置中的仅允许直播时加入');
|
||||
@@ -275,21 +275,21 @@
|
||||
originQueue.value.splice(existingIndex, 1, data.data); // 替换现有条目
|
||||
} else { // 新用户加入
|
||||
originQueue.value.push(data.data); // 添加到末尾 (排序由 computed 处理)
|
||||
message.success(`[${danmaku.name}] 添加至队列`);
|
||||
message.success(`[${danmaku.uname}] 添加至队列`);
|
||||
}
|
||||
}
|
||||
} else { // 添加失败
|
||||
const time = Date.now();
|
||||
notice.warning({
|
||||
title: danmaku.name + ' 排队失败',
|
||||
title: danmaku.uname + ' 排队失败',
|
||||
description: data.message,
|
||||
duration: isWarnMessageAutoClose.value ? 3000 : 0,
|
||||
meta: () => h(NTime, { type: 'relative', time: time, key: updateKey.value }), // 使用 updateKey 强制更新时间显示
|
||||
});
|
||||
console.log(`[OPEN-LIVE-QUEUE] [${danmaku.name}] 排队失败: ${data.message}`);
|
||||
console.log(`[OPEN-LIVE-QUEUE] [${danmaku.uname}] 排队失败: ${data.message}`);
|
||||
}
|
||||
} catch (err: any) {
|
||||
message.error(`[${danmaku.name}] 添加队列时出错: ${err.message || err}`);
|
||||
message.error(`[${danmaku.uname}] 添加队列时出错: ${err.message || err}`);
|
||||
console.error(`[OPEN-LIVE-QUEUE] 添加队列出错:`, err);
|
||||
}
|
||||
} else { // 未登录,操作本地队列
|
||||
@@ -298,7 +298,7 @@
|
||||
from: danmaku.type == EventDataTypes.Message ? QueueFrom.Danmaku : QueueFrom.Gift,
|
||||
giftPrice: danmaku.type == EventDataTypes.SC ? danmaku.price : undefined,
|
||||
user: {
|
||||
name: danmaku.name,
|
||||
name: danmaku.uname,
|
||||
uid: danmaku.uid,
|
||||
oid: danmaku.open_id,
|
||||
fans_medal_level: danmaku.fans_medal_level,
|
||||
@@ -311,7 +311,7 @@
|
||||
id: localQueues.value.length == 0 ? 1 : new List(localQueues.value).Max((s) => s.id) + 1, // 本地 ID
|
||||
} as ResponseQueueModel;
|
||||
localQueues.value.unshift(songData); // 添加到本地队列开头
|
||||
message.success(`[${danmaku.name}] 添加至本地队列`);
|
||||
message.success(`[${danmaku.uname}] 添加至本地队列`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -410,7 +410,7 @@
|
||||
function checkMessage(eventData: EventModel): boolean {
|
||||
// 未登录时,如果用户已在本地队列,则不允许重复添加 (简单检查)
|
||||
if (!configCanEdit.value && localQueues.value.some((q) => q.user?.uid == eventData.uid && q.status < QueueStatus.Finish)) {
|
||||
console.log(`[OPEN-LIVE-QUEUE] 本地队列已存在用户 [${eventData.name}],跳过`);
|
||||
console.log(`[OPEN-LIVE-QUEUE] 本地队列已存在用户 [${eventData.uname}],跳过`);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -357,7 +357,7 @@ function onGetEvent(data: EventModel) {
|
||||
exist.combineCount ??= 0
|
||||
exist.combineCount += data.num
|
||||
console.log(
|
||||
`[TTS] ${data.name} 增加已存在礼物数量: ${data.msg} [${exist.data.num - data.num} => ${exist.data.num}]`,
|
||||
`[TTS] ${data.uname} 增加已存在礼物数量: ${data.msg} [${exist.data.num - data.num} => ${exist.data.num}]`,
|
||||
)
|
||||
return
|
||||
}
|
||||
@@ -401,7 +401,7 @@ function getTextFromDanmaku(data: EventModel | undefined) {
|
||||
text = text
|
||||
.replace(
|
||||
templateConstants.name.regex,
|
||||
settings.value.voiceType == 'api' && settings.value.splitText ? `'${data.name}'` : data.name,
|
||||
settings.value.voiceType == 'api' && settings.value.splitText ? `'${data.uname}'` : data.uname,
|
||||
)
|
||||
.replace(templateConstants.count.regex, data.num.toString())
|
||||
.replace(templateConstants.price.regex, data.price.toString())
|
||||
@@ -483,7 +483,7 @@ function test(type: EventDataTypes) {
|
||||
case EventDataTypes.Message:
|
||||
forceSpeak({
|
||||
type: EventDataTypes.Message,
|
||||
name: accountInfo.value?.name ?? '测试用户',
|
||||
uname: accountInfo.value?.name ?? '测试用户',
|
||||
uid: accountInfo.value?.biliId ?? 0,
|
||||
msg: '测试弹幕',
|
||||
price: 0,
|
||||
@@ -502,7 +502,7 @@ function test(type: EventDataTypes) {
|
||||
case EventDataTypes.SC:
|
||||
forceSpeak({
|
||||
type: EventDataTypes.SC,
|
||||
name: accountInfo.value?.name ?? '测试用户',
|
||||
uname: accountInfo.value?.name ?? '测试用户',
|
||||
uid: accountInfo.value?.biliId ?? 0,
|
||||
msg: '测试留言',
|
||||
price: 30,
|
||||
@@ -521,7 +521,7 @@ function test(type: EventDataTypes) {
|
||||
case EventDataTypes.Guard:
|
||||
forceSpeak({
|
||||
type: EventDataTypes.Guard,
|
||||
name: accountInfo.value?.name ?? '测试用户',
|
||||
uname: accountInfo.value?.name ?? '测试用户',
|
||||
uid: accountInfo.value?.biliId ?? 0,
|
||||
msg: '舰长',
|
||||
price: 0,
|
||||
@@ -540,7 +540,7 @@ function test(type: EventDataTypes) {
|
||||
case EventDataTypes.Gift:
|
||||
forceSpeak({
|
||||
type: EventDataTypes.Gift,
|
||||
name: accountInfo.value?.name ?? '测试用户',
|
||||
uname: accountInfo.value?.name ?? '测试用户',
|
||||
uid: accountInfo.value?.biliId ?? 0,
|
||||
msg: '测试礼物',
|
||||
price: 5,
|
||||
@@ -790,7 +790,7 @@ onUnmounted(() => {
|
||||
> SC</NTag>
|
||||
</span>
|
||||
<NText>
|
||||
{{ item.data.name }}
|
||||
{{ item.data.uname }}
|
||||
</NText>
|
||||
<NText depth="3">
|
||||
{{ getTextFromDanmaku(item.data) }}
|
||||
|
||||
Reference in New Issue
Block a user