diff --git a/lx/latest.js b/lx/latest.js index 962e94e..8c298bd 100644 --- a/lx/latest.js +++ b/lx/latest.js @@ -214,24 +214,24 @@ const handleGetMusicLyric = async (source, musicInfo) => { } // 检查源脚本是否有更新 -// const checkUpdate = async () => { -// const request = await httpFetch(`${API_URL}/script?key=${API_KEY}&checkUpdate=${SCRIPT_MD5}`, { -// method: 'GET', -// headers: { -// 'Content-Type': 'application/json', -// 'User-Agent': `${env ? `lx-music-${env}/${version}` : `lx-music-request/${version}`}` -// }, -// }) -// const { body } = request +const checkUpdate = async () => { + const request = await httpFetch(`${API_URL}/script?key=${API_KEY}&checkUpdate=${SCRIPT_MD5}`, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + 'User-Agent': `${env ? `lx-music-${env}/${version}` : `lx-music-request/${version}`}` + }, + }) + const { body } = request -// if (!body || body.code !== 0) console.log('checkUpdate failed') -// else { -// console.log('checkUpdate success') -// if (body.data != null) { -// globalThis.lx.send(lx.EVENT_NAMES.updateAlert, { log: body.data.updateMsg, updateUrl: body.data.updateUrl }) -// } -// } -// } + if (!body || body.code !== 0) console.log('checkUpdate failed') + else { + console.log('checkUpdate success') + if (body.data != null) { + globalThis.lx.send(lx.EVENT_NAMES.updateAlert, { log: body.data.updateMsg, updateUrl: body.data.updateUrl }) + } + } +} // 生成歌曲信息 const musicSources = {} @@ -294,6 +294,6 @@ on(EVENT_NAMES.request, ({ action, source, info }) => { }) // 检查更新 -// if (UPDATE_ENABLE) checkUpdate() -// // 向 LX Music 发送初始化成功事件 -// send(EVENT_NAMES.inited, { status: true, openDevTools: DEV_ENABLE, sources: musicSources }) \ No newline at end of file +if (UPDATE_ENABLE) checkUpdate() +// 向 LX Music 发送初始化成功事件 +send(EVENT_NAMES.inited, { status: true, openDevTools: DEV_ENABLE, sources: musicSources }) \ No newline at end of file