mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-25 17:04:16 +00:00
feature(store) add
This commit is contained in:
parent
fe0210d573
commit
ea297fc23e
5 changed files with 65 additions and 37 deletions
|
|
@ -3,6 +3,14 @@
|
|||
/* global CloudCmd, DOM, MenuIO */
|
||||
|
||||
const Format = require('format-io');
|
||||
const currify = require('currify/legacy');
|
||||
const squad = require('squad');
|
||||
const store = require('../../common/store');
|
||||
|
||||
const call = currify((fn, callback) => {
|
||||
fn();
|
||||
callback();
|
||||
});
|
||||
|
||||
CloudCmd.EditFile = function EditFileProto(callback) {
|
||||
const Info = DOM.CurrentInfo;
|
||||
|
|
@ -25,26 +33,19 @@ CloudCmd.EditFile = function EditFileProto(callback) {
|
|||
};
|
||||
|
||||
function init(callback) {
|
||||
let editor;
|
||||
const editor = store();
|
||||
|
||||
const getMainEditor = () => CloudCmd.Edit.getEditor();
|
||||
const getEditor = squad(editor, getMainEditor);
|
||||
const auth = squad(authCheck, editor);
|
||||
const listeners = squad(setListeners, editor);
|
||||
|
||||
exec.series([
|
||||
CloudCmd.Edit,
|
||||
(callback) => {
|
||||
editor = CloudCmd.Edit.getEditor();
|
||||
callback();
|
||||
},
|
||||
(callback) => {
|
||||
authCheck(editor);
|
||||
callback();
|
||||
},
|
||||
|
||||
(callback) => {
|
||||
setListeners(editor);
|
||||
callback();
|
||||
},
|
||||
(callback) => {
|
||||
EditFile.show(callback);
|
||||
},
|
||||
call(getEditor),
|
||||
call(auth),
|
||||
call(listeners),
|
||||
EditFile.show,
|
||||
], callback);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,16 +64,17 @@ function EditProto(callback) {
|
|||
function initConfig(options = {}) {
|
||||
const config = Object.assign({}, options, ConfigView);
|
||||
|
||||
if (options.afterShow) {
|
||||
checkFn('options.afterShow', options.afterShow);
|
||||
|
||||
const afterShow = {config};
|
||||
|
||||
config.afterShow = () => {
|
||||
afterShow();
|
||||
options.afterShow();
|
||||
};
|
||||
}
|
||||
if (!options.afterShow)
|
||||
return config;
|
||||
|
||||
checkFn('options.afterShow', options.afterShow);
|
||||
|
||||
const afterShow = {config};
|
||||
|
||||
config.afterShow = () => {
|
||||
afterShow();
|
||||
options.afterShow();
|
||||
};
|
||||
|
||||
return config;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue