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
File diff suppressed because it is too large Load Diff
+34 -19
View File
@@ -1,7 +1,6 @@
import { db } from '~/drizzle/db'
import { systemSettings } from '~/drizzle/schema'
import { maskSystemSettingsSecrets } from './secretMask'
import { MUSIC_SOURCE_PLATFORMS } from '~~/server/config/constants'
import { CacheService } from '../../../services/cacheService'
import { SYSTEM_SETTINGS_DEFAULTS } from '~~/server/utils/system-settings-defaults'
export default defineEventHandler(async (event) => {
@@ -23,27 +22,33 @@ export default defineEventHandler(async (event) => {
}
try {
// 系统设置包含敏感配置,始终从数据库读取。
// 尝试从缓存获取系统设置
const cacheService = CacheService.getInstance()
let settings = await cacheService.getSystemSettings()
if (settings) {
return settings
}
// 缓存中没有,从数据库获取系统设置,如果不存在则创建默认设置
const settingsResult = await db.select().from(systemSettings).limit(1)
let settings = settingsResult[0]
settings = settingsResult[0] || null
if (!settings) {
const newSettingsResult = await db
.insert(systemSettings)
.values({
...SYSTEM_SETTINGS_DEFAULTS,
telemetryEnabled: true,
enablePlayTimeSelection: false,
siteTitle: process.env.NUXT_PUBLIC_SITE_TITLE || 'VoiceHub',
siteLogoUrl: process.env.NUXT_PUBLIC_SITE_LOGO || '/favicon.ico',
schoolLogoHomeUrl: null,
schoolLogoPrintUrl: null,
siteLogoUrl: process.env.NUXT_PUBLIC_SITE_LOGO || '/images/site-logo.png',
schoolLogoHomeUrl: '/images/school-logo-white.png',
schoolLogoPrintUrl: '/images/school-logo-transparent.png',
siteDescription:
process.env.NUXT_PUBLIC_SITE_DESCRIPTION || '校园广播站点歌系统 - 让你的声音被听见',
siteVersion: process.env.NUXT_PUBLIC_SITE_VERSION || null,
submissionGuidelines: '请遵守校园规定,提交健康向上的歌曲。',
icpNumber: null,
gonganNumber: null,
showBeianIcon: false,
enableSubmissionLimit: false,
dailySubmissionLimit: null,
weeklySubmissionLimit: null,
@@ -51,20 +56,30 @@ export default defineEventHandler(async (event) => {
showBlacklistKeywords: false,
enableCollaborativeSubmission: true,
enableSubmissionRemarks: false,
enableSubmissionRestriction: false,
submissionRestrictionScope: 'all',
sameSongRestrictionHours: null,
sameArtistRestrictionHours: null,
enabledPlatforms: JSON.stringify([...MUSIC_SOURCE_PLATFORMS]),
platformOrder: JSON.stringify([...MUSIC_SOURCE_PLATFORMS]),
defaultTheme: 'System',
enabledThemes: JSON.stringify(['System', 'ClassicDark', 'ClassicLight', 'ModernLight'])
enableRequestTimeLimitation: false,
forceBlockAllRequests: false,
enableReplayRequests: false,
smtpEnabled: false
})
.returning()
settings = newSettingsResult[0]
}
return maskSystemSettingsSecrets(settings)
// 将设置存入缓存
try {
const merged: any = { ...SYSTEM_SETTINGS_DEFAULTS, ...(settings || {}) }
settings = merged
await cacheService.setSystemSettings(settings)
} catch (cacheError) {
console.warn('缓存系统设置失败:', cacheError)
}
// 隐藏敏感字段
if (settings && settings.smtpPassword) {
settings.smtpPassword = '****************'
}
return settings
} catch (error) {
console.error('获取系统设置失败:', error)
throw createError({