From cc79470bd49318bbf7e74a5ce325cf61a218a57a Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Fri, 29 Nov 2019 15:30:01 +0800 Subject: [PATCH] =?UTF-8?q?Feat:=20=E4=BD=BF=E7=94=A8=E4=BB=A3=E7=90=86API?= =?UTF-8?q?=E7=BB=95=E5=BC=80Cookie=E8=B7=A8=E5=9F=9F=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/webpackDevServer.config.js | 6 ++++++ src/component/FileManager/ContextMenu.js | 4 ++-- src/component/FileManager/Navigator.js | 17 ++++++++++------- src/component/Uploader.js | 2 -- src/middleware/Api.js | 4 +++- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/config/webpackDevServer.config.js b/config/webpackDevServer.config.js index 93c6858..4de504b 100644 --- a/config/webpackDevServer.config.js +++ b/config/webpackDevServer.config.js @@ -83,6 +83,12 @@ module.exports = function(proxy, allowedHost) { }, public: allowedHost, proxy, + proxy: { + '/api': { + target: 'http://localhost:5000', + secure: false + } + }, before(app, server) { if (fs.existsSync(paths.proxySetup)) { // This registers user provided middleware for proxy reasons diff --git a/src/component/FileManager/ContextMenu.js b/src/component/FileManager/ContextMenu.js index a6c4d74..12a6c6d 100644 --- a/src/component/FileManager/ContextMenu.js +++ b/src/component/FileManager/ContextMenu.js @@ -30,7 +30,7 @@ import LinkIcon from '@material-ui/icons/InsertLink' import DeleteIcon from '@material-ui/icons/Delete' import OpenIcon from '@material-ui/icons/OpenInNew' import {MagnetOn} from 'mdi-material-ui' - +import {baseURL} from "../../middleware/Api" import { withStyles, Popover, Typography, MenuList, MenuItem, Divider, ListItemIcon } from '@material-ui/core'; const styles = theme => ({ @@ -124,7 +124,7 @@ class ContextMenuCompoment extends Component { } this.props.changeContextMenu("file",false); let downloadPath = this.props.selected[0].path === "/" ? this.props.selected[0].path+this.props.selected[0].name:this.props.selected[0].path+"/"+this.props.selected[0].name; - window.open(window.apiURL.download+"?action=download&path="+encodeURIComponent(downloadPath)); + window.open(baseURL+"/file"+(downloadPath)); } diff --git a/src/component/FileManager/Navigator.js b/src/component/FileManager/Navigator.js index 887e9fc..193b3dc 100644 --- a/src/component/FileManager/Navigator.js +++ b/src/component/FileManager/Navigator.js @@ -234,14 +234,17 @@ class NavigatorCompoment extends Component { } checkOverFlow = ()=>{ - const hasOverflowingChildren = this.element.current.offsetHeight < this.element.current.scrollHeight || - this.element.current.offsetWidth < this.element.current.scrollWidth; - if(hasOverflowingChildren && !this.state.hiddenMode){ - this.setState({hiddenMode:true}); - } - if(!hasOverflowingChildren && this.state.hiddenMode){ - this.setState({hiddenMode:false}); + if (this.element.current !== null){ + const hasOverflowingChildren = this.element.current.offsetHeight < this.element.current.scrollHeight || + this.element.current.offsetWidth < this.element.current.scrollWidth; + if(hasOverflowingChildren && !this.state.hiddenMode){ + this.setState({hiddenMode:true}); + } + if(!hasOverflowingChildren && this.state.hiddenMode){ + this.setState({hiddenMode:false}); + } } + } navigateTo=(event,id)=> { diff --git a/src/component/Uploader.js b/src/component/Uploader.js index d9d1a04..9aba16c 100644 --- a/src/component/Uploader.js +++ b/src/component/Uploader.js @@ -56,7 +56,6 @@ class UploaderCompoment extends Component { loaded = true; var user = Auth.GetUser(); window.uploadConfig = user.policy; - console.log(window.uploadConfig); this.uploader = window.Qiniu.uploader({ runtimes: "html5", browse_button: "pickfiles", @@ -84,7 +83,6 @@ class UploaderCompoment extends Component { window.pathCache[files.id] = this.props.path; this.fileList["enQueue"](files); }); - console.log(window.pathCache); }, BeforeUpload: function(up, file) {}, diff --git a/src/middleware/Api.js b/src/middleware/Api.js index 4076b5c..baa4038 100644 --- a/src/middleware/Api.js +++ b/src/middleware/Api.js @@ -1,8 +1,10 @@ import axios from "axios"; import Auth from "./Auth" +export const baseURL = "/api/v3"; + const instance = axios.create({ - baseURL: "http://127.0.0.1:5000/api/v3", + baseURL: baseURL, withCredentials: true, crossDomain: true, });