From 07867fc28a66facac4bb2cd63c94f4a82e5fec1d Mon Sep 17 00:00:00 2001 From: tengge1 <930372551@qq.com> Date: Wed, 3 Jul 2019 21:33:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ShadowEditor.UI/src/window/css/Confirm.css | 2 +- ShadowEditor.Web/src/Application.js | 16 ++++-- .../src/editor2/assets/ScenePanel.jsx | 6 +-- .../src/editor2/menu/SceneMenu.jsx | 49 +++++++------------ 4 files changed, 34 insertions(+), 39 deletions(-) diff --git a/ShadowEditor.UI/src/window/css/Confirm.css b/ShadowEditor.UI/src/window/css/Confirm.css index 1a49d07a..fc3ba3e4 100644 --- a/ShadowEditor.UI/src/window/css/Confirm.css +++ b/ShadowEditor.UI/src/window/css/Confirm.css @@ -1,4 +1,4 @@ .Window.Confirm { width: 320px; - height: 200px; + height: 180px; } \ No newline at end of file diff --git a/ShadowEditor.Web/src/Application.js b/ShadowEditor.Web/src/Application.js index 44ab26c2..84c1a075 100644 --- a/ShadowEditor.Web/src/Application.js +++ b/ShadowEditor.Web/src/Application.js @@ -86,7 +86,17 @@ Application.prototype.alert = function (title, content, onOK, onClose) { }; Application.prototype.confirm = function (title, content, onOK, onCancel) { - let component = React.createElement(Confirm, { + let component; + + let close = () => { + component && this.editor.removeComponent(component); + }; + + if (onCancel === undefined) { + onCancel = close; + } + + component = React.createElement(Confirm, { title, okText: L_OK, cancelText: L_CANCEL, @@ -99,9 +109,7 @@ Application.prototype.confirm = function (title, content, onOK, onCancel) { return { component, - close: () => { - this.editor.removeComponent(component); - }, + close, }; }; diff --git a/ShadowEditor.Web/src/editor2/assets/ScenePanel.jsx b/ShadowEditor.Web/src/editor2/assets/ScenePanel.jsx index 2e5afc34..6eae9a9d 100644 --- a/ShadowEditor.Web/src/editor2/assets/ScenePanel.jsx +++ b/ShadowEditor.Web/src/editor2/assets/ScenePanel.jsx @@ -110,9 +110,9 @@ class ScenePanel extends React.Component { }).then(obj => { this.onLoadScene(obj); - editor.sceneID = data.ID; - editor.sceneName = data.Name; - document.title = data.Name; + editor.sceneID = data.id; + editor.sceneName = data.title; + document.title = data.title; if (obj.options) { app.call('optionsChanged', this, app.options); diff --git a/ShadowEditor.Web/src/editor2/menu/SceneMenu.jsx b/ShadowEditor.Web/src/editor2/menu/SceneMenu.jsx index 55448f65..c44266ea 100644 --- a/ShadowEditor.Web/src/editor2/menu/SceneMenu.jsx +++ b/ShadowEditor.Web/src/editor2/menu/SceneMenu.jsx @@ -11,13 +11,7 @@ class SceneMenu extends React.Component { constructor(props) { super(props); - this.state = { - emptyConfirmShow: false, - }; - this.handleCreateEmptyScene = this.handleCreateEmptyScene.bind(this); - this.handleEmptyOK = this.handleEmptyOK.bind(this); - this.handleCreateGISScene = this.handleCreateGISScene.bind(this); this.handleSaveScene = this.handleSaveScene.bind(this); this.handleSaveAsScene = this.handleSaveAsScene.bind(this); @@ -25,21 +19,16 @@ class SceneMenu extends React.Component { } render() { - return <> - - - - - - - - - + return + + + - {this.state.emptyConfirmShow && {L_UNSAVED_WILL_LOSE_CONFIRM}} - ; + + + + + ; } // ---------------------------- 新建空场景 --------------------------------- @@ -52,20 +41,18 @@ class SceneMenu extends React.Component { editor.sceneID = null; editor.sceneName = null; document.title = L_NO_NAME; - UI.msg(L_CREATE_EMPTY_SCENE_SUCCESS); + app.toast(L_CREATE_EMPTY_SCENE_SUCCESS); return; } - this.setState({ emptyConfirmShow: true, }); - } - - handleEmptyOK() { - editor.clear(); - editor.sceneID = null; - editor.sceneName = null; - app.options.sceneType = 'Empty'; - document.title = L_NO_NAME; - app.editor.camera.userData.control = 'OrbitControls'; + app.confirm(L_CONFIRM, L_UNSAVED_WILL_LOSE_CONFIRM, () => { + editor.clear(); + editor.sceneID = null; + editor.sceneName = null; + app.options.sceneType = 'Empty'; + document.title = L_NO_NAME; + app.editor.camera.userData.control = 'OrbitControls'; + }); } // --------------------------- 新建GIS场景 -------------------------------------