UNPKG

nimble-ui

Version:
61 lines (58 loc) 1.97 kB
import { ClassProxy, callFn } from 'nimble-lib'; import Service from '../services'; /** * 代理Picker * * @export * @param {*} Vue Vue * @param {*} options 配置参数 * @returns {Picker} */ function keyboardFactory (Vue, options) { let _classProxy = new ClassProxy(); class KeyboardProxy extends Service { name = 'Keyboard'; constructor(vue, opts) { super(vue, opts); let _that = this; _classProxy.proxyHook(_that, () => { return _that.preload(); }, ['keyboard', 'carKeyboard']); } preload() { let _that = this; let res = _classProxy.initProxy(() => { return new Promise((resolve, reject) => { import(/* webpackChunkName: "_keyboard_" */ './keyboard').then((back) => { let Keyboard = back && back.default; let _res = Keyboard(Vue, options); if (_that._callInstall instanceof Function) { _that._callInstall((...args) => { _res._getParent = () => { return _that._getParent(); }; _res.install(...args); }); } resolve(_res); }, reject); }); }, 'preload')(); _that.preload = () => { return res; }; return res; } install(vue, opts) { super.install(vue, opts); this._callInstall = function(cb) { callFn(cb, [vue, opts]); }; } } return new KeyboardProxy(Vue, options); } keyboardFactory.install = (Vue, options) => { Vue.use(keyboardFactory(Vue, options), options); }; export default keyboardFactory;