mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-07-08 01:31:00 +08:00
Update
This commit is contained in:
18
server/task.ts
Normal file
18
server/task.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Task } from "../task.ts";
|
||||
import { TaskEventData } from "../task_manager.ts";
|
||||
import { DiscriminatedUnion } from "../utils.ts";
|
||||
|
||||
export type TaskServerSocketData = TaskEventData | { type: "close" } | {
|
||||
type: "tasks";
|
||||
tasks: Task[];
|
||||
running: number[];
|
||||
};
|
||||
|
||||
type EventMap = {
|
||||
new_download_task: { gid: number; token: string };
|
||||
new_export_zip_task: { gid: number; output?: string };
|
||||
};
|
||||
|
||||
export type TaskClientSocketData = DiscriminatedUnion<"type", EventMap> | {
|
||||
type: "close";
|
||||
} | { type: "task_list" };
|
||||
4
server/utils.ts
Normal file
4
server/utils.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export function get_ws_host() {
|
||||
const protocol = document.location.protocol === "https:" ? "wss:" : "ws:";
|
||||
return `${protocol}//${document.location.host}`;
|
||||
}
|
||||
Reference in New Issue
Block a user