From bdefc105bfecd1ef25b26b5c5fcc1271e5fc3ec1 Mon Sep 17 00:00:00 2001 From: HenryDu8133 <813367384@qq.com> Date: Sun, 13 Sep 2026 13:08:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(build):=20PlaylistCardPage=20=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E6=98=BE=E5=BC=8F=20TS=20=E7=B1=BB=E5=9E=8B=E6=B3=A8?= =?UTF-8?q?=E8=A7=A3=EF=BC=8C=E4=BF=9D=E6=8C=81=20pure=20JS=20=E9=A3=8E?= =?UTF-8?q?=E6=A0=BC=E9=81=BF=E5=85=8D=20babel=20parser=20Missing=20semico?= =?UTF-8?q?lon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/Admin/PlaylistCardPage.vue | 46 +++++++++++------------ 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/app/components/Admin/PlaylistCardPage.vue b/app/components/Admin/PlaylistCardPage.vue index 1acef80..a889c34 100644 --- a/app/components/Admin/PlaylistCardPage.vue +++ b/app/components/Admin/PlaylistCardPage.vue @@ -139,7 +139,7 @@ import AdminPlaylistCardGenerator from './PlaylistCardGenerator.vue' import { useAuth } from '~/composables/useAuth' const auth = import.meta.client ? useAuth() : { getAuthConfig: () => ({}) } -let adminInstance: any = null +let adminInstance = null const getAdmin = async () => { if (!import.meta.client) return null if (adminInstance) return adminInstance @@ -147,11 +147,11 @@ const getAdmin = async () => { adminInstance = mod.useAdmin() return adminInstance } -const adminShim: any = { +const adminShim = { loading: { value: false }, error: { value: '' }, - addSong: async (p: any) => { const a = await getAdmin(); return a ? a.addSong(p) : { success: false } }, - createSchedule: async (...args: any[]) => { const a = await getAdmin(); return a ? a.createSchedule(...args) : { success: false } } + addSong: async (p) => { const a = await getAdmin(); return a ? a.addSong(p) : { success: false } }, + createSchedule: async (...args) => { const a = await getAdmin(); return a ? a.createSchedule(...args) : { success: false } } } const admin = import.meta.client ? adminShim : adminShim @@ -171,7 +171,7 @@ const playTimes = ref([]) const displaySongs = computed(() => parsedSongs.value.length ? parsedSongs.value : schedules.value) const statusClass = (s) => { - const map: Record = { + const map = { '歌曲已创建': 'bg-emerald-500/15 text-emerald-400', '已匹配现有歌曲': 'bg-blue-500/15 text-blue-400', '匹配失败(未创建)': 'bg-amber-500/15 text-amber-400', @@ -184,7 +184,7 @@ const statusClass = (s) => { const parsePasteText = () => { if (!import.meta.client) return const lines = pasteText.value.split(/\r?\n/).map(l => l.trim()).filter(Boolean) - const out: Array<{ title: string, artist: string, status?: string }> = [] + const out = [] for (const line of lines) { let t = line t = t.replace(/^[\d]+[\s.、\-、)]+/, '') @@ -203,7 +203,7 @@ const parsePasteText = () => { else { title = t; artist = '' } if (title) out.push({ title, artist }) } - parsedSongs.value = out as any + parsedSongs.value = out } const clearParsed = () => { @@ -215,7 +215,7 @@ const fetchSchedules = async () => { if (!import.meta.client) return loading.value = true try { - const response = await $fetch('/api/admin/schedule/full', { + const response = await $fetch('/api/admin/schedule/full', { ...auth.getAuthConfig(), query: { date: selectedDate.value, includeDrafts: 'true' } }) @@ -224,32 +224,32 @@ const fetchSchedules = async () => { } else schedules.value = [] } catch (error) { console.error('Failed to fetch schedules:', error) - if ((window as any).$showNotification) (window as any).$showNotification('获取排期失败', 'error') + if (window.$showNotification) window.$showNotification('获取排期失败', 'error') } finally { loading.value = false } } const fetchPlayTimes = async () => { if (!import.meta.client) return try { - const r: any = await $fetch('/api/admin/play-times', { ...auth.getAuthConfig() }) + const r = await $fetch('/api/admin/play-times', { ...auth.getAuthConfig() }) if (r && r.success && r.data) playTimes.value = (r.data.playTimes || r.data || []).filter(Boolean) } catch (e) { console.warn(e) } } -const findOrCreateSong = async ({ title, artist }: { title: string, artist: string }) => { +const findOrCreateSong = async ({ title, artist }) => { if (!import.meta.client) return { created: false, song: null, failMsg: '客户端-only' } try { - const search: any = await $fetch('/api/songs', { + const search = await $fetch('/api/songs', { ...auth.getAuthConfig(), query: { q: `${title} ${artist}`, limit: 20 } }) - const list: any[] = search?.data?.songs || search?.songs || [] + const list = search?.data?.songs || search?.songs || [] const hit = list.find(s => s.title && s.title.toLowerCase() === title.toLowerCase() && (!artist || !s.artist || s.artist.toLowerCase() === artist.toLowerCase()) ) if (hit) return { created: false, song: hit } - const addResult: any = await (admin as any).addSong({ + const addResult = await admin.addSong({ title, artist: artist || '未知歌手', language: 'Chinese', sourceType: 'kugou', status: 'approved', contributor: 'admin', musicPlatform: 'kugou', platformSongId: '', lyrics: '', coverUrl: '', duration: 0, sourceUrl: '' @@ -258,7 +258,7 @@ const findOrCreateSong = async ({ title, artist }: { title: string, artist: stri if (addResult?.success && addResult?.data?.song) return { created: true, song: addResult.data.song } if (addResult?.song) return { created: true, song: addResult.song } return { created: false, song: null, failMsg: addResult?.message || '返回值无法解析' } - } catch (e: any) { + } catch (e) { return { created: false, song: null, failMsg: e?.message || '接口调用异常' } } } @@ -267,8 +267,8 @@ const generateSchedulesFromList = async () => { if (!import.meta.client || displaySongs.value.length === 0) return generatingSchedule.value = true try { - const toProcess: any[] = parsedSongs.value.length ? parsedSongs.value : schedules.value - const results: Array<{ title: string, artist: string, status: string }> = [] + const toProcess = parsedSongs.value.length ? parsedSongs.value : schedules.value + const results = [] const playDateStr = selectedDate.value let nextSeq = 1 for (const row of toProcess) { @@ -291,19 +291,19 @@ const generateSchedulesFromList = async () => { scheduleRow.status = '已匹配现有歌曲' } try { - const res: any = await (admin as any).createSchedule(Number(songObj.id), playDateStr, + const res = await admin.createSchedule(Number(songObj.id), playDateStr, (selectedPlayTimeId.value != null) ? Number(selectedPlayTimeId.value) : (songObj.preferredPlayTimeId || null), nextSeq) if (res?.success) { scheduleRow.status = '排期已创建'; nextSeq++ } else { scheduleRow.status = `排期保存失败:${res?.message || '未知原因'}` } - } catch (e: any) { scheduleRow.status = `排期保存失败:${e?.message || '接口异常'}` } + } catch (e) { scheduleRow.status = `排期保存失败:${e?.message || '接口异常'}` } results.push(scheduleRow) } - parsedSongs.value = results as any + parsedSongs.value = results await fetchSchedules() - if ((window as any).$showNotification) (window as any).$showNotification(`批量保存完成:${results.filter(r => r.status === '排期已创建').length}/${results.length} 成功`, 'success') - } catch (e: any) { + if (window.$showNotification) window.$showNotification(`批量保存完成:${results.filter(r => r.status === '排期已创建').length}/${results.length} 成功`, 'success') + } catch (e) { console.error(e) - if ((window as any).$showNotification) (window as any).$showNotification('批量排期失败:' + (e?.message || '未知错误'), 'error') + if (window.$showNotification) window.$showNotification('批量排期失败:' + (e?.message || '未知错误'), 'error') } finally { generatingSchedule.value = false } }