From 7069e367dfd78193410d8cf564ff4121648a03cc Mon Sep 17 00:00:00 2001 From: liteng <930372551@qq.com> Date: Sat, 16 Jun 2018 13:44:39 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81Config=E7=A7=BB=E5=8A=A8=E5=88=B0core?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=B9=E3=80=82=202=E3=80=81=E6=96=B0?= =?UTF-8?q?=E5=A2=9EOptions=E9=80=89=E9=A1=B9=E7=B1=BB=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Application.js | 4 +++- src/Editor.js | 2 +- src/Options.js | 10 ++++++++++ src/{ => core}/Config.js | 0 src/core/index.js | 1 + src/index.js | 2 +- 6 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 src/Options.js rename src/{ => core}/Config.js (100%) diff --git a/src/Application.js b/src/Application.js index 1d6a4f92..8f1139f8 100644 --- a/src/Application.js +++ b/src/Application.js @@ -1,3 +1,4 @@ +import Options from './Options'; import Editor from './Editor'; import EventDispatcher from './event/EventDispatcher'; import Viewport from './ui/Viewport'; @@ -12,9 +13,10 @@ import RemoveObjectCommand from './command/RemoveObjectCommand'; /** * 应用程序 */ -function Application(container) { +function Application(container, options) { this.container = container; + this.options = new Options(options); // 事件 this.event = new EventDispatcher(this); diff --git a/src/Editor.js b/src/Editor.js index 974510d2..9a7e670a 100644 --- a/src/Editor.js +++ b/src/Editor.js @@ -1,4 +1,4 @@ -import Config from './Config'; +import Config from './core/Config'; import Signal from './core/Signal'; import History from './core/History'; import Storage from './core/Storage'; diff --git a/src/Options.js b/src/Options.js new file mode 100644 index 00000000..0bb3d90e --- /dev/null +++ b/src/Options.js @@ -0,0 +1,10 @@ +/** + * 配置选项 + * @param {*} options 配置选项 + */ +function Options(options) { + options = options || {}; + this.server = options.server || 'http://127.0.0.1:1500'; +} + +export default Options; \ No newline at end of file diff --git a/src/Config.js b/src/core/Config.js similarity index 100% rename from src/Config.js rename to src/core/Config.js diff --git a/src/core/index.js b/src/core/index.js index dfbb3c17..517facab 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -1,3 +1,4 @@ +export { default as Config } from './Config'; export { default as History } from './History'; export { default as Storage } from './Storage'; export { default as Loader } from './Loader'; diff --git a/src/index.js b/src/index.js index 75f3c894..b68eeb65 100644 --- a/src/index.js +++ b/src/index.js @@ -7,6 +7,6 @@ export * from './ui/index'; export * from './menu/index'; export * from './panel/index'; -export { default as Config } from './Config'; +export { default as Options } from './Options'; export { default as Editor } from './Editor'; export { default as Application } from './Application'; \ No newline at end of file