mirror of
https://github.com/LinoSchmidt/StickExporterTX.git
synced 2026-03-21 01:51:15 +01:00
Added auto update
This commit is contained in:
@@ -2,16 +2,6 @@ import React, {useState} from "react";
|
|||||||
import { openSide, Side } from "../../renderer";
|
import { openSide, Side } from "../../renderer";
|
||||||
import {blender, blenderCmd} from "../blender-controller";
|
import {blender, blenderCmd} from "../blender-controller";
|
||||||
|
|
||||||
const UpdateButton = () => (
|
|
||||||
<div id="update-available">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
|
||||||
{/* Font Awesome Pro 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. */}
|
|
||||||
<path
|
|
||||||
d="M480 352h-133.5l-45.25 45.25C289.2 409.3 273.1 416 256 416s-33.16-6.656-45.25-18.75L165.5 352H32c-17.67 0-32 14.33-32 32v96c0 17.67 14.33 32 32 32h448c17.67 0 32-14.33 32-32v-96C512 366.3 497.7 352 480 352zM432 456c-13.2 0-24-10.8-24-24c0-13.2 10.8-24 24-24s24 10.8 24 24C456 445.2 445.2 456 432 456zM233.4 374.6C239.6 380.9 247.8 384 256 384s16.38-3.125 22.62-9.375l128-128c12.49-12.5 12.49-32.75 0-45.25c-12.5-12.5-32.76-12.5-45.25 0L288 274.8V32c0-17.67-14.33-32-32-32C238.3 0 224 14.33 224 32v242.8L150.6 201.4c-12.49-12.5-32.75-12.5-45.25 0c-12.49 12.5-12.49 32.75 0 45.25L233.4 374.6z" />
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
|
|
||||||
const MainSideButtons = () => (
|
const MainSideButtons = () => (
|
||||||
<div id="settings-button" onClick={() => openSide(Side.Settings)}>
|
<div id="settings-button" onClick={() => openSide(Side.Settings)}>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
||||||
@@ -45,7 +35,7 @@ const BlenderReadySVG = () => (
|
|||||||
let setBlenderLoading:React.Dispatch<React.SetStateAction<boolean>>;
|
let setBlenderLoading:React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
let setBlenderStatus:React.Dispatch<React.SetStateAction<string>>;
|
let setBlenderStatus:React.Dispatch<React.SetStateAction<string>>;
|
||||||
|
|
||||||
function Menu({updateAvailable, side}:{updateAvailable:boolean, side:Side}) {
|
function Menu({side}:{side:Side}) {
|
||||||
|
|
||||||
const [blenderLoading, setBlenderLoadingInner] = useState(true);
|
const [blenderLoading, setBlenderLoadingInner] = useState(true);
|
||||||
setBlenderLoading = setBlenderLoadingInner;
|
setBlenderLoading = setBlenderLoadingInner;
|
||||||
@@ -61,7 +51,6 @@ function Menu({updateAvailable, side}:{updateAvailable:boolean, side:Side}) {
|
|||||||
</div>
|
</div>
|
||||||
<p>{blenderStatus}</p>
|
<p>{blenderStatus}</p>
|
||||||
</div>
|
</div>
|
||||||
{updateAvailable? <UpdateButton/> : null}
|
|
||||||
{(side == Side.Main)? <MainSideButtons/> : null}
|
{(side == Side.Main)? <MainSideButtons/> : null}
|
||||||
{(side == Side.Settings)? <SettingsSideButtons/> : null}
|
{(side == Side.Settings)? <SettingsSideButtons/> : null}
|
||||||
{(side == Side.Rendering)? <RenderingSideButton/> : null}
|
{(side == Side.Rendering)? <RenderingSideButton/> : null}
|
||||||
|
|||||||
47
src/index.ts
47
src/index.ts
@@ -1,6 +1,51 @@
|
|||||||
import {app, BrowserWindow} from 'electron';
|
import {app, BrowserWindow, dialog} from 'electron';
|
||||||
import {initialize as remoteInitialize, enable as remoteEnable} from '@electron/remote/main';
|
import {initialize as remoteInitialize, enable as remoteEnable} from '@electron/remote/main';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import { autoUpdater } from "electron-updater";
|
||||||
|
import logger from 'electron-log';
|
||||||
|
|
||||||
|
logger.transports.console.format = "{h}:{i}:{s} {text}";
|
||||||
|
logger.transports.file.getFile();
|
||||||
|
logger.transports.file.resolvePath = () => path.join(app.getPath('userData'), "logs", "start.log");
|
||||||
|
|
||||||
|
autoUpdater.autoDownload = false;
|
||||||
|
|
||||||
|
autoUpdater.checkForUpdatesAndNotify();
|
||||||
|
|
||||||
|
autoUpdater.on('update-available', async () => {
|
||||||
|
const response = await dialog.showMessageBox({
|
||||||
|
type: 'info',
|
||||||
|
title: 'Update Available',
|
||||||
|
message: 'Found updates, do you want update now?',
|
||||||
|
buttons: ['Yes', 'Later'],
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.response === 0) {
|
||||||
|
logger.log('Downloading Update');
|
||||||
|
autoUpdater.downloadUpdate();
|
||||||
|
await dialog.showMessageBox({
|
||||||
|
type: 'info',
|
||||||
|
title: 'Update Downloading',
|
||||||
|
message:
|
||||||
|
'Update is being downloaded, you will be notified when it is ready to install',
|
||||||
|
buttons: [],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
autoUpdater.on('update-downloaded', async () => {
|
||||||
|
const response = await dialog.showMessageBox({
|
||||||
|
type: 'info',
|
||||||
|
buttons: ['Restart', 'Later'],
|
||||||
|
title: 'Application Update',
|
||||||
|
message: 'Update',
|
||||||
|
detail:
|
||||||
|
'A new version has been downloaded. Restart the application to apply the updates.',
|
||||||
|
});
|
||||||
|
if (response.response === 0) {
|
||||||
|
setImmediate(() => autoUpdater.quitAndInstall());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
|
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
|
||||||
if (require('electron-squirrel-startup')) {
|
if (require('electron-squirrel-startup')) {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ function openSide(side:Side) {
|
|||||||
|
|
||||||
root.render(
|
root.render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<Menu updateAvailable={false} side={side}/>
|
<Menu side={side}/>
|
||||||
{(side === Side.Main)? <MainSide/> : null}
|
{(side === Side.Main)? <MainSide/> : null}
|
||||||
{(side === Side.Settings)? <SettingsSite/> : null}
|
{(side === Side.Settings)? <SettingsSite/> : null}
|
||||||
{(side === Side.Rendering)? <RenderingSide/> : null}
|
{(side === Side.Rendering)? <RenderingSide/> : null}
|
||||||
|
|||||||
Reference in New Issue
Block a user