From 4414a25b7703cb03c99f1f8e5916f491de7bb634 Mon Sep 17 00:00:00 2001 From: Pan Date: Thu, 14 Mar 2019 13:48:57 +0800 Subject: [PATCH] add tags-view control --- src/components/RightPanel/index.vue | 8 +-- src/layout/Layout.vue | 16 +++--- src/layout/components/AppMain.vue | 9 +++- src/layout/components/Navbar.vue | 8 +++ src/layout/components/Settings/index.vue | 68 ++++++++++++++++++++++++ src/layout/components/index.js | 1 + src/settings.js | 22 ++++++++ src/store/index.js | 2 + src/store/modules/app.js | 3 +- src/store/modules/settings.js | 23 ++++++++ 10 files changed, 144 insertions(+), 16 deletions(-) create mode 100644 src/layout/components/Settings/index.vue create mode 100644 src/settings.js create mode 100644 src/store/modules/settings.js diff --git a/src/components/RightPanel/index.vue b/src/components/RightPanel/index.vue index 80ef8709..98d27df3 100644 --- a/src/components/RightPanel/index.vue +++ b/src/components/RightPanel/index.vue @@ -18,10 +18,6 @@ import { addClass, removeClass } from '@/utils' export default { name: 'RightPanel', props: { - value: { - default: false, - type: Boolean - }, clickNotClose: { default: false, type: Boolean @@ -29,7 +25,7 @@ export default { }, data() { return { - show: false + show: true } }, watch: { @@ -52,7 +48,7 @@ export default { window.addEventListener('click', this.closeSidebar) }, closeSidebar(evt) { - const parent = evt.target.closest('.rightPanel') + const parent = evt.target.closest('.rightPanel-container') if (!parent) { this.show = false window.removeEventListener('click', this.closeSidebar) diff --git a/src/layout/Layout.vue b/src/layout/Layout.vue index 7c5d753b..c0befd4b 100644 --- a/src/layout/Layout.vue +++ b/src/layout/Layout.vue @@ -2,18 +2,20 @@
-
+
- + - + + +
diff --git a/src/layout/components/index.js b/src/layout/components/index.js index 5262e113..e9f79ddd 100644 --- a/src/layout/components/index.js +++ b/src/layout/components/index.js @@ -2,3 +2,4 @@ export { default as Navbar } from './Navbar' export { default as Sidebar } from './Sidebar/index.vue' export { default as TagsView } from './TagsView/index.vue' export { default as AppMain } from './AppMain' +export { default as Settings } from './Settings' diff --git a/src/settings.js b/src/settings.js new file mode 100644 index 00000000..27e7e65a --- /dev/null +++ b/src/settings.js @@ -0,0 +1,22 @@ +export default { + + /** + * @type {boolean} true | false + * @description Whether show the settings right-panel + */ + showSettings: true, + + /** + * @type {boolean} true | false + * @description Whether need tagsView + */ + tagsView: true, + + /** + * @type {string | array} 'production' | ['production','development'] + * @description Need show err logs component. + * The default is only used in the production env + * If you want to use it in dev, you can pass ['production','development'] + */ + errorLog: 'production' +} diff --git a/src/store/index.js b/src/store/index.js index 24778fad..4842ea7e 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -4,6 +4,7 @@ import app from './modules/app' import errorLog from './modules/errorLog' import permission from './modules/permission' import tagsView from './modules/tagsView' +import settings from './modules/settings' import user from './modules/user' import getters from './getters' @@ -15,6 +16,7 @@ const store = new Vuex.Store({ errorLog, permission, tagsView, + settings, user }, getters diff --git a/src/store/modules/app.js b/src/store/modules/app.js index 4565d9db..fba4b05c 100644 --- a/src/store/modules/app.js +++ b/src/store/modules/app.js @@ -8,8 +8,7 @@ const app = { }, device: 'desktop', language: Cookies.get('language') || 'en', - size: Cookies.get('size') || 'medium', - showSettings: true + size: Cookies.get('size') || 'medium' }, mutations: { TOGGLE_SIDEBAR: state => { diff --git a/src/store/modules/settings.js b/src/store/modules/settings.js new file mode 100644 index 00000000..d47505c4 --- /dev/null +++ b/src/store/modules/settings.js @@ -0,0 +1,23 @@ +import defaultSettings from '@/settings' +const { showSettings, tagsView } = defaultSettings + +const settings = { + state: { + showSettings: showSettings, + tagsView: tagsView + }, + mutations: { + CHANGE_SETTING: (state, { key, value }) => { + if (state.hasOwnProperty(key)) { + state[key] = value + } + } + }, + actions: { + changeSetting({ commit }, data) { + commit('CHANGE_SETTING', data) + } + } +} + +export default settings