t-comm
Version:
专业、稳定、纯粹的工具库
62 lines (59 loc) • 1.7 kB
JavaScript
import { initApp } from './helper/init-app/v2.mjs';
import { initConfig } from './helper/init-config/v2.mjs';
import { initMixin } from './helper/init-mixin/index.mjs';
import { initRouter } from './helper/init-router/v2.mjs';
import { initStore } from './helper/init-store/v2.mjs';
import { initVLazy } from './helper/init-v-lazy/init-v-lazy.mjs';
import '../tslib.es6-096fffdd.js';
import './helper/init-config/helper.mjs';
import './helper/init-router/helper.mjs';
import '../v-lazy/v-lazy.mjs';
import '../image/image.mjs';
import '@babel/runtime/helpers/typeof';
var router;
var store;
/**
* Vue项目初始化
* @param {object} options 业务自定义配置
* @param {object} options.App 业务App.vue对象
* @param {Array<object>} [options.routerMap] 业务路由配置表
* @param {Function} [options.beforeStart] 钩子函数,业务自定义
* @param {boolean} [options.i18n] 支持国际化
* @returns {object} 返回 { router, store }
*/
function startApp(options) {
if (!options.Vue) {
console.warn('startApp need Vue');
return;
}
if (!options.App) {
console.warn('startApp need App');
return;
}
createRouterAndStore(options);
if (!options.noDependMixins) {
initMixin(options.Vue, options);
}
initConfig(options.Vue);
initVLazy(options);
if (typeof options.beforeStart === 'function') {
options.beforeStart(router, store);
}
initApp(options, router, store);
return {
router: router,
store: store
};
}
/**
* 创建路由和Store
* @private
*/
function createRouterAndStore(options) {
if (router || store) {
return;
}
router = initRouter(options);
store = initStore(options);
}
export { startApp };