fix(build): PlaylistCardPage 移除显式 TS 类型注解,保持 pure JS 风格避免 babel parser Missing semicolon
This commit is contained in:
@@ -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<string, string> = {
|
||||
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<any>('/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 }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user