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
+13 -4
View File
@@ -1,16 +1,16 @@
import { and, eq, gte, inArray, lte } from 'drizzle-orm'
import { db } from '~/drizzle/db'
import { schedules, songs } from '~/drizzle/schema'
import { cacheService } from '~~/server/services/cacheService'
import { createSystemNotification } from '~~/server/services/notificationService'
import { getClientIP } from '~~/server/utils/ip-utils'
import { getServerDate } from '~~/server/utils/serverTime'
export default defineEventHandler(async (event) => {
const user = event.context.user
if (!user || !['SONG_ADMIN', 'ADMIN', 'SUPER_ADMIN'].includes(user.role)) {
throw createError({
statusCode: 403,
message: '需要歌曲管理员及以上权限'
statusMessage: '需要歌曲管理员及以上权限'
})
}
@@ -47,6 +47,7 @@ export default defineEventHandler(async (event) => {
}
try {
const clientIP = getClientIP(event)
const moveResult = await db.transaction(async (tx) => {
const existingOnToDate = await tx
.select({ id: schedules.id })
@@ -80,7 +81,7 @@ export default defineEventHandler(async (event) => {
}
const scheduleIds = sourceSchedules.map((item) => item.id)
const updateTime = getServerDate()
const updateTime = new Date()
const movedSchedules = await tx
.update(schedules)
.set({
@@ -100,7 +101,7 @@ export default defineEventHandler(async (event) => {
const notificationsToSend = moveResult.movedSongs.map((item) => {
const message = `您投稿的歌曲《${item.songTitle}》原定于 ${fromDate} 播放,已调整至 ${toDate}。`
return createSystemNotification(item.requesterId, '排期调整通知', message)
return createSystemNotification(item.requesterId, '排期调整通知', message, clientIP)
})
if (notificationsToSend.length > 0) {
@@ -109,6 +110,14 @@ export default defineEventHandler(async (event) => {
})
}
try {
await cacheService.clearSchedulesCache()
await cacheService.clearSongsCache()
console.log('[Cache] 排期缓存和歌曲列表缓存已清除(迁移排期日期)')
} catch (cacheError) {
console.error('[Cache] 清除缓存失败:', cacheError)
}
return {
success: true,
fromDate,