代码仓库同步添加红山开源类型

This commit is contained in:
谢思 2026-05-28 10:22:18 +08:00
parent 86ede5d83a
commit a7e8bfc2ac
8 changed files with 60 additions and 14 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -4,6 +4,7 @@ import axios from 'axios';
import { branchForm, confirmInfo1, confirmInfo2, synchronizeTips } from './editStore';
import gitHub from '../../img/github.png';
import gitee from '../../img/gitee.png';
import osredm from '../../img/osredm.png';
import '../index.scss';
function DeleteBox({owner, projectsId, visible, setVisible, branchList, reload, form, sync_repositories_unique=[], repositoriesBranch}) {
@ -76,6 +77,7 @@ function DeleteBox({owner, projectsId, visible, setVisible, branchList, reload,
}}>
<Select.Option value="Github" disabled={!repositoriesBranch["Github"]}><img src={gitHub} alt="" className="storeLogo mr5"/>Github{!repositoriesBranch["Github"] && "获取分支列表失败请检查token是否有效"}</Select.Option>
<Select.Option value="Gitee" disabled={!repositoriesBranch["Gitee"]}><img src={gitee} alt="" className="storeLogo mr5"/>Gitee{!repositoriesBranch["Gitee"] && "获取分支列表失败请检查token是否有效"}</Select.Option>
<Select.Option value="Osredm" disabled={!repositoriesBranch["Osredm"]}><img src={osredm} alt="" className="storeLogo mr5"/>Osredm{!repositoriesBranch["Osredm"] && "获取分支列表失败请检查token是否有效"}</Select.Option>
</Select>
)}
</Form.Item>}

View File

@ -1,7 +1,5 @@
import React, {Fragment, forwardRef, useEffect, useState} from "react";
import { Button, Divider, Form, Icon, Input, Radio, Select, Steps, Tooltip, message, Modal , AutoComplete } from "antd";
import github from '../../img/github.png';
import gitee from '../../img/gitee.png';
import arrow from '../../img/arrow.png';
import '../index.scss';
import axios from "axios";
@ -148,10 +146,10 @@ function EditStore(props){
//
const synchronizedPlatformList = sync_repositories_unique.map(item=>{return item.type.split("::").pop()})
const platformList = (synchronizedPlatformList.length && ["Github", "Gitee"].filter(item=>synchronizedPlatformList.indexOf(item) === -1)) || ["Github", "Gitee"]
const platformList = (synchronizedPlatformList.length && ["Github", "Gitee", "Osredm"].filter(item=>synchronizedPlatformList.indexOf(item) === -1)) || ["Github", "Gitee", "Osredm"]
// giteegithub
const pattern = platform && (platform === "Github" ? /^https:\/\/github\.com\/.+\/.+$/ : /^https:\/\/gitee\.com\/.+\/.+$/)
const pattern = platform && (platform === "Github" ? /^https:\/\/(www\.)?github\.com\/.+\/.+$/ : platform === "Gitee" ? /^https:\/\/(www\.)?gitee\.com\/.+\/.+$/ : /^https:\/\/(www\.)?osredm\.com\/.+\/.+$/)
useEffect(()=>{
//
@ -248,6 +246,7 @@ function EditStore(props){
1登录{platform}确保拥有读写同步仓库的权限<br/>
{platform === "Github" && "2、找到已存在的token或新建一个token新建方式为点击个人头像→Settings→Developer Settings→Personal access tokens (classic)→Generate new token"}
{platform === "Gitee" && "2、找到已存在的token或新建一个token新建方式为点击个人头像→设置→私人令牌→生成新令牌"}
{platform === "Osredm" && "2、找到已存在的token或新建一个token新建方式为点击个人头像→账号管理→私人令牌→生成新令牌"}
<br/>
3确保token拥有仓库读写权限且未过期将token复制到此处token填写框
</div>}>
@ -300,7 +299,7 @@ function EditStore(props){
<Button type="primary" ghost className="mt10 mb10 ml10" onClick={()=>{
const {type, external_repo_address} = values;
if(external_repo_address){
window.open(`${external_repo_address.replace(/.git$/, "")}${type === "Github" ? "/settings/hooks" : "/hooks"}`)
window.open(`${external_repo_address.replace(/.git$/, "")}${type === "Github" ? "/settings/hooks" : type === "Gitee" ? "/hooks" : `/settings/webhooks`}`)
}else{
message.error("您暂未配置同步仓库地址")
}

View File

@ -2,9 +2,8 @@ import React, { Fragment, useState } from "react";
import '../index.scss';
import { Breadcrumb, Button, Input, Table, Tag, message } from "antd";
import { Link } from "react-router-dom";
import gitHub1 from '../../img/github1.png';
import gitee1 from '../../img/gitee1.png';
import axios from "axios";
import { platformLogo } from "..";
function RecordList(props){
const { owner , projectsId, platform } = props.match.params;
@ -13,7 +12,6 @@ function RecordList(props){
const [token, setToken] = useState({});
function inviteClick(idName) {
console.log('idName', idName);
const copyEle = document.querySelector(idName); //
if (!copyEle) {
console.error("您的CopyTool未设置正确的inputId");
@ -40,7 +38,7 @@ function RecordList(props){
const {type, external_repo_address, sync_repository_ids} = item
return <Fragment>
<div className="font-15 mt20 mb7">同步仓库平台</div>
<div className="infoBox">{<img src={type === "SyncRepositories::Github" ? gitHub1 : gitee1} alt="" style={{width: '75px'}}/>}</div>
<div className="infoBox">{type && platformLogo(type.split("::")[1])}</div>
<div className="font-15 mt20 mb7">同步仓库地址</div>
<div className="infoBox"><a href={external_repo_address} target="_blank">{external_repo_address}</a></div>
<div className="font-15 mt20 mb7">Webhook接受请求地址</div>

View File

@ -45,7 +45,7 @@ function StoreList(props){
const externalRepoInfo = {
address: repoInfoByType && repoInfoByType.external_repo_address,
branchName: external_branch_name,
type
type: type && type.split("::")[1]
}
const gitlinkRepoInfo = {
address: `${window.location.origin}/${owner}/${projectsId}.git`,
@ -53,7 +53,6 @@ function StoreList(props){
type: "gitlink"
}
useEffect(()=>{
axios.get(`/${owner}/${projectsId}/pulls/get_branches.json`, {}).then(res=>{
res && setBranchList(res.data);
@ -120,7 +119,7 @@ function StoreList(props){
let columns = [
{ title: '序号', dataIndex: 'index', className:"recordColumns", render: (text, item, index) => <span>{(current-1)*pageSize+index + 1}</span> },
{ title: '第三方平台分支', dataIndex: "external_branch_name", className:"recordColumns taskName", width: '300px', render: (text, item) => <span>
{platformLogoUnText(item.type, "21px")}{text}
{platformLogoUnText(item.type.split("::")[1], "21px")}{text}
</span> },
{ title: 'GitLink分支', dataIndex: 'gitlink_branch_name', width: '300px', className:"recordColumns", render: (text, item) => <span>
<img src={gitlinkLogo} alt="" style={{width: "20px"}} className="storeLogo mr5"/>{text}

View File

@ -6,6 +6,9 @@ import gitHub1 from '../img/github1.png';
import gitee1 from '../img/gitee1.png';
import gitHub from '../img/github.png';
import gitee from '../img/gitee.png';
import osredm from '../img/osredm.png';
import osredm1 from '../img/osredm1.png';
import gitlink from '../img/gitlink.jpg';
import gitlink1 from '../img/gitlink1.png';
import Loadable from "react-loadable";
import { Route, Switch } from "react-router";
@ -35,11 +38,56 @@ const Setting = Loadable({
});
export const platformLogo = (platform="Github", width="80px") => {
return <img src={platform.indexOf("Github") !== -1 ? gitHub1 : platform === "gitlink" ? gitlink1 : gitee1} alt="" style={{width: platform === "gitlink" ? '120px' : width}}/>
const normalizedPlatform = platform.toLowerCase() || "";
// logo
const logoMap = {
github: gitHub1,
gitee: gitee1,
gitlink: gitlink1,
osredm: osredm1
};
// logonull
const logo = logoMap[normalizedPlatform];
// logo
if (!logo) return null;
// gitlink
const imageWidth = normalizedPlatform === "gitlink" ? '110px' : width;
return <img src={logo} alt={platform} style={{ width: imageWidth }} />;
}
export const platformLogoUnText = (platform="Github", width="18px") => {
return <img src={platform.indexOf("Github") !== -1 ? gitHub : gitee} alt="" style={{width: width}} className="storeLogo mr5"/>
const normalizedPlatform = platform.toLowerCase() || "";
// logo
const logoMap = {
github: gitHub,
gitee: gitee,
gitlink: gitlink,
osredm: osredm
};
// logonull
const logo = logoMap[normalizedPlatform];
// logo
if (!logo) return null;
//
const imageWidth = normalizedPlatform === "osredm" ? '21px' : width;
return (
<img
src={logo}
alt={platform}
style={{ width: imageWidth }}
className="storeLogo mr5"
/>
);
}
function Reposyncer(propsF){