Files
dooring/packages/dooringx-example/src/pages/index.tsx

84 lines
1.9 KiB
TypeScript
Raw Normal View History

2021-07-10 19:35:06 +08:00
/*
* @Author: yehuozhili
* @Date: 2021-05-15 12:49:28
* @LastEditors: yehuozhili
2021-07-17 22:15:30 +08:00
* @LastEditTime: 2021-07-17 10:12:53
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,
2021-07-17 22:15:30 +08:00
postMessage,
2021-07-10 19:35:06 +08:00
} from 'dooringx-lib';
import { useContext } from 'react';
import { configContext } from '@/layouts';
import { useCallback } from 'react';
import { PREVIEWSTATE } from '@/constant';
export const HeaderHeight = '40px';
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 }}>
head
<button
onClick={() => {
window.open('/iframe');
}}
>
go preview
</button>
<button
onClick={() => {
window.open('/preview');
}}
>
go preview
</button>
</div>
<div
style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
height: `calc(100vh - ${HeaderHeight})`,
width: '100vw',
}}
>
<div style={{ height: '100%' }}>
<LeftConfig config={config}></LeftConfig>
</div>
2021-07-12 21:01:11 +08:00
<ContainerWrapper config={config}>
2021-07-10 19:35:06 +08:00
<>
<Control
config={config}
2021-07-12 21:01:11 +08:00
style={{ position: 'fixed', bottom: '60px', 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>
);
}