From 4e3862790b33d15ae42979000ca97e5cbb5d764b Mon Sep 17 00:00:00 2001 From: Fang_Zhijian Date: Sat, 11 May 2024 12:53:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E4=BA=86=E4=B8=AA=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E7=94=9F=E6=88=90=E6=B3=A2=E5=BD=A2=E7=9A=84=E5=B0=8F=E4=B8=9C?= =?UTF-8?q?=E8=A5=BF=EF=BC=88=E6=B5=8B=E8=AF=95=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + src/App.vue | 24 ++++-- src/assets/dataMap.ts | 2 +- src/socket/coyote.ts | 8 +- src/socket/index.ts | 3 +- src/waveHelper.ts | 5 ++ src/waveHelper.vue | 179 ++++++++++++++++++++++++++++++++++++++++++ waveHelper.html | 17 ++++ 8 files changed, 228 insertions(+), 11 deletions(-) create mode 100644 src/waveHelper.ts create mode 100644 src/waveHelper.vue create mode 100644 waveHelper.html diff --git a/README.md b/README.md index 02147ea..47fcf1d 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ > 本项目**不会**向服务端传递`access_key_id`和`access_key_secret`,请自行修改服务端代码(可参考[服务端本地搭建指南](https://github.com/klxf/BLive_Coyote/issues/1))。 - [BLive Coyote Demo](https://blive-coyote.babyfang.cn/) +- [波形助手](https://blive-coyote.babyfang.cn/waveHelper.html) ## 目录结构 ``` diff --git a/src/App.vue b/src/App.vue index 5ef27f4..4439173 100644 --- a/src/App.vue +++ b/src/App.vue @@ -4,7 +4,14 @@ import { ref } from "vue" import axios from "axios" import { createSocket, destroySocket } from "./socket/index" -import { createCoyoteSocket, closeCoyoteSocket, qrcodeSrc, qrcodeShow } from "./socket/coyote" +import { + createCoyoteSocket, + closeCoyoteSocket, + sendWaveData, + qrcodeSrc, + qrcodeShow, + addOrIncrease +} from "./socket/coyote" import { Notyf } from 'notyf' const notyf = new Notyf({ duration: 3000 }) @@ -151,12 +158,17 @@ const handleDestroySocket = () => { * 测试按钮 */ const test = () => { - let map = { - "123": "AAWWWWW", - "123456": "aaaaaaaa", + const waveData = { + "test": `["0A0A0A0A00000000","0A0A0A0A00000000","0A0A0A0A00000000","0A0A0A0A00000000","0A0A0A0A00000000","0A0A0A0A00000000","0A0A0A0A00000000","0A0A0A0A00000000","0A0A0A0A01010101","0A0A0A0A01010101","0A0A0A0A22222222","0A0A0A0A22222222","0A0A0A0A43434343","0A0A0A0A43434343","0A0A0A0A64646464","0A0A0A0A64646464"]` + } + try { + sendWaveData(5, 5, waveData["test"], waveData["test"]) + notyf.success("波形发送成功") + } + catch (e) { + console.log(e) + notyf.error("操作失败!") } - notyf.success({ message: '测试吐司', duration: 3000, ripple: true }) - notyf.success({ message: map[123], duration: 3000, ripple: true }) } /** diff --git a/src/assets/dataMap.ts b/src/assets/dataMap.ts index 7a81fa1..1a65125 100644 --- a/src/assets/dataMap.ts +++ b/src/assets/dataMap.ts @@ -4,7 +4,7 @@ const waveData = { "31037": `["0A0A0A0A00000000","0A0A0A0A0A0A0A0A","0A0A0A0A14141414","0A0A0A0A1E1E1E1E","0A0A0A0A28282828","0A0A0A0A32323232","0A0A0A0A3C3C3C3C","0A0A0A0A46464646","0A0A0A0A50505050","0A0A0A0A5A5A5A5A","0A0A0A0A64646464"]`, "31164": `["0A0A0A0A00000000","0D0D0D0D0F0F0F0F","101010101E1E1E1E","1313131332323232","1616161641414141","1A1A1A1A50505050","1D1D1D1D64646464","202020205A5A5A5A","2323232350505050","262626264B4B4B4B","2A2A2A2A41414141"]`, - "32609": `["4A4A4A4A64646464","4545454564646464","4040404064646464","3B3B3B3B64646464","3636363664646464","3232323264646464","2D2D2D2D64646464","2828282864646464","2323232364646464","1E1E1E1E64646464","1A1A1A1A64646464"]` + "32609": `["4A4A4A4A64646464","4545454564646464","4040404064646464","3B3B3B3B64646464","3636363664646464","3232323264646464","2D2D2D2D64646464","2828282864646464","2323232364646464","1E1E1E1E64646464","1A1A1A1A64646464"]`, } // 礼物id和礼物名的对应关系 diff --git a/src/socket/coyote.ts b/src/socket/coyote.ts index 44e9941..8123d60 100644 --- a/src/socket/coyote.ts +++ b/src/socket/coyote.ts @@ -1,6 +1,5 @@ import {ref} from "vue"; import { Notyf } from 'notyf' -import { waveData } from "../assets/dataMap"; import QRCode from 'qrcode' const notyf = new Notyf({ duration: 4000 }) @@ -140,8 +139,11 @@ function sendWaveData(timeA, timeB, waveA, waveB) { return } - const msg1 = `A:${waveData[waveA]}` - const msg2 = `B:${waveData[waveB]}` + /*const msg1 = `A:${waveData[waveA]}` + const msg2 = `B:${waveData[waveB]}`*/ + + const msg1 = `A:${waveA}` + const msg2 = `B:${waveB}` const data = { type: "clientMsg", message: msg1, message2: msg2, time1: timeA, time2: timeB } diff --git a/src/socket/index.ts b/src/socket/index.ts index 700df1b..e578068 100644 --- a/src/socket/index.ts +++ b/src/socket/index.ts @@ -1,6 +1,7 @@ import DanmakuWebSocket from "../assets/danmaku-websocket.min.js" import { Notyf } from 'notyf' import { closeCoyoteSocket, addOrIncrease, sendWaveData } from "./coyote" +import { waveData } from "../assets/dataMap"; let ws: DanmakuWebSocket const notyf = new Notyf({ duration: 4000 }) @@ -55,7 +56,7 @@ function createSocket(authBody: string, wssLinks: string[]) { } else { // 其他礼物,发送波形数据 try { - sendWaveData(5, 5, res.data.gift_id, res.data.gift_id) + sendWaveData(5, 5, waveData[res.data.gift_id], waveData[res.data.gift_id]) notyf.success("收到礼物" + res.data.gift_name) } catch (e) { diff --git a/src/waveHelper.ts b/src/waveHelper.ts new file mode 100644 index 0000000..4bf52cc --- /dev/null +++ b/src/waveHelper.ts @@ -0,0 +1,5 @@ +import { createApp } from "vue" +import App from "./waveHelper.vue" + +createApp(App).mount("#app") + diff --git a/src/waveHelper.vue b/src/waveHelper.vue new file mode 100644 index 0000000..dc31393 --- /dev/null +++ b/src/waveHelper.vue @@ -0,0 +1,179 @@ + + + + + diff --git a/waveHelper.html b/waveHelper.html new file mode 100644 index 0000000..ad65f5b --- /dev/null +++ b/waveHelper.html @@ -0,0 +1,17 @@ + + + + + + + + + waveHelper + + +
+ + + + +