|
|
|
|
@ -42,6 +42,7 @@ interface SideBarProps {
|
|
|
|
|
identity?: string;
|
|
|
|
|
onMenuSelect?: (selected: Selected) => void;
|
|
|
|
|
onRefresh: () => void;
|
|
|
|
|
onDeleteApp?: (appId: string) => void; // 添加删除应用的回调函数
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const compTypeMap = {
|
|
|
|
|
@ -54,21 +55,11 @@ const AppHandleModal = ({ appInfo, visible, type, onChangeVisible, onClose, onRe
|
|
|
|
|
const { info } = useSelector(state => state.ideContainer);
|
|
|
|
|
const [form] = Form.useForm();
|
|
|
|
|
|
|
|
|
|
if (appInfo) {
|
|
|
|
|
form.setFieldsValue({
|
|
|
|
|
id: appInfo?.id,
|
|
|
|
|
name: appInfo?.name,
|
|
|
|
|
description: appInfo?.description,
|
|
|
|
|
published: appInfo?.published === 1,
|
|
|
|
|
logo: 'scene04.png', // 先写死
|
|
|
|
|
sceneId: info.id
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const onOk = async () => {
|
|
|
|
|
await form.validate();
|
|
|
|
|
const formData = form.getFields();
|
|
|
|
|
|
|
|
|
|
// 新增
|
|
|
|
|
if (type === 'ADD') {
|
|
|
|
|
// 新增应用的入参
|
|
|
|
|
const params = {
|
|
|
|
|
@ -82,7 +73,18 @@ const AppHandleModal = ({ appInfo, visible, type, onChangeVisible, onClose, onRe
|
|
|
|
|
if (res.code === 200) Message.success('创建成功');
|
|
|
|
|
else Message.error(res.message);
|
|
|
|
|
}
|
|
|
|
|
// 编辑
|
|
|
|
|
else {
|
|
|
|
|
if (appInfo) {
|
|
|
|
|
form.setFieldsValue({
|
|
|
|
|
id: appInfo?.id,
|
|
|
|
|
name: appInfo?.name,
|
|
|
|
|
description: appInfo?.description,
|
|
|
|
|
published: appInfo?.published === 1,
|
|
|
|
|
logo: 'scene04.png', // 先写死
|
|
|
|
|
sceneId: info.id
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
const res: any = await editApp(formData);
|
|
|
|
|
if (res.code === 200) Message.success('编辑成功');
|
|
|
|
|
else Message.error(res.message);
|
|
|
|
|
@ -90,8 +92,8 @@ const AppHandleModal = ({ appInfo, visible, type, onChangeVisible, onClose, onRe
|
|
|
|
|
|
|
|
|
|
// 清空表单数据和其他变量数据
|
|
|
|
|
form.resetFields();
|
|
|
|
|
onClose();
|
|
|
|
|
onRefresh();
|
|
|
|
|
onClose();
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
@ -153,7 +155,7 @@ const AppHandleModal = ({ appInfo, visible, type, onChangeVisible, onClose, onRe
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const SideBar: React.FC<SideBarProps> = ({ selected, identity, subMenuData, onMenuSelect, onRefresh }) => {
|
|
|
|
|
const SideBar: React.FC<SideBarProps> = ({ selected, identity, subMenuData, onMenuSelect, onRefresh, onDeleteApp }) => {
|
|
|
|
|
const [menu, setMenu] = useState<MenuItemType[]>([]);
|
|
|
|
|
const [subMenuWidth, setSubMenuWidth] = useState(300); // 子菜单宽度状态
|
|
|
|
|
const [isSubMenuCollapsed, setIsSubMenuCollapsed] = useState(false); // 子菜单收起状态
|
|
|
|
|
@ -330,6 +332,8 @@ const SideBar: React.FC<SideBarProps> = ({ selected, identity, subMenuData, onMe
|
|
|
|
|
closable: false,
|
|
|
|
|
onOk: async () => {
|
|
|
|
|
await deleteApp(node.dataRef.id);
|
|
|
|
|
// 通知父组件应用已被删除
|
|
|
|
|
onDeleteApp?.(node.dataRef.id);
|
|
|
|
|
onRefresh();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|