diff --git a/src/api/apps.ts b/src/api/apps.ts index c447d31..1269819 100644 --- a/src/api/apps.ts +++ b/src/api/apps.ts @@ -55,17 +55,17 @@ export function copyApp(data: any) { } // 导入应用 -export function importApp(data: any) { - return axios.post(`${urlPrefix}/apps/import`, data); +export function importApp(file: File) { + return axios.post(`${urlPrefix}/apps/import`, { file }); } // 导出应用 -export function exportApp(data: any) { +export function exportApp(srcId: any) { return axios({ method: 'post', url: `${urlPrefix}/apps/export`, responseType: 'blob', - data: data + data: { srcId } }); } diff --git a/src/components/ResourceMonitorModal/index.tsx b/src/components/ResourceMonitorModal/index.tsx index 6b41434..f4af259 100644 --- a/src/components/ResourceMonitorModal/index.tsx +++ b/src/components/ResourceMonitorModal/index.tsx @@ -53,11 +53,19 @@ const ResourceMonitorModal: React.FC = ({ // CPU 使用率仪表盘配置 const getCpuGaugeOption = (): EChartsOption => { return { + grid: { + top: '25%', + bottom: '10%', + left: '10%', + right: '10%', + }, series: [ { type: 'gauge', startAngle: 180, endAngle: 0, + center: ['50%', '70%'], + radius: '90%', min: 0, max: 100, splitNumber: 10, @@ -128,11 +136,19 @@ const ResourceMonitorModal: React.FC = ({ // 内存使用率仪表盘配置 const getMemoryGaugeOption = (): EChartsOption => { return { + grid: { + top: '25%', + bottom: '10%', + left: '10%', + right: '10%', + }, series: [ { type: 'gauge', startAngle: 180, endAngle: 0, + center: ['50%', '70%'], + radius: '90%', min: 0, max: 100, splitNumber: 10, diff --git a/src/pages/ideContainer/sideBar.tsx b/src/pages/ideContainer/sideBar.tsx index fd8693d..74fee80 100644 --- a/src/pages/ideContainer/sideBar.tsx +++ b/src/pages/ideContainer/sideBar.tsx @@ -10,7 +10,8 @@ import { Message, Dropdown, Menu, - Popconfirm + Popconfirm, + Upload } from '@arco-design/web-react'; import { IconApps, @@ -24,7 +25,8 @@ import { IconExpand, IconShrink, IconLeft, - IconLoading + IconLoading, + IconUpload } from '@arco-design/web-react/icon'; import { menuData1, menuData2 } from './config/menuData'; import { Selected } from '@/pages/ideContainer/types'; @@ -39,7 +41,7 @@ import { updateIsRunning, updateRuntimeId } from '@/store/ideContainer'; -import { addApp, getProjectEnv, editApp, deleteApp } from '@/api/apps'; +import { addApp, getProjectEnv, editApp, deleteApp, exportApp, importApp } from '@/api/apps'; import _ from 'lodash'; import { getAppInfoNew } from '@/api/appRes'; import { getAppEventData } from '@/api/appEvent'; @@ -201,6 +203,9 @@ const SideBar: React.FC = ({ const [showModal, setShowModal] = useState(false); const [modalType, setModalType] = useState<'ADD' | 'EDIT'>('ADD'); const [currentApp, setCurrentApp] = useState(null); + const [showImportModal, setShowImportModal] = useState(false); // 导入应用弹窗 + const [importFile, setImportFile] = useState(null); // 导入的文件 + const [importing, setImporting] = useState(false); // 导入中状态 const [contextMenu, setContextMenu] = useState<{ visible: boolean; x: number; @@ -685,6 +690,36 @@ const SideBar: React.FC = ({ // 只有当 node.dataRef.id 存在时才渲染操作按钮 if (!node.dataRef?.id) return null; + // 导出应用处理函数 + const handleExportApp = async () => { + try { + const response: any = await exportApp(node.dataRef.id); + + // 创建下载链接 + const url = window.URL.createObjectURL(new Blob([response])); + const link = document.createElement('a'); + link.href = url; + + // 设置文件名,使用应用名称 + const fileName = `${node.dataRef.name || 'app'}_${new Date().getTime()}.zip`; + link.setAttribute('download', fileName); + + // 触发下载 + document.body.appendChild(link); + link.click(); + + // 清理 + document.body.removeChild(link); + window.URL.revokeObjectURL(url); + + Message.success('应用导出成功'); + setContextMenu(prev => ({ ...prev, visible: false })); // 隐藏右键菜单 + } catch (error) { + console.error('导出应用失败:', error); + Message.error('导出应用失败'); + } + }; + const dropList = ( = ({ 编辑信息 + + + + 导出应用 + + { @@ -850,10 +894,10 @@ const SideBar: React.FC = ({ />