token,用户名密码导入项目
This commit is contained in:
commit
fb14560809
|
|
@ -56,4 +56,4 @@ export const deepRoutes = [
|
|||
]
|
||||
|
||||
// 不进行组织或个人判断
|
||||
export const specialRoute = ["explore", "settings", "setting", "mulan", "wiki", "issues", "setting", "trending", "code", "projects", "pulls", "mine", "login", "register", "email", "export", "nopage", "404", "403", "500", "501", "search", "organize", "login", "register", "resetPassword", "aboutus","educoder", "glcc","bindlogin", "softbot","zone", "undefined", "admins", "oauth", "competitions"]
|
||||
export const specialRoute = ["explore", "settings", "setting", "mulan", "wiki", "issues", "setting", "trending", "code", "projects", "pulls", "mine", "login", "register", "email", "export", "nopage", "404", "403", "500", "501", "search", "organize", "login", "register", "resetPassword", "aboutus","educoder", "glcc","bindlogin", "softbot","zone", "undefined", "admins", "oauth", "competitions", "hiagent"]
|
||||
11
src/App.js
11
src/App.js
|
|
@ -159,6 +159,11 @@ const Topic = Loadable({
|
|||
loading: Loading,
|
||||
})
|
||||
|
||||
const Iframe = Loadable({
|
||||
loader: () => import("./forge/iframe"),
|
||||
loading: Loading,
|
||||
});
|
||||
|
||||
// 此处仅维护前端可能的一级路由,不用进行项目或者组织判断的字段。
|
||||
const keyWord = ["explore", "settings", "setting", "mulan", "wiki", "issues", "setting", "trending", "code", "projects", "pulls", "mine", "login", "register", "email", "export", "nopage", "404", "403", "500", "501", "search", "organize", "login", "register", "resetPassword", "aboutus","educoder", "glcc","bindlogin", "softbot","zone"];
|
||||
|
||||
|
|
@ -338,6 +343,12 @@ class App extends Component {
|
|||
{!pathName || (pathName && pathName.toLowerCase() !== 'glcc') ? <SiderBar {...this.props}/> : <SiderBarHelp/>}
|
||||
{/* <Router> */}
|
||||
<Switch>
|
||||
{/* iframe页面 */}
|
||||
<Route path="/hiagent"
|
||||
render={
|
||||
(props) => (<Iframe {...this.props} {...props} {...this.state} />)
|
||||
}
|
||||
></Route>
|
||||
{/* wiki预览 */}
|
||||
<Route path="/:owner/:projectsId/wiki/preview/:projectName/:projectId" render={
|
||||
(props) => {
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ class Detail extends Component {
|
|||
this.setState({
|
||||
firstSync: false,
|
||||
secondSync: false,
|
||||
mirror_status:data.mirror_status ? data.mirror_status : 0
|
||||
mirror_status:data.mirror_status || 0
|
||||
})
|
||||
this.getBanner(this.props.projectMenu)
|
||||
let projectdata
|
||||
|
|
|
|||
|
|
@ -1,14 +1,8 @@
|
|||
import React, { Component } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Input , Form , Select , Checkbox , Button , Spin , AutoComplete, Modal , Radio, Tooltip } from 'antd';
|
||||
import { Base64 } from 'js-base64';
|
||||
import { AlignCenter } from '../Component/layout';
|
||||
import { withTranslation } from 'react-i18next';
|
||||
import coding from './img/coding.png';
|
||||
import gitea from './img/gitea.png';
|
||||
import gitee from './img/gitee.png';
|
||||
import github from './img/github.png';
|
||||
import gitlab from './img/gitlab.png';
|
||||
|
||||
import '../css/index.scss';
|
||||
import './new.scss'
|
||||
|
|
@ -16,7 +10,7 @@ import axios from 'axios';
|
|||
|
||||
const addr={
|
||||
"gitea": "https://docs.gitea.com/development/api-usage",
|
||||
"gitee": "https://blog.csdn.net/weixin_42098295/article/details/134982972",
|
||||
"gitee": "https://forum.gitlink.org.cn/forums/10603/detail",
|
||||
"github": "https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token",
|
||||
"gitlab": "https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html",
|
||||
"gitcode": "https://docs.gitcode.com/docs/users/pat/"
|
||||
|
|
@ -70,8 +64,9 @@ class Index extends Component {
|
|||
tokenConTri: false,
|
||||
|
||||
gitHubUrl:false,
|
||||
checkToken:undefined,
|
||||
isPublic:true,
|
||||
checkToken:"",
|
||||
isToken:true,
|
||||
isPrivate:false,
|
||||
platName:undefined
|
||||
}
|
||||
}
|
||||
|
|
@ -113,8 +108,7 @@ class Index extends Component {
|
|||
owner = owner.filter(item=>item.id === user_id);
|
||||
}
|
||||
this.props.form.setFieldsValue({
|
||||
user_id:owner && owner[0].id,
|
||||
visibility:"public"
|
||||
user_id:owner && owner[0].id
|
||||
})
|
||||
owner && this.setState({
|
||||
owners_id:owner[0].id,
|
||||
|
|
@ -223,16 +217,15 @@ class Index extends Component {
|
|||
isSpin: true
|
||||
})
|
||||
const { projectsType } = this.props.match.params;
|
||||
const { project_language_id, project_category_id, license_id
|
||||
, ignore_id, owners_id, ignoreFlag, licenseFlag,
|
||||
categoreFlag, languageFlag, tokenConTri,gitHubUrl} = this.state;
|
||||
const { project_language_id, project_category_id, license_id, ignore_id, ignoreFlag,
|
||||
licenseFlag , categoreFlag, languageFlag, tokenConTri, isPrivate,isToken} = this.state;
|
||||
const decoderPass = Base64.encode(values.password);
|
||||
const url = (projectsType && projectsType === "mirror") ? "/projects/migrate.json" : "/projects.json";
|
||||
// 新建项目的时候,暂存数据,如果失败,返回的时候可以重新赋值
|
||||
sessionStorage.newProjectValue=JSON.stringify({...values,project_language_id,project_category_id,license_id,ignore_id});
|
||||
// 贡献值激励确权机制
|
||||
const {blockchain_init} = values;
|
||||
const { visibility , service , clone_addr } = values
|
||||
const { clone_addr } = values;
|
||||
axios.post(url, {
|
||||
...values,
|
||||
clone_addr:(projectsType && projectsType === "mirror") ? clone_addr.trim() :undefined,
|
||||
|
|
@ -242,12 +235,11 @@ class Index extends Component {
|
|||
license_id:licenseFlag ? license_id : undefined,
|
||||
ignore_id:ignoreFlag ? ignore_id : undefined,
|
||||
// user_id:owners_id,
|
||||
blockchain: tokenConTri,
|
||||
blockchain_token_all: 10000,
|
||||
blockchain_init_token: parseInt(blockchain_init),
|
||||
auth_token: visibility ==="private" ? values.auth_token : undefined,
|
||||
service: visibility ==="private" ? service : undefined,
|
||||
visibility:undefined
|
||||
blockchain: tokenConTri ,
|
||||
blockchain_token_all:tokenConTri ? 10000 : undefined,
|
||||
blockchain_init_token: tokenConTri ? parseInt(blockchain_init):undefined,
|
||||
auth_token: isPrivate && isToken ? values.auth_token : undefined,
|
||||
importType:undefined
|
||||
}).then((result) => {
|
||||
if (result && result.data.id) {
|
||||
projectsType && projectsType !== "mirror" && this.props.showNotification(`项目创建成功!`);
|
||||
|
|
@ -308,9 +300,9 @@ class Index extends Component {
|
|||
}
|
||||
|
||||
|
||||
ChangeAddr=(value)=>{
|
||||
ChangeAddr=(value,unUpdateName)=>{
|
||||
// 将路径最后一个/后的字符作为项目标识
|
||||
if(value.indexOf("/") > -1){
|
||||
if(value.indexOf("/") > -1 && !unUpdateName){
|
||||
let arr = value.split("/");
|
||||
let first = arr[arr.length-1];
|
||||
if(first.indexOf(".") > -1){
|
||||
|
|
@ -376,8 +368,7 @@ class Index extends Component {
|
|||
}
|
||||
|
||||
|
||||
blurFunc=(e)=>{
|
||||
let value = e.target.value;
|
||||
blurFunc=(rule, value, callback)=>{
|
||||
if(value){
|
||||
const { clone_addr } = this.props.form.getFieldsValue();
|
||||
if(clone_addr){
|
||||
|
|
@ -386,15 +377,17 @@ class Index extends Component {
|
|||
auth_token:value,
|
||||
clone_addr
|
||||
}).then(response=>{
|
||||
if(response && response.data){
|
||||
this.setState({
|
||||
checkToken:response.data.data
|
||||
})
|
||||
let res = response.data;
|
||||
if(res && res.data === false){
|
||||
callback("请输入正确的令牌");
|
||||
}else{
|
||||
callback();
|
||||
}
|
||||
callback();
|
||||
}).catch(error=>{})
|
||||
}
|
||||
}else{
|
||||
this.setState({checkToken:undefined})
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -416,16 +409,27 @@ class Index extends Component {
|
|||
|
||||
changeVisibility=(e)=>{
|
||||
let value = e.target.value;
|
||||
let flag = value === "public";
|
||||
this.setState({isPublic:flag})
|
||||
let flag = value === "token";
|
||||
this.setState({isToken:flag})
|
||||
let { clone_addr } = this.props.form.getFieldsValue();
|
||||
if(!flag && clone_addr){
|
||||
setTimeout(() => {
|
||||
this.ChangeAddr(clone_addr);
|
||||
this.ChangeAddr(clone_addr,true);
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
|
||||
changeIsPrivate=(e)=>{
|
||||
this.setState({
|
||||
isPrivate:e.target.checked
|
||||
})
|
||||
if(e.target.checked){
|
||||
this.props.form.setFieldsValue({
|
||||
importType:"token"
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { getFieldDecorator } = this.props.form;
|
||||
// 项目类型:deposit-托管项目,mirror-镜像项目
|
||||
|
|
@ -455,8 +459,9 @@ class Index extends Component {
|
|||
categoreFlag,
|
||||
tokenConTri,
|
||||
checkToken,
|
||||
isPublic,
|
||||
platName
|
||||
isToken,
|
||||
platName,
|
||||
isPrivate
|
||||
} = this.state;
|
||||
return (
|
||||
<div className="main back-white" style={{padding:"0px",border:"none"}}>
|
||||
|
|
@ -486,59 +491,75 @@ class Index extends Component {
|
|||
}
|
||||
{
|
||||
projectsType && projectsType === "mirror" &&
|
||||
<div className="mt20">
|
||||
<div className="mb10">
|
||||
<Form.Item
|
||||
label="导入仓库可见性"
|
||||
label=""
|
||||
style={{marginBottom:"0px"}}
|
||||
>
|
||||
{getFieldDecorator('visibility', {
|
||||
rules: [{required: true, message: ''}],
|
||||
{getFieldDecorator('isPrivate', {
|
||||
rules: [],
|
||||
})(
|
||||
<Checkbox value="importPrivate" onChange={this.changeIsPrivate}>导入私有项目</Checkbox>
|
||||
)}
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label=""
|
||||
style={{marginBottom:"10px",display:isPrivate?"block":"none"}}
|
||||
>
|
||||
{getFieldDecorator('importType', {
|
||||
rules: [],
|
||||
})(
|
||||
<Radio.Group onChange={this.changeVisibility}>
|
||||
<Radio value="public">公开</Radio>
|
||||
<Radio value="private">私有</Radio>
|
||||
<Radio value="token">访问令牌方式导入</Radio>
|
||||
<Radio value="pwd">用户名+密码方式导入</Radio>
|
||||
</Radio.Group>
|
||||
)}
|
||||
</Form.Item>
|
||||
{/* token导入 */}
|
||||
{
|
||||
!isPublic &&
|
||||
isToken && isPrivate &&
|
||||
<Form.Item
|
||||
label={<span>访问令牌(Access Token){addr[`${platName && platName.toLowerCase()}`] && <a className='color-blue' href={addr[`${platName.toLowerCase()}`]} target='_blank'>如何配置?</a>}</span>}
|
||||
>
|
||||
{getFieldDecorator('auth_token',{
|
||||
rules: [
|
||||
{required: true, message: '请输入需要导入仓库的访问令牌'},
|
||||
{validator:(rule, value, callback)=>this.blurFunc(rule, value, callback)}
|
||||
],
|
||||
validateTrigger:"onBlur",
|
||||
})(
|
||||
<Input placeholder="请输入需要导入仓库的访问令牌"/>
|
||||
)}
|
||||
</Form.Item>
|
||||
}
|
||||
{
|
||||
isPrivate && !isToken &&
|
||||
<div className="df mb20" style={{alignItems:'center'}}>
|
||||
{/* 用户名密码导入 */}
|
||||
<span className="mr10">用户名</span>
|
||||
<input type="password" style={{display:"none"}} />
|
||||
<Form.Item
|
||||
label="仓库所属平台"
|
||||
style={{width:"260px"}}
|
||||
style={{ marginBottom: "0px"}}
|
||||
label=""
|
||||
>
|
||||
{getFieldDecorator('service', {
|
||||
rules: [{
|
||||
required: true, message: '请选择源仓库所属平台'
|
||||
}],
|
||||
{getFieldDecorator('auth_username', {
|
||||
rules: [],
|
||||
})(
|
||||
<Select
|
||||
showSearch
|
||||
style={{width:"260px",height:"33px"}}
|
||||
placeholder="请选择源仓库所属平台"
|
||||
onSelect={(value)=>{this.setState({platName:value})}}
|
||||
>
|
||||
<Option value={"github"}><img src={github} width={"24px"} className='mr8'/>Github</Option>
|
||||
<Option value={"gitee"}><img src={gitee} width={"24px"} className='mr8'/>Gitee</Option>
|
||||
<Option value={"gitlab"}><img src={gitlab} width={"24px"} className='mr8'/>Gitlab</Option>
|
||||
<Option value={"gitea"}><img src={gitea} width={"24px"} className='mr8'/>Gitea</Option>
|
||||
<Option value={"gitcode"}><img src={coding} width={"24px"} className='mr8'/>Gitcode</Option>
|
||||
</Select>
|
||||
<Input placeholder="请输入对应平台的登录用户名" style={{width:"240px"}} />
|
||||
)}
|
||||
</Form.Item>
|
||||
}
|
||||
{
|
||||
platName && !isPublic &&
|
||||
<span className="mr10">密码</span>
|
||||
<Form.Item
|
||||
validateStatus={checkToken===false ? "error" :"success"}
|
||||
hasFeedback ={checkToken!==undefined}
|
||||
label={<span>访问令牌(ACCESS Token)<a href={addr[`${platName.toLowerCase()}`]} target='_blank'><i className='iconfont icon-bangzhuzhongxinicon2 color-blue'/></a></span>}
|
||||
style={{ marginBottom: "0px" }}
|
||||
>
|
||||
{getFieldDecorator('auth_token',{
|
||||
rules: [{required: true, message: '请输入需要导入仓库的访问令牌'}],
|
||||
{getFieldDecorator('password', {
|
||||
rules: [],
|
||||
})(
|
||||
<Input onBlur={this.blurFunc} placeholder="请输入需要导入仓库的访问令牌"/>
|
||||
<Input.Password placeholder="请输入对应平台的登录密码" autocomplete='new-password' style={{width:"240px"}}/>
|
||||
)}
|
||||
</Form.Item>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
<AlignCenter>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
import React, { useEffect, useState, useCallback } from 'react';
|
||||
import { withRouter } from "react-router";
|
||||
import { SnackbarHOC } from "educoder";
|
||||
import { CNotificationHOC } from "../modules/courses/common/CNotificationHOC";
|
||||
import { TPMIndexHOC } from "../modules/tpm/TPMIndexHOC";
|
||||
|
||||
|
||||
const Iframe = (props) => {
|
||||
|
||||
const history = props.history
|
||||
const location = history.location
|
||||
|
||||
// if (!location.state.url) {
|
||||
// history.push("/404");
|
||||
// }
|
||||
|
||||
function iframeLoad() {
|
||||
let myIframe = document.getElementById("iframe");
|
||||
myIframe.height = `${document.documentElement.clientHeight - 473 + 86}px`
|
||||
// if (myIframe.contentWindow.location && myIfram e.contentWindow.location.href) {
|
||||
// window.location.href = 'http://118.145.132.196:3000/product/llm/llm-chat'
|
||||
// //myIframe.contentWindow.location.href
|
||||
// }
|
||||
}
|
||||
|
||||
return <iframe
|
||||
id="iframe"
|
||||
width="100%"
|
||||
height="800px"
|
||||
className="test-iframe"
|
||||
src={ 'http://118.145.132.196:3000/product/llm/llm-chat' }
|
||||
onLoad={iframeLoad}
|
||||
></iframe>
|
||||
}
|
||||
|
||||
export default withRouter(CNotificationHOC()(SnackbarHOC()(TPMIndexHOC(Iframe))));
|
||||
|
|
@ -246,6 +246,11 @@ i.color-orange05:hover {
|
|||
border-radius: 6px;
|
||||
background-color: #ffebe9;
|
||||
padding: 10px 8px;
|
||||
font-size: 12px;
|
||||
font-size: 12px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.test-iframe {
|
||||
margin-top: -48px;
|
||||
vertical-align:bottom;
|
||||
}
|
||||
Loading…
Reference in New Issue