From 6b91b62ab9bb0ab5413e790e8596a2182556ec0e Mon Sep 17 00:00:00 2001 From: xion Date: Wed, 9 Oct 2024 18:11:08 +0800 Subject: [PATCH] perf: publish change and panel to App --- package.json | 3 +- src/modules/layout/LayoutUser.tsx | 7 +- src/modules/layout/Menu.tsx | 6 +- src/pages/app/edit/List.tsx | 16 +- src/pages/app/index.tsx | 2 +- src/pages/container/edit/List.tsx | 23 ++- src/pages/map/index.tsx | 2 +- src/pages/org/edit/List.tsx | 38 +++- src/pages/org/edit/UserList.tsx | 176 ++++++++++++++++++ src/pages/org/index.tsx | 3 + src/pages/org/store/index.ts | 27 +++ src/pages/panel/edit/List.tsx | 55 +++++- .../panel/edit/modal/PublishFormModal.tsx | 27 ++- theme | 2 +- 14 files changed, 347 insertions(+), 40 deletions(-) create mode 100644 src/pages/org/edit/UserList.tsx diff --git a/package.json b/package.json index 7ae91d2..8b2a3c9 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "lint": "eslint .", "preview": "vite preview", "prune": "pnpm store prune && rimraf node_modules/.vite", - "deploy": "rsync -avz --delete ./dist/ light:/root/apps/envision/web" + "deploy": "rsync -avz --delete ./dist/ light:/root/apps/envision/web", + "pub": "pnpm run build && pnpm run deploy" }, "dependencies": { "@abearxiong/container": "0.0.1-alpha.11", diff --git a/src/modules/layout/LayoutUser.tsx b/src/modules/layout/LayoutUser.tsx index edfd3fd..d8a086e 100644 --- a/src/modules/layout/LayoutUser.tsx +++ b/src/modules/layout/LayoutUser.tsx @@ -25,7 +25,12 @@ const meun = [ { title: 'Your orgs', icon: , - link: '/panel/edit/list', + link: '/org/edit/list', + }, + { + title: 'Site Map', + icon: , + link: '/map', }, ]; export const LayoutUser = () => { diff --git a/src/modules/layout/Menu.tsx b/src/modules/layout/Menu.tsx index edeebae..ff1240a 100644 --- a/src/modules/layout/Menu.tsx +++ b/src/modules/layout/Menu.tsx @@ -72,7 +72,11 @@ export const LayoutMenu = () => { const navigate = useNavigate(); return (
-
+
{ + setOpen(false); + }}>
Envision diff --git a/src/pages/app/edit/List.tsx b/src/pages/app/edit/List.tsx index beba214..53d3ba4 100644 --- a/src/pages/app/edit/List.tsx +++ b/src/pages/app/edit/List.tsx @@ -2,7 +2,7 @@ import { useShallow } from 'zustand/react/shallow'; import { useUserAppStore } from '../store'; import { useEffect } from 'react'; import { Button, Form, Input, Modal, Select, Tooltip } from 'antd'; -import { DeleteOutlined, EditOutlined, LinkOutlined, PlusOutlined, UnorderedListOutlined } from '@ant-design/icons'; +import { CodeOutlined, DashboardOutlined, DeleteOutlined, EditOutlined, LinkOutlined, PlusOutlined, UnorderedListOutlined } from '@ant-design/icons'; import { isObjectNull } from '@/utils/is-null'; import { useNavigate } from 'react-router'; import { FileUpload } from '../modules/FileUpload'; @@ -110,12 +110,22 @@ export const List = () => { }, []); return (
-
+
+ + + + + +
@@ -145,7 +155,7 @@ export const List = () => { diff --git a/src/pages/app/index.tsx b/src/pages/app/index.tsx index a2e7a2e..fe780ed 100644 --- a/src/pages/app/index.tsx +++ b/src/pages/app/index.tsx @@ -8,7 +8,7 @@ export const App = () => { }> }> } /> - } /> + } /> ); diff --git a/src/pages/container/edit/List.tsx b/src/pages/container/edit/List.tsx index 7e0627a..e387ee1 100644 --- a/src/pages/container/edit/List.tsx +++ b/src/pages/container/edit/List.tsx @@ -6,7 +6,17 @@ import { useShallow } from 'zustand/react/shallow'; import { Form } from 'antd'; import copy from 'copy-to-clipboard'; import { useNavigate } from 'react-router'; -import { EditOutlined, SettingOutlined, LinkOutlined, SaveOutlined, DeleteOutlined, LeftOutlined, MessageOutlined, PlusOutlined } from '@ant-design/icons'; +import { + EditOutlined, + SettingOutlined, + LinkOutlined, + SaveOutlined, + DeleteOutlined, + LeftOutlined, + MessageOutlined, + PlusOutlined, + DashboardOutlined, +} from '@ant-design/icons'; import clsx from 'clsx'; import { isObjectNull } from '@/utils/is-null'; import { CardBlank } from '@/components/card/CardBlank'; @@ -125,8 +135,13 @@ export const ContainerList = () => { }; return (
-
- +
+ + + + + +
@@ -200,12 +215,12 @@ export const ContainerList = () => { ); })} - {containerStore.list.length == 0 && (
No Data
)} +
diff --git a/src/pages/map/index.tsx b/src/pages/map/index.tsx index 121f36b..7f0a7a0 100644 --- a/src/pages/map/index.tsx +++ b/src/pages/map/index.tsx @@ -12,7 +12,7 @@ const serverPath = [ }, { path: 'app', - links: ['edit/list', ':app/verison/list'], + links: ['edit/list', ':app/version/list'], }, { path: 'file', diff --git a/src/pages/org/edit/List.tsx b/src/pages/org/edit/List.tsx index e0989b1..7e6446f 100644 --- a/src/pages/org/edit/List.tsx +++ b/src/pages/org/edit/List.tsx @@ -4,7 +4,17 @@ import { useOrgStore } from '../store'; import { useShallow } from 'zustand/react/shallow'; import { Form } from 'antd'; import { useNavigate } from 'react-router'; -import { EditOutlined, SettingOutlined, LinkOutlined, SaveOutlined, DeleteOutlined, LeftOutlined, PlusOutlined, SwapOutlined } from '@ant-design/icons'; +import { + EditOutlined, + SettingOutlined, + LinkOutlined, + SaveOutlined, + DeleteOutlined, + LeftOutlined, + PlusOutlined, + SwapOutlined, + UnorderedListOutlined, +} from '@ant-design/icons'; import clsx from 'clsx'; import { isObjectNull } from '@/utils/is-null'; import { CardBlank } from '@/components/card/CardBlank'; @@ -146,14 +156,24 @@ export const List = () => {
- + + + + + + + + + + + ); +}; + +export const UserList = () => { + const param = useParams(); + const navicate = useNavigate(); + const orgStore = useOrgStore( + useShallow((state) => { + return { + users: state.users, + org: state.org, + setOrgId: state.setOrgId, + getOrg: state.getOrg, + setFormData: state.setFormData, + setShowEdit: state.setShowEdit, + }; + }), + ); + useEffect(() => { + if (param.id) { + orgStore.setOrgId(param.id); + orgStore.getOrg(); + } + return () => { + orgStore.setFormData({}); + }; + }, []); + return ( +
+
+ +
+
+
+ + + +
+
+
+ {orgStore.users.map((item) => { + const isOwner = item.role === 'owner'; + return ( +
+
username: {item.username}
+
{item.role || '-'}
+
+ + + + + + + + +
+
+ ); + })} +
+
+
+ + +
+ ); +}; diff --git a/src/pages/org/index.tsx b/src/pages/org/index.tsx index b014bd1..4b66070 100644 --- a/src/pages/org/index.tsx +++ b/src/pages/org/index.tsx @@ -1,12 +1,15 @@ import { Navigate, Route, Routes } from 'react-router-dom'; import { List } from './edit/List'; import { Main } from './layouts'; +import { UserList } from './edit/UserList'; + export const App = () => { return ( }> }> } /> + } /> ); diff --git a/src/pages/org/store/index.ts b/src/pages/org/store/index.ts index a09c34d..fff2395 100644 --- a/src/pages/org/store/index.ts +++ b/src/pages/org/store/index.ts @@ -12,6 +12,12 @@ type OrgStore = { getList: () => Promise; updateData: (data: any) => Promise; deleteData: (id: string) => Promise; + org: any; + setOrg: (org: any) => void; + users: { id: string; username: string; role?: string }[]; + orgId: string; + setOrgId: (orgId: string) => void; + getOrg: () => Promise; }; export const useOrgStore = create((set, get) => { return { @@ -65,5 +71,26 @@ export const useOrgStore = create((set, get) => { message.error(res.message || 'Request failed'); } }, + org: {}, + setOrg: (org) => set({ org }), + orgId: '', + setOrgId: (orgId) => set({ orgId }), + users: [], + getOrg: async () => { + const { orgId } = get(); + const loaded = message.loading('Loading...', 0); + const res = await query.post({ + path: 'org', + key: 'get', + id: orgId, + }); + loaded(); + if (res.code === 200) { + const { org, users } = res.data || {}; + set({ org, users }); + } else { + message.error(res.message || 'Request failed'); + } + }, }; }); diff --git a/src/pages/panel/edit/List.tsx b/src/pages/panel/edit/List.tsx index c25667e..beb80a0 100644 --- a/src/pages/panel/edit/List.tsx +++ b/src/pages/panel/edit/List.tsx @@ -8,13 +8,19 @@ import { useNavigate } from 'react-router'; import { useToCodeEditor } from '@/pages/code-editor'; import { CardBlank } from '@/components/card/CardBlank'; import { + AppstoreFilled, + AppstoreOutlined, + ArrowRightOutlined, CloudDownloadOutlined, CloudUploadOutlined, + CodeOutlined, DeleteOutlined, EditOutlined, ForkOutlined, GoldOutlined, PlusOutlined, + RocketFilled, + RollbackOutlined, ToolOutlined, } from '@ant-design/icons'; import { isObjectNull } from '@/utils/is-null'; @@ -119,20 +125,40 @@ export const List = () => { return (
-
- +
+ + + + + + + + +
{editStore.list.length > 0 && editStore.list.map((item, index) => { + const publish = item.publish; + if (publish.id) { + console.log(item, item.publish); + } return (
{item.title}
@@ -181,6 +207,17 @@ export const List = () => { icon={} /> + {item.publish?.id && ( + +
); })} - {editStore.list.length === 0 &&
No data
} +
diff --git a/src/pages/panel/edit/modal/PublishFormModal.tsx b/src/pages/panel/edit/modal/PublishFormModal.tsx index 6c7212c..0f10757 100644 --- a/src/pages/panel/edit/modal/PublishFormModal.tsx +++ b/src/pages/panel/edit/modal/PublishFormModal.tsx @@ -74,9 +74,11 @@ export const PublishFormModal = () => { - 发布 -
+ !isEdit && ( +
+ 发布 +
+ ) } /> @@ -84,12 +86,19 @@ export const PublishFormModal = () => { - - +
+ + + {isEdit && ( + + )} +
diff --git a/theme b/theme index 66aae21..bff9266 160000 --- a/theme +++ b/theme @@ -1 +1 @@ -Subproject commit 66aae218f3962f2e5ab8f22f3a463b74d5e17362 +Subproject commit bff92667f4bed0f8d15ed5e6fe1c75ce22480bd2