/* Copyright (C) 2025 QuantumNous This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ import { ListFilter as ActionListFilter } from '@/components/common/icons/ActionIcons'; import React, { useEffect, useRef } from 'react'; import { Button } from 'antd'; import { useTranslation } from 'react-i18next'; import { SkillCardSkeleton } from './SkillCard'; const SKELETON_COUNT = 8; /** * 原型 .sm-catalog:结果栏(全部技能 · N 个技能 + 页面已有操作)、提示区、独立滚动的卡片列表、 * 加载骨架(Ant Design Card loading)、空态与分页。数据、计数与分页条件均由页面传入。 */ const SkillCatalog = ({ total, scope = 'all', selectedTagCount = 0, showTotal = true, extra = null, notice = null, loading = false, empty = false, onReset, pagination = null, children, scrollResetKey, selectedTags, mineCount = 0, filtersOpen = false, onToggleFilters, }) => { const { t } = useTranslation(); const listRef = useRef(null); // Reset creates a fresh tag array even when no filters are active. useEffect(() => { if (listRef.current) listRef.current.scrollTop = 0; }, [scrollResetKey, selectedTags]); const noOwnedSkills = scope === 'mine' && mineCount === 0; let body = null; if (loading) { body = (
{Array.from({ length: SKELETON_COUNT }, (_, index) => ( ))}
); } else if (empty) { body = (

{t(noOwnedSkills ? '还没有加入任何技能' : '没有符合条件的技能')}

{t( noOwnedSkills ? '浏览技能后,可加入我的技能。' : '试试其他关键词或调整标签。', )}

{onReset ? ( ) : null}
); } else { body =
{children}
; } return (

{t(scope === 'mine' ? '我的技能' : '全部技能')}

{showTotal ? ( {t('{{total}} 个技能', { total, count: total })} ) : null} {selectedTagCount > 0 && ( {t('已选 {{count}} 个标签', { count: selectedTagCount })} )}
{extra ?
{extra}
: null}
{notice}
{body} {!loading && !empty && pagination ? (
{pagination}
) : null}
); }; export default SkillCatalog;