feishin/src/renderer/layouts/default-layout.tsx

63 lines
1.5 KiB
TypeScript
Raw Normal View History

2023-03-28 23:59:51 -07:00
import { lazy } from 'react';
2022-12-19 15:59:14 -08:00
import isElectron from 'is-electron';
import styled from 'styled-components';
2023-03-30 06:44:33 -07:00
import { useWindowSettings, useSettingsStore } from '/@/renderer/store/settings.store';
2023-03-28 23:59:51 -07:00
import { Platform, PlaybackType } from '/@/renderer/types';
import { MainContent } from '/@/renderer/layouts/default-layout/main-content';
import { PlayerBar } from '/@/renderer/layouts/default-layout/player-bar';
2022-12-19 15:59:14 -08:00
if (!isElectron()) {
useSettingsStore.getState().actions.setSettings({
2023-03-30 06:44:33 -07:00
playback: {
...useSettingsStore.getState().playback,
2022-12-19 15:59:14 -08:00
type: PlaybackType.WEB,
},
});
}
2023-03-28 23:59:51 -07:00
const Layout = styled.div<{ windowBarStyle: Platform }>`
2022-12-19 15:59:14 -08:00
display: grid;
grid-template-areas:
2023-03-28 23:59:51 -07:00
'window-bar'
'main-content'
2022-12-19 15:59:14 -08:00
'player';
2023-03-30 04:57:51 -07:00
grid-template-rows: ${(props) =>
props.windowBarStyle !== Platform.WEB
? '30px calc(100vh - 120px) 90px'
: '0px calc(100vh - 90px) 90px'};
2022-12-19 15:59:14 -08:00
grid-template-columns: 1fr;
gap: 0;
height: 100%;
`;
2023-03-28 23:59:51 -07:00
const WindowBar = lazy(() =>
import('/@/renderer/layouts/window-bar').then((module) => ({
default: module.WindowBar,
})),
);
2022-12-19 15:59:14 -08:00
interface DefaultLayoutProps {
shell?: boolean;
}
export const DefaultLayout = ({ shell }: DefaultLayoutProps) => {
2023-03-30 06:44:33 -07:00
const { windowBarStyle } = useWindowSettings();
2022-12-19 15:59:14 -08:00
return (
2023-03-28 23:59:51 -07:00
<>
<Layout
id="default-layout"
windowBarStyle={windowBarStyle}
>
2023-03-28 23:59:51 -07:00
{windowBarStyle !== Platform.WEB && <WindowBar />}
<MainContent shell={shell} />
<PlayerBar />
</Layout>
</>
2022-12-19 15:59:14 -08:00
);
};
DefaultLayout.defaultProps = {
shell: false,
};