Przeglądaj źródła

fix #2193 width modification needs to trigger resize

陈帅 7 lat temu
rodzic
commit
555d8984d6
1 zmienionych plików z 5 dodań i 1 usunięć
  1. 5 1
      src/models/setting.js

+ 5 - 1
src/models/setting.js

@@ -33,6 +33,7 @@ const updateTheme = primaryColor => {
     }, 200);
   }
   if (!lessNodesAppended) {
+    // insert less.js and color.less
     const lessStyleNode = document.createElement('link');
     const lessConfigNode = document.createElement('script');
     const lessScriptNode = document.createElement('script');
@@ -106,10 +107,13 @@ export default {
           urlParams.searchParams.set(key, value);
         }
       });
-      const { primaryColor, colorWeak } = payload;
+      const { primaryColor, colorWeak, contentWidth } = payload;
       if (state.primaryColor !== primaryColor) {
         updateTheme(primaryColor);
       }
+      if (state.contentWidth !== contentWidth) {
+        window.dispatchEvent ? window.dispatchEvent(new Event('resize')) : null;
+      }
       updateColorWeak(colorWeak);
       window.history.replaceState(null, 'setting', urlParams.href);
       return {