From 95b1e63ae24f9edf3bbf07b0b5ce2de90d321989 Mon Sep 17 00:00:00 2001
From: "676015863@qq.com" <676015863@qq.com>
Date: Thu, 30 Jul 2026 23:10:28 +0800
Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E5=A4=8D=E6=8B=96=E5=8A=A8?=
=?UTF-8?q?=E7=B4=A0=E6=9D=90=E5=88=B0=E8=BD=A8=E9=81=93=E7=9A=84BUG=202?=
=?UTF-8?q?=E3=80=81=E4=BF=AE=E5=A4=8Dlottie=E6=96=87=E4=BB=B6=E4=B8=8A?=
=?UTF-8?q?=E4=BC=A0=E7=9A=84BUG?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/pages/editor/common/dragitem/DragItem.tsx | 9 +-
.../editor/common/dragitem/dragItemCls.ts | 6 +-
src/pages/editor/common/source/SourceList.tsx | 4 +-
.../editor/components/ai-chat/AIChat.tsx | 5 +-
.../editor/components/ai-chat/aiConfig.ts | 45 +++++
.../components/ai-chat/aiMovieEditor.ts | 3 +-
.../editor/components/sources/addItem.ts | 25 ++-
.../editor/components/sources/ai/AiMain.tsx | 9 +-
.../editor/components/sources/audio/Audio.tsx | 32 +---
.../components/sources/caption/Caption.tsx | 9 +-
.../components/sources/effect/Effect.tsx | 9 +-
.../components/sources/filter/Filter.tsx | 9 +-
.../editor/components/sources/image/Image.tsx | 40 ++---
src/pages/editor/components/sources/index.tsx | 40 ++---
.../components/sources/lottie/Lottie.tsx | 36 ++--
.../editor/components/sources/more/More.tsx | 154 ++++++++----------
.../editor/components/sources/my/List.tsx | 3 +
.../editor/components/sources/my/Sources.tsx | 10 +-
.../components/sources/template/Template.tsx | 62 +++----
.../editor/components/sources/text/Text.tsx | 9 +-
.../sources/transition/Transition.tsx | 43 ++---
.../editor/components/sources/video/Video.tsx | 43 ++---
.../timeline2/tracks/useDragItem.tsx | 4 +-
src/stores/editor.ts | 22 ++-
24 files changed, 272 insertions(+), 359 deletions(-)
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 (
<>
-
-
-
-
-
-
-
-
-
-
-
-
-
+ {type === 'template' ? : null}
+ {type === 'my' ? : null}
+ {type === 'caption' ? : null}
+ {type === 'image' ? : null}
+ {type === 'audio' ? : null}
+ {type === 'video' ? : null}
+ {type === 'text' ? : null}
+ {type === 'lottie' ? : null}
+ {type === 'filter' ? : null}
+ {type === 'effect' ? : null}
+ {type === 'transition' ? : null}
+ {type === 'ai' ? : null}
+ {type === 'more' ? : null}
{editor.sides?.map(item => {
const Panel = item.panel as any;
if (!Panel) {
return null;
}
- return (
+ return type === item.type ? (
- );
+ ) : null;
})}
>
);
diff --git a/src/pages/editor/components/sources/lottie/Lottie.tsx b/src/pages/editor/components/sources/lottie/Lottie.tsx
index aa840d5..d28790d 100644
--- a/src/pages/editor/components/sources/lottie/Lottie.tsx
+++ b/src/pages/editor/components/sources/lottie/Lottie.tsx
@@ -3,33 +3,17 @@ import styles from './lottie.module.less';
import { addLottieItem } from '../addItem';
import LottieItem from './LottieItem';
-export interface IProps {
- show: boolean;
-}
-
-// 判断是否加载了,只加载一次
-let hasRender = false;
-
-export default function Lottie(props: IProps) {
- if (!hasRender) {
- if (props.show) {
- hasRender = true;
- } else {
- return null;
- }
- }
+export default function Lottie() {
return (
-
- {
- // console.log(d);
- return ;
- }}
- itemClassName={styles.imgItem}
- // addItem={addLottieItem}
- />
-
+ {
+ // console.log(d);
+ return ;
+ }}
+ itemClassName={styles.imgItem}
+ // addItem={addLottieItem}
+ />
);
}
diff --git a/src/pages/editor/components/sources/more/More.tsx b/src/pages/editor/components/sources/more/More.tsx
index caf56b1..4cec428 100644
--- a/src/pages/editor/components/sources/more/More.tsx
+++ b/src/pages/editor/components/sources/more/More.tsx
@@ -8,20 +8,8 @@ import { QrcodeElement } from '@pages/editor/plugins/qrcode/ElementData';
import { language } from '@language/language';
import { stores } from '@stores/index';
-export interface IProps {
- show: boolean;
-}
-let hasRender = false;
-
-export default function More(props: IProps) {
+export default function More() {
const { editor } = stores;
- if (!hasRender) {
- if (props.show) {
- hasRender = true;
- } else {
- return null;
- }
- }
const addPlus = d => {
console.log('添加插件', d);
@@ -56,77 +44,75 @@ export default function More(props: IProps) {
const languageType = language.getLanguage();
return (
-
-
-
{language.val('more_plus')}
-
{
- return (
- {
- addPlus(d);
- }}
- className={styles.item}
- >
-
- {d.icon}
-
- {d.vip && }
- {languageType === 'zh-CN' ? d.name : d.ename}
-
-
-
- );
- }}
- list={[
- {
- id: 'qrcode',
- name: '二维码',
- ename: 'qrcode',
- icon: ,
- },
- // {
- // id: 'magnifyingGlass',
- // name: '放大镜',
- // icon: ,
- // },
- // {
- // id: 'chart',
- // name: '动态图表',
- // vip: true,
- // icon: ,
- // },
- // {
- // id: 'model3D',
- // name: '3D模型',
- // vip: true,
- // icon: ,
- // },
- // {
- // id: 'peopleKeletonMan',
- // name: '人物',
- // vip: true,
- // icon: ,
- // },
- // {
- // id: 'watermark',
- // name: '水印',
- // vip: true,
- // icon: ,
- // },
- // {
- // id: 'barrage',
- // name: '弹幕',
- // vip: true,
- // icon: ,
- // },
- ].map(d => {
- return { ...d, width: 100, height: 100 };
- })}
- />
-
+
+
{language.val('more_plus')}
+
{
+ return (
+ {
+ addPlus(d);
+ }}
+ className={styles.item}
+ >
+
+ {d.icon}
+
+ {d.vip && }
+ {languageType === 'zh-CN' ? d.name : d.ename}
+
+
+
+ );
+ }}
+ list={[
+ {
+ id: 'qrcode',
+ name: '二维码',
+ ename: 'qrcode',
+ icon: ,
+ },
+ // {
+ // id: 'magnifyingGlass',
+ // name: '放大镜',
+ // icon: ,
+ // },
+ // {
+ // id: 'chart',
+ // name: '动态图表',
+ // vip: true,
+ // icon: ,
+ // },
+ // {
+ // id: 'model3D',
+ // name: '3D模型',
+ // vip: true,
+ // icon: ,
+ // },
+ // {
+ // id: 'peopleKeletonMan',
+ // name: '人物',
+ // vip: true,
+ // icon: ,
+ // },
+ // {
+ // id: 'watermark',
+ // name: '水印',
+ // vip: true,
+ // icon: ,
+ // },
+ // {
+ // id: 'barrage',
+ // name: '弹幕',
+ // vip: true,
+ // icon: ,
+ // },
+ ].map(d => {
+ return { ...d, width: 100, height: 100 };
+ })}
+ />
);
}
diff --git a/src/pages/editor/components/sources/my/List.tsx b/src/pages/editor/components/sources/my/List.tsx
index f17a581..3e7421f 100644
--- a/src/pages/editor/components/sources/my/List.tsx
+++ b/src/pages/editor/components/sources/my/List.tsx
@@ -28,6 +28,7 @@ import Decoding from './Decoding';
import Intl from '@language/Intl';
import { language } from '@language/language';
import QrcodeUpload from './QrcodeUpload';
+import LottieItem from '../lottie/LottieItem';
import { IconTreeTriangleDown } from '@douyinfe/semi-icons';
import { config } from '@config/index';
import { stores } from '@stores/index';
@@ -661,6 +662,8 @@ export default function List(props: IProps) {
+ ) : d.status !== 'ready' && d.type === 'sticker' ? (
+
) : (

+ <>
{editor.userInfo ? (
@@ -47,7 +43,7 @@ function Sources(props: IProps) {
)}
-
+ >
);
}
diff --git a/src/pages/editor/components/sources/template/Template.tsx b/src/pages/editor/components/sources/template/Template.tsx
index edfc56e..2bed1a6 100644
--- a/src/pages/editor/components/sources/template/Template.tsx
+++ b/src/pages/editor/components/sources/template/Template.tsx
@@ -8,47 +8,31 @@ import { Modal } from '@douyinfe/semi-ui';
import { config } from '@config/index';
import { stores } from '@stores/index';
-export interface IProps {
- show: boolean;
-}
-
-// 判断是否加载了,只加载一次
-let hasRender = false;
-
-export default function Template(props: IProps) {
+export default function Template() {
const { editor } = stores;
- if (!hasRender) {
- if (props.show) {
- hasRender = true;
- } else {
- return null;
- }
- }
return (
-
-
{
- return
;
- }}
- itemClassName={styles.imgItem}
- addItem={item => {
- Modal.confirm({
- title: '系统提示',
- content: '模版替换会覆盖当前视频内容,是否继续?',
- onOk: async () => {
- console.log(item);
- const json = await $.get(editor.movie.reURL(item.url + '?t=' + +new Date()));
- transaction(() => {
- editor.data = util.reJSON(json) as MovieData;
- editor.movieDataUpdateKey = util.randomID();
- // editor.editMode = 'template';
- });
- },
- });
- }}
- />
-
+ {
+ return
;
+ }}
+ itemClassName={styles.imgItem}
+ addItem={item => {
+ Modal.confirm({
+ title: '系统提示',
+ content: '模版替换会覆盖当前视频内容,是否继续?',
+ onOk: async () => {
+ console.log(item);
+ const json = await $.get(editor.movie.reURL(item.url + '?t=' + +new Date()));
+ transaction(() => {
+ editor.data = util.reJSON(json) as MovieData;
+ editor.movieDataUpdateKey = util.randomID();
+ // editor.editMode = 'template';
+ });
+ },
+ });
+ }}
+ />
);
}
diff --git a/src/pages/editor/components/sources/text/Text.tsx b/src/pages/editor/components/sources/text/Text.tsx
index ee8a288..e4d7e1d 100644
--- a/src/pages/editor/components/sources/text/Text.tsx
+++ b/src/pages/editor/components/sources/text/Text.tsx
@@ -4,15 +4,8 @@ import { addTextItem } from '../addItem';
import { util } from '@utils/index';
import { stores } from '@stores/index';
-export interface IProps {
- show: boolean;
-}
-
-export default function Text(props: IProps) {
+export default function Text() {
const { editor } = stores;
- if (!props.show) {
- return null;
- }
return (
- {
- return (
- <>
-
- {d.name}
- >
- );
- }}
- itemClassName={styles.imgItem}
- // addItem={addTransitionItem}
- />
-
+ {
+ return (
+ <>
+
+ {d.name}
+ >
+ );
+ }}
+ itemClassName={styles.imgItem}
+ // addItem={addTransitionItem}
+ />
);
}
diff --git a/src/pages/editor/components/sources/video/Video.tsx b/src/pages/editor/components/sources/video/Video.tsx
index 3d3075b..50d3777 100644
--- a/src/pages/editor/components/sources/video/Video.tsx
+++ b/src/pages/editor/components/sources/video/Video.tsx
@@ -5,35 +5,22 @@ import { addImageVideoAudioItem } from '../addItem';
import { util } from '@utils/index';
import { stores } from '@stores/index';
-export interface IProps {
- show: boolean;
-}
-let hasRender = false;
-
-export default function Video(props: IProps) {
+export default function Video() {
const { editor } = stores;
- if (!hasRender) {
- if (props.show) {
- hasRender = true;
- } else {
- return null;
- }
- }
+
return (
-
-
{
- return (
- <>
- {utils.secToTime(d.attrs?.duration || 0, 'mm:ss')}
-
- >
- );
- }}
- itemClassName={styles.videoItem}
- // addItem={addImageVideoAudioItem}
- />
-
+ {
+ return (
+ <>
+ {utils.secToTime(d.attrs?.duration || 0, 'mm:ss')}
+
+ >
+ );
+ }}
+ itemClassName={styles.videoItem}
+ // addItem={addImageVideoAudioItem}
+ />
);
}
diff --git a/src/pages/editor/components/timeline2/tracks/useDragItem.tsx b/src/pages/editor/components/timeline2/tracks/useDragItem.tsx
index 3e22f8c..69e4da0 100644
--- a/src/pages/editor/components/timeline2/tracks/useDragItem.tsx
+++ b/src/pages/editor/components/timeline2/tracks/useDragItem.tsx
@@ -333,7 +333,6 @@ export default function useDragItem(params: Params) {
if (canInsertIndex !== null) {
$(`.tempInsertDom[data-insertindex="${canInsertIndex}"]`).addClass('tempInsertDomActive');
}
- // console.log('canInsertIndex', canInsertIndex);
// canIn可插入判断
canInIndex = null;
@@ -350,7 +349,8 @@ export default function useDragItem(params: Params) {
});
})
.on('mouseup.timelineDragElement', eu => {
- console.log('canInsert', canInsertIndex, canInIndex, editor.data);
+ console.log('canInsertIndex------------------------------->', canInsertIndex);
+ editor.tempInsertIndex = canInsertIndex;
$('.tempInsertDom').remove();
$(document).off('mousemove.timelineDragElement');
$(document).off('mouseup.timelineDragElement');
diff --git a/src/stores/editor.ts b/src/stores/editor.ts
index 318626c..79d4adb 100644
--- a/src/stores/editor.ts
+++ b/src/stores/editor.ts
@@ -216,6 +216,9 @@ export class Editor {
public copyTempFrameData: any;
public copyTempFrameDataType: string = '';
+ // 记录临时插入的位置
+ public tempInsertIndex: number = null;
+
// 水印配置
public watermark?: types.IWatermark;
@@ -229,21 +232,16 @@ export class Editor {
@observable trackBodysKey: string = '1';
// 资源切换后,缓存list数据
- public activeItems: Record = {};
+ public activeItems: SourceItem[] = [];
// 设置缓存数据
- setActiveItems = (items: SourceItem[], type: ctypes.SourceType) => {
- this.activeItems[type] = items;
-
- // 测试用
- if (!(window as any).activeItems) {
- (window as any).activeItems = {};
- }
- (window as any).activeItems[type] = items;
+ setActiveItems = (items: SourceItem[]) => {
+ this.activeItems = items;
};
// 从缓存数据中读取数据
- getFromActiveItems = (id: string, type: ctypes.SourceType) => {
- const items = this.activeItems[type] || [];
+ getFromActiveItems = (id: string) => {
+ // console.log('getFromActiveItems', id, this.activeItems);
+ const items = this.activeItems || [];
return items.find(d => d.id === id);
};
@@ -916,7 +914,7 @@ export class Editor {
this.movie = null;
this.copyTempData = null;
this.copyTempFrameData = null;
- this.activeItems = {};
+ this.activeItems = [];
this.watermark = null;
this.previewSource = null;
this.selectedElementIds = [];