From fd550545afd6b03d0d8d3785cea22488bffb24f0 Mon Sep 17 00:00:00 2001 From: Pan Date: Wed, 13 Mar 2019 18:23:06 +0800 Subject: [PATCH 1/4] init right-panel --- src/components/RightPanel/index.vue | 141 ++++++++++++++++++++++++++++ src/layout/Layout.vue | 15 +-- src/store/modules/app.js | 3 +- src/utils/index.js | 13 +++ 4 files changed, 165 insertions(+), 7 deletions(-) create mode 100644 src/components/RightPanel/index.vue diff --git a/src/components/RightPanel/index.vue b/src/components/RightPanel/index.vue new file mode 100644 index 00000000000..80ef8709b9f --- /dev/null +++ b/src/components/RightPanel/index.vue @@ -0,0 +1,141 @@ + + + + + + + diff --git a/src/layout/Layout.vue b/src/layout/Layout.vue index 4d0eaa2b5cb..7c5d753bead 100644 --- a/src/layout/Layout.vue +++ b/src/layout/Layout.vue @@ -6,17 +6,21 @@ + diff --git a/src/layout/components/index.js b/src/layout/components/index.js index 5262e113398..e9f79ddd7aa 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 00000000000..27e7e65a5a0 --- /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 24778fad11a..4842ea7e43a 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 4565d9dbb55..fba4b05c9d6 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 00000000000..d47505c468f --- /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 From 58663ba0063c8393ed4d30b6f8069d81680d57fd Mon Sep 17 00:00:00 2001 From: Pan Date: Thu, 14 Mar 2019 16:58:27 +0800 Subject: [PATCH 3/4] refine --- src/components/RightPanel/index.vue | 11 +++++++---- src/layout/components/Settings/index.vue | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/RightPanel/index.vue b/src/components/RightPanel/index.vue index 98d27df3ada..dda0083763b 100644 --- a/src/components/RightPanel/index.vue +++ b/src/components/RightPanel/index.vue @@ -2,7 +2,7 @@
-
+
@@ -21,11 +21,15 @@ export default { clickNotClose: { default: false, type: Boolean + }, + buttonTop: { + default: 240, + type: Number } }, data() { return { - show: true + show: false } }, watch: { @@ -48,7 +52,7 @@ export default { window.addEventListener('click', this.closeSidebar) }, closeSidebar(evt) { - const parent = evt.target.closest('.rightPanel-container') + const parent = evt.target.closest('.rightPanel') if (!parent) { this.show = false window.removeEventListener('click', this.closeSidebar) @@ -118,7 +122,6 @@ export default { position: absolute; left: -48px; border-radius: 4px 0 0 4px !important; - top: 240px; width: 48px; height: 48px; background: #1890ff; diff --git a/src/layout/components/Settings/index.vue b/src/layout/components/Settings/index.vue index 65a5da9b7b8..213f1189e68 100644 --- a/src/layout/components/Settings/index.vue +++ b/src/layout/components/Settings/index.vue @@ -10,10 +10,10 @@
-
+
From b0ddd295b0549077018ebffea1aaa6d7775514b9 Mon Sep 17 00:00:00 2001 From: Pan Date: Thu, 14 Mar 2019 17:10:42 +0800 Subject: [PATCH 4/4] refine css --- src/components/RightPanel/index.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/RightPanel/index.vue b/src/components/RightPanel/index.vue index dda0083763b..77a9d0d9bce 100644 --- a/src/components/RightPanel/index.vue +++ b/src/components/RightPanel/index.vue @@ -78,7 +78,7 @@ export default {