mirror of
https://github.com/imgfloat/server.git
synced 2026-02-05 03:39:26 +00:00
Re-add frame to electron window
This commit is contained in:
@@ -9,7 +9,7 @@ function createWindow() {
|
|||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
transparent: true,
|
transparent: true,
|
||||||
frame: false,
|
frame: true,
|
||||||
backgroundColor: '#00000000',
|
backgroundColor: '#00000000',
|
||||||
alwaysOnTop: false,
|
alwaysOnTop: false,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
@@ -79,46 +79,9 @@ function createWindow() {
|
|||||||
win.loadURL(url);
|
win.loadURL(url);
|
||||||
|
|
||||||
win.webContents.on('did-finish-load', () => {
|
win.webContents.on('did-finish-load', () => {
|
||||||
win.webContents.insertCSS(`
|
|
||||||
html, body {
|
|
||||||
-webkit-app-region: drag;
|
|
||||||
user-select: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
transition: opacity 120ms ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
a, button, input, select, textarea, option, [role="button"], [role="textbox"] {
|
|
||||||
-webkit-app-region: no-drag;
|
|
||||||
user-select: auto;
|
|
||||||
}
|
|
||||||
`);
|
|
||||||
|
|
||||||
win.webContents.executeJavaScript(`(() => {
|
|
||||||
const body = document.body;
|
|
||||||
if (!body) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const defaultOpacity = getComputedStyle(body).opacity || '1';
|
|
||||||
let timeout;
|
|
||||||
|
|
||||||
window.__imgfloatShowDragOverlay = () => {
|
|
||||||
body.style.opacity = '0.9';
|
|
||||||
clearTimeout(timeout);
|
|
||||||
timeout = setTimeout(() => {
|
|
||||||
body.style.opacity = defaultOpacity;
|
|
||||||
}, 150);
|
|
||||||
};
|
|
||||||
})();`);
|
|
||||||
|
|
||||||
handleNavigation(win.webContents.getURL());
|
handleNavigation(win.webContents.getURL());
|
||||||
});
|
});
|
||||||
|
|
||||||
win.on('move', () => {
|
|
||||||
win.webContents.executeJavaScript('window.__imgfloatShowDragOverlay && window.__imgfloatShowDragOverlay();');
|
|
||||||
});
|
|
||||||
|
|
||||||
win.webContents.on('did-navigate', (_event, navigationUrl) => handleNavigation(navigationUrl));
|
win.webContents.on('did-navigate', (_event, navigationUrl) => handleNavigation(navigationUrl));
|
||||||
win.webContents.on('did-navigate-in-page', (_event, navigationUrl) => handleNavigation(navigationUrl));
|
win.webContents.on('did-navigate-in-page', (_event, navigationUrl) => handleNavigation(navigationUrl));
|
||||||
win.on('closed', clearCanvasSizeInterval);
|
win.on('closed', clearCanvasSizeInterval);
|
||||||
|
|||||||
Reference in New Issue
Block a user