fix(require): fix modules not defined

This commit is contained in:
ElyPrism 2026-01-09 21:44:03 +08:00
parent 6613fbf50d
commit 748d5da8fe
No known key found for this signature in database
4 changed files with 24 additions and 28 deletions

View File

@ -20,7 +20,6 @@
<script src="https://fastly.jsdelivr.net/npm/axios@0.26.1/dist/axios.min.js"></script>
<script src="https://fastly.jsdelivr.net/npm/vue"></script>
<script>
const logger = require('../util/logger.js')
const app = Vue.createApp({
data() {
return {
@ -32,14 +31,14 @@
},
methods: {
getData() {
logger.info('getdata')
console.info('getdata')
const _this = this
axios({
url: `/user/cloud?time=${Date.now()}&cookie=${localStorage.getItem(
'cookie',
)}`,
}).then((res) => {
logger.info(res.data)
console.info(res.data)
_this.songs = res.data.data
})
},
@ -52,7 +51,7 @@
document
.querySelector('input[type="file"]')
.addEventListener('change', function (e) {
logger.info(this.files)
console.info(this.files)
let currentIndx = 0
fileLength = this.files.length
for (const item of this.files) {
@ -77,15 +76,15 @@
data: formData,
})
.then((res) => {
logger.info(`${file.name} 上传成功`)
console.info(`${file.name} 上传成功`)
if (currentIndx >= fileLength) {
logger.info('上传完毕')
console.info('上传完毕')
}
app.getData()
})
.catch(async (err) => {
logger.info(err)
logger.info(fileUpdateTime)
console.info(err)
console.info(fileUpdateTime)
fileUpdateTime[file.name]
? (fileUpdateTime[file.name] += 1)
: (fileUpdateTime[file.name] = 1)

View File

@ -12,7 +12,6 @@
</div>
<script src="https://fastly.jsdelivr.net/npm/axios@0.26.1/dist/axios.min.js"></script>
<script>
const logger = require('../util/logger.js')
async function main() {
const res = await axios({
url: `/homepage/block/page`,
@ -22,7 +21,7 @@
method: 'post',
})
let cursor = ''
logger.info(res.data.data)
console.info(res.data.data)
if (res.data.data.hasMore) {
cursor = res.data.data.cursor
const res2 = await axios({

View File

@ -88,7 +88,6 @@
</details>
</body>
<script>
const logger = require('../util/logger.js')
PetiteVue.createApp({
message: '请点击获取登录状态',
account: {
@ -140,7 +139,7 @@
cookie: localStorage.getItem('cookie'),
},
})
logger.info(res)
console.info(res)
if (res.data.code != 200) {
this.message = '加入房间出现问题: ' + res.data.message
} else {
@ -153,7 +152,7 @@
cookie: localStorage.getItem('cookie'),
},
})
logger.info(res2)
console.info(res2)
const res3 = await axios({
url: 'listentogether/sync/playlist/get',
method: 'post',
@ -174,7 +173,7 @@
cookie: localStorage.getItem('cookie'),
},
})
logger.info(resa)
console.info(resa)
this.playlistInfo.playlistTracks = resa.data.songs
}
},
@ -186,7 +185,7 @@
cookie: localStorage.getItem('cookie'),
},
})
logger.info(res)
console.info(res)
if (res.data.code != 200) {
this.message = '创建房间出现问题: ' + res.data.message
} else {
@ -201,7 +200,7 @@
cookie: localStorage.getItem('cookie'),
},
})
logger.info(res2)
console.info(res2)
}
},
refreshRoom: async function () {
@ -211,7 +210,7 @@
cookie: localStorage.getItem('cookie'),
},
})
logger.info(res)
console.info(res)
if (res.data.code != 200 || !res.data.data.inRoom) {
this.message = '房间状态获取失败, 可能退出了房间'
} else {
@ -227,7 +226,7 @@
cookie: localStorage.getItem('cookie'),
},
})
logger.info(res)
console.info(res)
if (res.data.code != 200 || !res.data.data.success) {
this.message = '房间关闭失败'
} else {
@ -244,7 +243,7 @@
cookie: localStorage.getItem('cookie'),
},
})
logger.info(res)
console.info(res)
this.playlistInfo.playlistName = res.data.playlist.name
this.playlistInfo.playlistTrackIds = res.data.playlist.trackIds
.map((track) => track.id)
@ -257,7 +256,7 @@
cookie: localStorage.getItem('cookie'),
},
})
logger.info(resa)
console.info(resa)
this.playlistInfo.playlistTracks = resa.data.songs
if (this.roomInfo.roomId) {
const resb = await axios({
@ -274,7 +273,7 @@
cookie: localStorage.getItem('cookie'),
},
})
logger.info(resb)
console.info(resb)
}
},
gotoTrack: async function (trackId) {
@ -317,7 +316,7 @@
cookie: localStorage.getItem('cookie'),
},
})
logger.info(res)
console.info(res)
},
}).mount()
</script>

View File

@ -35,7 +35,6 @@
<script src="https://fastly.jsdelivr.net/npm/axios@0.26.1/dist/axios.min.js"></script>
<script src="https://fastly.jsdelivr.net/npm/vue"></script>
<script>
const logger = require('../util/logger.js')
Vue.createApp({
data() {
return {
@ -62,7 +61,7 @@
},
methods: {
submit() {
logger.info('submit')
console.info('submit')
const file = document.querySelector('input[type=file]').files[0]
this.upload(file)
},
@ -72,14 +71,14 @@
url: `/voicelist/search?cookie=${localStorage.getItem('cookie')}`,
})
logger.info(res.data.data)
console.info(res.data.data)
this.voicelist = res.data.data.list
this.voicelist.map(async (i) => {
const res2 = await axios({
url: `/voicelist/list?voiceListId=${i.voiceListId}&limit=5`,
})
i.voiceListData = res2.data.data.list
logger.info(res2)
console.info(res2)
})
},
upload(file) {
@ -104,11 +103,11 @@
.then((res) => {
alert(`${file.name} 上传成功`)
if (currentIndx >= fileLength) {
logger.info('上传完毕')
console.info('上传完毕')
}
})
.catch(async (err) => {
logger.info(err)
console.info(err)
})
},
},