2021-07-10 19:35:06 +08:00
|
|
|
/*
|
|
|
|
* @Author: yehuozhili
|
|
|
|
* @Date: 2021-05-15 12:49:28
|
|
|
|
* @LastEditors: yehuozhili
|
2021-08-11 17:16:22 +08:00
|
|
|
* @LastEditTime: 2021-08-11 16:26:46
|
2021-07-10 19:35:06 +08:00
|
|
|
* @FilePath: \dooringx\packages\dooringx-example\src\pages\index.tsx
|
|
|
|
*/
|
|
|
|
import {
|
|
|
|
RightConfig,
|
|
|
|
Container,
|
|
|
|
useStoreState,
|
|
|
|
innerContainerDragUp,
|
|
|
|
LeftConfig,
|
|
|
|
ContainerWrapper,
|
|
|
|
Control,
|
|
|
|
} from 'dooringx-lib';
|
2021-08-12 11:06:46 +08:00
|
|
|
import { InsertRowBelowOutlined, CalendarOutlined } from '@ant-design/icons';
|
2021-07-10 19:35:06 +08:00
|
|
|
import { useContext } from 'react';
|
|
|
|
import { configContext } from '@/layouts';
|
|
|
|
import { useCallback } from 'react';
|
|
|
|
import { PREVIEWSTATE } from '@/constant';
|
2021-08-11 19:52:28 +08:00
|
|
|
import { Button, Popover } from 'antd';
|
2021-07-10 19:35:06 +08:00
|
|
|
export const HeaderHeight = '40px';
|
2021-08-11 19:52:28 +08:00
|
|
|
const footerConfig = function () {
|
|
|
|
return (
|
|
|
|
<>
|
2021-08-12 11:06:46 +08:00
|
|
|
<Popover content={'日历'} title={null} trigger="hover">
|
|
|
|
<Button type="text" icon={<CalendarOutlined />}></Button>
|
2021-08-11 19:52:28 +08:00
|
|
|
</Popover>
|
|
|
|
<Popover content={'快捷键'} title={null} trigger="hover">
|
|
|
|
<Button type="text" icon={<InsertRowBelowOutlined />}></Button>
|
|
|
|
</Popover>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
2021-07-10 19:35:06 +08:00
|
|
|
|
|
|
|
export default function IndexPage() {
|
|
|
|
const config = useContext(configContext);
|
|
|
|
|
|
|
|
const everyFn = () => {};
|
|
|
|
|
|
|
|
const subscribeFn = useCallback(() => {
|
|
|
|
localStorage.setItem(PREVIEWSTATE, JSON.stringify(config.getStore().getData()));
|
|
|
|
}, [config]);
|
|
|
|
|
|
|
|
const [state] = useStoreState(config, subscribeFn, everyFn);
|
|
|
|
return (
|
2021-07-12 21:01:11 +08:00
|
|
|
<div {...innerContainerDragUp(config)}>
|
2021-07-10 19:35:06 +08:00
|
|
|
<div style={{ height: HeaderHeight }}>
|
2021-08-11 19:52:28 +08:00
|
|
|
<Button
|
2021-07-10 19:35:06 +08:00
|
|
|
onClick={() => {
|
|
|
|
window.open('/iframe');
|
|
|
|
}}
|
|
|
|
>
|
2021-08-11 19:52:28 +08:00
|
|
|
iframe 预览
|
|
|
|
</Button>
|
|
|
|
<Button
|
2021-07-10 19:35:06 +08:00
|
|
|
onClick={() => {
|
|
|
|
window.open('/preview');
|
|
|
|
}}
|
|
|
|
>
|
2021-08-11 19:52:28 +08:00
|
|
|
普通预览
|
|
|
|
</Button>
|
2021-07-10 19:35:06 +08:00
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
display: 'flex',
|
|
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'center',
|
|
|
|
height: `calc(100vh - ${HeaderHeight})`,
|
|
|
|
width: '100vw',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<div style={{ height: '100%' }}>
|
2021-08-12 14:21:39 +08:00
|
|
|
<LeftConfig
|
|
|
|
mode="vertical"
|
|
|
|
showName={true}
|
|
|
|
footerConfig={footerConfig()}
|
|
|
|
config={config}
|
|
|
|
></LeftConfig>
|
2021-07-10 19:35:06 +08:00
|
|
|
</div>
|
|
|
|
|
2021-07-12 21:01:11 +08:00
|
|
|
<ContainerWrapper config={config}>
|
2021-07-10 19:35:06 +08:00
|
|
|
<>
|
|
|
|
<Control
|
|
|
|
config={config}
|
2021-08-11 17:16:22 +08:00
|
|
|
style={{ position: 'fixed', bottom: '160px', right: '450px', zIndex: 100 }}
|
2021-07-10 19:35:06 +08:00
|
|
|
></Control>
|
|
|
|
<Container state={state} config={config} context="edit"></Container>
|
|
|
|
</>
|
|
|
|
</ContainerWrapper>
|
|
|
|
<div className="rightrender" style={{ height: '100%' }}>
|
|
|
|
<RightConfig state={state} config={config}></RightConfig>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|