Add Download Task

This commit is contained in:
2023-06-27 19:19:17 +08:00
parent 086441e3b7
commit f58ad21a5c
12 changed files with 427 additions and 21 deletions

View File

@@ -2,6 +2,7 @@ import { signal } from "@preact/signals";
import { ConfigType } from "../config.ts";
import { get_ws_host } from "./utils.ts";
import { ConfigClientSocketData, ConfigSeverSocketData } from "./config.ts";
import { DEFAULT_DOWNLOAD_CONFIG, DownloadConfig } from "../tasks/download.ts";
export const cfg = signal<ConfigType | undefined>(undefined);
@@ -23,3 +24,15 @@ export function initCfg() {
sendMessage({ type: "close" });
});
}
export function generate_download_cfg(): DownloadConfig {
if (!cfg.value) return DEFAULT_DOWNLOAD_CONFIG;
const c = cfg.value;
return {
download_original_img: c.download_original_img,
max_download_img_count: c.max_download_img_count,
max_retry_count: c.max_retry_count,
mpv: c.mpv,
remove_previous_gallery: c.remove_previous_gallery,
};
}