mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-01-23 13:34:54 +03:00
feat: pass headers correctly to downloadURL
This commit is contained in:
parent
070340b34f
commit
e1ef8a9193
@ -26,6 +26,8 @@ const signOut = async (_event: Electron.IpcMainInvokeEvent) => {
|
|||||||
/* Disconnects libtorrent */
|
/* Disconnects libtorrent */
|
||||||
PythonInstance.killTorrent();
|
PythonInstance.killTorrent();
|
||||||
|
|
||||||
|
HydraApi.handleSignOut();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
databaseOperations,
|
databaseOperations,
|
||||||
HydraApi.post("/auth/logout").catch(() => {}),
|
HydraApi.post("/auth/logout").catch(() => {}),
|
||||||
|
@ -45,15 +45,14 @@ export class HTTPDownload {
|
|||||||
headers?: Record<string, string>
|
headers?: Record<string, string>
|
||||||
) {
|
) {
|
||||||
return new Promise<string>((resolve) => {
|
return new Promise<string>((resolve) => {
|
||||||
WindowManager.mainWindow?.webContents.downloadURL(downloadUrl, {
|
const options = headers ? { headers } : {};
|
||||||
headers,
|
WindowManager.mainWindow?.webContents.downloadURL(downloadUrl, options);
|
||||||
});
|
|
||||||
|
const gid = ++this.id;
|
||||||
|
|
||||||
WindowManager.mainWindow?.webContents.session.on(
|
WindowManager.mainWindow?.webContents.session.on(
|
||||||
"will-download",
|
"will-download",
|
||||||
(_event, item, _webContents) => {
|
(_event, item, _webContents) => {
|
||||||
const gid = ++this.id;
|
|
||||||
|
|
||||||
this.downloads[gid.toString()] = item;
|
this.downloads[gid.toString()] = item;
|
||||||
|
|
||||||
// Set the save path, making Electron not to prompt a save dialog.
|
// Set the save path, making Electron not to prompt a save dialog.
|
||||||
|
@ -64,6 +64,14 @@ export class HydraApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static handleSignOut() {
|
||||||
|
this.userAuth = {
|
||||||
|
authToken: "",
|
||||||
|
refreshToken: "",
|
||||||
|
expirationTimestamp: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static async setupApi() {
|
static async setupApi() {
|
||||||
this.instance = axios.create({
|
this.instance = axios.create({
|
||||||
baseURL: import.meta.env.MAIN_VITE_API_URL,
|
baseURL: import.meta.env.MAIN_VITE_API_URL,
|
||||||
|
@ -3751,10 +3751,10 @@ electron-vite@^2.0.0:
|
|||||||
magic-string "^0.30.5"
|
magic-string "^0.30.5"
|
||||||
picocolors "^1.0.0"
|
picocolors "^1.0.0"
|
||||||
|
|
||||||
electron@^30.1.0:
|
electron@^30.3.0:
|
||||||
version "30.3.0"
|
version "30.3.1"
|
||||||
resolved "https://registry.yarnpkg.com/electron/-/electron-30.3.0.tgz#9d7af06c11242d5c6ca5b9920c9dc49feab90299"
|
resolved "https://registry.yarnpkg.com/electron/-/electron-30.3.1.tgz#fe27ca2a4739bec832b2edd6f46140ab46bf53a0"
|
||||||
integrity sha512-/rWPcpCL4sYCUm1bY8if1dO8nyFTwXlPUP0dpL3ir5iLK/9NshN6lIJ8xceEY8CEYVLMIYRkxXb44Q9cdrjtOQ==
|
integrity sha512-Ai/OZ7VlbFAVYMn9J5lyvtr+ZWyEbXDVd5wBLb5EVrp4352SRmMAmN5chcIe3n9mjzcgehV9n4Hwy15CJW+YbA==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@electron/get" "^2.0.0"
|
"@electron/get" "^2.0.0"
|
||||||
"@types/node" "^20.9.0"
|
"@types/node" "^20.9.0"
|
||||||
|
Loading…
Reference in New Issue
Block a user