Skip to content

Commit

Permalink
set app icon
Browse files Browse the repository at this point in the history
  • Loading branch information
A1Gard committed Mar 12, 2023
1 parent cf4b576 commit 6de70a1
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 21 deletions.
43 changes: 22 additions & 21 deletions anubias2/electron/main/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { app, BrowserWindow, shell, ipcMain, Menu } from 'electron'
import { release } from 'node:os'
import { join } from 'node:path'
import {AppMenu} from './app-menu'
import {config} from './config'
import { app, BrowserWindow, shell, ipcMain, Menu } from 'electron';
import { release } from 'node:os';
import { join } from 'node:path';
import {AppMenu} from './app-menu';
import {config} from './config';
// console.log('menu',menuTemplate);

// The built directory structure
Expand All @@ -15,37 +15,37 @@ import {config} from './config'
// ├─┬ distele
// │ └── index.html > Electron-Renderer
//
process.env.DIST_ELECTRON = join(__dirname, '..')
process.env.DIST = join(process.env.DIST_ELECTRON, '../dist')
process.env.DIST_ELECTRON = join(__dirname, '..');
process.env.DIST = join(process.env.DIST_ELECTRON, '../dist');
process.env.PUBLIC = process.env.VITE_DEV_SERVER_URL
? join(process.env.DIST_ELECTRON, '../public')
: process.env.DIST
: process.env.DIST;

// Disable GPU Acceleration for Windows 7
if (release().startsWith('6.1')) app.disableHardwareAcceleration()
if (release().startsWith('6.1')) app.disableHardwareAcceleration();

// Set application name for Windows 10+ notifications
if (process.platform === 'win32') app.setAppUserModelId(app.getName())
if (process.platform === 'win32') app.setAppUserModelId(app.getName());

if (!app.requestSingleInstanceLock()) {
app.quit()
process.exit(0)
app.quit();
process.exit(0);
}

// Remove electron security warnings
// This warning only shows in development mode
// Read more on https://www.electronjs.org/docs/latest/tutorial/security
// process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true'

let win: BrowserWindow | null = null
let win: BrowserWindow | null = null;
// Here, you can also use other preload
const preload = join(__dirname, '../preload/index.js')
const url = process.env.VITE_DEV_SERVER_URL
const indexHtml = join(process.env.DIST, 'index.html')
const preload = join(__dirname, '../preload/index.js');
const url = process.env.VITE_DEV_SERVER_URL;
const indexHtml = join(process.env.DIST, 'index.html');

async function createWindow() {
win = new BrowserWindow({
title: 'Main window',
title: 'Anubias',
icon: join(process.env.PUBLIC, 'favicon.ico'),
webPreferences: {
preload,
Expand All @@ -55,20 +55,20 @@ async function createWindow() {
nodeIntegration: true,
contextIsolation: false,
},
})
});

let menuapp = new AppMenu(win);
let menu = Menu.buildFromTemplate(menuapp.menu());
Menu.setApplicationMenu(menu);
win.maximize();
if (process.env.VITE_DEV_SERVER_URL) { // electron-vite-vue#298
win.loadURL(url)
win.loadURL(url);
// Open devTool if the app is not packaged
if (config.isDebug){
win.webContents.openDevTools()
win.webContents.openDevTools();
}
} else {
win.loadFile(indexHtml)
win.loadFile(indexHtml);
}

// Test actively push message to the Electron-Renderer
Expand All @@ -82,6 +82,7 @@ async function createWindow() {
return { action: 'deny' }
})
// win.webContents.on('will-navigate', (event, url) => { }) #344
win.setIcon( join(process.env.PUBLIC, '256x256.png') );
}

app.whenReady().then(createWindow)
Expand Down
Binary file added anubias2/public/256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added anubias2/public/512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions anubias2/public/anubias.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Anubias
Comment=Anubias app
Exec=application
Icon=application.png
Categories=Development
Binary file modified anubias2/public/favicon.ico
Binary file not shown.
Binary file added anubias2/public/icon.icns
Binary file not shown.
Binary file added anubias2/public/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6de70a1

Please sign in to comment.