mirror of
https://github.com/imgfloat/server.git
synced 2026-02-05 03:39:26 +00:00
Add icons
This commit is contained in:
@@ -6,26 +6,21 @@
|
|||||||
"build": {
|
"build": {
|
||||||
"appId": "dev.kruhlmann.imgfloat.overlay",
|
"appId": "dev.kruhlmann.imgfloat.overlay",
|
||||||
"productName": "Imgfloat",
|
"productName": "Imgfloat",
|
||||||
"files": [
|
"files": [ "src/main/node/app.js" ],
|
||||||
"app.js"
|
|
||||||
],
|
|
||||||
"asar": false,
|
"asar": false,
|
||||||
"directories": {
|
"directories": { "output": "dist" },
|
||||||
"output": "dist"
|
|
||||||
},
|
|
||||||
"linux": {
|
"linux": {
|
||||||
"target": [
|
"target": ["AppImage"],
|
||||||
"AppImage"
|
|
||||||
],
|
|
||||||
"category": "Utility"
|
"category": "Utility"
|
||||||
|
"icon": "assets/icon/raw_icon.png"
|
||||||
},
|
},
|
||||||
"win": {
|
"win": {
|
||||||
"target": [
|
"target": ["nsis"]
|
||||||
"nsis"
|
"icon": "assets/icon/appicon.ico"
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"mac": {
|
"mac": {
|
||||||
"category": "public.app-category.productivity"
|
"category": "public.app-category.productivity"
|
||||||
|
"icon": "assets/icon/macos.icns"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -1,24 +1,22 @@
|
|||||||
const { app, BrowserWindow } = require('electron');
|
const { app, BrowserWindow } = require('electron');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
const url = process.env.ELECTRON_START_URL || "https://imgfloat.kruhlmann.dev/channels";
|
const url = "https://imgfloat.kruhlmann.dev/channels";
|
||||||
const width = Number.parseInt(process.env.ELECTRON_WINDOW_WIDTH, 10) || 960;
|
const initialWindowWidthPx = 960;
|
||||||
const height = Number.parseInt(process.env.ELECTRON_WINDOW_HEIGHT, 10) || 640;
|
const initialWindowHeightPx = 640;
|
||||||
|
const applicationWindow = new BrowserWindow({
|
||||||
const win = new BrowserWindow({
|
width: initialWindowWidthPx,
|
||||||
width: width,
|
height: initialWindowHeightPx,
|
||||||
height: height,
|
|
||||||
transparent: true,
|
transparent: true,
|
||||||
frame: true,
|
frame: true,
|
||||||
backgroundColor: '#00000000',
|
backgroundColor: '#00000000',
|
||||||
alwaysOnTop: false,
|
alwaysOnTop: false,
|
||||||
webPreferences: {
|
icon: path.join(__dirname, "../resources/assets/icon/appicon.ico"),
|
||||||
backgroundThrottling: false
|
webPreferences: { backgroundThrottling: false },
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let canvasSizeInterval;
|
let canvasSizeInterval;
|
||||||
|
|
||||||
const clearCanvasSizeInterval = () => {
|
const clearCanvasSizeInterval = () => {
|
||||||
if (canvasSizeInterval) {
|
if (canvasSizeInterval) {
|
||||||
clearInterval(canvasSizeInterval);
|
clearInterval(canvasSizeInterval);
|
||||||
@@ -27,11 +25,11 @@ function createWindow() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const lockWindowToCanvas = async () => {
|
const lockWindowToCanvas = async () => {
|
||||||
if (win.isDestroyed()) {
|
if (applicationWindow.isDestroyed()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const size = await win.webContents.executeJavaScript(`(() => {
|
const size = await applicationWindow.webContents.executeJavaScript(`(() => {
|
||||||
const canvas = document.getElementById('broadcast-canvas');
|
const canvas = document.getElementById('broadcast-canvas');
|
||||||
if (!canvas || !canvas.width || !canvas.height) {
|
if (!canvas || !canvas.width || !canvas.height) {
|
||||||
return null;
|
return null;
|
||||||
@@ -40,13 +38,13 @@ function createWindow() {
|
|||||||
})();`);
|
})();`);
|
||||||
|
|
||||||
if (size?.width && size?.height) {
|
if (size?.width && size?.height) {
|
||||||
const [currentWidth, currentHeight] = win.getSize();
|
const [currentWidth, currentHeight] = applicationWindow.getSize();
|
||||||
if (currentWidth !== size.width || currentHeight !== size.height) {
|
if (currentWidth !== size.width || currentHeight !== size.height) {
|
||||||
win.setSize(size.width, size.height, false);
|
applicationWindow.setSize(size.width, size.height, false);
|
||||||
}
|
}
|
||||||
win.setMinimumSize(size.width, size.height);
|
applicationWindow.setMinimumSize(size.width, size.height);
|
||||||
win.setMaximumSize(size.width, size.height);
|
applicationWindow.setMaximumSize(size.width, size.height);
|
||||||
win.setResizable(false);
|
applicationWindow.setResizable(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -66,27 +64,25 @@ function createWindow() {
|
|||||||
lockWindowToCanvas();
|
lockWindowToCanvas();
|
||||||
} else {
|
} else {
|
||||||
clearCanvasSizeInterval();
|
clearCanvasSizeInterval();
|
||||||
win.setResizable(true);
|
applicationWindow.setResizable(true);
|
||||||
win.setMinimumSize(320, 240);
|
applicationWindow.setMinimumSize(320, 240);
|
||||||
win.setMaximumSize(10000, 10000);
|
applicationWindow.setMaximumSize(10000, 10000);
|
||||||
win.setSize(width, height, false);
|
applicationWindow.setSize(initialWindowWidthPx, initialWindowHeightPx, false);
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// Ignore malformed URLs while navigating.
|
// Ignore malformed URLs while navigating.
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
win.loadURL(url);
|
applicationWindow.loadURL(url);
|
||||||
|
|
||||||
win.webContents.on('did-finish-load', () => {
|
applicationWindow.webContents.on('did-finish-load', () => {
|
||||||
handleNavigation(win.webContents.getURL());
|
handleNavigation(applicationWindow.webContents.getURL());
|
||||||
});
|
});
|
||||||
|
|
||||||
win.webContents.on('did-navigate', (_event, navigationUrl) => handleNavigation(navigationUrl));
|
applicationWindow.webContents.on('did-navigate', (_event, navigationUrl) => handleNavigation(navigationUrl));
|
||||||
win.webContents.on('did-navigate-in-page', (_event, navigationUrl) => handleNavigation(navigationUrl));
|
applicationWindow.webContents.on('did-navigate-in-page', (_event, navigationUrl) => handleNavigation(navigationUrl));
|
||||||
win.on('closed', clearCanvasSizeInterval);
|
applicationWindow.on('closed', clearCanvasSizeInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(createWindow);
|
||||||
createWindow();
|
|
||||||
});
|
|
||||||
|
|||||||
BIN
src/main/resources/assets/icon/appicon.ico
Normal file
BIN
src/main/resources/assets/icon/appicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 98 KiB |
BIN
src/main/resources/assets/icon/favicon.ico
Normal file
BIN
src/main/resources/assets/icon/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 98 KiB |
BIN
src/main/resources/assets/icon/macos.icns
Normal file
BIN
src/main/resources/assets/icon/macos.icns
Normal file
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
Reference in New Issue
Block a user