Skip to content

Let's use AI to Earn!

tishi

I5bijibne8dcb6cd13501
diff --git a/src/app/[lng]/material/ai-generate/ai-generate.module.scss b/src/app/[lng]/material/ai-generate/ai-generate.module.scss
index 1d5e7efa..cdf9bf05 100644
--- a/src/app/[lng]/material/ai-generate/ai-generate.module.scss
+++ b/src/app/[lng]/material/ai-generate/ai-generate.module.scss
@@ -377,4 +377,45 @@
width: 140px;
}
}
+}
+
+// 图片要求提示样式
+.imageRequirements {
+ background-color: #f0f8ff;
+ border: 1px solid #d6e4ff;
+ border-radius: 8px;
+ padding: 12px;
+ margin-top: 20px;
+
+ h4 {
+ margin: 0 0 8px 0;
+ color: #1890ff;
+ font-size: 14px;
+ font-weight: 500;
+ }
+
+ .requirementsList {
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+ }
+
+ .requirementItem {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ font-size: 12px;
+ color: #666;
+ }
+
+ .requirementLabel {
+ font-weight: 500;
+ color: #333;
+ min-width: 70px;
+ }
+
+ .requirementValue {
+ color: #1890ff;
+ font-weight: 500;
+ }
}
\ No newline at end of file
diff --git a/src/app/[lng]/material/ai-generate/page.tsx b/src/app/[lng]/material/ai-generate/page.tsx
index c05b9e2b..10152d1d 100644
--- a/src/app/[lng]/material/ai-generate/page.tsx
+++ b/src/app/[lng]/material/ai-generate/page.tsx
@@ -103,6 +103,33 @@ export default function AIGeneratePage() {
const [uploadingFirstFrame, setUploadingFirstFrame] = useState(false);
const [uploadingTailFrame, setUploadingTailFrame] = useState(false);
+ // 文件大小限制常量(字节)
+ const MAX_IMAGE_SIZE = 30 * 1024 * 1024; // 30MB
+
+ /**
+ * 检查文件大小是否在限制范围内
+ */
+ const checkFileSize = (file: File): boolean => {
+ if (file.size > MAX_IMAGE_SIZE) {
+ const sizeInMB = (MAX_IMAGE_SIZE / (1024 * 1024)).toFixed(0);
+ message.error(`图片大小限制: ${sizeInMB}MB`);
+ return false;
+ }
+ return true;
+ };
+
+ /**
+ * 检查图片文件格式
+ */
+ const checkImageFormat = (file: File): boolean => {
+ const allowedTypes = ['image/jpeg', 'image/jpg', 'image/png', 'image/webp'];
+ if (!allowedTypes.includes(file.type)) {
+ message.error(`支持格式: JPG, PNG, WEBP`);
+ return false;
+ }
+ return true;
+ };
+
const handlePickFirstFrame = () => {
firstFrameInputRef.current?.click();
};
@@ -114,6 +141,13 @@ export default function AIGeneratePage() {
const handleFirstFrameChange = async (e: React.ChangeEvent<HTMLInputElement>) => {
const file = e.target.files && e.target.files[0];
if (!file) return;
+
+ // 检查文件大小和格式
+ if (!checkFileSize(file) || !checkImageFormat(file)) {
+ if (e.target) e.target.value = "";
+ return;
+ }
+
try {
setUploadingFirstFrame(true);
const key = await uploadToOss(file);
@@ -131,6 +165,13 @@ export default function AIGeneratePage() {
const handleTailFrameChange = async (e: React.ChangeEvent<HTMLInputElement>) => {
const file = e.target.files && e.target.files[0];
if (!file) return;
+
+ // 检查文件大小和格式
+ if (!checkFileSize(file) || !checkImageFormat(file)) {
+ if (e.target) e.target.value = "";
+ return;
+ }
+
try {
setUploadingTailFrame(true);
const key = await uploadToOss(file);
@@ -744,7 +785,7 @@ export default function AIGeneratePage() {
key="videoGeneration"
>
-
+
<div className={styles.section}>
<div className={styles.form}>
<TextArea
@@ -781,13 +822,6 @@ export default function AIGeneratePage() {
</Option>
))}
</Select>
- {/* {(() => {
- const selected: any = ((filteredVideoModels as any[]) || []).find((m: any) => m.name === videoModel);
- if (!selected?.description) return null;
- return (
- <div style={{ marginTop: 6, color: '#888', fontSize: 12 }}>{selected.description}</div>
- );
- })()} */}
</div>
)}
<div className={styles.dimensions}>
@@ -930,6 +964,29 @@ export default function AIGeneratePage() {
)}
</div>
)}
+
+ {/* 图片要求提示 */}
+ <div className={styles.imageRequirements}>
+ <h4>图片要求</h4>
+ <div className={styles.requirementsList}>
+ <div className={styles.requirementItem}>
+ <span className={styles.requirementLabel}>宽高比范围:</span>
+ <span className={styles.requirementValue}>(0.4, 2.5)</span>
+ </div>
+ <div className={styles.requirementItem}>
+ <span className={styles.requirementLabel}>宽高长度范围:</span>
+ <span className={styles.requirementValue}>(300px, 6000px)</span>
+ </div>
+ <div className={styles.requirementItem}>
+ <span className={styles.requirementLabel}>图片大小限制:</span>
+ <span className={styles.requirementValue}>小于30MB</span>
+ </div>
+ <div className={styles.requirementItem}>
+ <span className={styles.requirementLabel}>支持格式:</span>
+ <span className={styles.requirementValue}>JPG, PNG, WEBP</span>
+ </div>
+ </div>
+ </div>
</div>
</TabPane>
<TabPane
diff --git a/src/app/i18n/locales/en/material.json b/src/app/i18n/locales/en/material.json
index b5accfb3..136b18ed 100644
--- a/src/app/i18n/locales/en/material.json
+++ b/src/app/i18n/locales/en/material.json
@@ -144,6 +144,15 @@
"templateEasy": "Border",
"templateWrite": "Handwriting",
"pleaseUploadFirstFrame": "Please upload first frame image",
- "pleaseUploadTailFrame": "Please upload tail frame image"
+ "pleaseUploadTailFrame": "Please upload tail frame image",
+ "imageRequirements": "Image Requirements",
+ "aspectRatioRange": "Aspect Ratio Range",
+ "aspectRatioRangeValue": "(0.4, 2.5)",
+ "dimensionRange": "Dimension Range",
+ "dimensionRangeValue": "(300px, 6000px)",
+ "imageSizeLimit": "Image Size Limit",
+ "imageSizeLimitValue": "Less than 30MB",
+ "imageFormatSupport": "Supported Formats",
+ "imageFormatSupportValue": "JPG, PNG, WEBP"
}
}
\ No newline at end of file
diff --git a/src/app/i18n/locales/zh-CN/material.json b/src/app/i18n/locales/zh-CN/material.json
index b74cb01c..cd51b1a7 100644
--- a/src/app/i18n/locales/zh-CN/material.json
+++ b/src/app/i18n/locales/zh-CN/material.json
@@ -149,6 +149,15 @@
"templateEasy": "边框",
"templateWrite": "手写",
"pleaseUploadFirstFrame": "请上传首帧图片",
- "pleaseUploadTailFrame": "请上传尾帧图片"
+ "pleaseUploadTailFrame": "请上传尾帧图片",
+ "imageRequirements": "图片要求",
+ "aspectRatioRange": "宽高比范围",
+ "aspectRatioRangeValue": "(0.4, 2.5)",
+ "dimensionRange": "宽高长度范围",
+ "dimensionRangeValue": "(300px, 6000px)",
+ "imageSizeLimit": "图片大小限制",
+ "imageSizeLimitValue": "小于30MB",
+ "imageFormatSupport": "支持格式",
+ "imageFormatSupportValue": "JPG, PNG, WEBP"
}
}
\ No newline at end of file