“重新编辑修改”

This commit is contained in:
sjy
2026-07-11 15:32:57 +08:00
parent af60e6720b
commit 36e4bec90e
5 changed files with 114 additions and 16 deletions
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -28,7 +28,7 @@
} }
})(); })();
</script> </script>
<script type="module" crossorigin src="/assets/index-OcL9GWjl.js"></script> <script type="module" crossorigin src="/assets/index-BeB-hsdi.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-JhRVnnL-.css"> <link rel="stylesheet" crossorigin href="/assets/index-JhRVnnL-.css">
</head> </head>
<body> <body>
+67 -3
View File
@@ -174,6 +174,8 @@ const AIChatPage: React.FC = () => {
const [loading, setLoading] = useState<boolean>(false); const [loading, setLoading] = useState<boolean>(false);
const [enginesLoaded, setEnginesLoaded] = useState(false);
const [referenceMode, setReferenceMode] = useState<'universal' | 'first_last_frame'>('universal'); const [referenceMode, setReferenceMode] = useState<'universal' | 'first_last_frame'>('universal');
const [firstFrame, setFirstFrame] = useState<MediaReference | null>(null); const [firstFrame, setFirstFrame] = useState<MediaReference | null>(null);
const [lastFrame, setLastFrame] = useState<MediaReference | null>(null); const [lastFrame, setLastFrame] = useState<MediaReference | null>(null);
@@ -203,6 +205,7 @@ const AIChatPage: React.FC = () => {
// @ 提及相关状态 // @ 提及相关状态
const [mentionVisible, setMentionVisible] = useState(false); const [mentionVisible, setMentionVisible] = useState(false);
const mentionInputRef = useRef<any>(null); const mentionInputRef = useRef<any>(null);
const isReEditingRef = useRef(false);
const [mentionPosition, setMentionPosition] = useState({ top: 0, left: 0 }); const [mentionPosition, setMentionPosition] = useState({ top: 0, left: 0 });
// 数字转中文数字(一、二、三、四) // 数字转中文数字(一、二、三、四)
@@ -539,16 +542,19 @@ const AIChatPage: React.FC = () => {
}, [gen_list.length, scrollToBottom]); }, [gen_list.length, scrollToBottom]);
useEffect(() => { useEffect(() => {
if (isReEditingRef.current) {
isReEditingRef.current = false;
return;
}
if (!enginesLoaded) return;
const newOptions = mediaType === 'image' ? enginesele.image : enginesele.video; const newOptions = mediaType === 'image' ? enginesele.image : enginesele.video;
if (newOptions && newOptions.length > 0) { if (newOptions && newOptions.length > 0) {
// 如果当前 countType 不在新选项中,重置为第一个选项
const isValidOption = newOptions.some((item: any) => item.id === countType); const isValidOption = newOptions.some((item: any) => item.id === countType);
if (!isValidOption) { if (!isValidOption) {
setCountType(newOptions[0].id); setCountType(newOptions[0].id);
} }
} }
}, [mediaType, enginesele]); }, [mediaType, enginesele, enginesLoaded]);
// 点击外部关闭弹窗 // 点击外部关闭弹窗
useEffect(() => { useEffect(() => {
@@ -579,6 +585,10 @@ const AIChatPage: React.FC = () => {
}, [showMediaTypeModal, showEngineModal, showImageSettingsModal, showVideoSettingsModal]); }, [showMediaTypeModal, showEngineModal, showImageSettingsModal, showVideoSettingsModal]);
useEffect(() => { useEffect(() => {
if (isReEditingRef.current) {
isReEditingRef.current = false;
return;
}
if (mediaType !== 'video') return; if (mediaType !== 'video') return;
const engine = enginesele?.video?.find((e: any) => e.id === countType); const engine = enginesele?.video?.find((e: any) => e.id === countType);
if (!engine) return; if (!engine) return;
@@ -602,6 +612,7 @@ const AIChatPage: React.FC = () => {
// console.log('引擎', data); // console.log('引擎', data);
setEnginesele(data.engine); setEnginesele(data.engine);
setEnginesLoaded(true);
// 如果是视频模式,初始化视频参数选项 // 如果是视频模式,初始化视频参数选项
if (data.engine.video && data.engine.video.length > 0) { if (data.engine.video && data.engine.video.length > 0) {
@@ -2183,7 +2194,60 @@ const AIChatPage: React.FC = () => {
onClick={(e) => { onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
setInputValue(msg.originalPrompt || ''); setInputValue(msg.originalPrompt || '');
let engineFound = true;
const engineId = msg.engineId || msg.engineSnapshot?.id || msg.engine_id;
if (engineId && msg.genType) {
const engineList = msg.genType === 'image' ? enginesele.image : enginesele.video;
const engine = engineList?.find((e: any) => e.id === engineId);
if (engine) {
setCountType(engine.id);
if (msg.genType === 'video') {
setEngineOptions({
ratios: engine.supportedRatios || ['16:9', '4:3', '1:1', '3:4', '9:16', '21:9'],
resolutions: engine.supportedResolutions || ['480p', '720p', '1080p'],
durations: engine.supportedDurations || [5, 8, 10, 12, 15],
});
}
if (msg.genType === 'image') {
const supportedSizes = engine.supportedSizes || {};
const resolutionLevels = Object.keys(supportedSizes).sort((a, b) => {
const levelOrder = { '1K': 0, '2K': 1, '4K': 2 };
return (levelOrder[a] || 0) - (levelOrder[b] || 0);
});
const primaryResolution = resolutionLevels[0] || '2K';
const supportedResolutions = Object.keys(supportedSizes[primaryResolution] || {});
const newRatioOptions = supportedResolutions.map((res: any) => ({
value: res,
label: res,
}));
setRatioOptions(newRatioOptions);
setCurrentEngineSupportedSizes(supportedSizes);
setResolutionOptions(resolutionLevels.map((level) => {
const match = level.match(/(\d+)K/);
const num = match ? parseInt(match[1]) : 1;
const labels: Record<number, string> = { 1: '标清', 2: '高清', 4: '超清' };
return {
value: level,
label: `${labels[num] || '高清'} ${level}`,
};
}));
if (supportedSizes[primaryResolution] && supportedSizes[primaryResolution][supportedResolutions[0]]) {
const defaultSize = supportedSizes[primaryResolution][supportedResolutions[0]];
const [w, h] = defaultSize.split(/[×x]/);
setWidth(Number(w));
setHeight(Number(h));
setSelectedRatio(supportedResolutions[0]);
setSelectedResolution(primaryResolution);
}
}
} else {
msgApi.error('该引擎已删除,无法重新编辑');
engineFound = false;
}
}
if (!engineFound) return;
if (msg.genType) { if (msg.genType) {
isReEditingRef.current = true;
setMediaType(msg.genType); setMediaType(msg.genType);
} }
if (msg.mediaReferences && msg.mediaReferences.length > 0) { if (msg.mediaReferences && msg.mediaReferences.length > 0) {
+1 -1
View File
@@ -1037,7 +1037,7 @@ const HomePage: React.FC = () => {
</div> </div>
{/* 素材案例网格 */} {/* 素材案例网格 */}
<div className="stagger-children" style={{ display: 'flex', flexWrap: 'wrap', gap: 16, justifyContent: 'space-between', overflowX: 'auto', paddingBottom: 8 }}> <div className="stagger-children" style={{ display: 'flex', flexWrap: 'wrap', gap: 16, justifyContent: 'flex-start', overflowX: 'auto', paddingBottom: 8 }}>
{caseAssets.length === 0 ? ( {caseAssets.length === 0 ? (
<div style={{ <div style={{
flex: 1, flex: 1,
@@ -1,5 +1,5 @@
import React, { useMemo } from 'react'; import React, { useMemo } from 'react';
import { Button, Card, Result, Typography } from 'antd'; import { Button, Card, Result, Typography, message } from 'antd';
const successStatuses = new Set(['group_active', 'callback_success']); const successStatuses = new Set(['group_active', 'callback_success']);
@@ -9,6 +9,40 @@ const PrivatePortraitAuthorizeResult: React.FC = () => {
const resultCode = params.get('resultCode') || ''; const resultCode = params.get('resultCode') || '';
const isSuccess = successStatuses.has(status) || resultCode === '10000'; const isSuccess = successStatuses.has(status) || resultCode === '10000';
const handleClose = () => {
const isWeChat = /MicroMessenger/i.test(navigator.userAgent);
const isAlipay = /AlipayClient/i.test(navigator.userAgent);
const isMobile = /Android|iPhone|iPad/i.test(navigator.userAgent);
if (isWeChat) {
try {
window.opener = null;
window.open('', '_self');
window.close();
} catch {
message.info('请点击右上角关闭按钮');
}
} else if (isAlipay) {
try {
window.close();
} catch {
message.info('请点击左上角返回');
}
} else if (isMobile) {
try {
window.history.back();
} catch {
window.location.href = '/';
}
} else {
try {
window.close();
} catch {
window.location.href = '/';
}
}
};
return ( return (
<div style={{ minHeight: '100vh', display: 'flex', alignItems: 'center', justifyContent: 'center', background: '#f8fafc', padding: 20 }}> <div style={{ minHeight: '100vh', display: 'flex', alignItems: 'center', justifyContent: 'center', background: '#f8fafc', padding: 20 }}>
<Card style={{ width: '100%', maxWidth: 520, borderRadius: 18 }}> <Card style={{ width: '100%', maxWidth: 520, borderRadius: 18 }}>
@@ -17,11 +51,11 @@ const PrivatePortraitAuthorizeResult: React.FC = () => {
title={isSuccess ? '真人认证已完成' : '真人认证未完成'} title={isSuccess ? '真人认证已完成' : '真人认证未完成'}
subTitle={isSuccess ? '请回到电脑端查看,项目组已创建成功。' : '请回到电脑端重新发起创建项目组。'} subTitle={isSuccess ? '请回到电脑端查看,项目组已创建成功。' : '请回到电脑端重新发起创建项目组。'}
extra={[ extra={[
<Button key="close" type="primary" onClick={() => window.close()}></Button>, <Button key="close" type="primary" onClick={handleClose}></Button>,
]} ]}
/> />
<Typography.Paragraph type="secondary" style={{ textAlign: 'center', marginBottom: 0 }}> <Typography.Paragraph type="secondary" style={{ textAlign: 'center', marginBottom: 0, fontSize: 13, marginTop: 12 }}>
{status || '-'}{resultCode || '-'}
</Typography.Paragraph> </Typography.Paragraph>
</Card> </Card>
</div> </div>