Commit 136f54c0 by 姜雷

添加公用处理方法

parent d39bbbc2
...@@ -12,6 +12,7 @@ import { formatRouteLink } from '@/utils/route'; ...@@ -12,6 +12,7 @@ import { formatRouteLink } from '@/utils/route';
import storeModule from './storeModule'; import storeModule from './storeModule';
import mixinModule from './mixins'; import mixinModule from './mixins';
import utilsModule from './utils';
const fetch = createBaseFetch( const fetch = createBaseFetch(
{ {
...@@ -20,58 +21,43 @@ const fetch = createBaseFetch( ...@@ -20,58 +21,43 @@ const fetch = createBaseFetch(
store store
); );
const createSystem = ({ routers, routeFilter }) => { class SystemShell {
class SystemShell { constructor() {
constructor() { this.Api = fetch;
this.createBaseFetch = createBaseFetch; this.storeModule = storeModule;
this.fetch = fetch; this.mixinModule = mixinModule;
this.initSystem(); this.utils = utilsModule;
} }
createSystem = ({ routers, routeFilter }) => {
mixins = mixinModule; routeStore.install(store);
storeModule = storeModule; extendCom(Vue);
configRoutePermission(router, store, routers);
initSystem() { Vue.config.productionTip = false;
routeStore.install(store);
extendCom(Vue); let app = new Vue({
configRoutePermission(router, store, routers); el: '#app',
Vue.config.productionTip = false; router,
} store,
render: h => {
mount() { let routes = [...constantRouterMap];
/* eslint-disable no-new */ let allRoute = store.getters.asyncRoutes;
let app = new Vue({ if (typeof routeFilter === 'function') {
el: '#app', allRoute = routeFilter(allRoute);
router, }
store, if (allRoute && allRoute.length) {
render: h => { let addRoute = formatRouteLink(allRoute);
let routes = [...constantRouterMap]; for (let index = 0; index < addRoute.length; index++) {
let allRoute = store.getters.asyncRoutes; const element = addRoute[index];
if (typeof routeFilter === 'function') { if (element.children) {
allRoute = routeFilter(allRoute); routes = routes.concat(element.children);
}
if (allRoute && allRoute.length) {
let addRoute = formatRouteLink(allRoute);
for (let index = 0; index < addRoute.length; index++) {
const element = addRoute[index];
if (element.children) {
routes = routes.concat(element.children);
}
} }
} }
return <App route={routes} allRoutes={allRoute} />; }
}, return <App route={routes} allRoutes={allRoute} />;
}); },
return app; });
} return app;
} };
const systemShell = new SystemShell(); createBaseFetch = createBaseFetch;
window.$$SystemShell = systemShell; }
return systemShell; export default new SystemShell();
};
export default {
createBaseFetch,
Api: fetch,
createSystem,
};
import * as main from '../utils/index';
import * as auth from '../utils/auth';
import downloadUrl from '../utils/download';
import { getYourIP } from '../utils/getIp';
import * as validate from '../utils/validate';
export default {
...main,
auth,
downloadFiles: downloadUrl,
getIp: getYourIP,
validate,
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment