mirror of
https://github.com/tengge1/ShadowEditor.git
synced 2026-02-01 16:08:17 +00:00
设置主题事件。
This commit is contained in:
parent
51c7910404
commit
76089152ec
@ -8,7 +8,6 @@ import Toolbar from './editor/Toolbar';
|
||||
import Menubar from './menu/Menubar';
|
||||
import Panel from './panel/Panel';
|
||||
import UI from './ui/UI';
|
||||
import RemoveObjectCommand from './command/RemoveObjectCommand';
|
||||
|
||||
/**
|
||||
* 应用程序
|
||||
|
||||
@ -45,12 +45,8 @@ function Editor(app) {
|
||||
|
||||
Editor.prototype = {
|
||||
|
||||
setTheme: function (value) {
|
||||
|
||||
document.getElementById('theme').href = value;
|
||||
|
||||
this.signals.themeChanged.dispatch(value);
|
||||
|
||||
setTheme: function (value) { // 设置编辑器主题
|
||||
this.app.call('setTheme', this, value);
|
||||
},
|
||||
|
||||
//
|
||||
|
||||
@ -11,6 +11,8 @@ import LoadFromHashEvent from './editor/LoadFromHashEvent';
|
||||
import AutoSaveEvent from './editor/AutoSaveEvent';
|
||||
import VREvent from './editor/VREvent';
|
||||
|
||||
import SetThemeEvent from './editor/SetThemeEvent';
|
||||
|
||||
/**
|
||||
* 事件执行器
|
||||
*/
|
||||
@ -20,6 +22,7 @@ function EventDispatcher(app) {
|
||||
this.addDomEventListener();
|
||||
|
||||
this.events = [
|
||||
// Application中的事件
|
||||
new DragOverEvent(this.app),
|
||||
new DropEvent(this.app),
|
||||
new KeyDownEvent(this.app),
|
||||
@ -27,7 +30,10 @@ function EventDispatcher(app) {
|
||||
//new MessageEvent(this.app),
|
||||
new LoadFromHashEvent(this.app),
|
||||
new AutoSaveEvent(this.app),
|
||||
new VREvent(this.app)
|
||||
new VREvent(this.app),
|
||||
|
||||
// Editor中的事件
|
||||
new SetThemeEvent(this.app),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -14,7 +14,10 @@ var EventList = [
|
||||
'mousewheel',
|
||||
'resize',
|
||||
'dragover',
|
||||
'drop'
|
||||
'drop',
|
||||
|
||||
// editor事件
|
||||
'setTheme', // 设置编辑器主题
|
||||
];
|
||||
|
||||
export default EventList;
|
||||
32
src/event/editor/SetThemeEvent.js
Normal file
32
src/event/editor/SetThemeEvent.js
Normal file
@ -0,0 +1,32 @@
|
||||
import BaseEvent from '../BaseEvent';
|
||||
|
||||
/**
|
||||
* 设置主题事件
|
||||
* @param {*} app
|
||||
*/
|
||||
function SetThemeEvent(app) {
|
||||
BaseEvent.call(this, app);
|
||||
}
|
||||
|
||||
SetThemeEvent.prototype = Object.create(BaseEvent.prototype);
|
||||
SetThemeEvent.prototype.constructor = SetThemeEvent;
|
||||
|
||||
SetThemeEvent.prototype.start = function () {
|
||||
var _this = this;
|
||||
this.app.on('setTheme.' + this.id, function (theme) {
|
||||
_this.onSetTheme(theme);
|
||||
});
|
||||
};
|
||||
|
||||
SetThemeEvent.prototype.stop = function () {
|
||||
this.app.on('setTheme.' + this.id, null);
|
||||
};
|
||||
|
||||
SetThemeEvent.prototype.onSetTheme = function (theme) {
|
||||
var signals = this.app.editor.signals;
|
||||
|
||||
document.getElementById('theme').href = theme;
|
||||
signals.themeChanged.dispatch(theme);
|
||||
};
|
||||
|
||||
export default SetThemeEvent;
|
||||
Loading…
x
Reference in New Issue
Block a user