Skip to content

Commit

Permalink
fix: 修复问题
Browse files Browse the repository at this point in the history
  • Loading branch information
JackySoft authored and jianbing.chen committed Dec 18, 2024
1 parent be10686 commit 41cd313
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions packages/editor/src/pages/home/project/components/ProjectCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ const { Paragraph } = Typography;
*/

export default function Category({ list }: { list: Project.ProjectItem[] }) {
const [item, setItem] = useState({ id: 0 });
const navigate = useNavigate();

// 单击打开项目配置
const handleClick = (id: number) => {
const handleOpenProject = (id: number) => {
navigate(`/project/${id}/config`);
};

// 双击加载项目下子页面
const handleDoubleClick = (id: number) => {
const handleOpenPages = (id: number) => {
navigate(`/project/pages?projectId=${id}`);
};

Expand Down Expand Up @@ -53,26 +52,26 @@ export default function Category({ list }: { list: Project.ProjectItem[] }) {
];

// 环境跳转
const onClick = ({ key }: { key: string }) => {
if (key === 'config') return handleClick(item.id);
return window.open(`${import.meta.env.VITE_ADMIN_URL}/project/${item.id}?env=${key}`, '_blank');
const onClick = (key: string, id: number) => {
if (key === 'config') return handleOpenProject(id);
return window.open(`${import.meta.env.VITE_ADMIN_URL}/project/${id}?env=${key}`, '_blank');
};

// 项目列表
return (
<div className={styles.projectGrid}>
{list.map((project) => {
return (
<div className={styles.projectCard} key={project.id} onDoubleClick={() => handleDoubleClick(project.id)}>
<div className={styles.projectCard} key={project.id}>
{/* 卡片头部 */}
<div className={styles.cardHeader} onClick={() => handleClick(project.id)}>
<div className={styles.cardHeader} onClick={() => handleOpenProject(project.id)}>
<h3 className={styles.cardTitle}>
<GlobalOutlined className={styles.cardIcon} />
{project.name}
</h3>
</div>
{/* 卡片内容 */}
<div className={styles.cardContent} onClick={() => handleDoubleClick(project.id)}>
<div className={styles.cardContent} onClick={() => handleOpenPages(project.id)}>
<Paragraph className={styles.description}>{project.remark}</Paragraph>
<div className={styles.metaInfo}>
<UserOutlined className={styles.metaIcon} />
Expand All @@ -87,8 +86,8 @@ export default function Category({ list }: { list: Project.ProjectItem[] }) {
</div>
{/* 卡片更多 */}
<div className={styles.moreInfo}>
<Dropdown menu={{ items, onClick }} arrow placement="bottomRight" trigger={['click']}>
<MoreOutlined className={styles.moreIcon} onClick={() => setItem(project)} />
<Dropdown menu={{ items, onClick: ({ key }) => onClick(key, project.id) }} arrow placement="bottomRight" trigger={['click']}>
<MoreOutlined className={styles.moreIcon} />
</Dropdown>
</div>
{/* 项目Logo */}
Expand Down

0 comments on commit 41cd313

Please sign in to comment.