fix(build): PlaylistCardPage 移除显式 TS 类型注解,保持 pure JS 风格避免 babel parser Missing semicolon
构建并部署 BYW VoiceHub / Preflight 语法与构建检查 (push) Failing after 2m31s
构建并部署 BYW VoiceHub / 镜像构建·预热(与 Preflight 并发:系统/镜像源/Builder 初始化) (push) Successful in 3m52s
构建并部署 BYW VoiceHub / 构建并推送容器镜像 (push) Skipped
构建并部署 BYW VoiceHub / 部署到生产服务器 (push) Skipped

This commit is contained in:
2026-09-13 13:08:22 +08:00
parent 8ff5bec4f0
commit bdefc105bf
+23 -23
View File
@@ -139,7 +139,7 @@ import AdminPlaylistCardGenerator from './PlaylistCardGenerator.vue'
import { useAuth } from '~/composables/useAuth' import { useAuth } from '~/composables/useAuth'
const auth = import.meta.client ? useAuth() : { getAuthConfig: () => ({}) } const auth = import.meta.client ? useAuth() : { getAuthConfig: () => ({}) }
let adminInstance: any = null let adminInstance = null
const getAdmin = async () => { const getAdmin = async () => {
if (!import.meta.client) return null if (!import.meta.client) return null
if (adminInstance) return adminInstance if (adminInstance) return adminInstance
@@ -147,11 +147,11 @@ const getAdmin = async () => {
adminInstance = mod.useAdmin() adminInstance = mod.useAdmin()
return adminInstance return adminInstance
} }
const adminShim: any = { const adminShim = {
loading: { value: false }, loading: { value: false },
error: { value: '' }, error: { value: '' },
addSong: async (p: any) => { const a = await getAdmin(); return a ? a.addSong(p) : { success: false } }, addSong: async (p) => { 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 } } createSchedule: async (...args) => { const a = await getAdmin(); return a ? a.createSchedule(...args) : { success: false } }
} }
const admin = import.meta.client ? adminShim : adminShim 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 displaySongs = computed(() => parsedSongs.value.length ? parsedSongs.value : schedules.value)
const statusClass = (s) => { const statusClass = (s) => {
const map: Record<string, string> = { const map = {
'歌曲已创建': 'bg-emerald-500/15 text-emerald-400', '歌曲已创建': 'bg-emerald-500/15 text-emerald-400',
'已匹配现有歌曲': 'bg-blue-500/15 text-blue-400', '已匹配现有歌曲': 'bg-blue-500/15 text-blue-400',
'匹配失败(未创建)': 'bg-amber-500/15 text-amber-400', '匹配失败(未创建)': 'bg-amber-500/15 text-amber-400',
@@ -184,7 +184,7 @@ const statusClass = (s) => {
const parsePasteText = () => { const parsePasteText = () => {
if (!import.meta.client) return if (!import.meta.client) return
const lines = pasteText.value.split(/\r?\n/).map(l => l.trim()).filter(Boolean) 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) { for (const line of lines) {
let t = line let t = line
t = t.replace(/^[\d]+[\s.、\-、)]+/, '') t = t.replace(/^[\d]+[\s.、\-、)]+/, '')
@@ -203,7 +203,7 @@ const parsePasteText = () => {
else { title = t; artist = '' } else { title = t; artist = '' }
if (title) out.push({ title, artist }) if (title) out.push({ title, artist })
} }
parsedSongs.value = out as any parsedSongs.value = out
} }
const clearParsed = () => { const clearParsed = () => {
@@ -215,7 +215,7 @@ const fetchSchedules = async () => {
if (!import.meta.client) return if (!import.meta.client) return
loading.value = true loading.value = true
try { try {
const response = await $fetch<any>('/api/admin/schedule/full', { const response = await $fetch('/api/admin/schedule/full', {
...auth.getAuthConfig(), ...auth.getAuthConfig(),
query: { date: selectedDate.value, includeDrafts: 'true' } query: { date: selectedDate.value, includeDrafts: 'true' }
}) })
@@ -224,32 +224,32 @@ const fetchSchedules = async () => {
} else schedules.value = [] } else schedules.value = []
} catch (error) { } catch (error) {
console.error('Failed to fetch schedules:', 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 } } finally { loading.value = false }
} }
const fetchPlayTimes = async () => { const fetchPlayTimes = async () => {
if (!import.meta.client) return if (!import.meta.client) return
try { 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) if (r && r.success && r.data) playTimes.value = (r.data.playTimes || r.data || []).filter(Boolean)
} catch (e) { console.warn(e) } } 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' } if (!import.meta.client) return { created: false, song: null, failMsg: '客户端-only' }
try { try {
const search: any = await $fetch('/api/songs', { const search = await $fetch('/api/songs', {
...auth.getAuthConfig(), ...auth.getAuthConfig(),
query: { q: `${title} ${artist}`, limit: 20 } 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 => const hit = list.find(s =>
s.title && s.title.toLowerCase() === title.toLowerCase() && s.title && s.title.toLowerCase() === title.toLowerCase() &&
(!artist || !s.artist || s.artist.toLowerCase() === artist.toLowerCase()) (!artist || !s.artist || s.artist.toLowerCase() === artist.toLowerCase())
) )
if (hit) return { created: false, song: hit } 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', title, artist: artist || '未知歌手', language: 'Chinese', sourceType: 'kugou', status: 'approved',
contributor: 'admin', musicPlatform: 'kugou', platformSongId: '', contributor: 'admin', musicPlatform: 'kugou', platformSongId: '',
lyrics: '', coverUrl: '', duration: 0, sourceUrl: '' 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?.success && addResult?.data?.song) return { created: true, song: addResult.data.song }
if (addResult?.song) return { created: true, song: addResult.song } if (addResult?.song) return { created: true, song: addResult.song }
return { created: false, song: null, failMsg: addResult?.message || '返回值无法解析' } return { created: false, song: null, failMsg: addResult?.message || '返回值无法解析' }
} catch (e: any) { } catch (e) {
return { created: false, song: null, failMsg: e?.message || '接口调用异常' } return { created: false, song: null, failMsg: e?.message || '接口调用异常' }
} }
} }
@@ -267,8 +267,8 @@ const generateSchedulesFromList = async () => {
if (!import.meta.client || displaySongs.value.length === 0) return if (!import.meta.client || displaySongs.value.length === 0) return
generatingSchedule.value = true generatingSchedule.value = true
try { try {
const toProcess: any[] = parsedSongs.value.length ? parsedSongs.value : schedules.value const toProcess = parsedSongs.value.length ? parsedSongs.value : schedules.value
const results: Array<{ title: string, artist: string, status: string }> = [] const results = []
const playDateStr = selectedDate.value const playDateStr = selectedDate.value
let nextSeq = 1 let nextSeq = 1
for (const row of toProcess) { for (const row of toProcess) {
@@ -291,19 +291,19 @@ const generateSchedulesFromList = async () => {
scheduleRow.status = '已匹配现有歌曲' scheduleRow.status = '已匹配现有歌曲'
} }
try { 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) (selectedPlayTimeId.value != null) ? Number(selectedPlayTimeId.value) : (songObj.preferredPlayTimeId || null), nextSeq)
if (res?.success) { scheduleRow.status = '排期已创建'; nextSeq++ } if (res?.success) { scheduleRow.status = '排期已创建'; nextSeq++ }
else { scheduleRow.status = `排期保存失败:${res?.message || '未知原因'}` } else { scheduleRow.status = `排期保存失败:${res?.message || '未知原因'}` }
} catch (e: any) { scheduleRow.status = `排期保存失败:${e?.message || '接口异常'}` } } catch (e) { scheduleRow.status = `排期保存失败:${e?.message || '接口异常'}` }
results.push(scheduleRow) results.push(scheduleRow)
} }
parsedSongs.value = results as any parsedSongs.value = results
await fetchSchedules() await fetchSchedules()
if ((window as any).$showNotification) (window as any).$showNotification(`批量保存完成:${results.filter(r => r.status === '排期已创建').length}/${results.length} 成功`, 'success') if (window.$showNotification) window.$showNotification(`批量保存完成:${results.filter(r => r.status === '排期已创建').length}/${results.length} 成功`, 'success')
} catch (e: any) { } catch (e) {
console.error(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 } } finally { generatingSchedule.value = false }
} }