mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
fix(electron): always show traffic light for mac (#7773)
fix AF-1209, fix PD-1550
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { app, nativeTheme, shell } from 'electron';
|
||||
import { getLinkPreview } from 'link-preview-js';
|
||||
|
||||
import { isMacOS } from '../../shared/utils';
|
||||
import { persistentConfig } from '../config-storage/persist';
|
||||
import { logger } from '../logger';
|
||||
import type { NamespaceHandlers } from '../type';
|
||||
@@ -43,12 +42,6 @@ export const uiHandlers = {
|
||||
handleThemeChange: async (_, theme: (typeof nativeTheme)['themeSource']) => {
|
||||
nativeTheme.themeSource = theme;
|
||||
},
|
||||
handleSidebarVisibilityChange: async (_, visible: boolean) => {
|
||||
if (isMacOS()) {
|
||||
const window = await getMainWindow();
|
||||
window?.setWindowButtonVisibility(visible);
|
||||
}
|
||||
},
|
||||
handleMinimizeApp: async () => {
|
||||
const window = await getMainWindow();
|
||||
window?.minimize();
|
||||
@@ -68,8 +61,8 @@ export const uiHandlers = {
|
||||
window.maximize();
|
||||
}
|
||||
},
|
||||
handleWindowResize: async () => {
|
||||
await handleWebContentsResize();
|
||||
handleWindowResize: async e => {
|
||||
await handleWebContentsResize(e.sender);
|
||||
},
|
||||
handleCloseApp: async () => {
|
||||
app.quit();
|
||||
|
||||
@@ -658,6 +658,8 @@ export class WebContentViewsManager {
|
||||
sorted.forEach(({ view }, idx) => {
|
||||
this.mainWindow?.contentView.addChildView(view, idx);
|
||||
});
|
||||
|
||||
handleWebContentsResize(activeView?.webContents).catch(logger.error);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -894,12 +896,12 @@ export async function getCookie(url?: string, name?: string) {
|
||||
|
||||
// there is no proper way to listen to webContents resize event
|
||||
// we will rely on window.resize event in renderer instead
|
||||
export async function handleWebContentsResize() {
|
||||
export async function handleWebContentsResize(webContents?: WebContents) {
|
||||
// right now when window is resized, we will relocate the traffic light positions
|
||||
if (isMacOS()) {
|
||||
const window = await getMainWindow();
|
||||
const factor = window?.webContents.getZoomFactor() || 1;
|
||||
window?.setWindowButtonPosition({ x: 20 * factor, y: 24 * factor - 6 });
|
||||
const factor = webContents?.getZoomFactor() || 1;
|
||||
window?.setWindowButtonPosition({ x: 16 * factor, y: 24 * factor - 6 });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user