Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ 原生 MacOs 标题栏 #215

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use tauri::Manager;
use tauri::{Manager, WebviewUrl, WebviewWindowBuilder};

mod command;
mod server;
Expand All @@ -8,8 +8,25 @@ mod utils;
pub fn run() {
tauri::Builder::default()
.setup(|app| {
let win_builder = WebviewWindowBuilder::new(app, "main", WebviewUrl::default(),)
.title("Matcha",)
.min_inner_size(620.0, 540.0,)
.inner_size(1080.0, 720.0,)
.center();

#[cfg(not(target_os = "macos"))]
let win_builder = win_builder.decorations(false,).transparent(true,);

#[cfg(target_os = "macos")]
let win_builder = win_builder
.decorations(true,)
.hidden_title(true,)
.title_bar_style(tauri::TitleBarStyle::Overlay,);

let window = win_builder.build().unwrap();

#[cfg(dev)]
app.get_webview_window("main",).unwrap().open_devtools();
window.open_devtools();

let cache_path = app.handle().path().app_cache_dir().unwrap();
let port: u16 = 8720;
Expand Down
10 changes: 0 additions & 10 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@
"app": {
"macOSPrivateApi": true,
"windows": [
{
"title": "Matcha",
"height": 720,
"width": 1080,
"minHeight": 540,
"minWidth": 620,
"center": true,
"decorations": false,
"transparent": true
}
],
"security": {
"csp": null
Expand Down
5 changes: 2 additions & 3 deletions src/components/AppSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ const isMacOs = $computed(() => unref(osType) === 'macos')

<template>
<aside
class="w-15 flex flex-col items-center gap-4 bg-background pb-5"
class="flex flex-col items-center gap-4 bg-background pb-5"
:class="[
focused ? 'bg-opacity-40 dark:bg-opacity-60' : 'bg-opacity-70 dark:bg-opacity-90',
isMacOs ? 'pt-2' : 'pt-7',
isMacOs ? 'pt-8 w-18' : 'pt-7 w-15',
]"
>
<WindowControls v-if="isMacOs" />
<AppLogo class="size-9" />
<AppSidebarNavigation />
<AppSidebarUserAvatar class="mt-auto" />
Expand Down
Loading