Skip to content

Let's use AI to Earn!

闻声图流光卡片界面

daoyian602d35e7e5e2
diff --git a/src/app/[lng]/material/ai-generate/ai-generate.module.scss b/src/app/[lng]/material/ai-generate/ai-generate.module.scss
new file mode 100644
index 00000000..7655d76f
--- /dev/null
+++ b/src/app/[lng]/material/ai-generate/ai-generate.module.scss
@@ -0,0 +1,201 @@
+.container {
+ padding: 24px;
+ max-width: 1200px;
+ margin: 0 auto;
+ background-color: #fff;
+ min-height: 100vh;
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
+}
+
+.header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-bottom: 24px;
+ padding: 16px;
+ background-color: #f8f9fa;
+ border-radius: 8px;
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
+
+ .headerLeft {
+ display: flex;
+ align-items: center;
+ gap: 16px;
+
+ h2 {
+ margin: 0;
+ font-size: 20px;
+ font-weight: 500;
+ color: #333;
+ display: flex;
+ align-items: center;
+ gap: 8px;
+
+ :global {
+ .anticon {
+ font-size: 24px;
+ color: #1890ff;
+ }
+ }
+ }
+ }
+
+ .backButton {
+ padding: 8px;
+ border: none;
+ background-color: transparent;
+ cursor: pointer;
+ transition: all 0.3s ease;
+ color: #666;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ border-radius: 4px;
+
+ &:hover {
+ color: #1890ff;
+ background-color: #f0f7ff;
+ }
+
+ :global {
+ .anticon {
+ font-size: 20px;
+ }
+ }
+ }
+}
+
+.content {
+ background-color: #f8f9fa;
+ border-radius: 8px;
+ padding: 24px;
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
+}
+
+.tabs {
+ :global {
+ .ant-tabs-nav {
+ margin-bottom: 24px;
+ }
+
+ .ant-tabs-tab {
+ font-size: 15px;
+ padding: 12px 24px;
+ color: #666;
+ transition: all 0.3s ease;
+
+ &:hover {
+ color: #1890ff;
+ }
+
+ :global {
+ .anticon {
+ margin-right: 8px;
+ font-size: 16px;
+ }
+ }
+ }
+
+ .ant-tabs-tab-active {
+ .ant-tabs-tab-btn {
+ color: #1890ff;
+ font-weight: 500;
+ }
+ }
+
+ .ant-tabs-ink-bar {
+ background-color: #1890ff;
+ height: 2px;
+ }
+ }
+}
+
+.section {
+ padding: 20px;
+ border: 1px solid #e8e8e8;
+ border-radius: 8px;
+ background-color: #fff;
+}
+
+.form {
+ display: flex;
+ flex-direction: column;
+ gap: 16px;
+}
+
+.dimensions {
+ display: flex;
+ gap: 16px;
+}
+
+.polling {
+ margin-top: 16px;
+ text-align: center;
+ padding: 24px;
+ background-color: #f8f9fa;
+ border-radius: 8px;
+ animation: fadeIn 0.3s ease;
+ border: 1px solid #e8e8e8;
+
+ :global {
+ .ant-spin {
+ margin-right: 8px;
+ }
+
+ .ant-spin-text {
+ font-size: 14px;
+ color: #666;
+ }
+ }
+}
+
+.result {
+ margin-top: 16px;
+ text-align: center;
+ padding: 16px;
+ border: 1px dashed #d9d9d9;
+ border-radius: 8px;
+ animation: fadeIn 0.3s ease;
+ background-color: #fff;
+
+ img {
+ max-width: 100%;
+ border-radius: 8px;
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
+ }
+}
+
+@keyframes fadeIn {
+ from {
+ opacity: 0;
+ transform: translateY(10px);
+ }
+ to {
+ opacity: 1;
+ transform: translateY(0);
+ }
+}
+
+// 添加响应式样式
+@media (max-width: 768px) {
+ .container {
+ padding: 16px;
+ }
+
+ .content {
+ padding: 16px;
+ }
+
+ .tabs {
+ :global {
+ .ant-tabs-tab {
+ padding: 8px 16px;
+ font-size: 14px;
+ }
+ }
+ }
+
+ .section {
+ padding: 16px;
+ }
+}
\ 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
new file mode 100644
index 00000000..049ae6e0
--- /dev/null
+++ b/src/app/[lng]/material/ai-generate/page.tsx
@@ -0,0 +1,238 @@
+"use client";
+
+import { useState } from "react";
+import { useParams, useRouter } from "next/navigation";
+import { message, Input, Button, Select, Spin, Tabs } from "antd";
+import { ArrowLeftOutlined, RobotOutlined, FireOutlined, PictureOutlined, FileTextOutlined } from "@ant-design/icons";
+import styles from "./ai-generate.module.scss";
+
+const { TextArea } = Input;
+const { Option } = Select;
+const { TabPane } = Tabs;
+
+export default function AIGeneratePage() {
+ const params = useParams();
+ const router = useRouter();
+ const albumId = params.id as string;
+
+ const [prompt, setPrompt] = useState("");
+ const [width, setWidth] = useState(512);
+ const [height, setHeight] = useState(512);
+ const [sessionIds, setSessionIds] = useState<string[]>([]);
+ const [loading, setLoading] = useState(false);
+ const [taskId, setTaskId] = useState<string | null>(null);
+ const [result, setResult] = useState<string | null>(null);
+ const [polling, setPolling] = useState(false);
+
+ const [content, setContent] = useState("");
+ const [title, setTitle] = useState("");
+ const [temp, setTemp] = useState("tempA");
+ const [loadingFirefly, setLoadingFirefly] = useState(false);
+ const [fireflyResult, setFireflyResult] = useState<string | null>(null);
+
+ const handleTextToImage = async () => {
+ if (!prompt) {
+ message.error("请输入提示词");
+ return;
+ }
+
+ try {
+ setLoading(true);
+ const response = await fetch("/tools/ai/jm/task", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ prompt,
+ width,
+ height,
+ sessionIds,
+ }),
+ });
+
+ const data = await response.json();
+ if (data.id) {
+ setTaskId(data.id);
+ setPolling(true);
+ pollTaskResult(data.id);
+ } else {
+ message.error("生成任务创建失败");
+ }
+ } catch (error) {
+ message.error("生成任务创建失败");
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ const pollTaskResult = async (id: string) => {
+ try {
+ const response = await fetch(`/tools/ai/jm/task/${id}`);
+ const data = await response.json();
+ if (data.status === "completed") {
+ setResult(data.result);
+ setPolling(false);
+ } else if (data.status === "failed") {
+ message.error("生成任务失败");
+ setPolling(false);
+ } else {
+ setTimeout(() => pollTaskResult(id), 1000);
+ }
+ } catch (error) {
+ message.error("获取任务结果失败");
+ setPolling(false);
+ }
+ };
+
+ const handleTextToFireflyCard = async () => {
+ if (!content || !title) {
+ message.error("请输入内容和标题");
+ return;
+ }
+
+ try {
+ setLoadingFirefly(true);
+ const response = await fetch("/tools/ai/fireflycard", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ content,
+ temp,
+ title,
+ }),
+ });
+
+ const data = await response.json();
+ if (data.url) {
+ setFireflyResult(data.url);
+ } else {
+ message.error("生成流光卡片失败");
+ }
+ } catch (error) {
+ message.error("生成流光卡片失败");
+ } finally {
+ setLoadingFirefly(false);
+ }
+ };
+
+ return (
+ <div className={styles.container}>
+ <div className={styles.header}>
+ <div className={styles.headerLeft}>
+ <button className={styles.backButton} onClick={() => router.back()}>
+ <ArrowLeftOutlined />
+ </button>
+ <p><RobotOutlined /> AI生成素材</p>
+ </div>
+ </div>
+
+ <div className={styles.content}>
+ <Tabs defaultActiveKey="textToImage" className={styles.tabs}>
+ <TabPane
+ tab={
+ <span>
+ <PictureOutlined /> 文生图
+ </span>
+ }
+ key="textToImage"
+ >
+ <div className={styles.section}>
+ <div className={styles.form}>
+ <TextArea
+ placeholder="请输入提示词"
+ value={prompt}
+ onChange={(e) => setPrompt(e.target.value)}
+ rows={4}
+ />
+ <div className={styles.dimensions}>
+ <Input
+ type="number"
+ placeholder="宽度"
+ value={width}
+ onChange={(e) => setWidth(Number(e.target.value))}
+ />
+ <Input
+ type="number"
+ placeholder="高度"
+ value={height}
+ onChange={(e) => setHeight(Number(e.target.value))}
+ />
+ </div>
+ <Button
+ type="primary"
+ onClick={handleTextToImage}
+ loading={loading}
+ disabled={!prompt}
+ icon={<PictureOutlined />}
+ >
+ 生成图片
+ </Button>
+ </div>
+ {polling && (
+ <div className={styles.polling}>
+ <Spin tip="正在生成图片,请稍候..." />
+ </div>
+ )}
+ {result && (
+ <div className={styles.result}>
+ <img src={result} alt="生成的图片" />
+ </div>
+ )}
+ </div>
+ </TabPane>
+ <TabPane
+ tab={
+ <span>
+ <FireOutlined /> 文生图文(流光卡片)
+ </span>
+ }
+ key="textToFireflyCard"
+ >
+ <div className={styles.section}>
+ <div className={styles.form}>
+ <Input
+ placeholder="请输入标题"
+ value={title}
+ onChange={(e) => setTitle(e.target.value)}
+ prefix={<FileTextOutlined />}
+ />
+ <TextArea
+ placeholder="请输入内容"
+ value={content}
+ onChange={(e) => setContent(e.target.value)}
+ rows={4}
+ />
+ <Select
+ value={temp}
+ onChange={setTemp}
+ style={{ width: "100%" }}
+ >
+ <Option value="tempA">模板A</Option>
+ <Option value="tempB">模板B</Option>
+ <Option value="tempC">模板C</Option>
+ </Select>
+ <Button
+ type="primary"
+ onClick={handleTextToFireflyCard}
+ loading={loadingFirefly}
+ disabled={!content || !title}
+ icon={<FireOutlined />}
+ >
+ 生成流光卡片
+ </Button>
+ </div>
+ {fireflyResult && (
+ <div className={styles.result}>
+ <img src={fireflyResult} alt="生成的流光卡片" />
+ </div>
+ )}
+ </div>
+ </TabPane>
+ </Tabs>
+ </div>
+ </div>
+ );
+}
\ No newline at end of file
diff --git a/src/app/[lng]/material/album/[id]/album.module.scss b/src/app/[lng]/material/album/[id]/album.module.scss
index bc4e31ef..aab54f7d 100644
--- a/src/app/[lng]/material/album/[id]/album.module.scss
+++ b/src/app/[lng]/material/album/[id]/album.module.scss
@@ -89,6 +89,13 @@
opacity: 1;
}
+.headerActions{
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ gap: 10px;
+}
+
.actionButton {
background: rgba(255, 255, 255, 0.9);
border: none;
diff --git a/src/app/[lng]/material/album/[id]/page.tsx b/src/app/[lng]/material/album/[id]/page.tsx
index 6ee891b9..6af195b9 100644
--- a/src/app/[lng]/material/album/[id]/page.tsx
+++ b/src/app/[lng]/material/album/[id]/page.tsx
@@ -1,7 +1,7 @@
"use client";
import { useEffect, useState } from "react";
-import { useParams } from "next/navigation";
+import { useParams, useRouter } from "next/navigation";
import { message, Popconfirm } from "antd";
import styles from "./album.module.scss";
import { createMedia, deleteMedia, getMediaList } from "@/api/media";
@@ -20,6 +20,7 @@ interface Media {
export default function AlbumPage() {
const params = useParams();
+ const router = useRouter();
const albumId = params.id as string;
console.log('idzhi id', albumId)
@@ -83,19 +84,32 @@ export default function AlbumPage() {
}
};
+ const handleAIGenerate = () => {
+ router.push(`/material/ai-generate`);
+ };
+
return (
<div className={styles.container}>
<div className={styles.header}>
<h2>媒体资源</h2>
- <label className={styles.uploadButton}>
- <input
- type="file"
- accept="image/*,video/*,audio/*"
- onChange={handleUpload}
- style={{ display: 'none' }}
- />
- <span>上传资源</span>
- </label>
+ <div className={styles.headerActions}>
+ <label className={styles.uploadButton} onClick={handleAIGenerate}>
+ AI生成素材
+ </label>
+
+ <label className={styles.uploadButton}>
+ <input
+ type="file"
+ accept="image/*,video/*,audio/*"
+ onChange={handleUpload}
+ style={{ display: 'none' }}
+ />
+ <span>上传资源</span>
+ </label>
+
+ </div>
+
+
</div>
<div className={styles.mediaGrid}>
diff --git a/src/app/i18n/locales/zh-CN/login.json b/src/app/i18n/locales/zh-CN/login.json
index df8f39b0..fa2b2d92 100644
--- a/src/app/i18n/locales/zh-CN/login.json
+++ b/src/app/i18n/locales/zh-CN/login.json
@@ -2,7 +2,7 @@
"welcomeBack": "哎呦赚",
"emailPlaceholder": "邮箱",
"passwordPlaceholder": "密码",
- "login": "登录",
+ "login": "登录/注册",
"or": "或",
"forgotPassword": "忘记密码?",
"completeRegistration": "完成注册",