diff --git a/package-lock.json b/package-lock.json index 2c5f2c418..3a6d57525 100644 --- a/package-lock.json +++ b/package-lock.json @@ -988,6 +988,30 @@ } } }, + "antd-img-crop": { + "version": "3.12.0", + "resolved": "https://registry.npm.taobao.org/antd-img-crop/download/antd-img-crop-3.12.0.tgz", + "integrity": "sha1-6S95QUkhNSwffjv7uu/Cc9pQFtU=", + "requires": { + "@babel/runtime": "^7.11.2", + "react-easy-crop": "^3.1.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=" + } + } + }, "anymatch": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.2.tgz", @@ -14809,6 +14833,21 @@ "prop-types": "^15.6.0" } }, + "react-easy-crop": { + "version": "3.2.0", + "resolved": "https://registry.npm.taobao.org/react-easy-crop/download/react-easy-crop-3.2.0.tgz", + "integrity": "sha1-HGaM4eTIV8CdryXdrzmKwkdfRTw=", + "requires": { + "tslib": "2.0.1" + }, + "dependencies": { + "tslib": { + "version": "2.0.1", + "resolved": "https://registry.npm.taobao.org/tslib/download/tslib-2.0.1.tgz?cache=0&sync_timestamp=1602286603545&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftslib%2Fdownload%2Ftslib-2.0.1.tgz", + "integrity": "sha1-QQ6w0RPltjVkkO7HSWA3JbAhtD4=" + } + } + }, "react-error-overlay": { "version": "6.1.0-next.80", "resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.1.0-next.80.tgz", diff --git a/package.json b/package.json index 0b17601d9..3d1b2407c 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "@novnc/novnc": "^1.1.0", "actioncable": "^5.2.4-3", "antd": "^3.26.15", + "antd-img-crop": "^3.9.0", "array-flatten": "^2.1.2", "autoprefixer": "7.1.6", "axios": "^0.18.1", diff --git a/public/index.html b/public/index.html index 1969fa0e0..07c2e378a 100755 --- a/public/index.html +++ b/public/index.html @@ -2,22 +2,12 @@ - - - - + + + + - diff --git a/src/App.js b/src/App.js index 28ec0d5f5..b8d91742b 100644 --- a/src/App.js +++ b/src/App.js @@ -61,7 +61,15 @@ const Shixunnopage = Loadable({ loader: () => import('./modules/404/Shixunnopage'), loading: Loading, }) - +// 新版论坛交流 +const Forums = Loadable({ + loader: () => import("./forums/Index"), + loading: Loading, +}); +const Account = Loadable({ + loader: () => import("./user_info/Index"), + loading: Loading, +}); //500页面 const http500 = Loadable({ loader: () => import('./modules/500/http500'), @@ -231,6 +239,19 @@ class App extends Component { } }> + ( + + )} + > + {/* 问吧、论坛交流 */} + ( + + )} + > {/*项目*/} { + const [loading, setLoading] = useState(false); + const [url, setUrl] = useState(undefined); + + useEffect(() => { + if (imageUrl) { + setUrl(imageUrl); + } + }, [imageUrl]) + + function getBase64(img, callback) { + const reader = new FileReader(); + reader.addEventListener('load', () => callback(reader.result)); + reader.readAsDataURL(img); + } + + function handleChange(info) { + if (info.file.status === 'uploading') { + setLoading(true); + return; + } + if (info.file.status === 'done') { + let filelist = info.fileList && info.fileList.length>0 && info.fileList[info.fileList.length-1]; + if(filelist && filelist.response && filelist.response.status === -1){ + setLoading(false) + setUrl(null) + message.error(filelist.response.message) + }else{ + getBase64(info.file.originFileObj, imageUrl =>{ + setLoading(false), + getImageUrl(filelist && filelist.response), + setUrl(imageUrl) + }); + } + } + }; + function beforeUpload(file) { + const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'; + if (!isJpgOrPng) { + message.error('只能上传图片!'); + } + const isLt2M = file.size / 1024 / 1024 < 2; + if (!isLt2M) { + message.error('图片大小必须小于2MB!'); + } + return isJpgOrPng && isLt2M; + } + const uploadButton = ( +
+ {loading ? : } +
+ ); + return ( + + {url ? avatar : uploadButton} + + ) +}) \ No newline at end of file diff --git a/src/forums/Component/Announcement.jsx b/src/forums/Component/Announcement.jsx new file mode 100644 index 000000000..6ecce1125 --- /dev/null +++ b/src/forums/Component/Announcement.jsx @@ -0,0 +1,130 @@ +import React, { useState, useEffect } from "react"; +import { WhiteBack } from "../css/layout"; +import Title from "./Title"; +import { Modal, Button, Input , notification, message } from "antd"; +import Nodata from "../Nodata"; +import axios from 'axios'; + +const TextArea = Input.TextArea; +export default (({ content , operation ,plateId }) => { + const [word, setWord] = useState(undefined); + const [editWord, setEditWord] = useState(undefined); + const [show, setShow] = useState(false); + const [visible, setVisible] = useState(false); + const [AnnModalType, setAnnModalType] = useState(1); //默认为1:查看,否则为编辑 + + let child = document.getElementById("annWords") && document.getElementById("annWords").offsetHeight; + useEffect(() => { + if (content) { + setWord(content.notice); + } + }, [content]); + + useEffect(() => { + changeShow(); + }, [word, child , content]); + + // 保存公告 + function saveAnn() { + setWord(editWord); + setVisible(false); + // 调用保存接口 + if(editWord){ + const url = `/v1/forum_sections/${plateId}/edit_notice.json`; + axios.post(url,{ + content:editWord + }).then(result=>{ + if(result && result.data){ + notification.open({message:"提示",description:result.data.message}); + changeShow(); + } + }).catch(error=>{ + console.log(error); + }) + } + } + + function changeShow(){ + let p = document.getElementById("annContent")&& document.getElementById("annContent").offsetHeight; + let c = document.getElementById("annWords") &&document.getElementById("annWords").offsetHeight; + if (c > p) { + setShow(true); + }else{ + setShow(false); + } + } + // 取消编辑公告 + function cancelAnn() { + setEditWord(word); + setVisible(false); + } + + // 查看(1)或者编辑(2) + function changeAnnModalType(type) { + setAnnModalType(type); + setVisible(true); + setEditWord(word); + } + + function changeText(e) { + setEditWord(e.target.value); + } + return ( + + setVisible(false)} + footer={ + AnnModalType === 1 ? false :
+ + +
+ } + > + {AnnModalType === 1 ? ( +

{word}

+ ) : ( +