修复移动端100vh兼容性

This commit is contained in:
whyour 2021-05-11 19:37:37 +08:00
parent d9db5442d3
commit 49a3662788
12 changed files with 45 additions and 40 deletions

View File

@ -71,6 +71,7 @@
"typescript": "^4.1.2", "typescript": "^4.1.2",
"umi": "^3.3.9", "umi": "^3.3.9",
"umi-request": "^1.3.5", "umi-request": "^1.3.5",
"vh-check": "^2.0.5",
"webpack": "^5.28.0", "webpack": "^5.28.0",
"yorkie": "^2.0.0" "yorkie": "^2.0.0"
} }

View File

@ -6,10 +6,13 @@ body {
@import '~codemirror/lib/codemirror.css'; @import '~codemirror/lib/codemirror.css';
.code-mirror-wrapper .CodeMirror { .ql-container-wrapper {
position: absolute; .CodeMirror {
height: calc(100vh - 128px); position: absolute;
width: calc(100% - 32px); height: calc(100vh - 128px);
height: calc(100vh - var(--vh-offset, 0px) - 128px);
width: calc(100% - 32px);
}
} }
.ant-pro-grid-content.wide { .ant-pro-grid-content.wide {
@ -18,6 +21,7 @@ body {
.ant-pro-page-container-children-content { .ant-pro-page-container-children-content {
overflow: auto; overflow: auto;
height: calc(100vh - 96px); height: calc(100vh - 96px);
height: calc(100vh - var(--vh-offset, 0px) - 96px);
background-color: #fff; background-color: #fff;
padding: 16px; padding: 16px;
} }
@ -29,13 +33,30 @@ body {
} }
} }
.log-select {
width: 300px;
}
@media (max-width: 768px) { @media (max-width: 768px) {
.ant-pro-grid-content.wide { .ant-pro-grid-content.wide {
.ant-pro-page-container-children-content { .ant-pro-page-container-children-content {
height: calc(100vh - 144px); height: calc(100vh - 144px);
height: calc(100vh - var(--vh-offset, 0px) - 144px);
} }
} }
.code-mirror-wrapper .CodeMirror { .ql-container-wrapper {
height: calc(100vh - 176px); &.crontab-wrapper {
.ant-pro-grid-content.wide .ant-pro-page-container-children-content {
height: calc(100vh - 184px);
height: calc(100vh - var(--vh-offset, 0px) - 184px);
}
}
.CodeMirror {
height: calc(100vh - 176px);
height: calc(100vh - var(--vh-offset, 0px) - 176px);
}
}
.log-select {
width: 200px;
} }
} }

View File

@ -13,6 +13,7 @@ import config from '@/utils/config';
import 'codemirror/mode/shell/shell.js'; import 'codemirror/mode/shell/shell.js';
import { request } from '@/utils/http'; import { request } from '@/utils/http';
import './index.less'; import './index.less';
import vhCheck from 'vh-check';
export default function (props: any) { export default function (props: any) {
const logout = () => { const logout = () => {
@ -27,6 +28,7 @@ export default function (props: any) {
if (!isAuth) { if (!isAuth) {
history.push('/login'); history.push('/login');
} }
vhCheck();
}, []); }, []);
useEffect(() => { useEffect(() => {

View File

@ -49,7 +49,7 @@ const Config = () => {
return ( return (
<PageContainer <PageContainer
className="code-mirror-wrapper" className="ql-container-wrapper"
title="config.sh" title="config.sh"
extra={[ extra={[
<Button key="1" type="primary" onClick={updateConfig}> <Button key="1" type="primary" onClick={updateConfig}>
@ -68,9 +68,6 @@ const Config = () => {
marginLeft, marginLeft,
}, },
}} }}
style={{
height: '100vh',
}}
> >
<CodeMirror <CodeMirror
value={value} value={value}

View File

@ -450,9 +450,6 @@ const Config = () => {
marginLeft, marginLeft,
}, },
}} }}
style={{
height: '100vh',
}}
> >
<DndProvider backend={HTML5Backend}> <DndProvider backend={HTML5Backend}>
<Table <Table

View File

@ -537,7 +537,7 @@ const Crontab = () => {
return ( return (
<PageContainer <PageContainer
className="code-mirror-wrapper" className="ql-container-wrapper crontab-wrapper"
title="定时任务" title="定时任务"
extra={[ extra={[
<Search <Search
@ -563,9 +563,6 @@ const Crontab = () => {
marginLeft, marginLeft,
}, },
}} }}
style={{
height: '100vh',
}}
> >
{selectedRowIds.length > 0 && ( {selectedRowIds.length > 0 && (
<div style={{ marginBottom: 16 }}> <div style={{ marginBottom: 16 }}>

View File

@ -1,12 +1,13 @@
.d2h-files-diff { .d2h-files-diff {
height: calc(100vh - 130px); height: calc(100vh - 130px);
overflow: auto; height: calc(100vh - var(--vh-offset, 0px) - 130px);
overflow: auto;
} }
.d2h-code-side-linenumber { .d2h-code-side-linenumber {
position: relative; position: relative;
} }
.d2h-code-side-line { .d2h-code-side-line {
padding: 0 0.5em; padding: 0 0.5em;
} }

View File

@ -46,7 +46,7 @@ const Crontab = () => {
return ( return (
<PageContainer <PageContainer
className="code-mirror-wrapper" className="ql-container-wrapper"
title="对比工具" title="对比工具"
loading={loading} loading={loading}
header={{ header={{
@ -61,9 +61,6 @@ const Crontab = () => {
marginLeft, marginLeft,
}, },
}} }}
style={{
height: '100vh',
}}
> >
<ReactDiffViewer <ReactDiffViewer
styles={{ styles={{

View File

@ -49,7 +49,7 @@ const Crontab = () => {
return ( return (
<PageContainer <PageContainer
className="code-mirror-wrapper" className="ql-container-wrapper"
title="extra.sh" title="extra.sh"
extra={[ extra={[
<Button key="1" type="primary" onClick={updateConfig}> <Button key="1" type="primary" onClick={updateConfig}>
@ -68,9 +68,6 @@ const Crontab = () => {
marginLeft, marginLeft,
}, },
}} }}
style={{
height: '100vh',
}}
> >
<CodeMirror <CodeMirror
value={value} value={value}

View File

@ -66,11 +66,11 @@ const Log = () => {
return ( return (
<PageContainer <PageContainer
className="code-mirror-wrapper" className="ql-container-wrapper"
title={title} title={title}
extra={[ extra={[
<TreeSelect <TreeSelect
style={{ width: 280 }} className="log-select"
value={select} value={select}
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }} dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
treeData={data} treeData={data}
@ -92,9 +92,6 @@ const Log = () => {
marginLeft, marginLeft,
}, },
}} }}
style={{
height: '100vh',
}}
> >
<CodeMirror <CodeMirror
value={value} value={value}

View File

@ -4,6 +4,7 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: 100vh; height: 100vh;
height: calc(100vh - var(--vh-offset, 0px));
overflow: auto; overflow: auto;
background: @layout-body-background; background: @layout-body-background;
} }

View File

@ -87,7 +87,7 @@ const Password = () => {
return ( return (
<PageContainer <PageContainer
className="code-mirror-wrapper" className="ql-container-wrapper"
title="系统设置" title="系统设置"
header={{ header={{
style: { style: {
@ -101,14 +101,11 @@ const Password = () => {
marginLeft, marginLeft,
}, },
}} }}
style={{
height: '100vh',
}}
> >
<Tabs <Tabs
defaultActiveKey="person" defaultActiveKey="person"
tabPosition="left" tabPosition="left"
style={{ height: 'calc(100vh - 128px)' }} style={{ height: 'calc(100vh - var(--vh-offset, 0px) - 128px)' }}
> >
<Tabs.TabPane tab="个人设置" key="person"> <Tabs.TabPane tab="个人设置" key="person">
<Form onFinish={handleOk} layout="vertical"> <Form onFinish={handleOk} layout="vertical">