valentichu 1 年之前
父節點
當前提交
3a329a8ca6
共有 3 個文件被更改,包括 16 次插入5 次删除
  1. 0 0
      lib/index.js
  2. 1 1
      src/pages/Alarm/components/components/AlarmDetail/index.jsx
  3. 15 4
      src/utils/theme/index.js

File diff suppressed because it is too large
+ 0 - 0
lib/index.js


+ 1 - 1
src/pages/Alarm/components/components/AlarmDetail/index.jsx

@@ -455,7 +455,7 @@ const Index = (props) => {
               format="YYYY-MM-DD HH:mm"
               value={range}
               onChange={setRange}
-              style={{ width: 360 }}
+              style={{ width: 360, zIndex: 99999 }}
               presets={rangePresets}
             />
           </div>

+ 15 - 4
src/utils/theme/index.js

@@ -181,8 +181,19 @@ const themeKeys = (themeKey) => {
 }
 
 const useTheme = () => {
-  // const [theme] = useThemeKey();
-  const [themeName] = useLocalStorageThemeName();
+  const [themeName, setThemeName] = useState(
+    localStorage.getItem("--dt-theme")
+  );
+  useEffect(() => {
+    const cb = (e) => {
+      const theme = localStorage.getItem("--dt-theme");
+      setThemeName(theme ?? null);
+    };
+    window.addEventListener("storage", cb);
+    return () => {
+      window.removeEventListener("storage", cb);
+    };
+  }, []);
 
   // useEffect(() => {
   //   changeTheme(theme);
@@ -191,9 +202,9 @@ const useTheme = () => {
 
   useEffect(() => {
     changeTheme(themeName);
-    localStorage.setItem('--dt-theme', themeName);
+    localStorage.setItem("--dt-theme", themeName);
     // console.log(themeName, 'useEffect')
-  }, [themeName])
+  }, [themeName]);
 
   return [themeName];
 };

Some files were not shown because too many files changed in this diff