feat: 添加Vuex支持

This commit is contained in:
eleven 2020-10-13 15:27:45 +08:00
parent dbd07e40d2
commit ed772bb4d4
2 changed files with 22 additions and 5 deletions

View File

@ -1,10 +1,12 @@
import Vue from 'vue'; import Vue from 'vue';
import VueRouter from 'vue-router'; import VueRouter from 'vue-router';
import Vuex from 'vuex';
import VueI18n from 'vue-i18n'; import VueI18n from 'vue-i18n';
// eslint-disable-next-line // eslint-disable-next-line
import UiWebank from '@webank/fes-ui'; import UiWebank from '@webank/fes-ui';
// eslint-disable-next-line // eslint-disable-next-line
import routerConfig from 'projectRoot/.cache/routeConfig.js'; import routerConfig from 'projectRoot/.cache/routeConfig.js';
import storeConfig from 'projectRoot/src/store/index.js';
// eslint-disable-next-line // eslint-disable-next-line
import commonCompConfig from 'projectRoot/.cache/commonComp.js'; import commonCompConfig from 'projectRoot/.cache/commonComp.js';
import Page from './page'; import Page from './page';
@ -56,7 +58,7 @@ class App {
this.router = null; this.router = null;
this.beforeRouter = null; this.beforeRouter = null;
this.afterRouter = null; this.afterRouter = null;
this.store = null;
this.i18n = null; this.i18n = null;
} }
@ -65,6 +67,7 @@ class App {
// ======================安装插件==================== // ======================安装插件====================
Vue.use(VueRouter); Vue.use(VueRouter);
Vue.use(Vuex);
Vue.use(UiWebank); Vue.use(UiWebank);
Vue.use(VueI18n); Vue.use(VueI18n);
Vue.use(fesComponents); Vue.use(fesComponents);
@ -105,11 +108,13 @@ class App {
run() { run() {
this.creatRouter(); this.creatRouter();
this.creatI18n(); this.creatI18n();
this.createStore();
// eslint-disable-next-line // eslint-disable-next-line
new Vue({ new Vue({
el: '#app', el: '#app',
extends: root, extends: root,
router: this.router, router: this.router,
store: this.store,
i18n: this.i18n i18n: this.i18n
}); });
} }
@ -189,6 +194,10 @@ class App {
this.setDefaultPage(); this.setDefaultPage();
} }
createStore() {
this.store = new Vuex.Store(storeConfig);
}
async getDefaultPage(update) { async getDefaultPage(update) {
// 如果router已初始化通过当前链接来找路由返回当前链接对应的路由 // 如果router已初始化通过当前链接来找路由返回当前链接对应的路由
if (this.router && !update) { if (this.router && !update) {
@ -317,9 +326,9 @@ class App {
} }
} }
util.merge(App.prototype, util.event); util.merge(App.prototype, util.event);
// 暂时去掉package.json引入安全检测不通过 // 暂时去掉package.json引入安全检测不通过
// App.prototype.version = packageConfig.version; // App.prototype.version = packageConfig.version;
App.prototype.engine = 'Vue'; App.prototype.engine = 'Vue';
export default new App(); export default new App();

View File

@ -0,0 +1,8 @@
export default {
state: {},
getters: {},
plugins: [],
modules: {},
mutations: {},
actions: {}
};