Skip to content

Let's use AI to Earn!

素材库界面

daoyianb42fa30aae51
diff --git a/src/app/[lng]/material/album/[id]/albumDetailCore.tsx b/src/app/[lng]/material/album/[id]/albumDetailCore.tsx
new file mode 100644
index 00000000..7d87e630
--- /dev/null
+++ b/src/app/[lng]/material/album/[id]/albumDetailCore.tsx
@@ -0,0 +1,119 @@
+"use client";
+
+import { useEffect, useState } from "react";
+import { Card, Row, Col, Typography, Button, Upload, message } from "antd";
+import { useRouter } from "next/navigation";
+import { PlusOutlined, PlayCircleOutlined, PictureOutlined, SoundOutlined } from "@ant-design/icons";
+import styles from "./styles/albumDetail.module.scss";
+
+const { Title } = Typography;
+
+interface Material {
+ id: string;
+ name: string;
+ url: string;
+ type: 'video' | 'image' | 'audio';
+ createTime: string;
+}
+
+interface AlbumDetailCoreProps {
+ albumId: string;
+}
+
+export const AlbumDetailCore = ({ albumId }: AlbumDetailCoreProps) => {
+ const router = useRouter();
+ const [materials, setMaterials] = useState<Material[]>([]);
+ const [albumInfo, setAlbumInfo] = useState({
+ name: "视频素材",
+ type: "video" as 'video' | 'image' | 'audio',
+ count: 0
+ });
+
+ useEffect(() => {
+ // 这里应该调用API获取素材库信息和素材列表
+ // 暂时使用模拟数据
+ setMaterials([
+ {
+ id: "1",
+ name: "示例视频1",
+ url: "https://example.com/video1.mp4",
+ type: "video",
+ createTime: "2024-01-01"
+ },
+ // 更多素材...
+ ]);
+ }, [albumId]);
+
+ const handleUpload = (file: File) => {
+ // 这里应该调用API上传素材
+ message.success('上传成功');
+ return false;
+ };
+
+ const getTypeIcon = (type: string) => {
+ switch (type) {
+ case 'video':
+ return <PlayCircleOutlined />;
+ case 'image':
+ return <PictureOutlined />;
+ case 'audio':
+ return <SoundOutlined />;
+ default:
+ return null;
+ }
+ };
+
+ return (
+ <div className={styles.albumDetailContainer}>
+ <div className={styles.header}>
+ <div className={styles.titleSection}>
+ <Title level={2}>{albumInfo.name}</Title>
+ <span className={styles.typeTag}>
+ {albumInfo.type === 'video' ? '视频' : albumInfo.type === 'image' ? '图片' : '音频'}
+ </span>
+ </div>
+ <Upload
+ accept={albumInfo.type === 'video' ? 'video/*' : albumInfo.type === 'image' ? 'image/*' : 'audio/*'}
+ showUploadList={false}
+ beforeUpload={handleUpload}
+ >
+ <Button type="primary" icon={<PlusOutlined />}>
+ 上传素材
+ </Button>
+ </Upload>
+ </div>
+
+ <Row gutter={[24, 24]}>
+ {materials.map((material) => (
+ <Col xs={24} sm={12} md={8} lg={6} key={material.id}>
+ <Card
+ hoverable
+ cover={
+ <div className={styles.coverWrapper}>
+ <img alt={material.name} src={material.url} />
+ {material.type === 'video' && (
+ <div className={styles.videoIcon}>
+ <PlayCircleOutlined />
+ </div>
+ )}
+ </div>
+ }
+ >
+ <Card.Meta
+ title={material.name}
+ description={
+ <div className={styles.materialInfo}>
+ <span>{material.createTime}</span>
+ <span className={styles.typeIcon}>
+ {getTypeIcon(material.type)}
+ </span>
+ </div>
+ }
+ />
+ </Card>
+ </Col>
+ ))}
+ </Row>
+ </div>
+ );
+};
\ No newline at end of file
diff --git a/src/app/[lng]/material/album/[id]/page.tsx b/src/app/[lng]/material/album/[id]/page.tsx
new file mode 100644
index 00000000..b7168e18
--- /dev/null
+++ b/src/app/[lng]/material/album/[id]/page.tsx
@@ -0,0 +1,27 @@
+import { useTranslation } from "@/app/i18n";
+import { PageParams } from "@/app/globals";
+import * as React from "react";
+import { getMetadata } from "@/utils/general";
+import { AlbumDetailCore } from "./albumDetailCore";
+
+export async function generateMetadata({ params }: PageParams) {
+ const { lng } = await params;
+ const { t } = await useTranslation(lng, "material");
+ return await getMetadata(
+ {
+ title: "素材库详情",
+ },
+ lng,
+ );
+}
+
+export default async function Page({ params }: PageParams) {
+ const { lng } = await params;
+ const { t } = await useTranslation(lng, "material");
+
+ return (
+ <>
+ <AlbumDetailCore albumId={params.id} />
+ </>
+ );
+}
\ No newline at end of file
diff --git a/src/app/[lng]/material/album/[id]/styles/albumDetail.module.scss b/src/app/[lng]/material/album/[id]/styles/albumDetail.module.scss
new file mode 100644
index 00000000..5d9e9c9d
--- /dev/null
+++ b/src/app/[lng]/material/album/[id]/styles/albumDetail.module.scss
@@ -0,0 +1,65 @@
+.albumDetailContainer {
+ padding: 24px;
+ max-width: 1200px;
+ margin: 0 auto;
+
+ .header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-bottom: 24px;
+ }
+
+ .titleSection {
+ display: flex;
+ align-items: center;
+ gap: 16px;
+ }
+
+ .typeTag {
+ background: #f0f0f0;
+ padding: 4px 12px;
+ border-radius: 16px;
+ font-size: 14px;
+ color: rgba(0, 0, 0, 0.65);
+ }
+}
+
+.coverWrapper {
+ position: relative;
+ width: 100%;
+ height: 200px;
+ overflow: hidden;
+
+ img {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ }
+}
+
+.videoIcon {
+ position: absolute;
+ left: 12px;
+ bottom: 12px;
+ background: rgba(0, 0, 0, 0.6);
+ color: white;
+ padding: 8px;
+ border-radius: 50%;
+ font-size: 24px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
+.materialInfo {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ color: rgba(0, 0, 0, 0.45);
+}
+
+.typeIcon {
+ font-size: 18px;
+ color: rgba(0, 0, 0, 0.65);
+}
\ No newline at end of file
diff --git a/src/app/[lng]/material/materialPageCore.tsx b/src/app/[lng]/material/materialPageCore.tsx
new file mode 100644
index 00000000..89956273
--- /dev/null
+++ b/src/app/[lng]/material/materialPageCore.tsx
@@ -0,0 +1,142 @@
+"use client";
+
+import { useEffect, useState } from "react";
+import { Card, Row, Col, Typography, Button, Modal, Input, Select } from "antd";
+import { useRouter } from "next/navigation";
+import { PlusOutlined, PlayCircleOutlined } from "@ant-design/icons";
+import styles from "./styles/material.module.scss";
+
+const { Title } = Typography;
+const { Option } = Select;
+
+interface Album {
+ id: string;
+ name: string;
+ cover: string;
+ count: number;
+ type: 'video' | 'image' | 'audio';
+ isCustom?: boolean;
+}
+
+export const MaterialPageCore = () => {
+ const router = useRouter();
+ const [albums, setAlbums] = useState<Album[]>([
+ {
+ id: "1",
+ name: "视频素材",
+ cover: "https://t9.baidu.com/it/u=4049930541,3060541868&fm=3031&app=3031&size=r3,4&q=100&n=0&g=11n&f=JPEG&fmt=auto&maxorilen2heic=2000000?s=5180DD1D4F1048C20269D5D303005030",
+ count: 10,
+ type: 'video'
+ },
+ {
+ id: "2",
+ name: "图片素材",
+ cover: "https://t9.baidu.com/it/u=355272986,883798233&fm=3031&app=3031&size=r3,4&q=100&n=0&g=11n&f=JPEG&fmt=auto&maxorilen2heic=2000000?s=BDD04B977503EEF04CA566E90300702E",
+ count: 20,
+ type: 'image'
+ },
+ {
+ id: "3",
+ name: "音频素材",
+ cover: "https://t9.baidu.com/it/u=3718371372,4045138797&fm=3031&app=3031&size=r3,4&q=100&n=0&g=11n&f=JPEG&fmt=auto&maxorilen2heic=2000000?s=BAA10F8E985263FD7899495E0300E0E6",
+ count: 15,
+ type: 'audio'
+ }
+ ]);
+
+ const [isModalVisible, setIsModalVisible] = useState(false);
+ const [newAlbumName, setNewAlbumName] = useState("");
+ const [newAlbumType, setNewAlbumType] = useState<'video' | 'image' | 'audio'>('video');
+
+ const handleAlbumClick = (albumId: string) => {
+ router.push(`/material/album/${albumId}`);
+ };
+
+ const handleCreateAlbum = () => {
+ if (!newAlbumName) return;
+
+ const newAlbum: Album = {
+ id: Date.now().toString(),
+ name: newAlbumName,
+ cover: "https://t9.baidu.com/it/u=4049930541,3060541868&fm=3031&app=3031&size=r3,4&q=100&n=0&g=11n&f=JPEG&fmt=auto&maxorilen2heic=2000000?s=5180DD1D4F1048C20269D5D303005030",
+ count: 0,
+ type: newAlbumType,
+ isCustom: true
+ };
+
+ setAlbums([...albums, newAlbum]);
+ setIsModalVisible(false);
+ setNewAlbumName("");
+ };
+
+ return (
+ <div className={styles.materialContainer}>
+ <div className={styles.header}>
+ <Title level={2}>素材库</Title>
+ <Button
+ type="primary"
+ icon={<PlusOutlined />}
+ onClick={() => setIsModalVisible(true)}
+ >
+ 创建素材库
+ </Button>
+ </div>
+
+ <Row gutter={[24, 24]}>
+ {albums.map((album) => (
+ <Col xs={24} sm={12} md={8} lg={6} key={album.id}>
+ <Card
+ hoverable
+ cover={
+ <div className={styles.coverWrapper}>
+ <img alt={album.name} src={album.cover} />
+ {album.type === 'video' && (
+ <div className={styles.videoIcon}>
+ <PlayCircleOutlined />
+ </div>
+ )}
+ </div>
+ }
+ onClick={() => handleAlbumClick(album.id)}
+ >
+ <Card.Meta
+ title={album.name}
+ description={
+ <div className={styles.albumInfo}>
+ <span>{album.type === 'video' ? '视频' : album.type === 'image' ? '图片' : '音频'}</span>
+ <span>共 {album.count} 个素材</span>
+ </div>
+ }
+ />
+ </Card>
+ </Col>
+ ))}
+ </Row>
+
+ <Modal
+ title="创建素材库"
+ open={isModalVisible}
+ onOk={handleCreateAlbum}
+ onCancel={() => setIsModalVisible(false)}
+ >
+ <div className={styles.createForm}>
+ <Input
+ placeholder="请输入素材库名称"
+ value={newAlbumName}
+ onChange={(e) => setNewAlbumName(e.target.value)}
+ style={{ marginBottom: 16 }}
+ />
+ <Select
+ value={newAlbumType}
+ onChange={(value) => setNewAlbumType(value)}
+ style={{ width: '100%' }}
+ >
+ <Option value="video">视频素材</Option>
+ <Option value="image">图片素材</Option>
+ <Option value="audio">音频素材</Option>
+ </Select>
+ </div>
+ </Modal>
+ </div>
+ );
+};
\ No newline at end of file
diff --git a/src/app/[lng]/material/page.tsx b/src/app/[lng]/material/page.tsx
new file mode 100644
index 00000000..58c8f3fd
--- /dev/null
+++ b/src/app/[lng]/material/page.tsx
@@ -0,0 +1,27 @@
+import { useTranslation } from "@/app/i18n";
+import { PageParams } from "@/app/globals";
+import * as React from "react";
+import { getMetadata } from "@/utils/general";
+import { MaterialPageCore } from "@/app/[lng]/material/materialPageCore";
+
+export async function generateMetadata({ params }: PageParams) {
+ const { lng } = await params;
+ const { t } = await useTranslation(lng, "material");
+ return await getMetadata(
+ {
+ title: "素材库",
+ },
+ lng,
+ );
+}
+
+export default async function Page({ params }: PageParams) {
+ const { lng } = await params;
+ const { t } = await useTranslation(lng, "material");
+
+ return (
+ <>
+ <MaterialPageCore />
+ </>
+ );
+}
\ No newline at end of file
diff --git a/src/app/[lng]/material/styles/material.module.scss b/src/app/[lng]/material/styles/material.module.scss
new file mode 100644
index 00000000..6cabc188
--- /dev/null
+++ b/src/app/[lng]/material/styles/material.module.scss
@@ -0,0 +1,68 @@
+.materialContainer {
+ padding: 24px;
+ max-width: 1200px;
+ margin: 0 auto;
+
+ .header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-bottom: 24px;
+ }
+
+ :global {
+ .ant-card {
+ transition: all 0.3s;
+
+ &:hover {
+ transform: translateY(-5px);
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
+ }
+ }
+
+ .ant-card-cover {
+ img {
+ height: 200px;
+ object-fit: cover;
+ }
+ }
+ }
+}
+
+.coverWrapper {
+ position: relative;
+ width: 100%;
+ height: 200px;
+ overflow: hidden;
+
+ img {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ }
+}
+
+.videoIcon {
+ position: absolute;
+ left: 12px;
+ bottom: 12px;
+ background: rgba(0, 0, 0, 0.6);
+ color: white;
+ padding: 8px;
+ border-radius: 50%;
+ font-size: 24px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
+.albumInfo {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ color: rgba(0, 0, 0, 0.45);
+}
+
+.createForm {
+ padding: 16px 0;
+}
\ No newline at end of file
diff --git a/src/app/layout/LyaoutHeader.tsx b/src/app/layout/LyaoutHeader.tsx
index 011978ed..926a941a 100644
--- a/src/app/layout/LyaoutHeader.tsx
+++ b/src/app/layout/LyaoutHeader.tsx
@@ -43,6 +43,18 @@ function UserInfo() {
},
{
key: "2",
+ label: (
+ <div
+ onClick={() => {
+ router.push("/material");
+ }}
+ >
+ 素材库
+ </div>
+ ),
+ },
+ {
+ key: "3",
label: (
<div
onClick={() => {