From 40f9a15294120e1d07b0ccab4d27380f3a567853 Mon Sep 17 00:00:00 2001 From: Aicirou <2643053021@qq.com> Date: Sat, 16 May 2020 04:13:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0grid=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.js | 5 +- src/store/modules/acrou/modules/view.js | 69 ++++++++++++++ src/views/common/BreadCrumb.vue | 67 +++++++++----- src/views/page/GoList.vue | 33 ++++--- src/views/page/components/grid/index.vue | 113 +++++++++++++++++++++++ 5 files changed, 248 insertions(+), 39 deletions(-) create mode 100644 src/store/modules/acrou/modules/view.js create mode 100644 src/views/page/components/grid/index.vue diff --git a/src/main.js b/src/main.js index 9dede23..8b84ae3 100644 --- a/src/main.js +++ b/src/main.js @@ -24,5 +24,8 @@ new Vue({ router, store, i18n, - render: h => h(App) + render: h => h(App), + mounted() { + this.$store.dispatch('acrou/view/load') + } }).$mount('#app') diff --git a/src/store/modules/acrou/modules/view.js b/src/store/modules/acrou/modules/view.js new file mode 100644 index 0000000..55c6402 --- /dev/null +++ b/src/store/modules/acrou/modules/view.js @@ -0,0 +1,69 @@ +export default { + namespaced: true, + state: { + // 视图模式 + mode: "list", + }, + actions: { + /** + * @description 从持久化数据读取视图模式设置 + * @param {Object} context + */ + load({ state, dispatch, commit }) { + // eslint-disable-next-line no-async-promise-executor + return new Promise(async (resolve) => { + // store 赋值 + state.mode = await dispatch( + "acrou/db/get", + { + dbName: "sys", + path: "view.mode.value", + defaultValue: "list", + user: true, + }, + { root: true } + ); + // 应用 + commit("set", state.mode); + // end + resolve(); + }); + }, + /** + * @description 切换视图模式 + * @param {Object} context + */ + toggle({ state, dispatch, commit }, mode) { + // eslint-disable-next-line no-async-promise-executor + return new Promise(async (resolve) => { + // store 赋值 + state.mode = mode || "list"; + // 持久化 + await dispatch( + "acrou/db/set", + { + dbName: "sys", + path: "view.mode.value", + value: state.mode, + user: true, + }, + { root: true } + ); + // 应用 + commit("set", state.mode); + // end + resolve(); + }); + }, + }, + mutations: { + /** + * @description 设置 store 里的视图模式 + * @param {Object} state state + * @param {Boolean} mode mode + */ + set(state, mode) { + state.mode = mode; + }, + }, +}; diff --git a/src/views/common/BreadCrumb.vue b/src/views/common/BreadCrumb.vue index a0bcecc..44d3b40 100644 --- a/src/views/common/BreadCrumb.vue +++ b/src/views/common/BreadCrumb.vue @@ -8,15 +8,21 @@
@@ -24,12 +30,19 @@
- +
@@ -38,39 +51,43 @@ \ No newline at end of file + diff --git a/src/views/page/GoList.vue b/src/views/page/GoList.vue index aefab76..cf3851a 100644 --- a/src/views/page/GoList.vue +++ b/src/views/page/GoList.vue @@ -1,13 +1,14 @@