From 6c30ebfc5d61eb61629f09eeea02df813d2e706f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A7=89?= Date: Tue, 31 Oct 2023 15:57:58 +0800 Subject: [PATCH] =?UTF-8?q?=E9=81=BF=E5=85=8D=E5=88=97=E8=A1=A8=E8=BF=98?= =?UTF-8?q?=E6=9C=AA=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo.html | 38 ++++++++++++++++++++++++++++++++++++++ demo.js | 12 ++++++++++++ package.json | 1 + src/main.js | 3 ++- 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 demo.html create mode 100644 demo.js diff --git a/demo.html b/demo.html new file mode 100644 index 0000000..f8cd698 --- /dev/null +++ b/demo.html @@ -0,0 +1,38 @@ + + + + + demo + + + + + diff --git a/demo.js b/demo.js new file mode 100644 index 0000000..84428b1 --- /dev/null +++ b/demo.js @@ -0,0 +1,12 @@ +import express from 'express' +import gun from 'gun' + +const app = express() +const port = 8000 +app.use(gun.serve) + +const server = app.listen(port, () => { + console.log("Listening at: http://localhost:" + port) +}) + +gun({web: server}) diff --git a/package.json b/package.json index 450f3c9..30a919d 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "buffer": "^6.0.3", "express": "^4.18.2", "express-ws": "^5.0.2", + "gun": "^0.2020.1239", "iconv-lite": "^0.6.3", "iconv-lite-umd": "^0.6.10", "idb-keyval": "^6.2.1", diff --git a/src/main.js b/src/main.js index 6dbe9b7..16169e6 100644 --- a/src/main.js +++ b/src/main.js @@ -142,8 +142,9 @@ const musicList = new MusicList({ } }) const client = clientList.clientlist.find(client => { - return client.musicList.find(x => x.id === item.id) + return client.musicList?.find(x => x.id === item.id) }) + if (!client) return console.error('未找到拥有此音乐的用户') console.info('向', client.name, '请求音乐数据') const c = Math.ceil(item.size / CHUNK_SIZE)