Files
Henry_Du 4ce4649aaf
Build VoiceHub FPK / build-fpk (push) Failing after 56m5s
Build and Push Docker Image / build-and-push (push) Canceled after 1h9m35s
初次提交
2026-09-06 08:19:02 +08:00

45 lines
1.6 KiB
TypeScript

/*
* @Author: HenryDu8133 813367384@qq.com
* @Date: 2026-04-11 13:07:14
* @LastEditors: HenryDu8133 813367384@qq.com
* @LastEditTime: 2026-04-11 13:43:49
* @FilePath: \BYWVoiceHub\server\plugins\update-logos.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import fs from 'node:fs'
import path from 'node:path'
import { db } from '~/drizzle/db'
import { systemSettings } from '~/drizzle/schema'
import { cacheService } from '../services/cacheService'
export default defineNitroPlugin(async (_nitroApp) => {
// 延迟执行以避免阻塞启动
setTimeout(async () => {
try {
const flagFile = path.resolve(process.cwd(), '.logos_updated')
if (fs.existsSync(flagFile)) {
return // 已经更新过了
}
const existingSettings = await db.select().from(systemSettings).limit(1)
if (existingSettings.length > 0) {
const updates: any = {
siteLogoUrl: '/images/site-logo.png',
schoolLogoHomeUrl: '/images/school-logo-white.png',
schoolLogoPrintUrl: '/images/school-logo-transparent.png'
}
await db.update(systemSettings).set(updates)
await cacheService.clearSystemSettingsCache()
console.log('[Startup] Force updated system settings logos to new paths')
// 标记为已更新
fs.writeFileSync(flagFile, 'updated')
}
} catch (err) {
console.error('[Startup] Failed to update system settings logos:', err)
}
}, 5000)
})