From 615a4debe55e18cf6cebd99defbed5c7ea0520a6 Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Thu, 24 Sep 2020 14:55:44 +0800 Subject: [PATCH 1/5] Add Attachment Video --- package-lock.json | 27 +++++ package.json | 3 +- src/AppConfig.js | 4 +- src/forge/Upload/attachment.js | 212 +++++++++++++++++++++++---------- src/forge/Upload/videos.js | 41 +++++++ 5 files changed, 219 insertions(+), 68 deletions(-) create mode 100644 src/forge/Upload/videos.js diff --git a/package-lock.json b/package-lock.json index 1c5d1e40..be44b428 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18762,6 +18762,33 @@ "extsprintf": "^1.2.0" } }, + "video-react": { + "version": "0.14.1", + "resolved": "https://registry.npm.taobao.org/video-react/download/video-react-0.14.1.tgz", + "integrity": "sha1-Sax7GfHQOcCz6+yC+BIkvC+ovfE=", + "requires": { + "@babel/runtime": "^7.4.5", + "classnames": "^2.2.6", + "lodash.throttle": "^4.1.1", + "prop-types": "^15.7.2", + "redux": "^4.0.1" + }, + "dependencies": { + "@babel/runtime": { + "version": "7.11.2", + "resolved": "https://registry.npm.taobao.org/@babel/runtime/download/@babel/runtime-7.11.2.tgz?cache=0&sync_timestamp=1596637887062&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Fruntime%2Fdownload%2F%40babel%2Fruntime-7.11.2.tgz", + "integrity": "sha1-9UnBPHVMxAuHZEufqfCaapX+BzY=", + "requires": { + "regenerator-runtime": "^0.13.4" + } + }, + "regenerator-runtime": { + "version": "0.13.7", + "resolved": "https://registry.npm.taobao.org/regenerator-runtime/download/regenerator-runtime-0.13.7.tgz?cache=0&sync_timestamp=1595456367497&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fregenerator-runtime%2Fdownload%2Fregenerator-runtime-0.13.7.tgz", + "integrity": "sha1-ysLazIoepnX+qrrriugziYrkb1U=" + } + } + }, "vm-browserify": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.2.tgz", diff --git a/package.json b/package.json index 0bcaa7fc..c126f645 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,6 @@ "babel-eslint": "7.2.3", "babel-jest": "20.0.3", "babel-loader": "7.1.2", - "code-prettify": "^0.1.0", "babel-plugin-syntax-dynamic-import": "^6.18.0", "babel-preset-react-app": "^3.1.1", "babel-runtime": "6.26.0", @@ -24,6 +23,7 @@ "chalk": "1.1.3", "classnames": "^2.2.5", "clipboard": "^2.0.6", + "code-prettify": "^0.1.0", "codemirror": "^5.53.0", "connected-react-router": "4.4.1", "css-loader": "^3.5.2", @@ -107,6 +107,7 @@ "styled-components": "^4.4.1", "sw-precache-webpack-plugin": "0.11.4", "url-loader": "0.6.2", + "video-react": "^0.14.1", "webpack-cli": "^3.3.11", "webpack-dev-server": "^3.10.3", "webpack-manifest-plugin": "^2.2.0", diff --git a/src/AppConfig.js b/src/AppConfig.js index dadadc5f..153780b3 100644 --- a/src/AppConfig.js +++ b/src/AppConfig.js @@ -64,8 +64,8 @@ export function initAxiosInterceptors(props) { initOnlineOfflineListener() // TODO 避免重复的请求 https://github.com/axios/axios#cancellation var - proxy = "http://localhost:3000" - proxy = "https://testforgeplus.trustie.net" + // proxy = "http://localhost:3000" + proxy = "https://forgeplus.trustie.net" const requestMap = {}; window.setfalseInRequestMap = function (keyName) { diff --git a/src/forge/Upload/attachment.js b/src/forge/Upload/attachment.js index 664fa15c..26f932a7 100644 --- a/src/forge/Upload/attachment.js +++ b/src/forge/Upload/attachment.js @@ -1,82 +1,164 @@ -import React, { Component } from 'react'; -import {Link} from 'react-router-dom'; +import React, { Component } from "react"; +import { Link } from "react-router-dom"; import axios from "axios"; -import {Popconfirm} from "antd"; -class Attachment extends Component{ - constructor(props){ +import { Popconfirm, Modal, Button, Icon } from "antd"; +import Videos from "./videos"; +class Attachment extends Component { + constructor(props) { super(props); - this.state={ + this.state = { canDelete: false, - Deleted:[] - } + show_video: false, + video_url: undefined, + video_title: undefined, + Deleted: [], + }; } - componentDidMount=()=>{ + componentDidMount = () => { this.getDetail(); - } + }; - getDetail=()=>{ + getDetail = () => { this.setState({ - canDelete: this.props.canDelete - }) - } + canDelete: this.props.canDelete, + }); + }; + + show_video_modal = (item) => { + this.setState({ + show_video: true, + video_url: item.url, + video_title: item.title, + }); + }; + hide_video_modal = () => { + this.setState({ + show_video: false, + video_url: undefined, + video_title: undefined, + }); + }; + + is_video = (name) => { + const video_names = ["mp4", "flv", "mkv", "3gp"]; + return video_names.indexOf(name.split(".").pop()) > -1; + }; deleteAttachment = (id) => { - const url = `/attachments/${id}.json` - axios.delete(url, { - }).then((response) => { - if (response.data) { - if (response.data.status === 0) { - this.setState({ - Deleted: this.state.Deleted.concat(id) - }); - this.props.showNotification("附件删除成功") - }else{ - this.props.showNotification(response.data.message) + const url = `/attachments/${id}.json`; + axios + .delete(url, {}) + .then((response) => { + if (response.data) { + if (response.data.status === 0) { + this.setState({ + Deleted: this.state.Deleted.concat(id), + }); + this.props.showNotification("附件删除成功"); + } else { + this.props.showNotification(response.data.message); + } } - } - }).catch(function (error) { - console.log(error); - }); - } + }) + .catch(function (error) { + console.log(error); + }); + }; - render(){ - const { Deleted , canDelete } = this.state; - const { attachments }= this.props - return( + render() { + const { + Deleted, + canDelete, + show_video, + video_url, + video_title, + } = this.state; + const { attachments } = this.props; + return (
- { - attachments ? -
- { - attachments.map((item,key)=>{ - return( -
0 && Deleted.indexOf(item.id) !== -1) ? "none" : "block"}} className="pd510 attachment-list-div" > - - - {item.title} - {item.filesize} - - { - canDelete ? - this.deleteAttachment(item.id)}> - - - : - "" - } -
+ {attachments ? ( +
+ {attachments.map((item, key) => { + return ( +
0 && Deleted.indexOf(item.id) !== -1 + ? "none" + : "block", + }} + className="pd510 attachment-list-div" + > + {this.is_video(item.title) ? ( + this.show_video_modal(item)} + className="attachment-list-a" + > + + {item.title} + {item.filesize} + + + ) : ( + + + {item.title} + {item.filesize} + + )} - ) - }) - } -
- - : - "" - } + {canDelete ? ( + this.deleteAttachment(item.id)} + > + + + + + ) : ( + "" + )} +
+ ); + })} +
+ ) : ( + "" + )} + {show_video ? ( + + + + ) : ( + "" + )}
- ) + ); } } -export default Attachment; \ No newline at end of file +export default Attachment; diff --git a/src/forge/Upload/videos.js b/src/forge/Upload/videos.js new file mode 100644 index 00000000..1bf68ec4 --- /dev/null +++ b/src/forge/Upload/videos.js @@ -0,0 +1,41 @@ +import React, { useEffect, useState, Fragment } from "react"; +import "../../../node_modules/video-react/dist/video-react.css"; +import { + Player, + ControlBar, + PlayToggle, // PlayToggle 播放/暂停按钮 若需禁止加 disabled + ReplayControl, // 后退按钮 + ForwardControl, // 前进按钮 + CurrentTimeDisplay, + TimeDivider, + PlaybackRateMenuButton, // 倍速播放选项 + VolumeMenuButton, + BigPlayButton, +} from "video-react"; +function videos(video_url) { + const [VideUrl, setUrl] = useState(null); //用户的内容 + useEffect(() => { + setUrl(video_url); + }, []); + + return ( + +
+ + + + + + + + + + + + + +
+
+ ); +} +export default videos; From dd9de256e417e86841e3a4430ca7f3554660bd06 Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Thu, 24 Sep 2020 14:57:11 +0800 Subject: [PATCH 2/5] Add Attachment Video --- src/forge/Upload/attachment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/forge/Upload/attachment.js b/src/forge/Upload/attachment.js index 26f932a7..50c5e2e0 100644 --- a/src/forge/Upload/attachment.js +++ b/src/forge/Upload/attachment.js @@ -28,7 +28,7 @@ class Attachment extends Component { show_video_modal = (item) => { this.setState({ show_video: true, - video_url: item.url, + video_url: item.absolute_path, video_title: item.title, }); }; From d228d7bcbf3c7278d918eaa5defed223df0b10e8 Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Fri, 25 Sep 2020 10:53:30 +0800 Subject: [PATCH 3/5] Add Attachment3 --- package-lock.json | 35 +++--------------- package.json | 1 - src/forge/Upload/attachment.js | 66 ++++++++++++++++++++++------------ src/forge/Upload/videos.js | 36 +++---------------- 4 files changed, 51 insertions(+), 87 deletions(-) diff --git a/package-lock.json b/package-lock.json index be44b428..2c5f2c41 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14939,8 +14939,8 @@ }, "react-player": { "version": "1.15.3", - "resolved": "https://registry.npmjs.org/react-player/-/react-player-1.15.3.tgz", - "integrity": "sha512-8fc0R1AipFIy7l4lKgnIg+gMU2IY32ZMxxBlINjXAq/YnN3HUP3hOaE+aQ0lQv+a1/MMZgbekWD86ZGDO7kB8g==", + "resolved": "https://registry.npm.taobao.org/react-player/download/react-player-1.15.3.tgz", + "integrity": "sha1-0AzxRfnIYYTLCgcaH7+Oy3tomH8=", "requires": { "deepmerge": "^4.0.0", "load-script": "^1.0.0", @@ -14949,8 +14949,8 @@ "dependencies": { "deepmerge": { "version": "4.2.2", - "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz", - "integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==" + "resolved": "https://registry.npm.taobao.org/deepmerge/download/deepmerge-4.2.2.tgz", + "integrity": "sha1-RNLqNnm49NT/ujPwPYZfwee/SVU=" } } }, @@ -18762,33 +18762,6 @@ "extsprintf": "^1.2.0" } }, - "video-react": { - "version": "0.14.1", - "resolved": "https://registry.npm.taobao.org/video-react/download/video-react-0.14.1.tgz", - "integrity": "sha1-Sax7GfHQOcCz6+yC+BIkvC+ovfE=", - "requires": { - "@babel/runtime": "^7.4.5", - "classnames": "^2.2.6", - "lodash.throttle": "^4.1.1", - "prop-types": "^15.7.2", - "redux": "^4.0.1" - }, - "dependencies": { - "@babel/runtime": { - "version": "7.11.2", - "resolved": "https://registry.npm.taobao.org/@babel/runtime/download/@babel/runtime-7.11.2.tgz?cache=0&sync_timestamp=1596637887062&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Fruntime%2Fdownload%2F%40babel%2Fruntime-7.11.2.tgz", - "integrity": "sha1-9UnBPHVMxAuHZEufqfCaapX+BzY=", - "requires": { - "regenerator-runtime": "^0.13.4" - } - }, - "regenerator-runtime": { - "version": "0.13.7", - "resolved": "https://registry.npm.taobao.org/regenerator-runtime/download/regenerator-runtime-0.13.7.tgz?cache=0&sync_timestamp=1595456367497&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fregenerator-runtime%2Fdownload%2Fregenerator-runtime-0.13.7.tgz", - "integrity": "sha1-ysLazIoepnX+qrrriugziYrkb1U=" - } - } - }, "vm-browserify": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.2.tgz", diff --git a/package.json b/package.json index c126f645..0b17601d 100644 --- a/package.json +++ b/package.json @@ -107,7 +107,6 @@ "styled-components": "^4.4.1", "sw-precache-webpack-plugin": "0.11.4", "url-loader": "0.6.2", - "video-react": "^0.14.1", "webpack-cli": "^3.3.11", "webpack-dev-server": "^3.10.3", "webpack-manifest-plugin": "^2.2.0", diff --git a/src/forge/Upload/attachment.js b/src/forge/Upload/attachment.js index 50c5e2e0..0d253e88 100644 --- a/src/forge/Upload/attachment.js +++ b/src/forge/Upload/attachment.js @@ -1,7 +1,7 @@ import React, { Component } from "react"; import { Link } from "react-router-dom"; import axios from "axios"; -import { Popconfirm, Modal, Button, Icon } from "antd"; +import { Popconfirm, Modal, Spin } from "antd"; import Videos from "./videos"; class Attachment extends Component { constructor(props) { @@ -11,6 +11,8 @@ class Attachment extends Component { show_video: false, video_url: undefined, video_title: undefined, + video_id: undefined, + move_spin: false, Deleted: [], }; } @@ -27,17 +29,42 @@ class Attachment extends Component { show_video_modal = (item) => { this.setState({ - show_video: true, - video_url: item.absolute_path, video_title: item.title, + move_spin: true, + video_id: item.id, }); + this.move_attachment(item.id, "preview"); }; hide_video_modal = () => { + const { video_id } = this.state; this.setState({ - show_video: false, - video_url: undefined, video_title: undefined, }); + this.move_attachment(video_id, "close"); + }; + + move_attachment = (id, status) => { + axios + .post(`/attachments/${id}/preview_attachment`, { status: status }) + .then((result) => { + if (result) { + this.setState({ + show_video: status === "preview", + video_url: status === "preview" ? "https://forgeplus.trustie.net" + result.data.url : undefined, + move_spin: false, + }); + } else { + this.setState({ + move_spin: false, + }); + } + }) + .catch((error) => { + this.setState({ + move_spin: false, + }); + console.log(error); + }); }; is_video = (name) => { @@ -73,6 +100,7 @@ class Attachment extends Component { show_video, video_url, video_title, + move_spin, } = this.state; const { attachments } = this.props; return ( @@ -92,24 +120,16 @@ class Attachment extends Component { className="pd510 attachment-list-div" > {this.is_video(item.title) ? ( - this.show_video_modal(item)} - className="attachment-list-a" - > - - {item.title} - {item.filesize} - - + + {item.title} + {item.filesize} + + ) : ( diff --git a/src/forge/Upload/videos.js b/src/forge/Upload/videos.js index 1bf68ec4..ab3be026 100644 --- a/src/forge/Upload/videos.js +++ b/src/forge/Upload/videos.js @@ -1,41 +1,13 @@ -import React, { useEffect, useState, Fragment } from "react"; -import "../../../node_modules/video-react/dist/video-react.css"; -import { - Player, - ControlBar, - PlayToggle, // PlayToggle 播放/暂停按钮 若需禁止加 disabled - ReplayControl, // 后退按钮 - ForwardControl, // 前进按钮 - CurrentTimeDisplay, - TimeDivider, - PlaybackRateMenuButton, // 倍速播放选项 - VolumeMenuButton, - BigPlayButton, -} from "video-react"; +import React, { useEffect, useState } from "react"; +import ReactPlayer from 'react-player' function videos(video_url) { const [VideUrl, setUrl] = useState(null); //用户的内容 useEffect(() => { - setUrl(video_url); + setUrl(video_url.video_url); }, []); return ( - -
- - - - - - - - - - - - - -
-
+ ); } export default videos; From c6eb67404a81f479082ad86c314ab1a391f8ea82 Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Fri, 25 Sep 2020 11:00:17 +0800 Subject: [PATCH 4/5] Add Attachment4 --- src/forge/Upload/attachment.js | 63 ++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/src/forge/Upload/attachment.js b/src/forge/Upload/attachment.js index 0d253e88..78e9871c 100644 --- a/src/forge/Upload/attachment.js +++ b/src/forge/Upload/attachment.js @@ -50,7 +50,10 @@ class Attachment extends Component { if (result) { this.setState({ show_video: status === "preview", - video_url: status === "preview" ? "https://forgeplus.trustie.net" + result.data.url : undefined, + video_url: + status === "preview" + ? "https://forgeplus.trustie.net" + result.data.url + : undefined, move_spin: false, }); } else { @@ -119,8 +122,8 @@ class Attachment extends Component { }} className="pd510 attachment-list-div" > - {this.is_video(item.title) ? ( - + + {this.is_video(item.title) ? ( this.show_video_modal(item)} className="attachment-list-a" @@ -129,34 +132,34 @@ class Attachment extends Component { {item.title} {item.filesize} - - ) : ( - - - {item.title} - {item.filesize} - - )} + ) : ( + + + {item.title} + {item.filesize} + + )} - {canDelete ? ( - this.deleteAttachment(item.id)} - > - - - - - ) : ( - "" - )} + {canDelete ? ( + this.deleteAttachment(item.id)} + > + + + + + ) : ( + "" + )} + ); })} From 2a5823a34720bdc6c3cfa5eaf6d31bcf7c13c289 Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Sun, 27 Sep 2020 13:58:44 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=B0=8F=E4=BF=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.html | 6 +++--- src/App.js | 12 ++++++------ src/forge/Main/CoderRootDirectory.js | 2 +- src/forge/Merge/MessageCount.js | 14 ++++++-------- src/forge/Order/newMilepost.js | 9 ++------- src/modules/tpm/TPMIndex.css | 2 +- src/modules/tpm/TPMIndexHOC.js | 5 +++-- 7 files changed, 22 insertions(+), 28 deletions(-) diff --git a/public/index.html b/public/index.html index 70396e4c..b024c3b7 100755 --- a/public/index.html +++ b/public/index.html @@ -20,7 +20,7 @@ - --> @@ -43,7 +43,7 @@
- + diff --git a/src/App.js b/src/App.js index 534706b8..28ec0d5f 100644 --- a/src/App.js +++ b/src/App.js @@ -213,13 +213,13 @@ class App extends Component { - + {/* */} this.Modifyloginvalue()}> - - - - - + {/* */} + {/* */} + {/* */} + {/* */} + {/* */} {/*项目*/} diff --git a/src/forge/Main/CoderRootDirectory.js b/src/forge/Main/CoderRootDirectory.js index aeecf7eb..47c2b0a5 100644 --- a/src/forge/Main/CoderRootDirectory.js +++ b/src/forge/Main/CoderRootDirectory.js @@ -427,7 +427,7 @@ class CoderRootDirectory extends Component { width: "60%", render: (text, item) => item.commit && item.commit.message ? - + {item.commit.message} : "" diff --git a/src/forge/Merge/MessageCount.js b/src/forge/Merge/MessageCount.js index c837ccb4..c7052fe7 100644 --- a/src/forge/Merge/MessageCount.js +++ b/src/forge/Merge/MessageCount.js @@ -378,14 +378,12 @@ class MessageCount extends Component { -
- {data.issue.description && - data.issue.description.length > 0 ? ( - this.commentCtx(data.issue.description) - ) : ( - 没有描述 - )} -
+ { + data.issue.description ? +
{this.commentCtx(data.issue.description)}
+ : +

没有描述

+ }
{pr_status === 2 && ( diff --git a/src/forge/Order/newMilepost.js b/src/forge/Order/newMilepost.js index 0e3e25d9..965e5a6a 100644 --- a/src/forge/Order/newMilepost.js +++ b/src/forge/Order/newMilepost.js @@ -52,12 +52,9 @@ class NewMilepost extends Component { const { projectsId , owner } = this.props.match.params; const url = `/${owner}/${projectsId}/milestones.json`; let time = undefined; - if (this.state.selectedValue === undefined) { - - } else { - time = this.state.selectedValue.format("YYYY-MM-DD") + if (this.state.selectedValue) { + time = this.state.selectedValue.format("YYYY-MM-DD"); } - axios.post(url, { ...values, project_id: projectsId, @@ -68,10 +65,8 @@ class NewMilepost extends Component { this.setState({ isSpin: false }) this.props.history.push(`/projects/${owner}/${projectsId}/milestones`); } - }).catch(error => { this.setState({ isSpin: false }) - console.log(error); }) }else{ this.setState({ isSpin: false }) diff --git a/src/modules/tpm/TPMIndex.css b/src/modules/tpm/TPMIndex.css index f47632d3..cf3b7ffe 100644 --- a/src/modules/tpm/TPMIndex.css +++ b/src/modules/tpm/TPMIndex.css @@ -29,7 +29,7 @@ body>.-task-title { width: 100%; height:70px; min-width: 1200px; - z-index: 1000; + z-index: 10000; -moz-box-shadow: 0px 2px 10px 0px rgba(0,0,0,0.1); background:rgba(255,255,255,1); box-shadow:0px 2px 10px 0px rgba(0,0,0,0.1); diff --git a/src/modules/tpm/TPMIndexHOC.js b/src/modules/tpm/TPMIndexHOC.js index a4c47d4f..e267d8d3 100644 --- a/src/modules/tpm/TPMIndexHOC.js +++ b/src/modules/tpm/TPMIndexHOC.js @@ -8,7 +8,6 @@ import './TPMIndex.css'; import LoginDialog from '../login/LoginDialog'; import AccountProfile from '../user/AccountProfile'; import AccountPhoneemail from '../user/AccountPhoneemail'; -import cookies from 'react-cookies'; export function TPMIndexHOC(WrappedComponent) { return class II extends React.Component { @@ -184,15 +183,16 @@ export function TPMIndexHOC(WrappedComponent) { json[key] = value; } } while (arr); - return json; }; + hideLoginDialog = () => { this.setState({ isRender: false, isloginCancel: undefined }) } + showLoginDialog = () => { this.setState({ isRender: true, @@ -209,6 +209,7 @@ export function TPMIndexHOC(WrappedComponent) { AccountProfiletype: false }) } + showProfileCompleteDialog = () => { this.dialogObj = {} this.setState({