feat: 新增本地背景功能与民谣歌单,重构背景切换逻辑
1. 新增两个后台接口获取本地背景文件列表和随机背景 2. 重构页面背景切换系统,增加本地默认背景模式并支持本地存储配置 3. 调整背景切换按钮样式为纯图标风格,新增本地模式开关 4. 新增民谣精选歌单文件 5. 优化主题轮播逻辑,支持本地背景自动轮换
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -6200,6 +6200,30 @@ app.get('/api/home/bg', async (req, res) => {
|
||||
}
|
||||
})
|
||||
|
||||
app.get('/api/home/bg/default-list', (req, res) => {
|
||||
try {
|
||||
const baseDir = path.join(process.cwd(), 'public', 'home-bg', 'default-c21f969b')
|
||||
if (!fs.existsSync(baseDir)) return res.json({ ok: true, files: [] })
|
||||
const files = fs.readdirSync(baseDir).filter(f => /\.(jpg|jpeg|png|webp)$/i.test(f))
|
||||
res.json({ ok: true, files })
|
||||
} catch (e) {
|
||||
res.json({ ok: true, files: [] })
|
||||
}
|
||||
})
|
||||
|
||||
app.get('/api/home/bg/default-random', (req, res) => {
|
||||
try {
|
||||
const baseDir = path.join(process.cwd(), 'public', 'home-bg', 'default-c21f969b')
|
||||
if (!fs.existsSync(baseDir)) return res.json({ ok: false, error: 'dir not found' })
|
||||
const files = fs.readdirSync(baseDir).filter(f => /\.(jpg|jpeg|png|webp)$/i.test(f))
|
||||
if (!files.length) return res.json({ ok: false, error: 'no files' })
|
||||
const pick = files[Math.floor(Math.random() * files.length)]
|
||||
res.json({ ok: true, url: `/home-bg/default-c21f969b/${pick}?v=${Date.now()}` })
|
||||
} catch (e) {
|
||||
res.status(500).json({ ok: false, error: String(e.message || e) })
|
||||
}
|
||||
})
|
||||
|
||||
app.post('/api/home/bg/populate', async (req, res) => {
|
||||
try {
|
||||
const themes = [
|
||||
|
||||
Reference in New Issue
Block a user