避免列表还未生成
This commit is contained in:
parent
662db2a75b
commit
6c30ebfc5d
38
demo.html
Normal file
38
demo.html
Normal file
@ -0,0 +1,38 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>demo</title>
|
||||
</head>
|
||||
<body>
|
||||
<script type="module">
|
||||
import GUN from 'gun'
|
||||
import SEA from 'gun/sea'
|
||||
|
||||
const gun = GUN({
|
||||
peers: ['http://localhost:8000/gun'],
|
||||
localStorage: false
|
||||
})
|
||||
|
||||
gun.get('text').once((node) => {
|
||||
console.log("Receiving Initial Data")
|
||||
console.log(node)
|
||||
})
|
||||
|
||||
gun.get('text').put({
|
||||
text: 'Hello World'
|
||||
})
|
||||
|
||||
gun.get('text').on((node) => {
|
||||
console.log("Receiving Update")
|
||||
console.log(node)
|
||||
})
|
||||
|
||||
document.addEventListener('click', () => {
|
||||
gun.get('text').put({
|
||||
text: 'Hello World'
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
12
demo.js
Normal file
12
demo.js
Normal file
@ -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})
|
@ -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",
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user