feat: 添加语言参数支持以处理多语言场景
在播客生成流程中添加 lang 参数,用于支持多语言场景。修改包括: - 在请求接口中添加 lang 字段 - 在 API 调用中传递 lang 参数 - 在服务端处理中接收并使用 lang 参数 - 简化客户端请求参数结构
This commit is contained in:
@@ -30,8 +30,7 @@ export async function GET(request: NextRequest) { // GET 函数接收 request
|
||||
}
|
||||
|
||||
export async function PUT(request: NextRequest) {
|
||||
const { task_id, auth_id, timestamp, status, usetime } = await request.json();
|
||||
const lang = getLanguageFromRequest(request); // 获取语言
|
||||
const { task_id, auth_id, timestamp, status, usetime, lang } = await request.json();
|
||||
const { t } = await getTranslation(lang, 'errors'); // 初始化翻译
|
||||
try {
|
||||
if(status !== 'completed') {
|
||||
|
||||
@@ -10,7 +10,7 @@ const API_BASE_URL = process.env.NEXT_PUBLIC_PODCAST_API_BASE_URL || 'http://192
|
||||
* 启动播客生成任务
|
||||
*/
|
||||
export async function startPodcastGenerationTask(body: PodcastGenerationRequest, userId: string, lang: string): Promise<ApiResponse<PodcastGenerationResponse>> {
|
||||
|
||||
body.lang = lang;
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/generate-podcast`, {
|
||||
method: 'POST',
|
||||
|
||||
@@ -10,6 +10,7 @@ export interface PodcastGenerationRequest {
|
||||
callback_url?: string; // 固定值
|
||||
usetime?: string; // 时长 来自选择
|
||||
output_language?: string; // 语言 来自设置
|
||||
lang?: string; // 子路径表示语言
|
||||
}
|
||||
|
||||
export interface PodcastGenerationResponse {
|
||||
|
||||
Reference in New Issue
Block a user