mirror of
https://github.com/sern-handler/gui
synced 2026-06-06 01:16:54 +00:00
feat: update checker, snowflakes and turkish translation
Co-authored-by: xxDeveloper <Murtatrxx@users.noreply.github.com>
This commit is contained in:
@@ -1,17 +1,19 @@
|
||||
import * as path from 'node:path'
|
||||
import { app, BrowserWindow, dialog, ipcMain } from 'electron';
|
||||
import { app, BrowserWindow, dialog, ipcMain, ipcRenderer } from 'electron';
|
||||
import * as colorette from 'colorette';
|
||||
import * as fs from 'node:fs'
|
||||
import * as os from 'node:os'
|
||||
import { exec, spawn } from 'node:child_process';
|
||||
import getPlatform from './utils/getPlatform.js';
|
||||
import updateChecker from './updateChecker.js';
|
||||
|
||||
function createWindow() {
|
||||
async function createWindow() {
|
||||
const mainWindow = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false
|
||||
contextIsolation: false,
|
||||
},
|
||||
icon: './icons/icon.png',
|
||||
show: false,
|
||||
@@ -24,8 +26,16 @@ function createWindow() {
|
||||
mainWindow.loadURL('http://localhost:5173');
|
||||
}
|
||||
|
||||
mainWindow.on('ready-to-show', () => {
|
||||
mainWindow.on('ready-to-show', async () => {
|
||||
mainWindow.show();
|
||||
|
||||
ipcMain.on('updateAvailable', async (event) => {
|
||||
const checkUpdates = await updateChecker()
|
||||
if (checkUpdates) {
|
||||
event.reply('updateAvailableResponse', checkUpdates)
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
mainWindow.on('page-title-updated', function (e) {
|
||||
@@ -122,22 +132,7 @@ app.on('activate', () => {
|
||||
}
|
||||
});
|
||||
|
||||
let currentOS: string
|
||||
switch (process.platform) {
|
||||
case 'linux':
|
||||
currentOS = 'linux'
|
||||
break;
|
||||
case 'win32':
|
||||
currentOS = 'windows'
|
||||
break;
|
||||
case 'darwin':
|
||||
currentOS = 'macOS'
|
||||
break;
|
||||
default:
|
||||
// defaulting for linux (most probable command syntax)
|
||||
currentOS = 'linux'
|
||||
break;
|
||||
}
|
||||
const currentOS = getPlatform()
|
||||
|
||||
const asciiart = ` .:-=-:.
|
||||
.:=+++++++++=-.
|
||||
|
||||
27
electron/updateChecker.ts
Normal file
27
electron/updateChecker.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { app } from "electron"
|
||||
import getPlatform from "./utils/getPlatform.js"
|
||||
|
||||
export default async function updateChecker() {
|
||||
const currentOS = getPlatform()
|
||||
const getLatest = await fetch('https://api.github.com/repos/sern-handler/gui/releases/latest')
|
||||
.then(res => res.json())
|
||||
|
||||
const dlUrl = getLatest.assets.map((asset) => {
|
||||
switch (asset.content_type) {
|
||||
case 'application/x-msdownload':
|
||||
return 'windows'
|
||||
case 'application/vnd.appimage':
|
||||
return 'linux'
|
||||
case 'application/x-apple-diskimage':
|
||||
return 'macOS'
|
||||
default:
|
||||
return null
|
||||
}
|
||||
})
|
||||
|
||||
if (`v${app.getVersion()}` !== getLatest.tag_name) {
|
||||
return { version: getLatest.tag_name as string, url: getLatest.html_url as string }
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
13
electron/utils/getPlatform.ts
Normal file
13
electron/utils/getPlatform.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export default function getPlatform() {
|
||||
switch (process.platform) {
|
||||
case 'linux':
|
||||
return 'linux'
|
||||
case 'win32':
|
||||
return 'windows'
|
||||
case 'darwin':
|
||||
return 'macOS'
|
||||
default:
|
||||
// defaulting for linux (most probable command syntax)
|
||||
return 'linux'
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user