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

View File

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

View File

@ -88,7 +88,6 @@
</details> </details>
</body> </body>
<script> <script>
const logger = require('../util/logger.js')
PetiteVue.createApp({ PetiteVue.createApp({
message: '请点击获取登录状态', message: '请点击获取登录状态',
account: { account: {
@ -140,7 +139,7 @@
cookie: localStorage.getItem('cookie'), cookie: localStorage.getItem('cookie'),
}, },
}) })
logger.info(res) console.info(res)
if (res.data.code != 200) { if (res.data.code != 200) {
this.message = '加入房间出现问题: ' + res.data.message this.message = '加入房间出现问题: ' + res.data.message
} else { } else {
@ -153,7 +152,7 @@
cookie: localStorage.getItem('cookie'), cookie: localStorage.getItem('cookie'),
}, },
}) })
logger.info(res2) console.info(res2)
const res3 = await axios({ const res3 = await axios({
url: 'listentogether/sync/playlist/get', url: 'listentogether/sync/playlist/get',
method: 'post', method: 'post',
@ -174,7 +173,7 @@
cookie: localStorage.getItem('cookie'), cookie: localStorage.getItem('cookie'),
}, },
}) })
logger.info(resa) console.info(resa)
this.playlistInfo.playlistTracks = resa.data.songs this.playlistInfo.playlistTracks = resa.data.songs
} }
}, },
@ -186,7 +185,7 @@
cookie: localStorage.getItem('cookie'), cookie: localStorage.getItem('cookie'),
}, },
}) })
logger.info(res) console.info(res)
if (res.data.code != 200) { if (res.data.code != 200) {
this.message = '创建房间出现问题: ' + res.data.message this.message = '创建房间出现问题: ' + res.data.message
} else { } else {
@ -201,7 +200,7 @@
cookie: localStorage.getItem('cookie'), cookie: localStorage.getItem('cookie'),
}, },
}) })
logger.info(res2) console.info(res2)
} }
}, },
refreshRoom: async function () { refreshRoom: async function () {
@ -211,7 +210,7 @@
cookie: localStorage.getItem('cookie'), cookie: localStorage.getItem('cookie'),
}, },
}) })
logger.info(res) console.info(res)
if (res.data.code != 200 || !res.data.data.inRoom) { if (res.data.code != 200 || !res.data.data.inRoom) {
this.message = '房间状态获取失败, 可能退出了房间' this.message = '房间状态获取失败, 可能退出了房间'
} else { } else {
@ -227,7 +226,7 @@
cookie: localStorage.getItem('cookie'), cookie: localStorage.getItem('cookie'),
}, },
}) })
logger.info(res) console.info(res)
if (res.data.code != 200 || !res.data.data.success) { if (res.data.code != 200 || !res.data.data.success) {
this.message = '房间关闭失败' this.message = '房间关闭失败'
} else { } else {
@ -244,7 +243,7 @@
cookie: localStorage.getItem('cookie'), cookie: localStorage.getItem('cookie'),
}, },
}) })
logger.info(res) console.info(res)
this.playlistInfo.playlistName = res.data.playlist.name this.playlistInfo.playlistName = res.data.playlist.name
this.playlistInfo.playlistTrackIds = res.data.playlist.trackIds this.playlistInfo.playlistTrackIds = res.data.playlist.trackIds
.map((track) => track.id) .map((track) => track.id)
@ -257,7 +256,7 @@
cookie: localStorage.getItem('cookie'), cookie: localStorage.getItem('cookie'),
}, },
}) })
logger.info(resa) console.info(resa)
this.playlistInfo.playlistTracks = resa.data.songs this.playlistInfo.playlistTracks = resa.data.songs
if (this.roomInfo.roomId) { if (this.roomInfo.roomId) {
const resb = await axios({ const resb = await axios({
@ -274,7 +273,7 @@
cookie: localStorage.getItem('cookie'), cookie: localStorage.getItem('cookie'),
}, },
}) })
logger.info(resb) console.info(resb)
} }
}, },
gotoTrack: async function (trackId) { gotoTrack: async function (trackId) {
@ -317,7 +316,7 @@
cookie: localStorage.getItem('cookie'), cookie: localStorage.getItem('cookie'),
}, },
}) })
logger.info(res) console.info(res)
}, },
}).mount() }).mount()
</script> </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/axios@0.26.1/dist/axios.min.js"></script>
<script src="https://fastly.jsdelivr.net/npm/vue"></script> <script src="https://fastly.jsdelivr.net/npm/vue"></script>
<script> <script>
const logger = require('../util/logger.js')
Vue.createApp({ Vue.createApp({
data() { data() {
return { return {
@ -62,7 +61,7 @@
}, },
methods: { methods: {
submit() { submit() {
logger.info('submit') console.info('submit')
const file = document.querySelector('input[type=file]').files[0] const file = document.querySelector('input[type=file]').files[0]
this.upload(file) this.upload(file)
}, },
@ -72,14 +71,14 @@
url: `/voicelist/search?cookie=${localStorage.getItem('cookie')}`, 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 = res.data.data.list
this.voicelist.map(async (i) => { this.voicelist.map(async (i) => {
const res2 = await axios({ const res2 = await axios({
url: `/voicelist/list?voiceListId=${i.voiceListId}&limit=5`, url: `/voicelist/list?voiceListId=${i.voiceListId}&limit=5`,
}) })
i.voiceListData = res2.data.data.list i.voiceListData = res2.data.data.list
logger.info(res2) console.info(res2)
}) })
}, },
upload(file) { upload(file) {
@ -104,11 +103,11 @@
.then((res) => { .then((res) => {
alert(`${file.name} 上传成功`) alert(`${file.name} 上传成功`)
if (currentIndx >= fileLength) { if (currentIndx >= fileLength) {
logger.info('上传完毕') console.info('上传完毕')
} }
}) })
.catch(async (err) => { .catch(async (err) => {
logger.info(err) console.info(err)
}) })
}, },
}, },