🎬 火宝短剧 - 基于AI的一站式短剧生成平台 《一句话生成完整短剧,从剧本到成片全自动化》 Huobao Drama - An AI-Powered End-to-End Short Drama Generator "One Sentence to Complete Drama: Fully Automated from Script to Final Video"
TypeScript
/**
* 应用设置路由 — 全局配置的读写入口(当前:AI 内容语言)
*/
import { Hono } from 'hono'
import { getContentLanguage, setContentLanguage, getToursSeen, setToursSeen, CONTENT_LANGUAGES, type ContentLanguage } from '../services/app-settings.js'
import { success, badRequest } from '../utils/response.js'
const app = new Hono()
// GET /content-language — 当前 AI 内容语言
app.get('/content-language', async (c) => {
return success(c, { language: await getContentLanguage() })
})
// PUT /content-language — 设置 AI 内容语言(body: { language: 'zh'|'en'|'ja'|'ko' })
app.put('/content-language', async (c) => {
const body = await c.req.json().catch(() => null)
const language = body?.language
if (!(CONTENT_LANGUAGES as readonly string[]).includes(language)) {
return badRequest(c, `language 必须是 ${CONTENT_LANGUAGES.join(' / ')} 之一`)
}
const saved = await setContentLanguage(language as ContentLanguage)
return success(c, { language: saved })
})
// GET /tours-seen — 已看过的引导漫游 id 列表
app.get('/tours-seen', async (c) => {
return success(c, { seen: await getToursSeen() })
})
// PUT /tours-seen — 写入已看过的引导漫游 id 列表(body: { seen: string[] })
app.put('/tours-seen', async (c) => {
const body = await c.req.json().catch(() => null)
if (!Array.isArray(body?.seen) || !body.seen.every((v: unknown) => typeof v === 'string')) {
return badRequest(c, 'seen 必须是字符串数组')
}
return success(c, { seen: await setToursSeen(body.seen) })
})
export default app