feat: 迁移自定义功能至 1.5.9.9 版本

包含音乐源限制、CI 防 OOM 优化、数据库连接池优化、管理端权限及 UI 细节定制等功能
This commit is contained in:
2026-09-12 19:26:42 +08:00
parent 34f0679117
commit 1106aeea6c
161 changed files with 18963 additions and 27900 deletions
+113 -139
View File
@@ -3,49 +3,49 @@
<!-- 页面标题 -->
<div class="flex flex-col md:flex-row md:items-end justify-between gap-6">
<div>
<h2 class="text-2xl font-black text-text-primary tracking-tight">{{ locale.title }}</h2>
<p class="text-xs text-text-tertiary mt-1">
{{ locale.desc }}
<h2 class="text-2xl font-black text-zinc-100 tracking-tight">播出时段管理</h2>
<p class="text-xs text-zinc-500 mt-1">
定义校园广播的常规播放窗口,用户仅可在这些时间段内进行点歌或查看排期
</p>
</div>
<div class="flex items-center gap-3">
<div
class="bg-bg-secondary-40 border border-border-secondary rounded-xl px-4 py-2 flex items-center gap-3"
class="bg-zinc-900/40 border border-zinc-800 rounded-xl px-4 py-2 flex items-center gap-3"
>
<span class="text-[10px] font-black text-text-tertiary uppercase tracking-widest"
>{{ locale.enableSelection }}</span
<span class="text-[10px] font-black text-zinc-500 uppercase tracking-widest"
>启用播出时段选择</span
>
<button
:class="[
'relative w-10 h-5 rounded-full transition-colors',
enablePlayTimeSelection ? 'bg-primary-hover' : 'bg-bg-tertiary'
enablePlayTimeSelection ? 'bg-blue-600' : 'bg-zinc-800'
]"
@click="toggleGlobalEnabled"
>
<div
:class="[
'absolute top-1 w-3 h-3 bg-bg-secondary rounded-full transition-all',
'absolute top-1 w-3 h-3 bg-white rounded-full transition-all',
enablePlayTimeSelection ? 'left-6' : 'left-1'
]"
/>
</button>
</div>
<button
class="flex items-center gap-2 px-6 py-2.5 bg-primary-hover hover:bg-primary text-text-primary text-xs font-black rounded-lg shadow-lg shadow-[var(--primary-glow)] transition-all active:scale-95"
class="flex items-center gap-2 px-6 py-2.5 bg-blue-600 hover:bg-blue-500 text-white text-xs font-black rounded-lg shadow-lg shadow-blue-900/20 transition-all active:scale-95"
@click="openAddForm"
>
<Plus :size="14" /> {{ locale.add }}
<Plus :size="14" /> 添加播出时段
</button>
</div>
</div>
<!-- 信息卡片 -->
<div class="bg-primary-hover-5 border border-primary-10 rounded-xl p-5 flex items-start gap-4">
<Info class="text-primary shrink-0 mt-0.5" :size="18" />
<div class="bg-blue-600/5 border border-blue-500/10 rounded-xl p-5 flex items-start gap-4">
<Info class="text-blue-500 shrink-0 mt-0.5" :size="18" />
<div class="space-y-1">
<p class="text-xs font-bold text-text-secondary">{{ locale.aboutTitle }}</p>
<p class="text-[11px] text-text-tertiary leading-relaxed">
{{ locale.aboutDesc }}
<p class="text-xs font-bold text-zinc-300">关于时段限制</p>
<p class="text-[11px] text-zinc-500 leading-relaxed">
启用全局时段选择后,系统将仅在定义的时段内开放点歌功能。如果未设置开始或结束时间,系统将视为该边界不设限。
</p>
</div>
</div>
@@ -53,35 +53,37 @@
<!-- 加载状态 -->
<div
v-if="loading"
class="flex flex-col items-center justify-center py-20 space-y-4 bg-bg-secondary-20 border border-border-secondary-50 rounded-xl"
class="flex flex-col items-center justify-center py-20 space-y-4 bg-zinc-900/20 border border-zinc-800/50 rounded-xl"
>
<AppSpinner :size="40" />
<p class="text-xs font-black text-text-tertiary uppercase tracking-widest">{{ locale.loading }}</p>
<div
class="w-10 h-10 border-4 border-blue-600/20 border-t-blue-600 rounded-full animate-spin"
/>
<p class="text-xs font-black text-zinc-500 uppercase tracking-widest">加载中...</p>
</div>
<!-- 错误状态 -->
<div
v-else-if="error"
class="bg-error-5 border border-error-10 rounded-xl p-5 flex items-start gap-4"
class="bg-red-500/5 border border-red-500/10 rounded-xl p-5 flex items-start gap-4"
>
<AlertCircle class="text-error shrink-0 mt-0.5" :size="18" />
<AlertCircle class="text-red-500 shrink-0 mt-0.5" :size="18" />
<div class="space-y-1">
<p class="text-xs font-bold text-text-secondary">{{ locale.fetchFailed }}</p>
<p class="text-[11px] text-text-tertiary leading-relaxed">{{ error }}</p>
<p class="text-xs font-bold text-zinc-300">获取数据失败</p>
<p class="text-[11px] text-zinc-500 leading-relaxed">{{ error }}</p>
</div>
</div>
<!-- 空状态 -->
<div
v-else-if="playTimes.length === 0"
class="flex flex-col items-center justify-center py-20 space-y-6 bg-bg-secondary-20 border border-border-secondary-50 rounded-xl"
class="flex flex-col items-center justify-center py-20 space-y-6 bg-zinc-900/20 border border-zinc-800/50 rounded-xl"
>
<div class="p-6 rounded-xl bg-bg-primary border border-border-secondary text-text-secondary">
<div class="p-6 rounded-xl bg-zinc-950 border border-zinc-800 text-zinc-700">
<Clock :size="48" />
</div>
<div class="text-center space-y-2">
<h3 class="text-lg font-bold text-text-primary">{{ locale.emptyTitle }}</h3>
<p class="text-xs text-text-tertiary">{{ locale.emptyDesc }}</p>
<h3 class="text-lg font-bold text-zinc-100">暂无播出时段</h3>
<p class="text-xs text-zinc-500">点击“添加播出时段”按钮创建第一个播出时段</p>
</div>
</div>
@@ -92,15 +94,15 @@
v-for="playTime in playTimes"
:key="playTime.id"
:class="[
'group relative bg-bg-secondary-30 border rounded-xl p-8 transition-all hover:shadow-2xl hover:shadow-[0_25px_50px_var(--shadow-color-deep)]',
playTime.enabled ? 'border-border-secondary-80' : 'border-border-secondary-40 opacity-60'
'group relative bg-zinc-900/30 border rounded-xl p-8 transition-all hover:shadow-2xl hover:shadow-black/40',
playTime.enabled ? 'border-zinc-800/80' : 'border-zinc-800/40 opacity-60'
]"
>
<div class="flex items-start justify-between mb-6">
<div
:class="[
'p-3 rounded-xl bg-bg-primary border border-border-secondary transition-all flex items-center justify-center',
playTime.enabled ? 'text-primary border-primary-20' : 'text-text-secondary'
'p-3 rounded-xl bg-zinc-950 border border-zinc-800 transition-all',
playTime.enabled ? 'text-blue-500 border-blue-500/20' : 'text-zinc-700'
]"
>
<Clock :size="20" />
@@ -110,13 +112,13 @@
:class="[
'px-2 py-0.5 rounded text-[9px] font-black uppercase tracking-widest border transition-all',
playTime.enabled
? 'bg-success-10 text-success border-success-20'
: 'bg-bg-tertiary-50 text-text-disabled border-border-tertiary-50'
? 'bg-emerald-500/10 text-emerald-500 border-emerald-500/20'
: 'bg-zinc-800/50 text-zinc-600 border-zinc-700/50'
]"
>
{{ playTime.enabled ? locale.enabled : locale.disabled }}
{{ playTime.enabled ? '已启用' : '已禁用' }}
</span>
<button class="p-1.5 text-text-secondary hover:text-text-tertiary">
<button class="p-1.5 text-zinc-700 hover:text-zinc-400">
<MoreVertical :size="14" />
</button>
</div>
@@ -125,34 +127,34 @@
<div class="space-y-4">
<div>
<h4
class="text-lg font-black text-text-primary group-hover:text-primary transition-colors"
class="text-lg font-black text-zinc-100 group-hover:text-blue-400 transition-colors"
>
{{ playTime.name }}
</h4>
<div
class="flex items-center gap-2 mt-1.5 text-primary-80 font-black tracking-tighter"
class="flex items-center gap-2 mt-1.5 text-blue-500/80 font-black tracking-tighter"
>
<span class="text-xl">{{ playTime.startTime || locale.unlimited }}</span>
<div class="w-4 h-[2px] bg-bg-tertiary" />
<span class="text-xl">{{ playTime.endTime || locale.unlimited }}</span>
<span class="text-xl">{{ playTime.startTime || '不限' }}</span>
<div class="w-4 h-[2px] bg-zinc-800" />
<span class="text-xl">{{ playTime.endTime || '不限' }}</span>
</div>
</div>
<p class="text-xs text-text-tertiary font-medium leading-relaxed min-h-[32px] line-clamp-2">
{{ playTime.description || locale.noDescription }}
<p class="text-xs text-zinc-500 font-medium leading-relaxed min-h-[32px] line-clamp-2">
{{ playTime.description || '暂无详细描述...' }}
</p>
</div>
<div class="mt-8 pt-6 border-t border-border-secondary-50 flex items-center justify-between">
<div class="mt-8 pt-6 border-t border-zinc-800/50 flex items-center justify-between">
<div class="flex gap-2">
<button
class="p-2.5 bg-bg-primary border border-border-secondary rounded-lg text-text-tertiary hover:text-primary hover:border-primary-30 transition-all"
class="p-2.5 bg-zinc-950 border border-zinc-800 rounded-lg text-zinc-500 hover:text-blue-400 hover:border-blue-500/30 transition-all"
@click="editPlayTime(playTime)"
>
<Edit2 :size="14" />
</button>
<button
class="p-2.5 bg-bg-primary border border-border-secondary rounded-lg text-text-tertiary hover:text-error hover:border-error-30 transition-all"
class="p-2.5 bg-zinc-950 border border-zinc-800 rounded-lg text-zinc-500 hover:text-red-400 hover:border-red-500/30 transition-all"
@click="confirmDelete(playTime)"
>
<Trash2 :size="14" />
@@ -162,13 +164,13 @@
:class="[
'flex items-center gap-2 px-4 py-2 rounded-lg text-[10px] font-black uppercase tracking-widest transition-all',
playTime.enabled
? 'bg-bg-tertiary text-text-tertiary hover:text-text-primary'
: 'bg-success text-text-primary shadow-lg shadow-[var(--success-glow-20)]'
? 'bg-zinc-800 text-zinc-400 hover:text-zinc-200'
: 'bg-emerald-600 text-white shadow-lg shadow-emerald-900/20'
]"
@click="togglePlayTimeStatus(playTime)"
>
<Power :size="12" />
{{ playTime.enabled ? locale.disable : locale.enable }}
{{ playTime.enabled ? '禁用' : '启用' }}
</button>
</div>
</div>
@@ -181,17 +183,17 @@
v-if="showAddForm || editingPlayTime"
class="fixed inset-0 z-50 flex items-center justify-center p-4"
>
<div class="absolute inset-0 bg-bg-primary-80 backdrop-blur-sm" @click="cancelForm" />
<div class="absolute inset-0 bg-black/80 backdrop-blur-sm" @click="cancelForm" />
<div
class="relative w-full max-w-lg bg-bg-secondary border border-border-secondary rounded-xl shadow-2xl overflow-hidden"
class="relative w-full max-w-lg bg-zinc-900 border border-zinc-800 rounded-xl shadow-2xl overflow-hidden"
>
<div class="p-8">
<div class="flex items-center justify-between mb-8">
<h3 class="text-xl font-black text-text-primary tracking-tight">
{{ editingPlayTime ? locale.editTitle : locale.addTitle }}
<h3 class="text-xl font-black text-zinc-100 tracking-tight">
{{ editingPlayTime ? '编辑播出时段' : '添加播出时段' }}
</h3>
<button
class="p-2 text-text-tertiary hover:text-text-primary transition-colors"
class="p-2 text-zinc-500 hover:text-zinc-200 transition-colors"
@click="cancelForm"
>
<X :size="20" />
@@ -200,64 +202,64 @@
<div class="space-y-6">
<div class="space-y-2">
<label class="text-[10px] font-black text-text-disabled uppercase tracking-widest px-1"
>{{ locale.name }}</label
<label class="text-[10px] font-black text-zinc-600 uppercase tracking-widest px-1"
>时段名称</label
>
<input
v-model="formData.name"
type="text"
:placeholder="locale.namePlaceholder"
class="w-full bg-bg-primary border border-border-secondary rounded-lg px-5 py-3.5 text-sm text-text-primary focus:outline-none focus:border-primary-30"
placeholder="例如: 午间广播"
class="w-full bg-zinc-950 border border-zinc-800 rounded-lg px-5 py-3.5 text-sm text-zinc-200 focus:outline-none focus:border-blue-500/30"
>
</div>
<div class="grid grid-cols-2 gap-6">
<div class="space-y-2">
<label class="text-[10px] font-black text-text-disabled uppercase tracking-widest px-1"
>{{ locale.startTimeOptional }}</label
<label class="text-[10px] font-black text-zinc-600 uppercase tracking-widest px-1"
>开始时间 (可选)</label
>
<div class="relative">
<input
v-model="formData.startTime"
type="time"
class="w-full bg-bg-primary border border-border-secondary rounded-lg px-5 py-3.5 text-sm text-text-primary focus:outline-none focus:border-primary-30 appearance-none"
class="w-full bg-zinc-950 border border-zinc-800 rounded-lg px-5 py-3.5 text-sm text-zinc-200 focus:outline-none focus:border-blue-500/30 appearance-none"
>
<Clock
class="absolute right-4 top-1/2 -translate-y-1/2 text-text-secondary pointer-events-none"
class="absolute right-4 top-1/2 -translate-y-1/2 text-zinc-700 pointer-events-none"
:size="14"
/>
</div>
<p class="text-[9px] text-text-disabled px-1">{{ locale.startTimeHint }}</p>
<p class="text-[9px] text-zinc-600 px-1">留空表示不限制开始时间</p>
</div>
<div class="space-y-2">
<label class="text-[10px] font-black text-text-disabled uppercase tracking-widest px-1"
>{{ locale.endTimeOptional }}</label
<label class="text-[10px] font-black text-zinc-600 uppercase tracking-widest px-1"
>结束时间 (可选)</label
>
<div class="relative">
<input
v-model="formData.endTime"
type="time"
class="w-full bg-bg-primary border border-border-secondary rounded-lg px-5 py-3.5 text-sm text-text-primary focus:outline-none focus:border-primary-30 appearance-none"
class="w-full bg-zinc-950 border border-zinc-800 rounded-lg px-5 py-3.5 text-sm text-zinc-200 focus:outline-none focus:border-blue-500/30 appearance-none"
>
<Clock
class="absolute right-4 top-1/2 -translate-y-1/2 text-text-secondary pointer-events-none"
class="absolute right-4 top-1/2 -translate-y-1/2 text-zinc-700 pointer-events-none"
:size="14"
/>
</div>
<p class="text-[9px] text-text-disabled px-1">{{ locale.endTimeHint }}</p>
<p class="text-[9px] text-zinc-600 px-1">留空表示不限制结束时间</p>
</div>
</div>
<div class="space-y-2">
<label
class="text-[10px] font-black text-text-disabled uppercase tracking-widest px-1 flex items-center gap-2"
class="text-[10px] font-black text-zinc-600 uppercase tracking-widest px-1 flex items-center gap-2"
>
<AlignLeft :size="10" /> {{ locale.descriptionOptional }}
<AlignLeft :size="10" /> 描述 (可选)
</label>
<textarea
v-model="formData.description"
:placeholder="locale.descriptionPlaceholder"
class="w-full bg-bg-primary border border-border-secondary rounded-lg px-5 py-4 text-sm text-text-primary focus:outline-none focus:border-primary-30 min-h-[100px] resize-none"
placeholder="请输入时段描述信息..."
class="w-full bg-zinc-950 border border-zinc-800 rounded-lg px-5 py-4 text-sm text-zinc-200 focus:outline-none focus:border-blue-500/30 min-h-[100px] resize-none"
/>
</div>
@@ -265,36 +267,36 @@
<input
v-model="formData.enabled"
type="checkbox"
class="w-4 h-4 rounded border-border-secondary bg-bg-primary"
class="w-4 h-4 rounded border-zinc-800 bg-zinc-950 accent-blue-600"
>
<span
class="text-xs font-bold text-text-secondary group-hover:text-primary transition-colors"
>{{ locale.enableThisPlayTime }}</span
class="text-xs font-bold text-zinc-300 group-hover:text-blue-400 transition-colors"
>启用此播出时段</span
>
</label>
<div
v-if="formError"
class="bg-error-10 border border-error-20 rounded-lg p-3 text-[11px] text-error"
class="bg-red-500/10 border border-red-500/20 rounded-lg p-3 text-[11px] text-red-400"
>
{{ formError }}
</div>
</div>
</div>
<div class="px-8 py-6 bg-bg-primary-50 border-t border-border-secondary flex justify-end gap-3">
<div class="px-8 py-6 bg-zinc-950/50 border-t border-zinc-800 flex justify-end gap-3">
<button
class="px-6 py-2.5 text-xs font-bold text-text-tertiary hover:text-text-secondary"
class="px-6 py-2.5 text-xs font-bold text-zinc-500 hover:text-zinc-300"
@click="cancelForm"
>
{{ locale.cancel }}
取消
</button>
<button
:disabled="formSubmitting"
class="px-8 py-2.5 bg-primary-hover hover:bg-primary disabled:opacity-50 disabled:cursor-not-allowed text-text-primary text-xs font-black rounded-lg shadow-lg transition-all active:scale-95"
class="px-8 py-2.5 bg-blue-600 hover:bg-blue-500 disabled:opacity-50 disabled:cursor-not-allowed text-white text-xs font-black rounded-lg shadow-lg transition-all active:scale-95"
@click="savePlayTime"
>
{{ formSubmitting ? locale.saving : locale.saveSettings }}
{{ formSubmitting ? '保存中...' : '保存设置' }}
</button>
</div>
</div>
@@ -305,40 +307,40 @@
<Transition name="modal">
<div v-if="showDeleteConfirm" class="fixed inset-0 z-50 flex items-center justify-center p-4">
<div
class="absolute inset-0 bg-bg-primary-80 backdrop-blur-sm"
class="absolute inset-0 bg-black/80 backdrop-blur-sm"
@click="showDeleteConfirm = false"
/>
<div
class="relative w-full max-w-sm bg-bg-secondary border border-border-secondary rounded-xl shadow-2xl overflow-hidden"
class="relative w-full max-w-sm bg-zinc-900 border border-zinc-800 rounded-xl shadow-2xl overflow-hidden"
>
<div class="p-8">
<div class="flex flex-col items-center py-4 space-y-6">
<div
class="w-16 h-16 rounded-xl bg-error-10 text-error flex items-center justify-center border border-error-10 shadow-xl shadow-[var(--error-glow-5)]"
class="w-16 h-16 rounded-xl bg-red-600/10 text-red-500 flex items-center justify-center border border-red-500/10 shadow-xl shadow-red-900/5"
>
<AlertCircle :size="32" />
</div>
<div class="text-center space-y-2 px-4">
<h4 class="text-lg font-bold text-text-primary">
{{ deleteConfirmTitleText }}
<h4 class="text-lg font-bold text-zinc-100">
确定要删除播出时段 "{{ playTimeToDelete?.name }}" 吗?
</h4>
<p class="text-xs text-text-tertiary leading-relaxed">
{{ locale.deleteConfirmDesc }}
<p class="text-xs text-zinc-500 leading-relaxed">
此操作不可恢复,相关的歌曲点播和排期的时段设置将受影响或被清除。
</p>
</div>
<div class="flex gap-3 w-full pt-4">
<button
class="flex-1 px-4 py-3 bg-bg-primary border border-border-secondary text-text-tertiary text-xs font-black rounded-lg transition-all hover:bg-bg-tertiary"
class="flex-1 px-4 py-3 bg-zinc-950 border border-zinc-800 text-zinc-500 text-xs font-black rounded-lg transition-all hover:bg-zinc-800"
@click="showDeleteConfirm = false"
>
{{ locale.cancel }}
取消
</button>
<button
:disabled="deleteInProgress"
class="flex-1 px-4 py-3 bg-error hover:bg-error disabled:opacity-50 disabled:cursor-not-allowed text-text-primary text-xs font-black rounded-lg shadow-xl shadow-[var(--error-glow-20)] transition-all active:scale-95"
class="flex-1 px-4 py-3 bg-red-600 hover:bg-red-500 disabled:opacity-50 disabled:cursor-not-allowed text-white text-xs font-black rounded-lg shadow-xl shadow-red-900/20 transition-all active:scale-95"
@click="deletePlayTime"
>
{{ deleteInProgress ? locale.deleting : locale.confirmDelete }}
{{ deleteInProgress ? '删除中...' : '确认删除' }}
</button>
</div>
</div>
@@ -350,12 +352,10 @@
</template>
<script lang="ts" setup>
import { computed, onMounted, reactive, ref } from 'vue'
import { onMounted, reactive, ref } from 'vue'
import { useAuth } from '~/composables/useAuth'
import { useToast } from '~/composables/useToast'
import { useLocale } from '~/utils/locale'
import type { PlayTime } from '~/types'
import AppSpinner from '~/components/UI/Common/AppSpinner.vue'
import type { PlayTime } from '~~/types'
import {
Plus,
Clock,
@@ -371,17 +371,6 @@ import {
const { getAuthConfig, isAdmin } = useAuth()
const { showToast: showNotification } = useToast()
const { admin } = useLocale()
const locale = computed(() => {
const base = admin.value?.playTimeManager || {}
const emptyText = () => ''
return useSafeLocale({
...base,
errors: { ...(base.errors || {}) },
messages: { ...(base.messages || {}) },
deleteConfirmTitle: base.deleteConfirmTitle || emptyText
})
})
const playTimes = ref<PlayTime[]>([])
const loading = ref(false)
@@ -394,12 +383,6 @@ const formSubmitting = ref(false)
const deleteInProgress = ref(false)
const formError = ref('')
const enablePlayTimeSelection = ref(false)
const deleteConfirmTitleText = computed(() => {
const title = locale.value.deleteConfirmTitle
const name = playTimeToDelete.value?.name || ''
if (typeof title === 'function') return title(name)
return (title || '').replace('{0}', name)
})
// 表单数据
const formData = reactive({
@@ -420,7 +403,7 @@ onMounted(async () => {
// 获取播出时段列表
const fetchPlayTimes = async () => {
if (!isAdmin.value) {
error.value = locale.value.errors.adminOnly
error.value = '只有管理员才能管理播出时段'
return
}
@@ -428,10 +411,11 @@ const fetchPlayTimes = async () => {
error.value = ''
try {
const authConfig = getAuthConfig()
const data = await $fetch('/api/admin/play-times', {
...authConfig
})
const authConfig = getAuthConfig()
const data = await $fetch('/api/admin/play-times', {
...authConfig,
query: { t: Date.now() }
})
// 自定义排序:先按启用状态排序,然后有时间的排在前面,没有时间的排在后面
playTimes.value = data.sort((a: PlayTime, b: PlayTime) => {
@@ -463,7 +447,7 @@ const fetchPlayTimes = async () => {
return a.name.localeCompare(b.name)
})
} catch (err: any) {
error.value = getErrorMessage(err) || locale.value.errors.fetchPlayTimesFailed
error.value = err.message || '获取播出时段失败'
} finally {
loading.value = false
}
@@ -480,7 +464,7 @@ const fetchSystemSettings = async () => {
})
enablePlayTimeSelection.value = data.enablePlayTimeSelection
} catch (err: any) {
console.error('获取系统设置失败:', getErrorMessage(err))
console.error('获取系统设置失败:', err.message)
}
}
@@ -504,9 +488,9 @@ const updateSystemSettings = async () => {
...authConfig
})
showNotification(locale.value.messages.systemSettingsUpdated, 'success')
showNotification('系统设置已更新', 'success')
} catch (err: any) {
error.value = getErrorMessage(err) || locale.value.errors.updateSystemSettingsFailed
error.value = err.message || '更新系统设置失败'
showNotification(error.value, 'error')
// 如果失败,恢复状态
enablePlayTimeSelection.value = !enablePlayTimeSelection.value
@@ -555,14 +539,9 @@ const togglePlayTimeStatus = async (playTime: PlayTime) => {
// 更新本地数据
await fetchPlayTimes()
showNotification(
playTime.enabled
? (locale.value?.messages?.playTimeDisabled || 'Play time disabled')
: (locale.value?.messages?.playTimeEnabled || 'Play time enabled'),
'success'
)
showNotification(playTime.enabled ? '播出时段已禁用' : '播出时段已启用', 'success')
} catch (err: any) {
error.value = getErrorMessage(err) || locale.value.errors.updatePlayTimeStatusFailed
error.value = err.message || '更新播出时段状态失败'
showNotification(error.value, 'error')
}
}
@@ -590,9 +569,9 @@ const deletePlayTime = async () => {
await fetchPlayTimes()
showDeleteConfirm.value = false
playTimeToDelete.value = null
showNotification(locale.value?.messages?.playTimeDeleted || 'Play time deleted', 'success')
showNotification('播出时段已删除', 'success')
} catch (err: any) {
error.value = getErrorMessage(err) || locale.value.errors.deletePlayTimeFailed
error.value = err.message || '删除播出时段失败'
showNotification(error.value, 'error')
} finally {
deleteInProgress.value = false
@@ -605,13 +584,13 @@ const savePlayTime = async () => {
// 时间验证(仅当两个时间都有填写时才进行比较)
if (formData.startTime && formData.endTime && formData.startTime >= formData.endTime) {
formError.value = locale.value.errors.startBeforeEnd
formError.value = '开始时间必须早于结束时间'
return
}
// 至少要有名称
if (!formData.name.trim()) {
formError.value = locale.value.errors.nameRequired
formError.value = '时段名称不能为空'
return
}
@@ -624,7 +603,7 @@ const savePlayTime = async () => {
)
if (nameExists) {
formError.value = locale.value.errors.nameExists
formError.value = '播出时段名称已存在,请使用其他名称'
return
}
@@ -648,14 +627,9 @@ const savePlayTime = async () => {
// 更新本地数据
await fetchPlayTimes()
cancelForm()
showNotification(
isUpdate
? (locale.value?.messages?.playTimeUpdated || 'Play time updated')
: (locale.value?.messages?.playTimeCreated || 'Play time created'),
'success'
)
showNotification(isUpdate ? '播出时段已更新' : '播出时段已创建', 'success')
} catch (err: any) {
formError.value = getErrorMessage(err) || locale.value.errors.savePlayTimeFailed
formError.value = err.message || '保存播出时段失败'
showNotification(formError.value, 'error')
} finally {
formSubmitting.value = false