diff --git a/src/pages/editor/common/dragitem/DragItem.tsx b/src/pages/editor/common/dragitem/DragItem.tsx index 82d3d7a..28ee80e 100644 --- a/src/pages/editor/common/dragitem/DragItem.tsx +++ b/src/pages/editor/common/dragitem/DragItem.tsx @@ -67,21 +67,21 @@ export default function DragItem(props: IProps) { } const hasAudio = await util.checkVideoUrlHasAudio(editor.movie.reURL(item.urls.url), item.type); // 通过 _localPath 判断资源是否来自本地存储 - const isLocal = !!(item._localPath); + const isLocal = !!item._localPath; console.log('hasAudio', hasAudio); // 添加素材 const resource = new ResourceItem({ id: utils.createID(), originId: item.id, - url: isLocal ? (item._localPath || item.urls.url) : item.urls.url, + url: isLocal ? item._localPath || item.urls.url : item.urls.url, name: item.name, fileType: item.type, type: item.type as any, isLocal: isLocal ? true : false, noAudioTracks: !hasAudio, mustFetch: item.type === 'image' ? true : false, - thumb: isLocal ? (item._thumbPath || item.urls.thumb) : item.urls.thumb, + thumb: isLocal ? item._thumbPath || item.urls.thumb : item.urls.thumb, frames: item.attrs.frames, wave: item.attrs.wave, styleSize: { @@ -260,7 +260,8 @@ export default function DragItem(props: IProps) { await replaceElementById($item.attr('data-id'), d); } } else { - let trackIndex = tempElement.trackIndex; + console.log('tempElement', { ...tempElement }); + let trackIndex = editor.tempInsertIndex + 0.5; setElement({ id: 'temp', duration: 5, diff --git a/src/pages/editor/common/dragitem/dragItemCls.ts b/src/pages/editor/common/dragitem/dragItemCls.ts index c830323..9a1d2d6 100644 --- a/src/pages/editor/common/dragitem/dragItemCls.ts +++ b/src/pages/editor/common/dragitem/dragItemCls.ts @@ -44,10 +44,10 @@ export class DragItemCls { if ($(e.target).closest('a')[0]) { return; } - const [id, type] = $(this).attr('data-dragitem').split('_'); - const item = editor.getFromActiveItems(id, type); + const [id, type] = $(this).attr('data-dragitem').split('#'); + const item = editor.getFromActiveItems(id); if (!item) { - console.error('数据异常', id, type, this); + console.error('数据异常', id, this); return; } self.events.dragstart(item, { x: e.pageX, y: e.pageY }, e); diff --git a/src/pages/editor/common/source/SourceList.tsx b/src/pages/editor/common/source/SourceList.tsx index 91bfeae..fbbf2f4 100644 --- a/src/pages/editor/common/source/SourceList.tsx +++ b/src/pages/editor/common/source/SourceList.tsx @@ -64,7 +64,7 @@ export default function SourceList(props: IProps) { } // 设置缓存数据,用于拖动元素的时候获取数据 - editor.setActiveItems(items, props.type); + editor.setActiveItems(items); return (
@@ -79,7 +79,7 @@ export default function SourceList(props: IProps) { return ( { if (props.type === 'template') { diff --git a/src/pages/editor/components/ai-chat/AIChat.tsx b/src/pages/editor/components/ai-chat/AIChat.tsx index 8569348..56e3aa1 100644 --- a/src/pages/editor/components/ai-chat/AIChat.tsx +++ b/src/pages/editor/components/ai-chat/AIChat.tsx @@ -9,6 +9,7 @@ import type * as st from '@config/sdk.d'; import { addImageVideoAudioItem } from '../sources/addItem'; import { getUploadBeforeData } from '../../tools/uploadBeforeData'; import { getSystemPrompt, parseToolCalls, executeToolCall, splitUserCommand } from './aiMovieEditor'; +import { DEFAULT_LLM_MODEL } from './aiConfig'; import { getCredits } from './price'; import ChatMessages from './ChatMessages'; import type { ChatMessage, MediaContent } from './ChatMessages'; @@ -835,7 +836,7 @@ export default function AIChat() { ]; const [res, err] = await editor.apiServer!.openAiChat({ - model: 'doubao-seed-1-6-251015', + model: DEFAULT_LLM_MODEL, messages: chatMessages, }); @@ -865,7 +866,7 @@ export default function AIChat() { { role: 'user' as const, content: '请立即使用 格式直接执行上述操作,不要只回复文字或计划。' }, ]; const [res2, err2] = await editor.apiServer!.openAiChat({ - model: 'doubao-seed-1-6-251015', + model: DEFAULT_LLM_MODEL, messages: retryMessages, }); diff --git a/src/pages/editor/components/ai-chat/aiConfig.ts b/src/pages/editor/components/ai-chat/aiConfig.ts index df37365..c89e881 100644 --- a/src/pages/editor/components/ai-chat/aiConfig.ts +++ b/src/pages/editor/components/ai-chat/aiConfig.ts @@ -2,6 +2,51 @@ import { Toast } from '@douyinfe/semi-ui'; import { stores } from '@stores/index'; import { util } from '@utils/index'; +// ==================== LLM 模型配置 ==================== + +interface LLMModelConfig { + name: string; + modelId: string; + provider: string; + description?: string; +} + +/** 可用的 LLM 模型列表 */ +export const LLM_MODELS: Record = { + 'doubao-seed-1-6-251015': { + name: '豆包 Seed 1.6', + modelId: 'doubao-seed-1-6-251015', + provider: 'huoshan', + description: '通用大语言模型,用于 AI 对话和指令拆解', + }, + 'deepseek-v4-pro-260425': { + name: 'Deepseek V4 Pro', + modelId: 'deepseek-v4-pro-260425', + provider: 'deepseek', + description: '专业级大语言模型,用于复杂任务和专业领域', + }, + 'deepseek-v4-flash-260425': { + name: 'Deepseek V4 Flash', + modelId: 'deepseek-v4-flash-260425', + provider: 'deepseek', + description: '专业级大语言模型,用于复杂任务和专业领域', + }, +}; + +/** 默认 LLM 模型 */ +export const DEFAULT_LLM_MODEL = 'deepseek-v4-pro-260425'; + +/** + * 获取 LLM 模型配置 + * @param modelId 模型 ID,默认使用 DEFAULT_LLM_MODEL + */ +export function getLLMModel(modelId?: string): LLMModelConfig { + const id = modelId || DEFAULT_LLM_MODEL; + return LLM_MODELS[id] || LLM_MODELS[DEFAULT_LLM_MODEL]; +} + +// ==================== 图片/视频生成参数 ==================== + // https://www.volcengine.com/docs/82379/1393047 export async function getImageToVideoParams(formData: Record) { const { editor } = stores; diff --git a/src/pages/editor/components/ai-chat/aiMovieEditor.ts b/src/pages/editor/components/ai-chat/aiMovieEditor.ts index 4606e44..98c7474 100644 --- a/src/pages/editor/components/ai-chat/aiMovieEditor.ts +++ b/src/pages/editor/components/ai-chat/aiMovieEditor.ts @@ -1,6 +1,7 @@ import type * as sdkTypes from 'video-core-sdk'; import { utils, speedHelper } from 'video-core-sdk'; import type { Editor } from '@stores/editor'; +import { DEFAULT_LLM_MODEL } from './aiConfig'; // ==================== Tool Definitions ==================== @@ -1604,7 +1605,7 @@ export async function splitUserCommand( try { const [res, err] = await apiServer.openAiChat({ - model: 'doubao-seed-1-6-251015', + model: DEFAULT_LLM_MODEL, messages: [ { role: 'system', content: systemPrompt }, { role: 'user', content: userCommand }, diff --git a/src/pages/editor/components/sources/addItem.ts b/src/pages/editor/components/sources/addItem.ts index 0c9c1d0..8a80703 100644 --- a/src/pages/editor/components/sources/addItem.ts +++ b/src/pages/editor/components/sources/addItem.ts @@ -103,27 +103,34 @@ export const addImageVideoAudioItem = async ( export const addLottieItem = async (item: any, insertTime?: number, trackIndex?: number) => { console.log('添加元素', item); const { editor } = stores; - const resource = new ResourceItem({ + const isLocal = !!item._localPath; + + let resource: ResourceItem | any = new ResourceItem({ id: utils.createID(), originId: item.id, - url: item.urls.url, + url: isLocal ? item._localPath : item.urls.url, name: item.name, - fileType: item.urls.url.split('.').pop(), + fileType: item.type, type: 'lottie', + isLocal: isLocal ? true : false, mustFetch: true, - thumb: item.thumb || item.urls.thumb, - frames: item.attrs.frames, + thumb: isLocal ? item._thumbPath || '' : item.urls.thumb, + frames: isLocal ? item.attrs.frames || '' : item.attrs.frames, styleSize: { - width: item.attrs.width, - height: item.attrs.height, + width: Number(item.attrs.width), + height: Number(item.attrs.height), }, duration: itemDuration(item), from: item.from, - extend: { ...item.attrs }, + attrs: { ...item.attrs }, }); console.log('resource', resource); // 素材duration保留一位小数 resource.duration = util.timeToNum(resource.duration); + // 本地存储模式:将资源中的相对路径解析为 blob URL + if (isLocal && editor.movie?.resourceManage) { + await hydrateResourcePaths([resource as any], editor.movie.resourceManage); + } const elementData = await editor.movie.addElementByResource(resource as any, { time: insertTime || editor.currentTime, @@ -499,6 +506,7 @@ export function itemDuration(item: any): number { } export async function addItem(item: any, insertTime: number, trackIndex: number) { + const { editor } = stores; if (editor.globalLoading) { @@ -526,6 +534,7 @@ export async function addItem(item: any, insertTime: number, trackIndex: number) } else { item.from = 'system'; } + let elem = null; switch (item.type) { // case 'model3D': diff --git a/src/pages/editor/components/sources/ai/AiMain.tsx b/src/pages/editor/components/sources/ai/AiMain.tsx index e765fb2..2f2527c 100644 --- a/src/pages/editor/components/sources/ai/AiMain.tsx +++ b/src/pages/editor/components/sources/ai/AiMain.tsx @@ -9,14 +9,7 @@ import Login from '@components/login'; import { language, Intl } from '@language/index'; import { stores } from '@stores/index'; -export interface IProps { - show: boolean; -} - -export default function AiMain(props: IProps) { - if (!props.show) { - return null; - } +export default function AiMain() { const { editor } = stores; if (!editor.token) { diff --git a/src/pages/editor/components/sources/audio/Audio.tsx b/src/pages/editor/components/sources/audio/Audio.tsx index bbdf4f8..1ebf04c 100644 --- a/src/pages/editor/components/sources/audio/Audio.tsx +++ b/src/pages/editor/components/sources/audio/Audio.tsx @@ -4,31 +4,17 @@ import { observer } from 'mobx-react'; import AudioItem from './AudioItem'; // import { addImageVideoAudioItem } from '../addItem'; -export interface IProps { - show: boolean; -} -let hasRender = false; - -function Audio(props: IProps) { - if (!hasRender) { - if (props.show) { - hasRender = true; - } else { - return null; - } - } +function Audio() { return ( -
- { - return ; - }} - itemClassName={styles.audioItem + ' audioSourceItem'} - // addItem={addImageVideoAudioItem} - /> -
+ { + return ; + }} + itemClassName={styles.audioItem + ' audioSourceItem'} + // addItem={addImageVideoAudioItem} + /> ); } diff --git a/src/pages/editor/components/sources/caption/Caption.tsx b/src/pages/editor/components/sources/caption/Caption.tsx index 302b96e..227e7b0 100644 --- a/src/pages/editor/components/sources/caption/Caption.tsx +++ b/src/pages/editor/components/sources/caption/Caption.tsx @@ -2,14 +2,7 @@ import React from 'react'; import styles from './caption.module.less'; import Captions from './captions'; -export interface IProps { - show: boolean; -} - -export default function Caption(props: IProps) { - if (!props.show) { - return null; - } +export default function Caption() { return (
diff --git a/src/pages/editor/components/sources/effect/Effect.tsx b/src/pages/editor/components/sources/effect/Effect.tsx index fbf1c8d..b3ddcae 100644 --- a/src/pages/editor/components/sources/effect/Effect.tsx +++ b/src/pages/editor/components/sources/effect/Effect.tsx @@ -5,15 +5,8 @@ import { stores } from '@stores/index'; // import { editor } from '@stores/index'; // import { addEffectItem } from '../addItem'; -export interface IProps { - show: boolean; -} - -export default function Effect(props: IProps) { +export default function Effect() { const { editor } = stores; - if (!props.show) { - return null; - } return ( - { - if (d.urls.url.indexOf('.gif') !== -1) { - return ; - } - return ; - }} - itemClassName={styles.imgItem} - // addItem={addImageVideoAudioItem} - /> -
+ { + if (d.urls.url.indexOf('.gif') !== -1) { + return ; + } + return ; + }} + itemClassName={styles.imgItem} + // addItem={addImageVideoAudioItem} + /> ); } diff --git a/src/pages/editor/components/sources/index.tsx b/src/pages/editor/components/sources/index.tsx index 9901587..3496a90 100644 --- a/src/pages/editor/components/sources/index.tsx +++ b/src/pages/editor/components/sources/index.tsx @@ -6,7 +6,6 @@ import Text from './text'; import Filter from './filter'; import Effect from './effect'; import Transition from './transition'; -// import Background from '../options/components/background'; import Audio from './audio'; import More from './more'; import Lottie from './lottie'; @@ -14,44 +13,41 @@ import Template from './template'; import Caption from './caption'; import AiComp from './ai'; import { stores } from '@stores/index'; -// import styles from './sources.module.less'; export interface IProps {} function Sources(props: IProps) { const { editor } = stores; + const type = editor.sourceType; + return ( <> -