diff --git a/web/README.zh.md b/web/README.zh.md index 30bb6f1..abb750e 100644 --- a/web/README.zh.md +++ b/web/README.zh.md @@ -96,4 +96,45 @@ web/src/api/service.js router > api ``` +### store 例子 +```vue +// store/index.js +import Vue from 'vue' +import Vuex from 'vuex' + +Vue.use(Vuex) + +export default new Vuex.Store({ + state: { + count: 0, + // 其他状态... + }, + mutations: { + increment(state) { + state.count++ + }, + // 其他 mutation 函数... + }, + actions: { + // 可能包含异步操作的 action 函数... + }, + getters: { + getCount: state => state.count, + // 其他 getter 函数... + } +}) +``` +```vue +// 在任何一个 Vue 组件中,你就可以通过 this.$store 访问 Vuex store +// 任意Vue组件内部 +export default { + mounted() { + console.log(this.$store.state.count) // 访问状态 + this.$store.commit('increment') // 提交 mutation 更新状态 + this.$store.dispatch('someAction') // 分发 action + const count = this.$store.getters.getCount // 获取 getter 数据 + } +} +``` + diff --git a/web/src/layout/header-aside/components/menu-side/index.js b/web/src/layout/header-aside/components/menu-side/index.js index 8ce3cbc..3e81717 100644 --- a/web/src/layout/header-aside/components/menu-side/index.js +++ b/web/src/layout/header-aside/components/menu-side/index.js @@ -3,6 +3,9 @@ import menuMixin from '../mixin/menu' import { createMenu } from '../libs/util.menu' import BScroll from 'better-scroll' +/** + * 渲染侧栏菜单 + */ export default { name: 'd2-layout-header-aside-menu-side', mixins: [ diff --git a/web/src/store/modules/d2admin/modules/page.js b/web/src/store/modules/d2admin/modules/page.js index a051450..71d2ffe 100644 --- a/web/src/store/modules/d2admin/modules/page.js +++ b/web/src/store/modules/d2admin/modules/page.js @@ -369,6 +369,7 @@ export default { state.current = fullPath }, /** + * 路由池 * @class pool * @description 保存 pool (候选池) * @param {Object} state state @@ -378,6 +379,7 @@ export default { const pool = [] const push = function (routes) { routes.forEach(route => { + console.log('=========================== app handle router ===========================', route) if (route.children && route.children.length > 0) { push(route.children) } else {