From a8a4fd3866c2ede803a837dc42f7d7fb6b2fecbd Mon Sep 17 00:00:00 2001 From: moux1024 <403053463@qq.com> Date: Mon, 29 Sep 2025 20:06:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0:=20=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=E5=9F=8B=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/DTO/movie_start_dto.ts | 10 ++++++++++ api/common.ts | 14 ++++++++++++++ api/create_movie.ts | 10 +++++++--- app/service/Interaction/ImageStoryService.ts | 2 ++ app/service/Interaction/templateStoryService.ts | 2 ++ compile_prod.sh | 1 + components/ChatInputBox/ChatInputBox.tsx | 2 ++ 7 files changed, 38 insertions(+), 3 deletions(-) diff --git a/api/DTO/movie_start_dto.ts b/api/DTO/movie_start_dto.ts index 869452e..0180ed8 100644 --- a/api/DTO/movie_start_dto.ts +++ b/api/DTO/movie_start_dto.ts @@ -92,6 +92,11 @@ export interface CreateMovieProjectV2Request { script: string; /** 用户ID */ user_id: string; + /** 客户端用户数据 */ + user_data?: { + is_mobile: 1 | 0; + user_agent: string; + }; /** 模式:auto | manual */ mode: "auto" | "manual"; /** 分辨率:720p | 1080p | 4k */ @@ -206,6 +211,11 @@ export interface CreateMovieProjectV3Request { category: string; /** 用户ID */ user_id: string; + /** 客户端用户数据 */ + user_data?: { + is_mobile: 1 | 0; + user_agent: string; + }; /** 模式:auto | manual */ mode: "auto" | "manual"; /** 分辨率:720p | 1080p | "4k" */ diff --git a/api/common.ts b/api/common.ts index 4fef3e8..4afd68f 100644 --- a/api/common.ts +++ b/api/common.ts @@ -34,6 +34,20 @@ export interface QiniuUploadResponse { } +/** + * 获取当前客户端的 UA 与设备信息 + */ +export const getClientUserData = (): { user_agent: string; is_mobile: 1 | 0 } => { + try { + const ua = typeof navigator !== 'undefined' && navigator.userAgent ? navigator.userAgent : '' + const isMobile = /Mobile|Android|iPhone/i.test(ua) + return { user_agent: ua, is_mobile: isMobile ? 1 : 0 } + } catch { + return { user_agent: '', is_mobile: 0 } + } +} + + // 获取七牛云上传token(包含domain) export const getUploadToken = async (timeoutMs: number = 10000): Promise<{ token: string, domain: string }> => { // 添加超时控制 diff --git a/api/create_movie.ts b/api/create_movie.ts index d24446e..89db035 100644 --- a/api/create_movie.ts +++ b/api/create_movie.ts @@ -3,13 +3,15 @@ import { CreateMovieProjectV3Request, } from "./DTO/movie_start_dto"; import { post } from "./request"; +import { getClientUserData } from './common'; import { withQueuePolling, QueueResponse } from './movie_queue'; // 新-创建接口 export const createMovieProject = async (data: any): Promise => { const apiCall = (params: any) => post('/movie/create_movie_project', params); - return withQueuePolling(apiCall, data); + const user_data = getClientUserData(); + return withQueuePolling(apiCall, { ...data, user_data }); }; /** @@ -22,7 +24,8 @@ export const createMovieProjectV2 = async ( ): Promise => { const apiCall = (params: CreateMovieProjectV2Request) => post("/movie/create_movie_project_v2", params); - return withQueuePolling(apiCall, request); + const user_data = getClientUserData(); + return withQueuePolling(apiCall, { ...(request as any), user_data } as any); }; /** @@ -35,5 +38,6 @@ export const createMovieProjectV3 = async ( ): Promise => { const apiCall = (params: CreateMovieProjectV3Request) => post("/movie/create_movie_project_v3", params); - return withQueuePolling(apiCall, request); + const user_data = getClientUserData(); + return withQueuePolling(apiCall, { ...(request as any), user_data } as any); }; \ No newline at end of file diff --git a/app/service/Interaction/ImageStoryService.ts b/app/service/Interaction/ImageStoryService.ts index 3a3a300..9bdc254 100644 --- a/app/service/Interaction/ImageStoryService.ts +++ b/app/service/Interaction/ImageStoryService.ts @@ -15,6 +15,7 @@ import { } from "@/api/DTO/movie_start_dto"; import { MovieProjectService, MovieProjectMode } from "./MovieProjectService"; import { AspectRatioValue } from '@/components/ChatInputBox/AspectRatioSelector' +import { getClientUserData } from "@/api/common"; interface UseImageStoryService { /** 当前图片故事数据 */ @@ -477,6 +478,7 @@ export const useImageStoryServiceHook = (): UseImageStoryService => { const params: CreateMovieProjectV2Request = { script: storyContent, user_id, + user_data: getClientUserData(), mode, resolution, genre: selectedCategory, diff --git a/app/service/Interaction/templateStoryService.ts b/app/service/Interaction/templateStoryService.ts index 03bc35c..523e653 100644 --- a/app/service/Interaction/templateStoryService.ts +++ b/app/service/Interaction/templateStoryService.ts @@ -7,6 +7,7 @@ import { generateTextToImage } from "@/api/movie_start"; import { MovieProjectService, MovieProjectMode } from "./MovieProjectService"; import { CreateMovieProjectV3Request } from "@/api/DTO/movie_start_dto"; import { AspectRatioValue } from '@/components/ChatInputBox/AspectRatioSelector' +import { getClientUserData } from "@/api/common"; interface UseTemplateStoryService { /** 模板列表 */ @@ -267,6 +268,7 @@ export const useTemplateStoryServiceHook = (): UseTemplateStoryService => { script: script, category: selectedTemplate?.category || "", user_id, + user_data: getClientUserData(), mode, resolution, storyRole: selectedTemplate?.storyRole || [], diff --git a/compile_prod.sh b/compile_prod.sh index b0b23a1..4e0efc7 100755 --- a/compile_prod.sh +++ b/compile_prod.sh @@ -44,6 +44,7 @@ if [ "$current_branch" = "$BRANCH_NAME" ]; then # 准备dist目录 mkdir -p dist + rm -rf .next/cache cp -r .next dist/ cp -r public dist/ cp package.json dist/ diff --git a/components/ChatInputBox/ChatInputBox.tsx b/components/ChatInputBox/ChatInputBox.tsx index 4d16c53..86ac272 100644 --- a/components/ChatInputBox/ChatInputBox.tsx +++ b/components/ChatInputBox/ChatInputBox.tsx @@ -51,6 +51,7 @@ import { PcPhotoStoryModal } from "./PcPhotoStoryModal"; import { H5PhotoStoryDrawer } from "./H5PhotoStoryDrawer"; import { AspectRatioSelector, AspectRatioValue } from "./AspectRatioSelector"; import { useTemplateStoryServiceHook } from "@/app/service/Interaction/templateStoryService"; +import { getClientUserData } from "@/api/common"; const LauguageOptions = [ { value: "english", label: "English", isVip: false, code:'EN' }, @@ -270,6 +271,7 @@ export function ChatInputBox({ noData }: { noData: boolean }) { // 创建剧集数据 let episodeData: any = { user_id: String(User.id), + user_data: getClientUserData(), script: script, mode: configOptions.mode, resolution: configOptions.resolution,