Эх сурвалжийг харах

主题自定义预设逻辑

zhuth 6 жил өмнө
parent
commit
84fffd0c7c

+ 5 - 4
kanban-client/app/component/factory.dev.js

@@ -7,7 +7,7 @@ import URL from '../constants/url.dev.json';
 import 'whatwg-fetch';
 import { getThemeConfig, applyTheme } from './theme/applyTheme.js';
 
-import tempdata from '../data/testbar.json';
+import tempdata from '../data/temp.json';
 
 class Factory extends React.Component {
 
@@ -35,9 +35,10 @@ class Factory extends React.Component {
             return (response.json())
         }).then((json) => {
             let theme = json.theme || 'dark';
+            let themeConfig = json.themeConfig || {};
             me.setState({
                 theme: theme,
-                themeConfig: getThemeConfig(theme),
+                themeConfig: getThemeConfig(theme, themeConfig),
             });
             return json;
         }).then((json) => {
@@ -132,8 +133,8 @@ class Factory extends React.Component {
         let { code, index } = this.props;
         if(this.dev == 'local') {
             this.setState({
-                theme: this.theme,
-                themeConfig: getThemeConfig(this.theme),
+                theme: tempdata.theme || 'dark',
+                themeConfig: getThemeConfig(tempdata.theme, tempdata.themeConfig),
                 model: converter(tempdata.data[0]),
             });
             this.refreshNext = setInterval(function () {

+ 2 - 1
kanban-client/app/component/factory.js

@@ -30,9 +30,10 @@ class Factory extends React.Component {
             return (response.json())
         }).then((json) => {
             let theme = json.theme || 'dark';
+            let themeConfig = json.themeConfig || {};
             me.setState({
                 theme: theme,
-                themeConfig: getThemeConfig(theme),
+                themeConfig: getThemeConfig(theme, themeConfig),
             });
             return json;
         }).then((json) => {

+ 13 - 4
kanban-client/app/component/theme/applyTheme.js

@@ -1,17 +1,26 @@
 import themes from './index.js';
 
-function getThemeConfig(themeName) {
+function getThemeConfig(themeName, themeConfig) {
     let theme = themes[themeName];
-    let themeConfig = {};
+    let cfg = {};
     for(let key in theme) {
         let p = theme[key];
         for(let k in p) {
             if(k == 'config') {
-                themeConfig[key] = p[k]
+                let obj = p[k];
+                
+                // 替换自定义配置
+                if(typeof themeConfig == 'object' && themeConfig.hasOwnProperty(key)) {
+                    for(let s in themeConfig[key]) {
+                        obj[s] = themeConfig[key][s];
+                    }
+                }
+
+                cfg[key] = obj;
             }
         }
     }
-    return themeConfig;
+    return cfg;
 }
 
 function applyTheme(themeName) {

+ 4 - 3
kanban-client/app/component/theme/blue.js

@@ -5,7 +5,7 @@ var blue = {
         backgroundSize: '42px 42px'
     },
     title: {
-        padding: '10px 10px 0 10px',
+        padding: '16px 16px 0 16px',
         backgroundColor: 'linear-gradient(to right, #6b73fd, #b195ff)',
         borderWidth: 0,
         borderColor: '#114591',
@@ -14,10 +14,11 @@ var blue = {
         // padding: '10px 0 0 10px'
     },
     items: {
+        background: 'rgba(33, 73, 153, 0.6)',
         border: '1px solid #055CB6',
-        boxShadow: 'inset 0 0 43px 0 rgba(5,92,182,0.62)',
+        boxShadow: 'inset 0 0 43px 0 rgba(79,166,255,0.62)',
         config: {
-            margin: [10, 10]
+            margin: [16, 16]
         }
     },
     table: {