重构平台判断代码

This commit is contained in:
hanhh
2021-08-02 15:19:20 +08:00
parent 5d846beabd
commit dc5b4de5fa
9 changed files with 250 additions and 252 deletions
+3 -25
View File
@@ -10,6 +10,7 @@ import {
setFetchMethod,
} from 'darkreader';
import { history } from 'umi';
import { useCtx } from '@/utils/hooks';
const optionsWithDisabled = [
{ label: '亮色', value: 'light' },
@@ -18,13 +19,11 @@ const optionsWithDisabled = [
];
const Password = () => {
const [width, setWidth] = useState('100%');
const [marginLeft, setMarginLeft] = useState(0);
const [marginTop, setMarginTop] = useState(-72);
const [value, setValue] = useState('');
const [loading, setLoading] = useState(true);
const defaultDarken = localStorage.getItem('qinglong_dark_theme') || 'auto';
const [theme, setTheme] = useState(defaultDarken);
const { headerStyle, isPhone } = useCtx();
const handleOk = (values: any) => {
request
@@ -54,18 +53,6 @@ const Password = () => {
});
};
useEffect(() => {
if (document.body.clientWidth < 768) {
setWidth('auto');
setMarginLeft(0);
setMarginTop(0);
} else {
setWidth('100%');
setMarginLeft(0);
setMarginTop(-72);
}
}, []);
useEffect(() => {
setFetchMethod(window.fetch);
if (theme === 'dark') {
@@ -90,16 +77,7 @@ const Password = () => {
className="ql-container-wrapper"
title="系统设置"
header={{
style: {
padding: '4px 16px 4px 15px',
position: 'sticky',
top: 0,
left: 0,
zIndex: 20,
marginTop,
width,
marginLeft,
},
style: headerStyle,
}}
>
<Tabs