diff --git a/src/api/componentGitea.ts b/src/api/componentGitea.ts new file mode 100644 index 0000000..098c562 --- /dev/null +++ b/src/api/componentGitea.ts @@ -0,0 +1,14 @@ +import axios from 'axios'; + +// 公共路径 +const urlPrefix = '/api/v1/bpms-workbench'; + +// 拉取代码 +export function gitPull(componentBaseId) { + return axios.post(`${urlPrefix}/componentGitea/${componentBaseId}/pull`); +} + +// 提交代码 +export function gitCommit(componentBaseId, params: { commit: string }) { + return axios.post(`${urlPrefix}/componentGitea/${componentBaseId}/commit`, params); +} \ No newline at end of file diff --git a/src/pages/componentDevelopment/componentCoding/index.tsx b/src/pages/componentDevelopment/componentCoding/index.tsx index b618264..c6165f7 100644 --- a/src/pages/componentDevelopment/componentCoding/index.tsx +++ b/src/pages/componentDevelopment/componentCoding/index.tsx @@ -1,11 +1,12 @@ import React, { useEffect, useState, useRef } from 'react'; import styles from './style/index.module.less'; -import { Button, Select, Space } from '@arco-design/web-react'; +import { Button, Select, Space, Message, Modal, Input } from '@arco-design/web-react'; import { IconFullscreen, IconFullscreenExit } from '@arco-design/web-react/icon'; import { useSelector, useDispatch } from 'react-redux'; import { getMyComponentList } from '@/api/componentBase'; import { updateComponentCodingPath } from '@/store/ideContainer'; import { getComponentBaseInfo } from '@/api/componentDevelopProcess'; +import { gitCommit, gitPull } from '@/api/componentGitea'; const Option = Select.Option; @@ -15,6 +16,8 @@ const ComponentCoding = () => { const [originList, setOriginList] = useState([]); // 原始数据-组件列表 const [currentComponent, setCurrentComponent] = useState({}); // 当前组件信息 const [isFullscreen, setIsFullscreen] = useState(false); // 全屏状态 + const [commitMessage, setCommitMessage] = useState(''); // 提交信息 + const [commitModal, setCommitModal] = useState(false); // 提交信息弹窗 const iframeRef = useRef(null); const { componentCoding } = useSelector((state: any) => state.ideContainer); const dispatch = useDispatch(); @@ -39,6 +42,70 @@ const ComponentCoding = () => { } }; + + // 切换全屏状态 + const toggleFullscreen = () => { + const iframeContainer = document.querySelector(`.${styles['code-iframe']}`) as HTMLElement; + + if (!isFullscreen) { + // 进入全屏 + if (iframeContainer.requestFullscreen) { + iframeContainer.requestFullscreen(); + } + else if ((iframeContainer as any).webkitRequestFullscreen) { + (iframeContainer as any).webkitRequestFullscreen(); + } + else if ((iframeContainer as any).mozRequestFullScreen) { + (iframeContainer as any).mozRequestFullScreen(); + } + else if ((iframeContainer as any).msRequestFullscreen) { + (iframeContainer as any).msRequestFullscreen(); + } + } + else { + // 退出全屏 + if (document.exitFullscreen) { + document.exitFullscreen(); + } + else if ((document as any).webkitExitFullscreen) { + (document as any).webkitExitFullscreen(); + } + else if ((document as any).mozCancelFullScreen) { + (document as any).mozCancelFullScreen(); + } + else if ((document as any).msExitFullscreen) { + (document as any).msExitFullscreen(); + } + } + }; + + const gitPullHandler = async () => { + const res: any = await gitPull(componentCoding.id); + if (res.code === 200) { + Message.success('代码拉取成功'); + } + else { + Message.error('代码拉取失败'); + } + }; + + const gitCommitHandler = async () => { + const res: any = await gitCommit(componentCoding.id, { commit: commitMessage }); + if (res.code === 200) { + Message.success('代码提交成功'); + setCommitModal(false); + setCommitMessage(''); + } + else { + Message.error('代码提交失败'); + } + }; + + const openModal = (value) => { + const selectedItem = originList.find(item => item.localProjectPath === value); + dispatch(updateComponentCodingPath(selectedItem)); + }; + useEffect(() => { getOptionsList(); }, []); @@ -78,42 +145,6 @@ const ComponentCoding = () => { }; }, []); - // 切换全屏状态 - const toggleFullscreen = () => { - const iframeContainer = document.querySelector(`.${styles['code-iframe']}`) as HTMLElement; - - if (!isFullscreen) { - // 进入全屏 - if (iframeContainer.requestFullscreen) { - iframeContainer.requestFullscreen(); - } - else if ((iframeContainer as any).webkitRequestFullscreen) { - (iframeContainer as any).webkitRequestFullscreen(); - } - else if ((iframeContainer as any).mozRequestFullScreen) { - (iframeContainer as any).mozRequestFullScreen(); - } - else if ((iframeContainer as any).msRequestFullscreen) { - (iframeContainer as any).msRequestFullscreen(); - } - } - else { - // 退出全屏 - if (document.exitFullscreen) { - document.exitFullscreen(); - } - else if ((document as any).webkitExitFullscreen) { - (document as any).webkitExitFullscreen(); - } - else if ((document as any).mozCancelFullScreen) { - (document as any).mozCancelFullScreen(); - } - else if ((document as any).msExitFullscreen) { - (document as any).msExitFullscreen(); - } - } - }; - return (