Skip to content

Let's use AI to Earn!

样式优化

daoyian101c8a7e35e3
diff --git a/src/app/[lng]/material/album/[id]/album.module.scss b/src/app/[lng]/material/album/[id]/album.module.scss
index e43a509c..bc4e31ef 100644
--- a/src/app/[lng]/material/album/[id]/album.module.scss
+++ b/src/app/[lng]/material/album/[id]/album.module.scss
@@ -164,7 +164,7 @@
left: 0;
right: 0;
bottom: 0;
- background: rgba(0, 0, 0, 0.5);
+ background: rgba(0, 0, 0, 0.8);
display: flex;
align-items: center;
justify-content: center;
@@ -175,28 +175,62 @@
background: white;
padding: 24px;
border-radius: 8px;
- max-width: 90%;
+ width: 90%;
+ max-width: 1200px;
max-height: 90vh;
- overflow: auto;
+ display: flex;
+ flex-direction: column;
+ gap: 16px;
}
.modalHeader {
display: flex;
justify-content: space-between;
align-items: center;
- margin-bottom: 24px;
+ margin-bottom: 8px;
h3 {
margin: 0;
- font-size: 20px;
+ font-size: var(--fs-lg);
+ color: var(--text-primary);
}
button {
background: none;
border: none;
- font-size: 20px;
+ font-size: 24px;
cursor: pointer;
- color: #666;
+ color: var(--grayColor8);
+ padding: 4px;
+ line-height: 1;
+
+ &:hover {
+ color: var(--text-primary);
+ }
+ }
+}
+
+.previewContent {
+ flex: 1;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ min-height: 0;
+ overflow: hidden;
+
+ img, video, audio {
+ max-width: 100%;
+ max-height: calc(90vh - 100px);
+ object-fit: contain;
+ }
+
+ video {
+ width: 100%;
+ height: auto;
+ }
+
+ audio {
+ width: 100%;
}
}
diff --git a/src/app/[lng]/material/album/[id]/page.tsx b/src/app/[lng]/material/album/[id]/page.tsx
index bd522357..6b7f3903 100644
--- a/src/app/[lng]/material/album/[id]/page.tsx
+++ b/src/app/[lng]/material/album/[id]/page.tsx
@@ -2,14 +2,14 @@
import { useEffect, useState } from "react";
import { useParams } from "next/navigation";
-import { message } from "antd";
+import { message, Popconfirm } from "antd";
import styles from "./album.module.scss";
-import { createMedia, deleteMedia, getMediaList, updateMediaInfo } from "@/api/media";
+import { createMedia, deleteMedia, getMediaList } from "@/api/media";
import { uploadToOss } from "@/api/oss";
import { getOssUrl } from "@/utils/oss";
interface Media {
- id: string;
+ _id: string;
name: string;
url: string;
type: 'video' | 'img' | 'audio';
@@ -20,14 +20,13 @@ interface Media {
export default function AlbumPage() {
const params = useParams();
- const albumId = params.id as string;
+ const albumId = params._id as string;
const [mediaList, setMediaList] = useState<Media[]>([]);
const [loading, setLoading] = useState(false);
const [currentPage, setCurrentPage] = useState(1);
const pageSize = 12;
- const [editingMedia, setEditingMedia] = useState<Media | null>(null);
const [previewMedia, setPreviewMedia] = useState<Media | null>(null);
useEffect(() => {
@@ -74,8 +73,6 @@ export default function AlbumPage() {
};
const handleDelete = async (mediaId: string) => {
- if (!confirm('确定要删除吗?')) return;
-
try {
await deleteMedia(mediaId);
message.success('删除成功');
@@ -85,26 +82,6 @@ export default function AlbumPage() {
}
};
- const handleEditSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
- event.preventDefault();
- if (!editingMedia) return;
-
- const formData = new FormData(event.currentTarget);
- const values = {
- title: formData.get('title') as string,
- desc: formData.get('desc') as string
- };
-
- try {
- await updateMediaInfo(editingMedia.id, values);
- message.success('更新成功');
- setEditingMedia(null);
- fetchMediaList();
- } catch (error) {
- message.error('更新失败');
- }
- };
-
return (
<div className={styles.container}>
<div className={styles.header}>
@@ -123,7 +100,7 @@ export default function AlbumPage() {
<div className={styles.mediaGrid}>
{mediaList.length > 0 ? (
mediaList.map((media) => (
- <div key={media.id} className={styles.mediaCard}>
+ <div key={media._id} className={styles.mediaCard}>
<div className={styles.mediaWrapper} onClick={() => setPreviewMedia(media)}>
{media.type === 'video' ? (
<video src={getOssUrl(media.url)} />
@@ -133,24 +110,23 @@ export default function AlbumPage() {
<audio src={getOssUrl(media.url)} />
)}
<div className={styles.mediaActions}>
- <button
- className={styles.actionButton}
- onClick={(e) => {
- e.stopPropagation();
- setEditingMedia(media);
- }}
- >
- 编辑
- </button>
- <button
- className={`${styles.actionButton} ${styles.delete}`}
- onClick={(e) => {
- e.stopPropagation();
- handleDelete(media.id);
+ <Popconfirm
+ title="确定要删除这个媒体资源吗?"
+ onConfirm={(e) => {
+ e?.stopPropagation();
+ handleDelete(media._id);
}}
+ onCancel={(e) => e?.stopPropagation()}
+ okText="确定"
+ cancelText="取消"
>
- 删除
- </button>
+ <button
+ className={`${styles.actionButton} ${styles.delete}`}
+ onClick={(e) => e.stopPropagation()}
+ >
+ 删除
+ </button>
+ </Popconfirm>
</div>
</div>
<div className={styles.mediaInfo}>
@@ -174,47 +150,15 @@ export default function AlbumPage() {
<h3>{previewMedia.title}</h3>
<button onClick={() => setPreviewMedia(null)}>×</button>
</div>
- {previewMedia.type === 'video' ? (
- <video src={getOssUrl(previewMedia.url)} controls autoPlay />
- ) : previewMedia.type === 'img' ? (
- <img alt={previewMedia.title} src={getOssUrl(previewMedia.url)} />
- ) : (
- <audio src={getOssUrl(previewMedia.url)} controls autoPlay />
- )}
- </div>
- </div>
- )}
-
- {editingMedia && (
- <div className={styles.modal} onClick={() => setEditingMedia(null)}>
- <div className={styles.modalContent} onClick={e => e.stopPropagation()}>
- <div className={styles.modalHeader}>
- <h3>编辑媒体信息</h3>
- <button onClick={() => setEditingMedia(null)}>×</button>
+ <div className={styles.previewContent}>
+ {previewMedia.type === 'video' ? (
+ <video src={getOssUrl(previewMedia.url)} controls autoPlay />
+ ) : previewMedia.type === 'img' ? (
+ <img alt={previewMedia.title} src={getOssUrl(previewMedia.url)} />
+ ) : (
+ <audio src={getOssUrl(previewMedia.url)} controls autoPlay />
+ )}
</div>
- <form className={styles.form} onSubmit={handleEditSubmit}>
- <div className={styles.formGroup}>
- <label htmlFor="title">标题</label>
- <input
- type="text"
- id="title"
- name="title"
- defaultValue={editingMedia.title}
- required
- />
- </div>
- <div className={styles.formGroup}>
- <label htmlFor="desc">描述</label>
- <textarea
- id="desc"
- name="desc"
- defaultValue={editingMedia.desc}
- />
- </div>
- <button type="submit" className={styles.submitButton}>
- 保存
- </button>
- </form>
</div>
</div>
)}
diff --git a/src/app/[lng]/material/materialPageCore.tsx b/src/app/[lng]/material/materialPageCore.tsx
index 29b4db13..ccc6e7d0 100644
--- a/src/app/[lng]/material/materialPageCore.tsx
+++ b/src/app/[lng]/material/materialPageCore.tsx
@@ -137,10 +137,13 @@ export const MaterialPageCore = () => {
</div>
)}
<div className={styles.cardActions}>
- <button onClick={(e) => {
- e.stopPropagation();
- showEditModal(group);
- }}>
+ <button
+ className={styles.actionButton}
+ onClick={(e) => {
+ e.stopPropagation();
+ showEditModal(group);
+ }}
+ >
编辑
</button>
<Popconfirm
@@ -154,7 +157,7 @@ export const MaterialPageCore = () => {
cancelText="取消"
>
<button
- className="delete"
+ className={`${styles.actionButton} ${styles.delete}`}
onClick={(e) => e.stopPropagation()}
>
删除
diff --git a/src/app/[lng]/material/styles/material.module.scss b/src/app/[lng]/material/styles/material.module.scss
index eb3c8235..4f8580b3 100644
--- a/src/app/[lng]/material/styles/material.module.scss
+++ b/src/app/[lng]/material/styles/material.module.scss
@@ -133,25 +133,34 @@
opacity: 0;
transition: opacity 0.3s;
z-index: 1;
+}
- button {
- background: rgba(255, 255, 255, 0.9);
- border: none;
- padding: 6px 12px;
- border-radius: 4px;
- cursor: pointer;
- color: var(--grayColor8);
- transition: all 0.3s;
- font-size: var(--fs-sm);
- backdrop-filter: blur(4px);
+.actionButton {
+ background: rgba(255, 255, 255, 0.9);
+ border: none;
+ padding: 6px 12px;
+ border-radius: 4px;
+ cursor: pointer;
+ color: var(--grayColor8);
+ transition: all 0.3s;
+ font-size: var(--fs-sm);
+ backdrop-filter: blur(4px);
+ color: var(--theColor5);
+
+ &:hover {
+ background: white;
+ color: var(--theColor6);
+ }
+
+ &.delete {
+ color: var(--error-color);
&:hover {
- background: white;
- color: var(--theColor5);
+ color: #ff7875;
}
- &.delete:hover {
- color: var(--error-color);
+ &:active {
+ color: #d9363e;
}
}
}