mirror of
https://github.com/lobehub/lobe-chat.git
synced 2026-06-13 19:20:04 +00:00
🐛 fix(desktop): adjust mac fullscreen titlebar spacing (#15693)
This commit is contained in:
@@ -91,6 +91,13 @@ export default class BrowserWindowsCtr extends ControllerModule {
|
||||
});
|
||||
}
|
||||
|
||||
@IpcMethod()
|
||||
isWindowFullScreen() {
|
||||
return this.withSenderIdentifier((identifier) => {
|
||||
return this.app.browserManager.isWindowFullScreen(identifier);
|
||||
});
|
||||
}
|
||||
|
||||
@IpcMethod()
|
||||
setWindowAlwaysOnTop(flag: boolean) {
|
||||
this.withSenderIdentifier((identifier) => {
|
||||
|
||||
@@ -29,6 +29,7 @@ const mockCloseWindow = vi.fn();
|
||||
const mockMinimizeWindow = vi.fn();
|
||||
const mockMaximizeWindow = vi.fn();
|
||||
const mockIsWindowMaximized = vi.fn();
|
||||
const mockIsWindowFullScreen = vi.fn();
|
||||
const mockRetrieveByIdentifier = vi.fn();
|
||||
const mockStartSession = vi.fn();
|
||||
const testSenderIdentifierString: string = 'test-window-event-id';
|
||||
@@ -58,6 +59,7 @@ const mockApp = {
|
||||
minimizeWindow: mockMinimizeWindow,
|
||||
maximizeWindow: mockMaximizeWindow,
|
||||
isWindowMaximized: mockIsWindowMaximized,
|
||||
isWindowFullScreen: mockIsWindowFullScreen,
|
||||
retrieveByIdentifier: mockRetrieveByIdentifier.mockImplementation(
|
||||
(identifier: AppBrowsersIdentifiers | string) => {
|
||||
if (identifier === 'some-other-window') {
|
||||
@@ -166,6 +168,20 @@ describe('BrowserWindowsCtr', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('isWindowFullScreen', () => {
|
||||
it('should return fullscreen state for the sender window', () => {
|
||||
mockIsWindowFullScreen.mockReturnValueOnce(true);
|
||||
|
||||
const sender = {} as any;
|
||||
const context = { sender, event: { sender } as any } as IpcContext;
|
||||
const result = runWithIpcContext(context, () => browserWindowsCtr.isWindowFullScreen());
|
||||
|
||||
expect(mockGetIdentifierByWebContents).toHaveBeenCalledWith(context.sender);
|
||||
expect(mockIsWindowFullScreen).toHaveBeenCalledWith(testSenderIdentifierString);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('interceptRoute', () => {
|
||||
const baseParams = { source: 'link-click' as const };
|
||||
|
||||
|
||||
@@ -219,6 +219,7 @@ export default class Browser {
|
||||
this.setupReadyToShowListener(browserWindow);
|
||||
this.setupCloseListener(browserWindow);
|
||||
this.setupFocusListener(browserWindow);
|
||||
this.setupFullscreenListener(browserWindow);
|
||||
this.setupTopLevelNavigationListener(browserWindow);
|
||||
this.setupWillPreventUnloadListener(browserWindow);
|
||||
this.setupContextMenu(browserWindow);
|
||||
@@ -309,6 +310,18 @@ export default class Browser {
|
||||
});
|
||||
}
|
||||
|
||||
private setupFullscreenListener(browserWindow: BrowserWindow): void {
|
||||
logger.debug(`[${this.identifier}] Setting up fullscreen event listeners.`);
|
||||
|
||||
browserWindow.on('enter-full-screen', () => {
|
||||
this.broadcast('windowFullscreenChanged', { isFullScreen: true });
|
||||
});
|
||||
|
||||
browserWindow.on('leave-full-screen', () => {
|
||||
this.broadcast('windowFullscreenChanged', { isFullScreen: false });
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup context menu with platform-specific features
|
||||
* Delegates to MenuManager for consistent platform behavior
|
||||
|
||||
@@ -368,6 +368,11 @@ export class BrowserManager {
|
||||
return browser?.browserWindow.isMaximized() ?? false;
|
||||
}
|
||||
|
||||
isWindowFullScreen(identifier: string) {
|
||||
const browser = this.browsers.get(identifier);
|
||||
return browser?.browserWindow.isFullScreen() ?? false;
|
||||
}
|
||||
|
||||
setWindowSize(identifier: string, size: { height?: number; width?: number }) {
|
||||
const browser = this.browsers.get(identifier);
|
||||
browser?.setWindowSize(size);
|
||||
|
||||
@@ -541,6 +541,30 @@ describe('Browser', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('fullscreen events', () => {
|
||||
it('should broadcast fullscreen state changes', () => {
|
||||
const enterHandler = mockBrowserWindow.on.mock.calls.find(
|
||||
(call) => call[0] === 'enter-full-screen',
|
||||
)?.[1];
|
||||
const leaveHandler = mockBrowserWindow.on.mock.calls.find(
|
||||
(call) => call[0] === 'leave-full-screen',
|
||||
)?.[1];
|
||||
|
||||
expect(enterHandler).toBeDefined();
|
||||
expect(leaveHandler).toBeDefined();
|
||||
|
||||
enterHandler();
|
||||
expect(mockBrowserWindow.webContents.send).toHaveBeenCalledWith('windowFullscreenChanged', {
|
||||
isFullScreen: true,
|
||||
});
|
||||
|
||||
leaveHandler();
|
||||
expect(mockBrowserWindow.webContents.send).toHaveBeenCalledWith('windowFullscreenChanged', {
|
||||
isFullScreen: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('close', () => {
|
||||
it('should close window', () => {
|
||||
browser.close();
|
||||
|
||||
Reference in New Issue
Block a user