handleControlItemClick(command)">
diff --git a/src/layout/header-aside/layout.vue b/src/layout/header-aside/layout.vue
index 3a15413c..b90f977a 100644
--- a/src/layout/header-aside/layout.vue
+++ b/src/layout/header-aside/layout.vue
@@ -29,6 +29,7 @@
+
@@ -92,6 +93,7 @@ export default {
'd2-tabs': () => import('./components/tabs'),
'd2-header-fullscreen': () => import('./components/header-fullscreen'),
'd2-header-search': () => import('./components/header-search'),
+ 'd2-header-size': () => import('./components/header-size'),
'd2-header-theme': () => import('./components/header-theme'),
'd2-header-user': () => import('./components/header-user'),
'd2-header-error-log': () => import('./components/header-error-log')
@@ -106,12 +108,12 @@ export default {
},
computed: {
...mapState('d2admin', {
+ keepAlive: state => state.page.keepAlive,
grayActive: state => state.gray.active,
transitionActive: state => state.transition.active,
asideCollapse: state => state.menu.asideCollapse
}),
...mapGetters('d2admin', {
- keepAlive: 'page/keepAlive',
themeActiveSetting: 'theme/activeSetting'
}),
/**
diff --git a/src/pages/login/page.vue b/src/pages/login/page.vue
index c7b46bef..c0a08c96 100644
--- a/src/pages/login/page.vue
+++ b/src/pages/login/page.vue
@@ -9,7 +9,7 @@
-
+
diff --git a/src/plugin/d2admin/index.js b/src/plugin/d2admin/index.js
index c27d7f42..6af7047b 100644
--- a/src/plugin/d2admin/index.js
+++ b/src/plugin/d2admin/index.js
@@ -3,6 +3,8 @@ import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// flex 布局库
import 'flex.css'
+// store
+import store from '@/store/index'
// 组件
import '@/components'
// svg 图标
@@ -15,9 +17,19 @@ import pluginLog from '@/plugin/log'
import pluginOpen from '@/plugin/open'
export default {
- install (Vue, options) {
+ async install (Vue, options) {
+ // 获得用户设置的全局尺寸
+ const size = await store.dispatch('d2admin/db/get', {
+ dbName: 'sys',
+ path: 'size.value',
+ defaultValue: '',
+ user: true
+ })
+ console.log('size: ', size)
// Element
- Vue.use(ElementUI)
+ Vue.use(ElementUI, {
+ size
+ })
// 插件
Vue.use(pluginError)
Vue.use(pluginExport)
diff --git a/src/store/modules/d2admin/index.js b/src/store/modules/d2admin/index.js
index 2cc2fbc3..3b844113 100644
--- a/src/store/modules/d2admin/index.js
+++ b/src/store/modules/d2admin/index.js
@@ -11,6 +11,7 @@ import gray from './modules/gray'
import page from './modules/page'
import transition from './modules/transition'
import search from './modules/search'
+import size from './modules/size'
export default {
namespaced: true,
@@ -27,6 +28,7 @@ export default {
gray,
page,
transition,
- search
+ search,
+ size
}
}
diff --git a/src/store/modules/d2admin/modules/account.js b/src/store/modules/d2admin/modules/account.js
index 9aab7091..78569bd9 100644
--- a/src/store/modules/d2admin/modules/account.js
+++ b/src/store/modules/d2admin/modules/account.js
@@ -108,8 +108,10 @@ export default {
this.commit('d2admin/transition/load')
// DB -> store 持久化数据加载上次退出时的多页列表
this.commit('d2admin/page/openedLoad')
- // DB -> store 持久化数据加载这个用户之前设置的侧边栏折叠状态
+ // DB -> store 持久化数据加载侧边栏折叠状态
this.commit('d2admin/menu/asideCollapseLoad')
+ // DB -> store 持久化数据加载全局尺寸
+ this.commit('d2admin/size/load')
}
}
}
diff --git a/src/store/modules/d2admin/modules/page.js b/src/store/modules/d2admin/modules/page.js
index 8d88d517..c2f51013 100644
--- a/src/store/modules/d2admin/modules/page.js
+++ b/src/store/modules/d2admin/modules/page.js
@@ -9,15 +9,18 @@ export default {
// 当前显示的多页面列表
opened: setting.page.opened,
// 当前页面
- current: ''
+ current: '',
+ // 需要缓存的页面 name
+ keepAlive: []
},
- getters: {
+ mutations: {
/**
- * @description 从当前所有打开的多标签页里返回需要缓存的页面 name
- * @param {*} state vuex state
+ * @class keepAlive
+ * @description 从已经打开的页面记录中更新需要缓存的页面记录
+ * @param {Object} state vuex state
*/
- keepAlive (state) {
- return state.opened.filter(item => {
+ updateKeepAliveFromOpened (state) {
+ state.keepAlive = state.opened.filter(item => {
if (item.meta) {
if (item.meta.notCache) {
return false
@@ -25,9 +28,7 @@ export default {
}
return true
}).map(e => e.name)
- }
- },
- mutations: {
+ },
/**
* @class current
* @description 打开一个新的页面
diff --git a/src/store/modules/d2admin/modules/size.js b/src/store/modules/d2admin/modules/size.js
new file mode 100644
index 00000000..b500e033
--- /dev/null
+++ b/src/store/modules/d2admin/modules/size.js
@@ -0,0 +1,38 @@
+export default {
+ namespaced: true,
+ state: {
+ // 尺寸
+ value: '' // medium small mini
+ },
+ mutations: {
+ /**
+ * @description 设置尺寸
+ * @param {Object} state vuex state
+ * @param {String} size 尺寸
+ */
+ set (state, size) {
+ // store 赋值
+ state.value = size
+ // 持久化
+ this.dispatch('d2admin/db/set', {
+ dbName: 'sys',
+ path: 'size.value',
+ value: state.value,
+ user: true
+ })
+ },
+ /**
+ * @description 从持久化数据读取尺寸设置
+ * @param {Object} state vuex state
+ */
+ async load (state) {
+ // store 赋值
+ state.value = await this.dispatch('d2admin/db/get', {
+ dbName: 'sys',
+ path: 'size.value',
+ defaultValue: 'default',
+ user: true
+ })
+ }
+ }
+}