mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-11-04 15:11:31 +08:00 
			
		
		
		
	fix(native-buttons): watching for changes on other platforms than win32
This commit is contained in:
		
							parent
							
								
									04cbb7ea07
								
							
						
					
					
						commit
						2d0e88b503
					
				@ -54,29 +54,29 @@ function initOnElectron() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function initTitleBarButtons() {
 | 
					function initTitleBarButtons() {
 | 
				
			||||||
    function applyTitleBarOverlaySettings() {
 | 
					    const electronRemote = utils.dynamicRequire("@electron/remote");    
 | 
				
			||||||
        const electronRemote = utils.dynamicRequire("@electron/remote");    
 | 
					    const currentWindow = electronRemote.getCurrentWindow();
 | 
				
			||||||
        const currentWindow = electronRemote.getCurrentWindow();
 | 
					    const style = window.getComputedStyle(document.body);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    if (window.glob.platform === "win32") {
 | 
				
			||||||
 | 
					        const applyWindowsOverlay = () => {
 | 
				
			||||||
 | 
					            const color = style.getPropertyValue("--native-titlebar-background");
 | 
				
			||||||
 | 
					            const symbolColor = style.getPropertyValue("--native-titlebar-foreground");
 | 
				
			||||||
 | 
					            if (color && symbolColor) {
 | 
				
			||||||
 | 
					                currentWindow.setTitleBarOverlay({ color, symbolColor });
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        const style = window.getComputedStyle(document.body);
 | 
					        applyWindowsOverlay();
 | 
				
			||||||
        const color = style.getPropertyValue("--native-titlebar-background");
 | 
					 | 
				
			||||||
        const symbolColor = style.getPropertyValue("--native-titlebar-foreground");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (window.glob.platform === "win32" && color && symbolColor) {
 | 
					        // Register for changes to the native title bar colors.
 | 
				
			||||||
            currentWindow.setTitleBarOverlay({ color, symbolColor });
 | 
					        window.matchMedia("(prefers-color-scheme: dark)")
 | 
				
			||||||
        }
 | 
					            .addEventListener("change", applyWindowsOverlay);
 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (window.glob.platform === "darwin") {
 | 
					 | 
				
			||||||
            const xOffset = parseInt(style.getPropertyValue("--native-titlebar-darwin-x-offset"), 10);
 | 
					 | 
				
			||||||
            const yOffset = parseInt(style.getPropertyValue("--native-titlebar-darwin-y-offset"), 10);
 | 
					 | 
				
			||||||
            currentWindow.setWindowButtonPosition({ x: xOffset, y: yOffset });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    // Update the native title bar buttons.
 | 
					    if (window.glob.platform === "darwin") {
 | 
				
			||||||
    applyTitleBarOverlaySettings();
 | 
					        const xOffset = parseInt(style.getPropertyValue("--native-titlebar-darwin-x-offset"), 10);
 | 
				
			||||||
    
 | 
					        const yOffset = parseInt(style.getPropertyValue("--native-titlebar-darwin-y-offset"), 10);
 | 
				
			||||||
    // Register for changes to the native title bar colors.
 | 
					        currentWindow.setWindowButtonPosition({ x: xOffset, y: yOffset });
 | 
				
			||||||
    window.matchMedia("(prefers-color-scheme: dark)")
 | 
					    }    
 | 
				
			||||||
        .addEventListener("change", applyTitleBarOverlaySettings);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user