update 响应式处理

This commit is contained in:
2021-06-25 17:59:09 +08:00
parent 4eace63902
commit fd9665c265
9 changed files with 275 additions and 72 deletions

View File

@@ -33,13 +33,20 @@ export default class index extends Component {
}
render() {
const { allowSiderCollapsed } = this.state
return (
<Layout.Header>
<Container mode="fluid">
<div className="header-actions">
<span className="header-action mr-md" onClick={() => this.onCollapsed()}>
<AntIcon type="menu" />
</span>
{allowSiderCollapsed && (
<span
className="header-action mr-md"
onClick={() => this.onCollapsed()}
>
<AntIcon type="menu" />
</span>
)}
<Logo />
<Search />
</div>

View File

@@ -1,10 +1,9 @@
import React, { Component } from 'react'
import { Spin, Layout } from 'antd'
import { LoadingOutlined } from '@ant-design/icons'
import { api } from 'common/api'
import { cloneDeep, groupBy, findIndex, last } from 'lodash'
import store from 'store'
import { EMPTY_ID } from 'util/global'
import { EMPTY_ID, SIDER_BREAK_POINT } from 'util/global'
import Header from './_layout/header'
import Sider from './_layout/sider'
@@ -83,6 +82,9 @@ export default class index extends Component {
})
})
})
window.addEventListener('resize', this.onResizeSider)
this.onResizeSider()
}
/**
@@ -231,6 +233,13 @@ export default class index extends Component {
})
}
onResizeSider = () => {
dispatch({
type: 'AUTO_TOGGLE_COLLAPSED',
siderCollapsed: window.innerWidth <= SIDER_BREAK_POINT,
})
}
render() {
const { loading, panes, actived } = this.state