This commit is contained in:
caicai8 2020-03-20 18:54:02 +08:00
parent 44366b8a26
commit 1457bc1adc
7 changed files with 55 additions and 53 deletions

View File

@ -5,12 +5,12 @@ const { Search } = Input;
const $ = window.$; const $ = window.$;
const isDev = window.location.port == 3007; const isDev = window.location.port == 3007;
export const TEST_HOST = "https://test-newweb.educoder.net" export const TEST_HOST = "https://testforgeplus.trustie.net"
export function getImageUrl(path) { export function getImageUrl(path) {
// https://www.educoder.net // https://www.educoder.net
// https://testbdweb.trustie.net // https://testbdweb.trustie.net
// const local = 'http://localhost:3000' // const local = 'http://localhost:3000'
const local = 'https://test-newweb.educoder.net' const local = 'https://testforgeplus.trustie.net'
if (isDev) { if (isDev) {
return `${local}/${path}` return `${local}/${path}`
} }
@ -18,7 +18,7 @@ export function getImageUrl(path) {
} }
export function setImagesUrl(path){ export function setImagesUrl(path){
const local = 'https://test-newweb.educoder.net' const local = 'https://testforgeplus.trustie.net'
let firstStr=path.substr(0,1); let firstStr=path.substr(0,1);
// console.log(firstStr); // console.log(firstStr);
if(firstStr=="/"){ if(firstStr=="/"){

View File

@ -40,42 +40,28 @@ class Index extends Component{
} }
} }
componentDidMount=()=>{ componentDidMount=()=>{
this.getUserInfo();
document.title="forge开源"; document.title="forge开源";
} }
getUserInfo=()=>{
const url = `/users/me.json`;
axios.get(url).then(result=>{
// result && result.data.login
if(result && result.data.login){
this.setState({
current_user:result.data
})
}
}).catch(error=>{
console.log(error)
})
}
render(){ render(){
const { current_user } = this.state;
return( return(
<div className="newMain clearfix"> <div className="newMain clearfix">
<Switch {...this.props}> <Switch {...this.props}>
<Route path="/projects/:projectsType/new" <Route path="/projects/:projectsType/new"
render={ render={
(props) => (<ProjectNew {...this.props} {...props} {...this.state} current_user={current_user}/>) (props) => (<ProjectNew {...this.props} {...props} {...this.state}/>)
} }
></Route> ></Route>
<Route path="/projects/:projectsId/:author" <Route path="/projects/:projectsId/:author"
render={ render={
(props) => (<ProjectDetail {...this.props} {...props} {...this.state} current_user={current_user}/>) (props) => (<ProjectDetail {...this.props} {...props} {...this.state}/>)
} }
></Route> ></Route>
<Route exact path="/projects" <Route exact path="/projects"
render={ render={
(props) => (<ProjectIndex {...this.props} {...props} {...this.state} current_user={current_user}/>) (props) => (<ProjectIndex {...this.props} {...props} {...this.state}/>)
} }
></Route> ></Route>
</Switch> </Switch>

View File

@ -63,10 +63,10 @@ class CoderRootDirectory extends Component{
// 获取根目录 // 获取根目录
getProjectRoot=(branch)=>{ getProjectRoot=(branch)=>{
const { current_user } = this.props; const { current_user } = this.props;
const { projectsId } = this.props.match.params; const { projectsId , author } = this.props.match.params;
const { state } = this.props.history.location; const { state } = this.props.history.location;
console.log(this.props); console.log(this.props);
const url = `/${state ? state : current_user && current_user.login}/${projectsId}/entries.json`; const url = `/${author}/${projectsId}/entries.json`;
axios.get((url),{ axios.get((url),{
params:{ params:{
branch branch

View File

@ -138,6 +138,7 @@ class Detail extends Component{
forked_count:undefined, forked_count:undefined,
http_url: undefined, http_url: undefined,
author:undefined, author:undefined,
current_user:undefined,
branchs:undefined, branchs:undefined,
branchList:undefined, branchList:undefined,
@ -161,7 +162,7 @@ class Detail extends Component{
componentDidMount=()=>{ componentDidMount=()=>{
// this.getUserInfo(); this.getUserInfo();
this.getDetail(); this.getDetail();
} }
@ -287,7 +288,7 @@ class Detail extends Component{
render(){ render(){
const { projectDetail , watchers_count , praises_count , forked_count , project_id } = this.state; const { projectDetail , watchers_count , praises_count , forked_count , project_id , current_user } = this.state;
const url = this.props.history.location.pathname; const url = this.props.history.location.pathname;
const urlFlag = (url.split("/").length === 3); const urlFlag = (url.split("/").length === 3);
const { isManager , isDeveloper } = this.props; const { isManager , isDeveloper } = this.props;
@ -348,55 +349,55 @@ class Detail extends Component{
{/* 新建文件 */} {/* 新建文件 */}
<Route path="/projects/:projectsId/:author/coder/:branch/newfile/:path" <Route path="/projects/:projectsId/:author/coder/:branch/newfile/:path"
render={ render={
(props) => (<FileNew {...this.props} {...props} {...this.state}/>) (props) => (<FileNew {...this.props} {...props} {...this.state} current_user={current_user}/>)
} }
></Route> ></Route>
<Route path="/projects/:projectsId/:author/coder/:branch/newfile" <Route path="/projects/:projectsId/:author/coder/:branch/newfile"
render={ render={
(props) => (<FileNew {...this.props} {...props} {...this.state}/>) (props) => (<FileNew {...this.props} {...props} {...this.state} current_user={current_user}/>)
} }
></Route> ></Route>
{/* 标签列表 */} {/* 标签列表 */}
<Route path="/projects/:projectsId/:author/orders/tags" <Route path="/projects/:projectsId/:author/orders/tags"
render={ render={
(props) => (<TagList {...this.props} {...props} {...this.state}/>) (props) => (<TagList {...this.props} {...props} {...this.state} current_user={current_user}/>)
} }
></Route> ></Route>
{/* 仓库设置 */} {/* 仓库设置 */}
<Route path="/projects/:projectsId/:author/setting" <Route path="/projects/:projectsId/:author/setting"
render={ render={
(props) => (<Setting {...this.props} {...props} {...this.state} getDetail={this.getDetail}/>) (props) => (<Setting {...this.props} {...props} {...this.state} getDetail={this.getDetail} current_user={current_user}/>)
} }
></Route> ></Route>
{/* 工单详情 */} {/* 工单详情 */}
<Route path="/projects/:projectsId/:author/orders/:orderId/detail" <Route path="/projects/:projectsId/:author/orders/:orderId/detail"
render={ render={
(props) => (<OrderDetail {...this.props} {...props} {...this.state}/>) (props) => (<OrderDetail {...this.props} {...props} {...this.state} current_user={current_user}/>)
} }
></Route> ></Route>
{/* 里程碑 */} {/* 里程碑 */}
<Route path="/projects/:projectsId/:author/orders/Milepost" <Route path="/projects/:projectsId/:author/orders/Milepost"
render={ render={
(props) => (<OrderMilepost {...this.props} {...props} {...this.state}/>) (props) => (<OrderMilepost {...this.props} {...props} {...this.state} current_user={current_user}/>)
} }
></Route> ></Route>
{/* 新建里程碑 */} {/* 新建里程碑 */}
<Route path="/projects/:projectsId/:author/orders/meilpost" <Route path="/projects/:projectsId/:author/orders/meilpost"
render={ render={
(props) => (<OrdernewMilepost {...this.props} {...props} {...this.state}/>) (props) => (<OrdernewMilepost {...this.props} {...props} {...this.state} current_user={current_user}/>)
} }
></Route> ></Route>
{/*里程碑详情*/ } {/*里程碑详情*/ }
<Route path="/projects/:projectsId/:author/orders/:meilid/MilepostDetail" <Route path="/projects/:projectsId/:author/orders/:meilid/MilepostDetail"
render={ render={
(props) => (<MilepostDetail {...this.props} {...props} {...this.state}/>) (props) => (<MilepostDetail {...this.props} {...props} {...this.state} current_user={current_user}/>)
} }
></Route> ></Route>
{/*修改里程碑*/} {/*修改里程碑*/}
<Route path="/projects/:projectsId/:author/orders/:meilid/meilpost" <Route path="/projects/:projectsId/:author/orders/:meilid/meilpost"
render={ render={
(props) => (<OrderupdateMilepost {...this.props} {...props} {...this.state}/>) (props) => (<OrderupdateMilepost {...this.props} {...props} {...this.state} current_user={current_user}/>)
} }
></Route> ></Route>
@ -405,28 +406,28 @@ class Detail extends Component{
<Route path="/projects/:projectsId/:author/orders/new" <Route path="/projects/:projectsId/:author/orders/new"
render={ render={
(props) => (<OrderNew {...this.props} {...props} {...this.state}/>) (props) => (<OrderNew {...this.props} {...props} {...this.state} current_user={current_user}/>)
} }
></Route> ></Route>
{/* 修改详情 */} {/* 修改详情 */}
<Route path="/projects/:projectsId/:author/orders/:orderId/updatedetail" <Route path="/projects/:projectsId/:author/orders/:orderId/updatedetail"
render={ render={
(props) => (<OrderupdateDetail {...this.props} {...props} {...this.state}/>) (props) => (<OrderupdateDetail {...this.props} {...props} {...this.state} current_user={current_user}/>)
} }
></Route> ></Route>
{/* 复制详情 */} {/* 复制详情 */}
<Route path="/projects/:projectsId/:author/orders/:orderId/copyetail" <Route path="/projects/:projectsId/:author/orders/:orderId/copyetail"
render={ render={
(props) => (<OrdercopyDetail {...this.props} {...props} {...this.state}/>) (props) => (<OrdercopyDetail {...this.props} {...props} {...this.state} current_user={current_user}/>)
} }
></Route> ></Route>
{/* 动态 */} {/* 动态 */}
<Route path="/projects/:projectsId/:author/trends" <Route path="/projects/:projectsId/:author/trends"
render={ render={
(props) => (<TrendsIndex {...this.props} {...props} {...this.state}/>) (props) => (<TrendsIndex {...this.props} {...props} {...this.state} current_user={current_user}/>)
} }
></Route> ></Route>
@ -434,66 +435,66 @@ class Detail extends Component{
{/* 代码Index */} {/* 代码Index */}
<Route path="/projects/:projectsId/:author/orders" <Route path="/projects/:projectsId/:author/orders"
render={ render={
(props) => (<OrderIndex {...this.props} {...props} {...this.state}/>) (props) => (<OrderIndex {...this.props} {...props} {...this.state} current_user={current_user}/>)
} }
></Route> ></Route>
<Route path="/projects/:projectsId/:author/merge/new" <Route path="/projects/:projectsId/:author/merge/new"
render={ render={
(props) => (<CreateMerge {...this.props} {...props} {...this.state}/>) (props) => (<CreateMerge {...this.props} {...props} {...this.state} current_user={current_user}/>)
} }
></Route> ></Route>
<Route path="/projects/:projectsId/:author/merge/:mergeId/UpdateMerge" <Route path="/projects/:projectsId/:author/merge/:mergeId/UpdateMerge"
render={ render={
(props) => (<UpdateMerge {...this.props} {...props} {...this.state}/>) (props) => (<UpdateMerge {...this.props} {...props} {...this.state} current_user={current_user}/>)
} }
></Route> ></Route>
<Route path="/projects/:projectsId/:author/merge/:mergeId/Messagecount" <Route path="/projects/:projectsId/:author/merge/:mergeId/Messagecount"
render={ render={
(props) => (<MessageCount {...this.props} {...props} {...this.state}/>) (props) => (<MessageCount {...this.props} {...props} {...this.state} current_user={current_user}/>)
} }
></Route> ></Route>
<Route path="/projects/:projectsId/:author/merge/:mergeId/MergeSubmit" <Route path="/projects/:projectsId/:author/merge/:mergeId/MergeSubmit"
render={ render={
(props) => (<MergeSubmit {...this.props} {...props} {...this.state}/>) (props) => (<MergeSubmit {...this.props} {...props} {...this.state} current_user={current_user}/>)
} }
></Route> ></Route>
<Route path="/projects/:projectsId/:author/version/new" <Route path="/projects/:projectsId/:author/version/new"
render={ render={
(props) => (<NewVersionIndex {...this.props} {...props} {...this.state}/>) (props) => (<NewVersionIndex {...this.props} {...props} {...this.state} current_user={current_user}/>)
} }
></Route> ></Route>
<Route path="/projects/:projectsId/:author/version/:versionId/upversion" <Route path="/projects/:projectsId/:author/version/:versionId/upversion"
render={ render={
(props) => (<UpVersionIndex {...this.props} {...props} {...this.state}/>) (props) => (<UpVersionIndex {...this.props} {...props} {...this.state} current_user={current_user}/>)
} }
></Route> ></Route>
<Route path="/projects/:projectsId/:author/version" <Route path="/projects/:projectsId/:author/version"
render={ render={
(props) => (<VersionIndex {...this.props} {...props} {...this.state}/>) (props) => (<VersionIndex {...this.props} {...props} {...this.state} current_user={current_user}/>)
} }
></Route> ></Route>
<Route path="/projects/:projectsId/:author/merge" <Route path="/projects/:projectsId/:author/merge"
render={ render={
(props) => (<MergeIndexDetail {...this.props} {...props} {...this.state}/>) (props) => (<MergeIndexDetail {...this.props} {...props} {...this.state} current_user={current_user}/>)
} }
></Route> ></Route>
<Route path="/projects/:projectsId/:author/coder" <Route path="/projects/:projectsId/:author/coder"
render={ render={
(props) => (<CoderRootIndex {...this.props} {...props} {...this.state}/>) (props) => (<CoderRootIndex {...this.props} {...props} {...this.state} current_user={current_user}/>)
} }
></Route> ></Route>
<Route path="/projects/:projectsId/:author" <Route path="/projects/:projectsId/:author"
render={ render={
(props) => (<CoderRootIndex {...this.props} {...props} {...this.state}/>) (props) => (<CoderRootIndex {...this.props} {...props} {...this.state} current_user={current_user}/>)
} }
></Route> ></Route>
</Switch> </Switch>

View File

@ -22,10 +22,25 @@ class Index extends Component{
LanguageList:undefined, LanguageList:undefined,
GitignoreList:undefined, GitignoreList:undefined,
LicensesList:undefined, LicensesList:undefined,
isSpin:false isSpin:false,
current_user:undefined
} }
} }
getUserInfo=()=>{
const url = `/users/me.json`;
axios.get(url).then(result=>{
if(result && result.data.login){
this.setState({
current_user:result.data
})
this.getDetail();
}
}).catch(error=>{
console.log(error)
})
}
componentDidMount=()=>{ componentDidMount=()=>{
this.getUserInfo();
// 获取项目类别 // 获取项目类别
this.getCategory(); this.getCategory();
// 获取项目语言 // 获取项目语言
@ -101,7 +116,7 @@ class Index extends Component{
}) })
this.props.form.validateFieldsAndScroll((err, values) => { this.props.form.validateFieldsAndScroll((err, values) => {
if(!err){ if(!err){
const { current_user } = this.props; const { current_user } = this.state;
const { projectsType } =this.props.match.params; const { projectsType } =this.props.match.params;
const url = projectsType === "deposit" ? "/projects.json" :"/projects/migrate.json"; const url = projectsType === "deposit" ? "/projects.json" :"/projects/migrate.json";
axios.post(url,{ axios.post(url,{

View File

@ -429,7 +429,7 @@ class Detail extends Component{
<p> <p>
{ {
data ? data ?
<span className="font-20">{data.issue_classify === "issue" ? data.tracker : "合并请求"}</span> <span className="font-20">{data.issue_classify === "issue" ? (data.tracker ? data.tracker : " 缺陷" ) : "合并请求"}</span>
: :
"" ""
} }

View File

@ -175,7 +175,7 @@ function QuillForEditor({
const result = await fetchUploadImage(formData); const result = await fetchUploadImage(formData);
// 获取上传图片的url // 获取上传图片的url
if (result.data && result.data.id) { if (result.data && result.data.id) {
fileUrl = (`http://123.59.135.93:56666/api/attachments/${result.data.id}`); fileUrl = (`https://testforgeplus.trustie.net/api/attachments/${result.data.id}`);
} }
// 根据id获取文件路径 // 根据id获取文件路径
const { width, height } = imgAttrs; const { width, height } = imgAttrs;