progress status and progress communication done
This commit is contained in:
parent
4569d35a65
commit
756ae1be58
42
main.js
42
main.js
|
@ -18,7 +18,11 @@ function isDev() {
|
||||||
|
|
||||||
function registerIPCPipes() {
|
function registerIPCPipes() {
|
||||||
ipcMain.handle("ezpplauncher:login", async (e, args) => {
|
ipcMain.handle("ezpplauncher:login", async (e, args) => {
|
||||||
|
const timeout = new AbortController();
|
||||||
|
const timeoutId = setTimeout(() => timeout.abort(), 8000);
|
||||||
|
try {
|
||||||
const fetchResult = await fetch("https://ez-pp.farm/login/check", {
|
const fetchResult = await fetch("https://ez-pp.farm/login/check", {
|
||||||
|
signal: timeout.signal,
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
username: args.username,
|
username: args.username,
|
||||||
|
@ -29,6 +33,8 @@ function registerIPCPipes() {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
clearTimeout(timeoutId);
|
||||||
|
|
||||||
if (fetchResult.ok) {
|
if (fetchResult.ok) {
|
||||||
const result = await fetchResult.json();
|
const result = await fetchResult.json();
|
||||||
if ("user" in result) {
|
if ("user" in result) {
|
||||||
|
@ -44,6 +50,12 @@ function registerIPCPipes() {
|
||||||
code: 500,
|
code: 500,
|
||||||
message: "Something went wrong while logging you in.",
|
message: "Something went wrong while logging you in.",
|
||||||
};
|
};
|
||||||
|
} catch (err) {
|
||||||
|
return {
|
||||||
|
code: 500,
|
||||||
|
message: "Something went wrong while logging you in.",
|
||||||
|
};
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.handle("ezpplauncher:autologin", async (e) => {
|
ipcMain.handle("ezpplauncher:autologin", async (e) => {
|
||||||
|
@ -54,7 +66,11 @@ function registerIPCPipes() {
|
||||||
if (username == undefined || password == undefined) {
|
if (username == undefined || password == undefined) {
|
||||||
return { code: 200, message: "No autologin" };
|
return { code: 200, message: "No autologin" };
|
||||||
}
|
}
|
||||||
|
const timeout = new AbortController();
|
||||||
|
const timeoutId = setTimeout(() => timeout.abort(), 8000);
|
||||||
|
try {
|
||||||
const fetchResult = await fetch("https://ez-pp.farm/login/check", {
|
const fetchResult = await fetch("https://ez-pp.farm/login/check", {
|
||||||
|
signal: timeout.signal,
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
username: username,
|
username: username,
|
||||||
|
@ -65,6 +81,8 @@ function registerIPCPipes() {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
clearTimeout(timeoutId);
|
||||||
|
|
||||||
if (fetchResult.ok) {
|
if (fetchResult.ok) {
|
||||||
const result = await fetchResult.json();
|
const result = await fetchResult.json();
|
||||||
return result;
|
return result;
|
||||||
|
@ -73,6 +91,12 @@ function registerIPCPipes() {
|
||||||
code: 500,
|
code: 500,
|
||||||
message: "Something went wrong while logging you in.",
|
message: "Something went wrong while logging you in.",
|
||||||
};
|
};
|
||||||
|
} catch (err) {
|
||||||
|
return {
|
||||||
|
code: 500,
|
||||||
|
message: "Something went wrong while logging you in.",
|
||||||
|
};
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.handle("ezpplauncher:guestlogin", (e) => {
|
ipcMain.handle("ezpplauncher:guestlogin", (e) => {
|
||||||
|
@ -87,6 +111,24 @@ function registerIPCPipes() {
|
||||||
config.remove("guest");
|
config.remove("guest");
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcMain.handle("ezpplauncher:launch", async (e) => {
|
||||||
|
mainWindow.webContents.send("ezpplauncher:launchstatus", {
|
||||||
|
status: "Checking osu! directory...",
|
||||||
|
});
|
||||||
|
await new Promise((res) => setTimeout(res, 1500));
|
||||||
|
mainWindow.webContents.send("ezpplauncher:launchstatus", {
|
||||||
|
status: "Checking for osu! updates...",
|
||||||
|
});
|
||||||
|
mainWindow.webContents.send("ezpplauncher:launchprogress", {
|
||||||
|
progress: 0,
|
||||||
|
});
|
||||||
|
await new Promise((res) => setTimeout(res, 1500));
|
||||||
|
mainWindow.webContents.send("ezpplauncher:launchprogress", {
|
||||||
|
progress: 100,
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
|
|
16
preload.js
16
preload.js
|
@ -36,3 +36,19 @@ window.addEventListener("logout", async (e) => {
|
||||||
window.addEventListener("guest-login", async (e) => {
|
window.addEventListener("guest-login", async (e) => {
|
||||||
await ipcRenderer.invoke("ezpplauncher:guestlogin");
|
await ipcRenderer.invoke("ezpplauncher:guestlogin");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.addEventListener("launch", async (e) => {
|
||||||
|
await ipcRenderer.invoke("ezpplauncher:launch");
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.addListener("ezpplauncher:launchstatus", (e, args) => {
|
||||||
|
window.dispatchEvent(
|
||||||
|
new CustomEvent("launchStatusUpdate", { detail: args }),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.addListener("ezpplauncher:launchprogress", (e, args) => {
|
||||||
|
window.dispatchEvent(
|
||||||
|
new CustomEvent("launchProgressUpdate", { detail: args }),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
|
@ -4,19 +4,20 @@
|
||||||
Dropdown,
|
Dropdown,
|
||||||
DropdownItem,
|
DropdownItem,
|
||||||
DropdownHeader,
|
DropdownHeader,
|
||||||
DropdownDivider
|
DropdownDivider,
|
||||||
} from "flowbite-svelte";
|
} from "flowbite-svelte";
|
||||||
import {
|
import {
|
||||||
ArrowRightFromBracketSolid,
|
ArrowRightFromBracketSolid,
|
||||||
ArrowRightToBracketSolid,
|
ArrowRightToBracketSolid,
|
||||||
UserSettingsSolid
|
UserSettingsSolid,
|
||||||
} from "flowbite-svelte-icons";
|
} from "flowbite-svelte-icons";
|
||||||
import ezppLogo from "../public/favicon.png";
|
import ezppLogo from "../public/favicon.png";
|
||||||
import {
|
import {
|
||||||
currentPage,
|
currentPage,
|
||||||
currentUser,
|
currentUser,
|
||||||
launching,
|
launching,
|
||||||
launchStatus
|
launchPercentage,
|
||||||
|
launchStatus,
|
||||||
} from "./storage/localStore";
|
} from "./storage/localStore";
|
||||||
import { Page } from "./consts/pages";
|
import { Page } from "./consts/pages";
|
||||||
import Login from "./pages/Login.svelte";
|
import Login from "./pages/Login.svelte";
|
||||||
|
@ -40,9 +41,16 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener("launchStatusUpdate", (e) => {
|
window.addEventListener("launchStatusUpdate", (e) => {
|
||||||
const status = (e as CustomEvent).detail;
|
console.log((e as CustomEvent).detail);
|
||||||
|
const status = (e as CustomEvent).detail.status;
|
||||||
launchStatus.set(status);
|
launchStatus.set(status);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.addEventListener("launchProgressUpdate", (e) => {
|
||||||
|
console.log((e as CustomEvent).detail);
|
||||||
|
const progress = (e as CustomEvent).detail.progress;
|
||||||
|
launchPercentage.set(progress);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Toaster></Toaster>
|
<Toaster></Toaster>
|
||||||
|
|
|
@ -54,6 +54,10 @@ html .cet-titlebar .cet-control-icon svg {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.animatedProgress div {
|
||||||
|
transition: width 0.35s cubic-bezier(0.65, -0.02, 0.31, 1.01);
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes progress-loading {
|
@keyframes progress-loading {
|
||||||
50% {
|
50% {
|
||||||
background-position-x: -115%;
|
background-position-x: -115%;
|
||||||
|
|
|
@ -142,7 +142,9 @@
|
||||||
{/if}
|
{/if}
|
||||||
</Button>
|
</Button>
|
||||||
</Input>
|
</Input>
|
||||||
<Checkbox bind:checked={saveCredentials}>Save credentials</Checkbox>
|
<Checkbox bind:checked={saveCredentials} disabled={loading}
|
||||||
|
>Save credentials</Checkbox
|
||||||
|
>
|
||||||
<div class="flex flex-col justify-center items-center gap-5 mt-1">
|
<div class="flex flex-col justify-center items-center gap-5 mt-1">
|
||||||
<Button
|
<Button
|
||||||
class="dark:active:!bg-gray-900 active:scale-95 transition-transform duration-75"
|
class="dark:active:!bg-gray-900 active:scale-95 transition-transform duration-75"
|
||||||
|
|
3
src/util/mathUtil.ts
Normal file
3
src/util/mathUtil.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export const clamp = (val: number, min: number, max: number) => {
|
||||||
|
return val <= min ? min : val >= max ? max : val;
|
||||||
|
};
|
|
@ -21,6 +21,9 @@ const config = {
|
||||||
fadeIn: "fadeIn 1s ease forwards",
|
fadeIn: "fadeIn 1s ease forwards",
|
||||||
fadeOut: "fadeOut 1s ease forwards",
|
fadeOut: "fadeOut 1s ease forwards",
|
||||||
},
|
},
|
||||||
|
transitionProperty: {
|
||||||
|
'width': 'width',
|
||||||
|
},
|
||||||
colors: {
|
colors: {
|
||||||
// flowbite-svelte
|
// flowbite-svelte
|
||||||
primary: {
|
primary: {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user