From 0470b7b55bf6fb08ff7591ce7f5ab3d5e69a7046 Mon Sep 17 00:00:00 2001 From: noahcode Date: Tue, 4 Jun 2024 17:55:45 +0800 Subject: [PATCH] =?UTF-8?q?perf:=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 帐号登陆后即添加直播间号; 删除默认小红豆表情包; 修复弹幕不显示的问题; 修改弹幕功能区块样式; 更新虚拟列表包版本; 优化@不可点击自己; --- package.json | 2 +- pnpm-lock.yaml | 47 ++++++---- src-tauri/Cargo.lock | 2 +- src/apis/live.ts | 28 ++++-- src/components/Control.vue | 4 +- src/components/Danmu/Client.vue | 8 +- src/components/Danmu/Host.vue | 10 +-- src/components/Danmu/HostItem.vue | 4 + src/components/QRCode.vue | 16 +++- src/stores/index.ts | 6 +- src/types/components.d.ts | 5 -- src/utils/message.ts | 140 +++++++++++------------------- src/utils/room.ts | 9 +- 13 files changed, 139 insertions(+), 142 deletions(-) diff --git a/package.json b/package.json index 1c9995d..16a5de7 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "tauri-plugin-context-menu": "^0.7.0", "vue": "^3.4.23", "vue-router": "^4.3.2", - "vue-tiny-virtual-list": "^1.4.0" + "vue-virt-list": "^1.2.1" }, "devDependencies": { "@antfu/eslint-config": "^2.15.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 090867a..cc464a2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -71,9 +71,9 @@ importers: vue-router: specifier: ^4.3.2 version: 4.3.2(vue@3.4.23(typescript@5.4.5)) - vue-tiny-virtual-list: - specifier: ^1.4.0 - version: 1.4.0(vue@3.4.23(typescript@5.4.5)) + vue-virt-list: + specifier: ^1.2.1 + version: 1.2.1(vue@3.4.23(typescript@5.4.5)) devDependencies: '@antfu/eslint-config': specifier: ^2.15.0 @@ -3105,6 +3105,17 @@ packages: '@vue/composition-api': optional: true + vue-demi@0.14.8: + resolution: {integrity: sha512-Uuqnk9YE9SsWeReYqK2alDI5YzciATE0r2SkA6iMAtuXvNTMNACJLJEXNXaEy94ECuBe4Sk6RzRU80kjdbIo1Q==} + engines: {node: '>=12'} + hasBin: true + peerDependencies: + '@vue/composition-api': ^1.0.0-rc.1 + vue: ^3.0.0-0 || ^2.6.0 + peerDependenciesMeta: + '@vue/composition-api': + optional: true + vue-eslint-parser@9.4.2: resolution: {integrity: sha512-Ry9oiGmCAK91HrKMtCrKFWmSFWvYkpGglCeFAIqDdr9zdXmMMpJOmUJS7WWsW7fX81h6mwHmUZCQQ1E0PkSwYQ==} engines: {node: ^14.17.0 || >=16.0.0} @@ -3119,8 +3130,14 @@ packages: vue-template-compiler@2.7.16: resolution: {integrity: sha512-AYbUWAJHLGGQM7+cNTELw+KsOG9nl2CnSv467WobS5Cv9uk3wFcnr1Etsz2sEIHEZvw1U+o9mRlEO6QbZvUPGQ==} - vue-tiny-virtual-list@1.4.0: - resolution: {integrity: sha512-j3P68/ewGJt4RyT3axOx9N/pte2lsPz+8ytcbcKnOUNbbDFJQcfQNQtMyk73uoC+kmfMd4GDWq9QYmB8Ugudnw==} + vue-tsc@2.0.13: + resolution: {integrity: sha512-a3nL3FvguCWVJUQW/jFrUxdeUtiEkbZoQjidqvMeBK//tuE2w6NWQAbdrEpY2+6nSa4kZoKZp8TZUMtHpjt4mQ==} + hasBin: true + peerDependencies: + typescript: '*' + + vue-virt-list@1.2.1: + resolution: {integrity: sha512-M6EfUui0EWOD1zE1rj+ujnQzDzY3Oga9uIb5YJCSes9dcKKmAvXDu322ocyIgoE2BCyq60ndYn+nLNRELvir6Q==} peerDependencies: '@vue/composition-api': ^1.0.0-rc.1 vue: ^2.0.0 || >=3.0.0 @@ -3128,12 +3145,6 @@ packages: '@vue/composition-api': optional: true - vue-tsc@2.0.13: - resolution: {integrity: sha512-a3nL3FvguCWVJUQW/jFrUxdeUtiEkbZoQjidqvMeBK//tuE2w6NWQAbdrEpY2+6nSa4kZoKZp8TZUMtHpjt4mQ==} - hasBin: true - peerDependencies: - typescript: '*' - vue@3.4.23: resolution: {integrity: sha512-X1y6yyGJ28LMUBJ0k/qIeKHstGd+BlWQEOT40x3auJFTmpIhpbKLgN7EFsqalnJXq1Km5ybDEsp6BhuWKciUDg==} peerDependencies: @@ -6416,6 +6427,10 @@ snapshots: dependencies: vue: 3.4.23(typescript@5.4.5) + vue-demi@0.14.8(vue@3.4.23(typescript@5.4.5)): + dependencies: + vue: 3.4.23(typescript@5.4.5) + vue-eslint-parser@9.4.2(eslint@9.0.0): dependencies: debug: 4.3.4 @@ -6439,11 +6454,6 @@ snapshots: de-indent: 1.0.2 he: 1.2.0 - vue-tiny-virtual-list@1.4.0(vue@3.4.23(typescript@5.4.5)): - dependencies: - vue: 3.4.23(typescript@5.4.5) - vue-demi: 0.14.7(vue@3.4.23(typescript@5.4.5)) - vue-tsc@2.0.13(typescript@5.4.5): dependencies: '@volar/typescript': 2.2.0-alpha.8 @@ -6451,6 +6461,11 @@ snapshots: semver: 7.6.0 typescript: 5.4.5 + vue-virt-list@1.2.1(vue@3.4.23(typescript@5.4.5)): + dependencies: + vue: 3.4.23(typescript@5.4.5) + vue-demi: 0.14.8(vue@3.4.23(typescript@5.4.5)) + vue@3.4.23(typescript@5.4.5): dependencies: '@vue/compiler-dom': 3.4.23 diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index e234e22..f780b3c 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -147,7 +147,7 @@ checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "bili-message" -version = "1.2.8" +version = "1.2.9" dependencies = [ "futures-channel", "futures-util", diff --git a/src/apis/live.ts b/src/apis/live.ts index b8abb16..7189660 100644 --- a/src/apis/live.ts +++ b/src/apis/live.ts @@ -21,13 +21,13 @@ function getLiveCodeApi() { // 获取ws认证token function getLiveTokenApi() { - const { currentUser, room } = useAppStore() + const { currentUser, currentRoom } = useAppStore() return request({ url: `${LIVE_URL_PREFIX}/xlive/web-room/v1/index/getDanmuInfo`, method: 'GET', params: { - id: room, + id: currentRoom, }, headers: { cookie: currentUser?.cookie, @@ -37,14 +37,14 @@ function getLiveTokenApi() { // 获取表情列表 function getEmojiApi() { - const { currentUser, room } = useAppStore() + const { currentUser, currentRoom } = useAppStore() return request({ url: `${LIVE_URL_PREFIX}/xlive/web-ucenter/v2/emoticon/GetEmoticons`, method: 'GET', params: { platform: 'pc', - room_id: room, + room_id: currentRoom, }, headers: { cookie: currentUser?.cookie, @@ -54,9 +54,9 @@ function getEmojiApi() { // 发送消息 function sendMessageApi(message: string, type: EDMType, replyMid = 0) { - const { currentUser, room, currentMedal } = useAppStore() + const { currentUser, currentRoom, currentMedal } = useAppStore() const data = { - roomid: type === EDMType.打卡专用 ? `${currentMedal?.roomid}` : `${room}`, + roomid: type === EDMType.打卡专用 ? `${currentMedal?.roomid}` : `${currentRoom}`, msg: message, dm_type: type === EDMType.打卡专用 ? '0' : type, bubble: '0', @@ -84,17 +84,28 @@ function sendMessageApi(message: string, type: EDMType, replyMid = 0) { // 获取当前直播状态 function getLiveStatusApi() { - const { room } = useAppStore() + const { currentRoom } = useAppStore() return request({ url: `${LIVE_URL_PREFIX}/xlive/web-room/v1/index/getRoomBaseInfo`, method: 'GET', params: { - room_ids: room, + room_ids: currentRoom, req_biz: 'link-center', }, }) } +// 获取主播信息 +function getMasterInfoApi(uid: number) { + return request({ + url: `${LIVE_URL_PREFIX}/live_user/v1/Master/info`, + method: 'GET', + params: { + uid, + }, + }) +} + // 获取用户持有的粉丝勋章 function getMedalApi(page: number = 1) { const { currentUser } = useAppStore() @@ -154,4 +165,5 @@ export { getMedalApi, wearMedalApi, unWearMedalApi, + getMasterInfoApi, } diff --git a/src/components/Control.vue b/src/components/Control.vue index 5b8ac73..7fd0ffa 100644 --- a/src/components/Control.vue +++ b/src/components/Control.vue @@ -4,7 +4,7 @@ import { appWindow } from '@tauri-apps/api/window' import { connected, startWebsocket, stopWebsocket } from '@/utils/room' import { openWindow } from '@/utils/window' -const { room, isFix, isBroadcast, roomList } = storeToRefs(useAppStore()) +const { currentRoom, isFix, isBroadcast, roomList } = storeToRefs(useAppStore()) const { deleteRoom } = useAppStore() watchEffect(() => { @@ -29,7 +29,7 @@ watch(connected, () => {
-import { VirtualList } from 'vue-tiny-virtual-list' +import { VirtList } from 'vue-virt-list' import { demos } from './config' @@ -15,7 +15,7 @@ const demo = computed(() => { const { autoScroll } = storeToRefs(useAppStore()) -const danmuRef: Ref | null> = ref(null) +const danmuRef: Ref | null> = ref(null) watch(() => props.msgList, () => { if (!danmuRef.value || !autoScroll.value) @@ -37,7 +37,7 @@ watch(autoScroll, (val) => { diff --git a/src/components/Danmu/Host.vue b/src/components/Danmu/Host.vue index ef3b496..94d3049 100644 --- a/src/components/Danmu/Host.vue +++ b/src/components/Danmu/Host.vue @@ -1,7 +1,7 @@