-
-
-
锦囊资源上传
-
支持视频、图片、文档、PPT等多种格式文件
-
-
- {/* 上传区域 */}
-
-
-
-
- {
- console.log('文件IDs:', value);
- setFileIds(value);
- }}
- />
-
-
- {/*
-
-
setDescription(e.target.value)}
- placeholder="请输入文件描述信息"
- autoSize={{ minRows: 3, maxRows: 6 }}
- className="bg-transparent border-none focus:ring-0"
- />
-
-
- */}
-
- {fileIds.length > 0 && (
-
- }
- >
- 上传
-
-
- )}
+ if (!confirmed) return;
- {/* 文件展示区域 */}
-
- {/* 图片资源展示 */}
- {/* {imageResources?.length > 0 && (
-
-
图片列表
-
-
- {imageResources.map((resource) => (
-
-
-
-
-
- {resource.title}
- }
- onClick={(e) => {
- e.stopPropagation(); // 防止触发图片预览
- handleDelete(resource.id);
- }}
- />
+ await deleteMutation.mutateAsync({
+ ids: [id],
+ });
+ } catch (error) {
+ console.error("Delete error:", error);
+ message.error("删除失败,请重试");
+ }
-
-
-
-
- ))}
-
-
-
- )} */}
+ refetch();
+ message.success("删除成功");
+ };
- {/* 其他文件资源展示 */}
- {fileResources?.length > 0 && (
-
-
文件列表
-
- {fileResources.map((resource) => (
-
-
- {getFileIcon(resource.url)}
-
-
-
- {resource.title || '未命名文件'}
-
- {resource.description && (
-
- 描述: {resource.description}
-
- )}
-
- {dayjs(resource.createdAt).format('YYYY-MM-DD')}
- {resource.meta?.size && formatFileSize(resource.meta.size)}
-
-
-
-
- }
- onClick={(e) => {
- e.stopPropagation(); // 防止触发下载
- handleDelete(resource.id);
- }}
- />
-
-
- ))}
-
-
- )}
-
-
+ return (
+
+
+
+
资源上传
+
支持视频、图片、文档、PPT等多种格式文件
- );
-};
\ No newline at end of file
+
+
+ {!isAuthenticated && (
+
+ )}
+
+ {isAuthenticated && !isDomainAdmin && (
+
+ )}
+
+ {/* 上传区域 */}
+
+
+
+
+ {
+ if (!isDomainAdmin) {
+ message.error("只有管理员才能上传文件");
+ return;
+ }
+ setFileIds(value);
+ }}
+ />
+
+
+
+ {isDomainAdmin && fileIds.length > 0 && (
+
+ }
+ >
+ 上传
+
+
+ )}
+
+ {/* 文件展示区域 */}
+
+ {/* 其他文件资源展示 */}
+ {filePagination?.total > 0 && (
+
+
+
文件列表
+
+ 共 {filePagination.total} 个文件
+
+
+
+
+ {fileResources.map((resource) => (
+
+
+ {getFileIcon(resource.url)}
+
+
+
+ {resource.title || "未命名文件"}
+
+ {resource.description && (
+
+ 描述: {resource.description}
+
+ )}
+
+
+ {dayjs(resource.createdAt).format("YYYY-MM-DD")}
+
+
+ {resource.meta?.size &&
+ formatFileSize(resource.meta.size)}
+
+
+
+
+
+ {isDomainAdmin && (
+ }
+ onClick={(e) => {
+ e.stopPropagation();
+ handleDelete(resource.id);
+ }}
+ />
+ )}
+
+
+ ))}
+
+
+ {/* 文件分页 */}
+ {filePagination.total > pageSize && (
+
+
setFilePage(page)}
+ showSizeChanger={false}
+ />
+
+ )}
+
+ )}
+
+
+
+ );
+}
diff --git a/apps/web/src/app/main/help/PsychologyNav.tsx b/apps/web/src/app/main/help/PsychologyNav.tsx
old mode 100644
new mode 100755
index 56cdde6..2bcc421
--- a/apps/web/src/app/main/help/PsychologyNav.tsx
+++ b/apps/web/src/app/main/help/PsychologyNav.tsx
@@ -7,46 +7,46 @@ import {
BookOutlined
} from '@ant-design/icons';
import { VideoContent } from './VideoContent';
-import { CourseContent } from './CourseContent';
import { MusicContent } from './MusicContent';
import { ScienceContent } from './ScienceContent';
-import { MoreContent } from './MoreContent';
+import { PublicityContent } from './PublicityContent';
+import { ExampleContent } from './ExampleContent';
import './pt.css';
export function PsychologyNav() {
const items = [
- // {
- // key: 'more',
- // label: (
- //
- //
- // 宣传报道
- //
- // ),
- // children:
- // },
- // {
- // key: 'music',
- // label: (
- //
- // < ReadOutlined className="text-lg" />
- // 常识科普
- //
- // ),
- // children:
- // },
- // {
- // key: 'courses',
- // label: (
- //
- //
- // 案例分析
- //
- // ),
- // children:
- // },
+ {
+ key: 'publicity',
+ label: (
+
+
+ 宣传报道
+
+ ),
+ children:
+ },
{
key: 'science',
+ label: (
+
+ < ReadOutlined className="text-lg" />
+ 常识科普
+
+ ),
+ children:
+ },
+ {
+ key: 'example',
+ label: (
+
+
+ 案例分析
+
+ ),
+ children:
+ },
+ {
+ key: 'video',
label: (
< FileTextOutlined className="text-lg" />
@@ -56,7 +56,7 @@ export function PsychologyNav() {
children:
},
{
- key: 'vedio',
+ key: 'music',
label: (
@@ -71,7 +71,7 @@ export function PsychologyNav() {
return (
- 心理小课件
+ 宣传报道
{/* 这里放课件列表内容 */}
);
diff --git a/apps/web/src/app/main/help/ScienceContent.tsx b/apps/web/src/app/main/help/ScienceContent.tsx
old mode 100644
new mode 100755
diff --git a/apps/web/src/app/main/help/VideoContent.tsx b/apps/web/src/app/main/help/VideoContent.tsx
old mode 100644
new mode 100755
index d5b4f26..74fdaa0
--- a/apps/web/src/app/main/help/VideoContent.tsx
+++ b/apps/web/src/app/main/help/VideoContent.tsx
@@ -9,6 +9,7 @@ import {
Modal,
Input,
Alert,
+ Pagination,
} from "antd";
import { TusUploader } from "@web/src/components/common/uploader/TusUploader";
import { SendOutlined, DeleteOutlined, LoginOutlined } from "@ant-design/icons";
@@ -25,11 +26,15 @@ export function VideoContent() {
const { isAuthenticated, user, hasSomePermissions } = useAuth();
const [fileIds, setFileIds] = useState([]);
const [uploaderKey, setUploaderKey] = useState(0);
- // const [description, setDescription] = useState('');
+
+ // 分页状态
+ const [imagePage, setImagePage] = useState(1);
+ const [filePage, setFilePage] = useState(1);
+ const pageSize = 12; // 每页显示的数量
// 检查是否为域管理员
const isDomainAdmin = useMemo(() => {
- return hasSomePermissions("MANAGE_DOM_STAFF", "MANAGE_ANY_STAFF"); // 使用权限检查而不是角色名称
+ return hasSomePermissions("MANAGE_DOM_STAFF", "MANAGE_ANY_STAFF");
}, [hasSomePermissions]);
// 获取资源列表
@@ -46,30 +51,57 @@ export function VideoContent() {
createdAt: "desc",
},
});
+
// 处理资源数据
- const { imageResources, fileResources } = useMemo(() => {
- if (!resources) return { imageResources: [], fileResources: [] };
- const isImage = (url: string) => /\.(png|jpg|jpeg|gif|webp)$/i.test(url);
-
- const processedResources = resources
- .map((resource) => {
- if (!resource?.url) return null;
- const original = `http://${env.SERVER_IP}:${env.UPLOAD_PORT}/uploads/${resource.url}`;
- const isImg = isImage(resource.url);
+ const { imageResources, fileResources, imagePagination, filePagination } =
+ useMemo(() => {
+ if (!resources)
return {
- ...resource,
- url: isImg ? getCompressedImageUrl(original) : original,
- originalUrl: original,
- isImage: isImg,
+ imageResources: [],
+ fileResources: [],
+ imagePagination: { total: 0, data: [] },
+ filePagination: { total: 0, data: [] },
};
- })
- .filter(Boolean);
- return {
- imageResources: processedResources.filter((res) => res.isImage),
- fileResources: processedResources.filter((res) => !res.isImage),
- };
- }, [resources]);
+ const isImage = (url: string) => /\.(png|jpg|jpeg|gif|webp)$/i.test(url);
+
+ const processedResources = resources
+ .map((resource) => {
+ if (!resource?.url) return null;
+ const original = `http://${env.SERVER_IP}:${env.UPLOAD_PORT}/uploads/${resource.url}`;
+ const isImg = isImage(resource.url);
+ return {
+ ...resource,
+ url: isImg ? getCompressedImageUrl(original) : original,
+ originalUrl: original,
+ isImage: isImg,
+ };
+ })
+ .filter(Boolean);
+
+ const allImageResources = processedResources.filter((res) => res.isImage);
+ const allFileResources = processedResources.filter((res) => !res.isImage);
+
+ // 分页处理
+ const imageStart = (imagePage - 1) * pageSize;
+ const fileStart = (filePage - 1) * pageSize;
+
+ return {
+ imageResources: allImageResources.slice(
+ imageStart,
+ imageStart + pageSize
+ ),
+ fileResources: allFileResources.slice(fileStart, fileStart + pageSize),
+ imagePagination: {
+ total: allImageResources.length,
+ data: allImageResources,
+ },
+ filePagination: {
+ total: allFileResources.length,
+ data: allFileResources,
+ },
+ };
+ }, [resources, imagePage, filePage]);
const createMutation = api.resource.create.useMutation({});
const handleSubmit = async () => {
@@ -95,7 +127,6 @@ export function VideoContent() {
await createMutation.mutateAsync({
data: {
fileId,
- // description: description.trim(),
isPublic: true,
},
});
@@ -112,7 +143,6 @@ export function VideoContent() {
}
message.success("上传成功!");
setFileIds([]);
- // setDescription('');
setUploaderKey((prev) => prev + 1);
refetch(); // 刷新列表
} catch (error) {
@@ -166,7 +196,7 @@ export function VideoContent() {
-
锦囊资源上传
+
资源上传
支持视频、图片、文档、PPT等多种格式文件
@@ -209,13 +239,6 @@ export function VideoContent() {
setFileIds(value);
}}
/>
- {/* {!isDomainAdmin && (
-
-
- 只有管理员才能使用上传功能
-
-
- )} */}
@@ -235,9 +258,15 @@ export function VideoContent() {
{/* 文件展示区域 */}
{/* 图片资源展示 */}
- {imageResources?.length > 0 && (
+ {imagePagination?.total > 0 && (
-
图片列表
+
+
图片列表
+
+ 共 {imagePagination.total} 张图片
+
+
+
{imageResources.map((resource) => (
@@ -275,13 +304,32 @@ export function VideoContent() {
))}
+
+ {/* 图片分页 */}
+ {imagePagination.total > pageSize && (
+
+
setImagePage(page)}
+ showSizeChanger={false}
+ />
+
+ )}
)}
{/* 其他文件资源展示 */}
- {fileResources?.length > 0 && (
+ {filePagination?.total > 0 && (
-
文件列表
+
+
文件列表
+
+ 共 {filePagination.total} 个文件
+
+
+
{fileResources.map((resource) => (
))}
+
+ {/* 文件分页 */}
+ {filePagination.total > pageSize && (
+
+
setFilePage(page)}
+ showSizeChanger={false}
+ />
+
+ )}
)}
diff --git a/apps/web/src/components/models/post/detail/PostCommentCard.tsx b/apps/web/src/components/models/post/detail/PostCommentCard.tsx
index 7c06646..8cb78da 100755
--- a/apps/web/src/components/models/post/detail/PostCommentCard.tsx
+++ b/apps/web/src/components/models/post/detail/PostCommentCard.tsx
@@ -35,7 +35,7 @@ export default function PostCommentCard({