diff --git a/packages/editor/src/pages/home/project/components/ProjectCard.tsx b/packages/editor/src/pages/home/project/components/ProjectCard.tsx
index fb649088..8afe7521 100644
--- a/packages/editor/src/pages/home/project/components/ProjectCard.tsx
+++ b/packages/editor/src/pages/home/project/components/ProjectCard.tsx
@@ -4,29 +4,31 @@ import { UserOutlined, GlobalOutlined, MoreOutlined, SettingOutlined, Deployment
import type { MenuProps } from 'antd';
import { Project } from '@/api/types';
import styles from './../page.module.less';
+import { useState } from 'react';
const { Paragraph } = Typography;
/**
* 页面列表
*/
-export default function Category({ project }: { project: Project.ProjectItem }) {
+export default function Category({ list }: { list: Project.ProjectItem[] }) {
+ const [item, setItem] = useState({ id: 0 });
const navigate = useNavigate();
// 单击打开项目配置
const handleClick = () => {
- navigate(`/project/${project.id}/config`);
+ navigate(`/project/${item.id}/config`);
};
// 双击加载项目下属页面
- const handleDoubleClick = () => {
- navigate(`/project/pages?projectId=${project.id}`);
+ const handleDoubleClick = (id: number) => {
+ navigate(`/project/pages?projectId=${id}`);
};
// 打开对应环境
const handleVisitEnv = (e: React.MouseEvent, env: string) => {
e.preventDefault();
e.stopPropagation();
- return window.open(`${import.meta.env.VITE_ADMIN_URL}/project/${project.id}?env=${env}`, '_blank');
+ return window.open(`${import.meta.env.VITE_ADMIN_URL}/project/${item.id}?env=${env}`, '_blank');
};
// 卡片下拉项
@@ -58,34 +60,43 @@ export default function Category({ project }: { project: Project.ProjectItem })
// 项目列表
return (
-
-
-
-
- {project.name}
-
-
-
-
{project.remark}
-
-
-
-
- {project.count} 个页面
-
-
-
-
- 双击查看页面
-
-
-
-
-
-
+
+ {list.map((project) => {
+ return (
+
handleDoubleClick(project.id)}>
+ {/* 卡片头部 */}
+
+
+
+ {project.name}
+
+
+ {/* 卡片内容 */}
+
+
{project.remark}
+
+
+
+
+ {project.count} 个页面
+
+
+
+ {/* 卡片更多 */}
+
+ 双击查看页面
+
+ setItem(project)} />
+
+
+ {/* 项目Logo */}
+
+
+ );
+ })}
);
}
diff --git a/packages/editor/src/pages/home/project/index.tsx b/packages/editor/src/pages/home/project/index.tsx
new file mode 100644
index 00000000..40807545
--- /dev/null
+++ b/packages/editor/src/pages/home/project/index.tsx
@@ -0,0 +1,132 @@
+import { memo, useRef, useState } from 'react';
+import { useSearchParams } from 'react-router-dom';
+import { Button, Empty, Form, Layout, Pagination, Spin } from 'antd';
+import { PlusOutlined } from '@ant-design/icons';
+import { useMediaQuery } from 'react-responsive';
+import { useAntdTable } from 'ahooks';
+import { getPageList } from '@/api';
+import pageApi from '@/api/page';
+import CreatePage from '@/components/CreatePage';
+import SearchBar from '@/components/Searchbar/SearchBar';
+import PageCard from './components/PageCard';
+import ProjectCard from './components/ProjectCard';
+import CreateProject from '@/components/CreateProject';
+import styles from './../index.module.less';
+
+/**
+ * 页面列表
+ */
+
+function Category() {
+ const [form] = Form.useForm();
+ const [type, setType] = useState('project');
+ const [searchParams] = useSearchParams();
+ const createProjectRef = useRef<{ open: () => void }>();
+ const createPageRef = useRef<{ open: () => void }>();
+ // 判断是否是超大屏
+ const isXLarge = useMediaQuery({ query: '(min-width: 1920px)' });
+
+ // 获取列表数据
+ const getTableData = ({ current, pageSize }: { current: number; pageSize: number }, { keyword }: { keyword: string }) => {
+ const promise = type === 'project' ? pageApi.getCategoryList : getPageList;
+ return promise({
+ pageNum: current,
+ pageSize: pageSize,
+ keyword,
+ projectId: Number(searchParams.get('projectId')),
+ }).then((res) => {
+ return {
+ total: res.total,
+ list: res.list,
+ };
+ });
+ };
+
+ const { tableProps, loading, search } = useAntdTable(getTableData, {
+ form,
+ defaultPageSize: isXLarge ? 15 : 12,
+ });
+
+ // 列表切换
+ const handleViewChange = (value: string) => {
+ setType(value);
+ search.submit();
+ };
+
+ // 新建项目或页面
+ const handleCreate = () => {
+ if (type === 'project') {
+ createProjectRef.current?.open();
+ } else {
+ createPageRef.current?.open();
+ }
+ };
+
+ return (
+
+ {/* 搜索工具条 */}
+
+
+ {/* 加载项目列表 */}
+ {type === 'project' ? (
+
+
+ {tableProps.dataSource.length > 0 ? (
+
+ ) : (
+
+ } onClick={handleCreate}>
+ 创建项目
+
+
+ )}
+
+
+ ) : null}
+
+ {/* 加载子页面列表 */}
+ {type === 'page' ? (
+
+
+ {tableProps.dataSource.length > 0 ? (
+
+ ) : (
+
+ } onClick={handleCreate}>
+ 创建页面
+
+
+ )}
+
+
+ ) : null}
+
+ {/* 分页器 */}
+ {tableProps.dataSource.length > 0 ? (
+ tableProps.onChange({ current, pageSize })}
+ showSizeChanger
+ showTotal={(total) => `总共 ${total} 条`}
+ align="end"
+ />
+ ) : null}
+
+ {/* 新建项目 */}
+
+
+ {/* 新建页面 */}
+
+
+ );
+}
+
+export default memo(Category);
diff --git a/packages/editor/src/router/index.tsx b/packages/editor/src/router/index.tsx
index c71b23c2..e89547d7 100644
--- a/packages/editor/src/router/index.tsx
+++ b/packages/editor/src/router/index.tsx
@@ -25,7 +25,7 @@ export const router = [
children: [
{
path: '/projects',
- element: lazyLoad(React.lazy(() => import('@/pages/home/project/Category'))),
+ element: lazyLoad(React.lazy(() => import('@/pages/home/project/index'))),
},
{
path: '/project/pages',
diff --git a/packages/materials/Scene/GridForm/GridForm.tsx b/packages/materials/Scene/GridForm/GridForm.tsx
index 666b48c0..c0e19143 100644
--- a/packages/materials/Scene/GridForm/GridForm.tsx
+++ b/packages/materials/Scene/GridForm/GridForm.tsx
@@ -160,13 +160,7 @@ const GridForm = ({ id, type, config, elements, onSearch, onChange, onReset }: C
onValuesChange={handleValuesChange}
>
- {elements.length ? (
-
- ) : (
-
- )}
+ {elements.length ? : null}
} onClick={handleReset}>