From d7f3c766b4ce23f2f2d1c91c57dbd4fd18a11e12 Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Fri, 19 Mar 2021 15:46:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E8=88=AA=E6=A0=8F=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/forge/Main/Detail.js | 97 +++++----------- src/forge/Main/sub/DetailBanner.jsx | 165 +++++++++++++++++----------- src/forge/Merge/merge.js | 4 +- src/forge/Order/index.scss | 3 +- src/forge/Order/order.js | 4 +- src/forge/Settings/Index.js | 2 +- src/forge/Settings/Setting.js | 101 ++++++++++++----- 7 files changed, 210 insertions(+), 166 deletions(-) diff --git a/src/forge/Main/Detail.js b/src/forge/Main/Detail.js index 07de51c3e..43194996e 100644 --- a/src/forge/Main/Detail.js +++ b/src/forge/Main/Detail.js @@ -2,6 +2,7 @@ import React, { Component } from 'react'; import { Spin, Tooltip } from 'antd'; import { Link, Route, Switch } from 'react-router-dom'; import { Content } from '../Component/layout'; +import DetailBanner from './sub/DetailBanner'; import '../css/index.scss' import './list.css'; @@ -257,6 +258,7 @@ class Detail extends Component { getDetail = () => { const { projectsId , owner } = this.props.match.params; + this.getBanner(); const url = `/${owner}/${projectsId}/detail.json`; axios.get(url).then((result) => { if (result && result.data) { @@ -278,6 +280,19 @@ class Detail extends Component { }).catch((error) => { }) } + // 获取动态导航栏菜单 + getBanner(){ + const { projectsId , owner } = this.props.match.params; + const url = `/${owner}/${projectsId}/menu_list.json`; + axios.get(url).then(result=>{ + if(result){ + this.setState({ + bannerList:result.data + }) + } + }).catch(error=>{}) + } + // 关注和取消关注 focusFunc = (flag) => { const { platform } = this.state; @@ -374,7 +389,7 @@ class Detail extends Component { const { projectDetail, watchers_count, praises_count, forked_count, firstSync , secondSync , isManager, watched, praised, - project , open_devops , platform , defaultBranch } = this.state; + project , open_devops , platform , defaultBranch , bannerList } = this.state; const url = this.props.history.location.pathname; const urlArr = url.split("/"); const urlFlag = (urlArr.length === 3); @@ -494,79 +509,25 @@ class Detail extends Component { { firstSync ? "" : -
- + 项目标签
diff --git a/src/forge/Settings/Setting.js b/src/forge/Settings/Setting.js index 263db31e1..dda9a9f81 100644 --- a/src/forge/Settings/Setting.js +++ b/src/forge/Settings/Setting.js @@ -2,11 +2,20 @@ import React, { Component } from "react"; import { Form, Input, Checkbox, Select , Spin } from "antd"; import Title from '../Component/Title'; import {WhiteBack} from '../Component/layout'; - import axios from "axios"; import "./setting.scss"; const { TextArea } = Input; const { Option } = Select; + +const menu = [ + {name:"主页",index:"home"}, + {name:"代码库",index:"code"}, + {name:"易修 (Issue)",index:"issues"}, + {name:"合并请求",index:"pulls"}, + {name:"工作流(beta版)",index:"devops"}, + {name:"里程碑",index:"versions"}, + {name:"动态",index:"activity"}, +] class Setting extends Component { constructor(props) { super(props); @@ -14,7 +23,8 @@ class Setting extends Component { CategoryList: undefined, LanguageList: undefined, private_check: undefined, - loading:true + loading:true, + project_units:['home',"activity"] }; } @@ -51,12 +61,18 @@ class Setting extends Component { .get(url) .then((result) => { if (result) { + const { project_units } = this.state; + let units = result.data.project_units; + units.push(...project_units); + this.props.form.setFieldsValue({ ...result.data, + project_units:units }); this.setState({ private_check: result.data.private, - loading:false + loading:false, + project_units:units }); } }) @@ -104,36 +120,46 @@ class Setting extends Component { loading:true }) const { projectsId , owner } = this.props.match.params; + const navUrl = `/${owner}/${projectsId}/project_units.json`; - const { private_check } = this.state; - const url = `/${owner}/${projectsId}.json`; - axios - .put(url, { - name: values.project_name, - description: values.project_description, - private: private_check, - ...values, - }) - .then((result) => { - if (result) { - this.props.showNotification(`仓库信息修改成功!`); - const { getDetail } = this.props; - getDetail && getDetail(); - this.setState({ - loading:false - }) - } - }) - .catch((error) => { - console.log(error); - this.setState({ - loading:false - }) - }); + let unit = values.project_units.filter(item => (item !== "home" && item!== "activity")); + axios.post(navUrl, { + unit_types:unit + }).then((result) => { + if (result) { + this.update(values); + } + }).catch(error=>{}) } }); }; + update=(values)=>{ + const { projectsId , owner } = this.props.match.params; + const { private_check } = this.state; + const url = `/${owner}/${projectsId}.json`; + axios.put(url, { + name: values.project_name, + description: values.project_description, + private: private_check, + ...values, + }).then((result) => { + if (result) { + this.props.showNotification(`仓库信息修改成功!`); + const { getDetail } = this.props; + getDetail && getDetail(); + this.setState({ + loading:false + }) + } + }).catch((error) => { + console.log(error); + this.setState({ + loading:false + }) + }); + } + // 删除本仓库 deleteProject = () => { this.props.confirm({ @@ -224,6 +250,25 @@ class Setting extends Component { ], })()} +