Skip to content

Commit

Permalink
fix(desktop): don't use custom titlebar
Browse files Browse the repository at this point in the history
when tauri 2.0 stable is released, we can use the custom titlebar
close #279
  • Loading branch information
drl990114 committed Sep 8, 2023
1 parent 36e2f06 commit 77067f7
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 28 deletions.
12 changes: 6 additions & 6 deletions apps/desktop/src-tauri/src/app/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ pub mod cmd {
.inner_size(1000.0, 600.0)
.min_inner_size(500.0, 500.0);

#[cfg(target_os = "macos")]
{
conf_win = conf_win
.title_bar_style(TitleBarStyle::Overlay)
.hidden_title(true);
}
// #[cfg(target_os = "macos")]
// {
// conf_win = conf_win
// .title_bar_style(TitleBarStyle::Overlay)
// .hidden_title(true);
// }

conf_win.build().unwrap();
});
Expand Down
12 changes: 6 additions & 6 deletions apps/desktop/src-tauri/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ pub fn init(app: &mut App) -> Result<(), Box<dyn std::error::Error>> {
.inner_size(1200.0, 800.0)
.min_inner_size(400.0, 400.0);

#[cfg(target_os = "macos")]
{
main_win = main_win
.title_bar_style(TitleBarStyle::Overlay)
.hidden_title(true);
}
// #[cfg(target_os = "macos")]
// {
// main_win = main_win
// .title_bar_style(TitleBarStyle::Overlay)
// .hidden_title(true);
// }

main_win.build().unwrap();
});
Expand Down
3 changes: 2 additions & 1 deletion apps/desktop/src/components/TitleBar/styled.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { TITLEBAR_HEIGHT } from '@/constants/styled'
import styled from 'styled-components'

const TITLEBAR_HEIGHT = '32px'

export const TitleBarBg = styled.div`
height: ${TITLEBAR_HEIGHT};
background: ${(props) => props.theme.bgColor};
Expand Down
1 change: 0 additions & 1 deletion apps/desktop/src/constants/styled.ts

This file was deleted.

9 changes: 9 additions & 0 deletions apps/desktop/src/layout/PageLayout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import styled from "styled-components"

export const PageLayout = styled.div`
display: flex;
flex-direction: column;
height: 100vh;
width: 100vw;
overflow: hidden;
`
10 changes: 6 additions & 4 deletions apps/desktop/src/router/Root/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { Container } from './styles'
import { AppInfoDialog, SideBar } from '@/components'
import EditorArea from '@/components/EditorArea'
import { useEditorStore } from '@/stores'
import TitleBar, { setTitleBarText } from '@/components/TitleBar'
import { setTitleBarText } from '@/components/TitleBar'
import TableDialog from '@/editorToolBar/TableDialog'
import { useCommandInit } from '@/hooks/useCommandInit'
import { BookMarkDialog } from '@/bookmarks/BookMarkDialog'
import useBookMarksStore from '@/bookmarks/useBookMarksStore'
import { PageLayout } from '@/layout/PageLayout'

function Root() {
const { activeId } = useEditorStore()
Expand All @@ -24,16 +25,17 @@ function Root() {
}, [activeId])

return (
<>
<TitleBar />
<PageLayout>
{/* TODO customer titlebar, when tauri 2.0 stable. */}
{/* <TitleBar /> */}
<Container>
<SideBar />
<EditorArea />
<AppInfoDialog />
<TableDialog />
<BookMarkDialog />
</Container>
</>
</PageLayout>
)
}

Expand Down
5 changes: 2 additions & 3 deletions apps/desktop/src/router/Root/styles.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { TITLEBAR_HEIGHT } from '@/constants/styled'
import styled from 'styled-components'

export const Container = styled.div`
height: calc(100vh - ${TITLEBAR_HEIGHT});
display: flex;
overflow: hidden;
flex: 1;
height: 100vh;
`
8 changes: 4 additions & 4 deletions apps/desktop/src/router/Setting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { Container } from './styles'
import settingMap from '@/router/Setting/settingMap'
import Logo from '@/assets/logo.svg'
import { invoke } from '@tauri-apps/api'
import TitleBar from '@/components/TitleBar'
import { KeyboardTable } from './KeyboardTable'
import { CopyButton } from '@/components/UI/Button'
import { PageLayout } from '@/layout/PageLayout'

export interface DialogTitleProps {
children?: ReactNode
Expand Down Expand Up @@ -54,8 +54,8 @@ function Setting() {
}

return (
<>
<TitleBar transparent />
<PageLayout>
{/* <TitleBar transparent /> */}
<Container>
<div id="sidebar">
<div className="title">
Expand Down Expand Up @@ -93,7 +93,7 @@ function Setting() {
{renderCurrentSettingData()}
</div>
</Container>
</>
</PageLayout>
)
}

Expand Down
5 changes: 2 additions & 3 deletions apps/desktop/src/router/Setting/styles.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { TITLEBAR_HEIGHT } from '@/constants/styled'
import styled from 'styled-components'

export const Container = styled.div`
display: flex;
height: calc(100vh - ${TITLEBAR_HEIGHT});
margin-top: ${TITLEBAR_HEIGHT};
flex: 1;
height: 100vh;
#sidebar {
width: 250px;
Expand Down

0 comments on commit 77067f7

Please sign in to comment.