-
+
+
+
@@ -30,6 +32,11 @@ export default {
show: false
}
},
+ computed: {
+ theme() {
+ return this.$store.state.settings.theme
+ }
+ },
watch: {
show(value) {
if (value && !this.clickNotClose) {
@@ -130,7 +137,16 @@ export default {
height: 48px;
pointer-events: auto;
z-index: 0;
+ cursor: pointer;
+ pointer-events: auto;
font-size: 24px;
text-align: center;
+ color: #fff;
+ line-height: 48px;
+
+ i {
+ font-size: 24px;
+ line-height: 48px;
+ }
}
diff --git a/src/components/ThemePicker/index.vue b/src/components/ThemePicker/index.vue
index 42eba3fb..0a556248 100644
--- a/src/components/ThemePicker/index.vue
+++ b/src/components/ThemePicker/index.vue
@@ -1,7 +1,7 @@
@@ -11,17 +11,18 @@
const version = require('element-ui/package.json').version // element-ui version from node_modules
const ORIGINAL_THEME = '#409EFF' // default color
+import defaultSettings from '@/settings'
export default {
data() {
return {
chalk: '', // content of theme-chalk css
- theme: ORIGINAL_THEME
+ theme: defaultSettings.theme
}
},
watch: {
async theme(val) {
- const oldVal = this.theme
+ const oldVal = this.chalk ? this.theme : ORIGINAL_THEME
if (typeof val !== 'string') return
const themeCluster = this.getThemeCluster(val.replace('#', ''))
const originalCluster = this.getThemeCluster(oldVal.replace('#', ''))
@@ -70,6 +71,8 @@ export default {
style.innerText = this.updateStyle(innerText, originalCluster, themeCluster)
})
+ this.$emit('change', val)
+
$message.close()
}
},
diff --git a/src/layout/components/Settings/index.vue b/src/layout/components/Settings/index.vue
index 1c07866f..19e4e68b 100644
--- a/src/layout/components/Settings/index.vue
+++ b/src/layout/components/Settings/index.vue
@@ -5,7 +5,7 @@
{{ $t('settings.theme') }}
-
+
@@ -69,6 +69,14 @@ export default {
})
}
}
+ },
+ methods: {
+ themeChange(val) {
+ this.$store.dispatch('settings/changeSetting', {
+ key: 'theme',
+ value: val
+ })
+ }
}
}
diff --git a/src/settings.js b/src/settings.js
index 6bfa9726..a146e5a0 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -1,4 +1,7 @@
+import variables from '@/styles/element-variables.scss'
+
export default {
+ theme: variables.theme,
/**
* @type {boolean} true | false
* @description Whether show the settings right-panel
diff --git a/src/store/modules/settings.js b/src/store/modules/settings.js
index 0107e9c6..8522a5aa 100644
--- a/src/store/modules/settings.js
+++ b/src/store/modules/settings.js
@@ -1,7 +1,8 @@
import defaultSettings from '@/settings'
-const { showSettings, tagsView, fixedHeader, sidebarLogo } = defaultSettings
+const { showSettings, tagsView, fixedHeader, sidebarLogo, theme } = defaultSettings
const state = {
+ theme: theme,
showSettings: showSettings,
tagsView: tagsView,
fixedHeader: fixedHeader,
diff --git a/src/styles/element-variables.scss b/src/styles/element-variables.scss
index a8fab287..30a0e6bc 100644
--- a/src/styles/element-variables.scss
+++ b/src/styles/element-variables.scss
@@ -23,3 +23,9 @@ $--table-border:1px solid#dfe6ec;
$--font-path: '~element-ui/lib/theme-chalk/fonts';
@import "~element-ui/packages/theme-chalk/src/index";
+
+// the :export directive is the magic sauce for webpack
+// https://www.bluematador.com/blog/how-to-share-variables-between-js-and-sass
+:export {
+ theme: $--color-primary;
+}