Merge branch 'pre_gitlink_ssr' of https://gitlink.org.cn/Gitlink/forgeplus-react into gitlink_ssr_head

This commit is contained in:
谢思 2026-05-28 10:25:28 +08:00
commit 65a652d0c1
14 changed files with 98 additions and 26 deletions

View File

@ -93,7 +93,7 @@ function PublicBanner(props) {
function apply() { function apply() {
if (checkIfLogin() === false) { if (checkIfLogin() === false) {
showLoginDialog() showLoginDialog(`/zone/${deptId}`)
return false; return false;
} else if (memberStatus === memberStatusEnum.applying) { } else if (memberStatus === memberStatusEnum.applying) {
message.info("您已提交申请,请耐心等待管理员审核!") message.info("您已提交申请,请耐心等待管理员审核!")
@ -108,7 +108,7 @@ function PublicBanner(props) {
function toLessonsFunc(){ function toLessonsFunc(){
if (checkIfLogin() === false) { if (checkIfLogin() === false) {
showLoginDialog() showLoginDialog(`/zone/${deptId}/lessons`)
return false; return false;
} else{ } else{
window.location.href = `/zone/${deptId}/lessons`; window.location.href = `/zone/${deptId}/lessons`;

View File

@ -29,10 +29,11 @@ export function getCheckZoneRole(id) {
}); });
} }
export function getCurrentRole(id) { export function getCurrentRole(id, deptId) {
return fetch({ return fetch({
url: `/zone/zoneFront/${id}/checkCurrentRole`, url: `/zone/zoneFront/${id}/checkCurrentRole`,
method: 'get', method: 'get',
headers: {'Dept-Id': deptId}
}); });
} }

View File

@ -46,7 +46,7 @@ function Main(props){
<div> <div>
<AgreementModal visible={visible} onCancel={()=>setVisible(false)} onOk={onOk}/> <AgreementModal visible={visible} onCancel={()=>setVisible(false)} onOk={onOk}/>
<ul className="serverlist"> <ul className="serverlist">
<li> {/* <li>
<span className="servername"> <span className="servername">
<img src={require('./img/logo.png')} alt=""/> <img src={require('./img/logo.png')} alt=""/>
<a onClick={openDetail}>重睛鸟代码溯源</a> <a onClick={openDetail}>重睛鸟代码溯源</a>
@ -55,7 +55,7 @@ function Main(props){
<span className="serverbtn"> <span className="serverbtn">
<a onClick={openDetail} className="btnhover">查看详情</a> <a onClick={openDetail} className="btnhover">查看详情</a>
</span> </span>
</li> </li> */}
{ {
// //
projectDetail && parseInt(projectDetail.type) !== 2 && <li> projectDetail && parseInt(projectDetail.type) !== 2 && <li>

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 { branchForm, confirmInfo1, confirmInfo2, synchronizeTips } from './editStore';
import gitHub from '../../img/github.png'; import gitHub from '../../img/github.png';
import gitee from '../../img/gitee.png'; import gitee from '../../img/gitee.png';
import osredm from '../../img/osredm.png';
import '../index.scss'; import '../index.scss';
function DeleteBox({owner, projectsId, visible, setVisible, branchList, reload, form, sync_repositories_unique=[], repositoriesBranch}) { 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="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="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> </Select>
)} )}
</Form.Item>} </Form.Item>}

View File

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

View File

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

View File

@ -45,7 +45,7 @@ function StoreList(props){
const externalRepoInfo = { const externalRepoInfo = {
address: repoInfoByType && repoInfoByType.external_repo_address, address: repoInfoByType && repoInfoByType.external_repo_address,
branchName: external_branch_name, branchName: external_branch_name,
type type: type && type.split("::")[1]
} }
const gitlinkRepoInfo = { const gitlinkRepoInfo = {
address: `${window.location.origin}/${owner}/${projectsId}.git`, address: `${window.location.origin}/${owner}/${projectsId}.git`,
@ -53,7 +53,6 @@ function StoreList(props){
type: "gitlink" type: "gitlink"
} }
useEffect(()=>{ useEffect(()=>{
axios.get(`/${owner}/${projectsId}/pulls/get_branches.json`, {}).then(res=>{ axios.get(`/${owner}/${projectsId}/pulls/get_branches.json`, {}).then(res=>{
res && setBranchList(res.data); res && setBranchList(res.data);
@ -120,7 +119,7 @@ function StoreList(props){
let columns = [ let columns = [
{ title: '序号', dataIndex: 'index', className:"recordColumns", render: (text, item, index) => <span>{(current-1)*pageSize+index + 1}</span> }, { 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> { 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> }, </span> },
{ title: 'GitLink分支', dataIndex: 'gitlink_branch_name', width: '300px', className:"recordColumns", render: (text, item) => <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} <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 gitee1 from '../img/gitee1.png';
import gitHub from '../img/github.png'; import gitHub from '../img/github.png';
import gitee from '../img/gitee.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 gitlink1 from '../img/gitlink1.png';
import Loadable from "react-loadable"; import Loadable from "react-loadable";
import { Route, Switch } from "react-router"; import { Route, Switch } from "react-router";
@ -35,11 +38,56 @@ const Setting = Loadable({
}); });
export const platformLogo = (platform="Github", width="80px") => { 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") => { 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){ function Reposyncer(propsF){

View File

@ -431,6 +431,7 @@ class LoginDialog extends Component {
render() { render() {
let { login, isGoing, isGoingValue, disabled , Phonenumberisnotco , dialogBox, isRender, weixinlogin, settings } = this.state; let { login, isGoing, isGoingValue, disabled , Phonenumberisnotco , dialogBox, isRender, weixinlogin, settings } = this.state;
const {gopage} = this.props
if (isRender === undefined) { if (isRender === undefined) {
isRender = false isRender = false
@ -536,7 +537,7 @@ class LoginDialog extends Component {
<span className="fr"> <span className="fr">
<a href="/resetPassword" className="mr3 color-grey-9">找回密码</a> <a href="/resetPassword" className="mr3 color-grey-9">找回密码</a>
<em className="vertical-line"></em> <em className="vertical-line"></em>
<a href="/register" className="color-grey-9">注册</a> <a href={`/register${gopage ? `?go_page=${gopage}` : ""}`} className="color-grey-9">注册</a>
</span> </span>
</p> </p>
<OtherLogin location={this.props.location} main_site_url={settings.common.main_site_url}/> <OtherLogin location={this.props.location} main_site_url={settings.common.main_site_url}/>

View File

@ -11,6 +11,7 @@ import OtherLogin from "./component/otherLogin";
import cookie from 'react-cookies'; import cookie from 'react-cookies';
import './LoginRegisterPage.scss'; import './LoginRegisterPage.scss';
import { Encrypt } from "../../common/Env"; import { Encrypt } from "../../common/Env";
import { getCurrentRole } from "../../forge/Information/api";
function Login(props){ function Login(props){
const [message,setMessage] = useState(); const [message,setMessage] = useState();
@ -55,8 +56,17 @@ function Login(props){
const searchParams = new URLSearchParams(search.substring(1)); const searchParams = new URLSearchParams(search.substring(1));
const goPage = searchParams.get("go_page"); const goPage = searchParams.get("go_page");
// if(goPage && goPage.includes("gitlink.educoder.net")){
window.location.href = goPage ? goPage : `/${response.data.login}` const {login, real_name, nickname, email, custom_department, phone} = response.data;
const params =`websiteName=gitlink&openkey=`+Base64.encode("05e9081ede2e7425db064df44b5fb1897234f44f922443b89597d17b60dc8f3e")+`&sign=cdf0f69b4d5b4293f7914cc1f1f31742&login=`+login+`&lastname=`+real_name+`&nickname=`+nickname+`&mail=`+email+`&school_name=`+custom_department+`&phone=`+phone+``;
getCurrentRole(34, 375).finally(()=>{
const decodedGoPage = decodeURIComponent(goPage);
const separator = decodedGoPage.includes('?') ? '&' : '?';
window.location.href = decodedGoPage + separator + params;
})
}else{
window.location.href = goPage ? decodeURIComponent(goPage) : `/${response.data.login}`
}
} }
}).catch((error) => { }).catch((error) => {
console.log('error',error); console.log('error',error);
@ -81,7 +91,7 @@ function Login(props){
<div className="right_cont login_content"> <div className="right_cont login_content">
<div className="login_register_head mb30"> <div className="login_register_head mb30">
<span>欢迎登录 GitLink</span> <span>欢迎登录 GitLink</span>
<span className="link_span">没有账号<Link to={`/register`}>去注册</Link></span> <span className="link_span">没有账号<Link to={`/register${search}`}>去注册</Link></span>
</div> </div>
<p className = {message?"message active mb10":"message"}>{message}</p> <p className = {message?"message active mb10":"message"}>{message}</p>
<Form className="login-form"> <Form className="login-form">

View File

@ -6,9 +6,11 @@ import { setmiyah } from 'educoder';
import './LoginRegisterPage.scss'; import './LoginRegisterPage.scss';
import OtherLogin from "./component/otherLogin"; import OtherLogin from "./component/otherLogin";
import { Encrypt } from "../../common/Env"; import { Encrypt } from "../../common/Env";
import { getCurrentRole } from "../../forge/Information/api";
function Register(props){ function Register(props){
const {form, mygetHelmetapi,location} = props; const {form, mygetHelmetapi,location} = props;
const {search} = location;
const {getFieldDecorator, setFieldsValue } = form; const {getFieldDecorator, setFieldsValue } = form;
// //
const [emailStr, setEmailStr] = useState(undefined); const [emailStr, setEmailStr] = useState(undefined);
@ -45,9 +47,10 @@ function Register(props){
function handleSubmit(){ function handleSubmit(){
form.validateFields((err, values) => { form.validateFields((err, values) => {
if (!err) { if (!err) {
const user_login = values.register_username.trim()
values.agreement && axios.post(`/accounts/register.json`, { values.agreement && axios.post(`/accounts/register.json`, {
login: values.email, login: values.email,
namespace: values.register_username.trim(), namespace: user_login,
password: Encrypt(values.register_psd), password: Encrypt(values.register_psd),
password_confirmation: Encrypt(values.psdComfirm), password_confirmation: Encrypt(values.psdComfirm),
code: values.captcha code: values.captcha
@ -59,7 +62,18 @@ function Register(props){
setEmailStr(values.email); setEmailStr(values.email);
}else if(response.data && response.data.status === 0){ }else if(response.data && response.data.status === 0){
//forge //forge
window.location.href = "/"+values.register_username.trim(); const searchParams = new URLSearchParams(search.substring(1));
const goPage = searchParams.get("go_page");
if(goPage && goPage.includes("gitlink.educoder.net")){
const params = `websiteName=gitlink&openkey=${Base64.encode("05e9081ede2e7425db064df44b5fb1897234f44f922443b89597d17b60dc8f3e")}&sign=cdf0f69b4d5b4293f7914cc1f1f31742&login=${user_login}${values.email.includes("@") ? `&mail=${values.email}` : `&phone=${values.email}&mail=${user_login}@example.org`}`
getCurrentRole(34, 375).finally(()=>{
const decodedGoPage = decodeURIComponent(goPage);
const separator = decodedGoPage.includes('?') ? '&' : '?';
window.location.href = decodedGoPage + separator + params;
})
}else{
window.location.href = goPage ? decodeURIComponent(goPage) : `/${user_login}`
}
} else { } else {
setEmailStr(values.email); setEmailStr(values.email);
setMess(response.data.message); setMess(response.data.message);
@ -229,7 +243,7 @@ function Register(props){
<div className="right_cont Register_content"> <div className="right_cont Register_content">
<div className="login_register_head mb30"> <div className="login_register_head mb30">
<span>欢迎注册 GitLink</span> <span>欢迎注册 GitLink</span>
<span className="link_span">已有账号<Link to={`/login`}>立即登录</Link></span> <span className="link_span">已有账号<Link to={`/login${search}`}>立即登录</Link></span>
</div> </div>
<div className="registerNav mb20 font-18"> <div className="registerNav mb20 font-18">
<a className={`type ${registerType ? '' : 'activeRegisterNav'}`} onClick={()=>{changeRegisterType(0)}}>手机号注册</a> <a className={`type ${registerType ? '' : 'activeRegisterNav'}`} onClick={()=>{changeRegisterType(0)}}>手机号注册</a>