fix(mac): 修复隐藏标题栏拖拽;标题与内容左对齐;增加 banner 高度以避让交通灯
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
|||||||
import { store } from "./store";
|
import { store } from "./store";
|
||||||
|
|
||||||
let mainWindow: BrowserWindow | null = null;
|
let mainWindow: BrowserWindow | null = null;
|
||||||
|
const isMac = process.platform === "darwin";
|
||||||
|
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
@@ -27,7 +28,8 @@ function createWindow() {
|
|||||||
contextIsolation: true,
|
contextIsolation: true,
|
||||||
nodeIntegration: false,
|
nodeIntegration: false,
|
||||||
},
|
},
|
||||||
titleBarStyle: "hiddenInset",
|
// 使用 macOS 隐藏式标题栏,仅在 macOS 启用
|
||||||
|
...(isMac ? { titleBarStyle: "hiddenInset" as const } : {}),
|
||||||
autoHideMenuBar: true,
|
autoHideMenuBar: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -14,3 +14,8 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
|||||||
openConfigFolder: () => ipcRenderer.invoke('openConfigFolder'),
|
openConfigFolder: () => ipcRenderer.invoke('openConfigFolder'),
|
||||||
openExternal: (url: string) => ipcRenderer.invoke('openExternal', url)
|
openExternal: (url: string) => ipcRenderer.invoke('openExternal', url)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 暴露平台信息给渲染进程,用于平台特定样式控制
|
||||||
|
contextBridge.exposeInMainWorld('platform', {
|
||||||
|
isMac: process.platform === 'darwin'
|
||||||
|
})
|
||||||
|
|||||||
@@ -12,6 +12,9 @@
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||||
|
/* 允许作为 Electron 的拖拽区域(macOS 隐藏标题栏时生效) */
|
||||||
|
-webkit-app-region: drag;
|
||||||
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.app-header h1 {
|
.app-header h1 {
|
||||||
@@ -22,6 +25,8 @@
|
|||||||
.header-actions {
|
.header-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
|
/* header 内的交互元素需要排除拖拽,否则无法点击 */
|
||||||
|
-webkit-app-region: no-drag;
|
||||||
}
|
}
|
||||||
|
|
||||||
.refresh-btn, .add-btn {
|
.refresh-btn, .add-btn {
|
||||||
@@ -31,6 +36,8 @@
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
transition: all 0.2s;
|
transition: all 0.2s;
|
||||||
|
/* 明确按钮不可拖拽,确保可点击 */
|
||||||
|
-webkit-app-region: no-drag;
|
||||||
}
|
}
|
||||||
|
|
||||||
.refresh-btn {
|
.refresh-btn {
|
||||||
|
|||||||
@@ -19,3 +19,12 @@ body {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 仅在 macOS 下为顶部预留交通灯空间 */
|
||||||
|
/* 保持 mac 下与内容区域左对齐(不额外偏移) */
|
||||||
|
|
||||||
|
/* 在 macOS 下稍微增加 banner 高度,拉开与交通灯的垂直距离 */
|
||||||
|
body.is-mac .app-header {
|
||||||
|
padding-top: 1.4rem;
|
||||||
|
padding-bottom: 1.4rem;
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,6 +3,17 @@ import ReactDOM from 'react-dom/client'
|
|||||||
import App from './App'
|
import App from './App'
|
||||||
import './index.css'
|
import './index.css'
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
platform?: { isMac?: boolean }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据平台添加 body class,便于平台特定样式
|
||||||
|
if (window.platform?.isMac) {
|
||||||
|
document.body.classList.add('is-mac')
|
||||||
|
}
|
||||||
|
|
||||||
ReactDOM.createRoot(document.getElementById('root')!).render(
|
ReactDOM.createRoot(document.getElementById('root')!).render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<App />
|
<App />
|
||||||
|
|||||||
Reference in New Issue
Block a user