mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-06-06 05:38:44 +08:00
Fix
This commit is contained in:
@@ -6,6 +6,8 @@ import {
|
||||
get_file_response,
|
||||
GetFileResponseOptions,
|
||||
} from "../server/get_file_response.ts";
|
||||
import { exists } from "std/fs/exists.ts";
|
||||
import { get_task_manager } from "../server.ts";
|
||||
|
||||
const STATIC_FILES = ["/common.css", "/scrollBar.css", "/sw.js", "/sw.js.map"];
|
||||
|
||||
@@ -73,6 +75,24 @@ export async function handler(req: Request, ctx: MiddlewareHandlerContext) {
|
||||
}
|
||||
return get_file_response(file, opts);
|
||||
}
|
||||
if (url.pathname == "/flutter" || url.pathname.startsWith("/flutter/")) {
|
||||
const m = get_task_manager();
|
||||
if (!m.cfg.flutter_frontend) {
|
||||
return new Response("Flutter frontend is not enabled", {
|
||||
status: 404,
|
||||
});
|
||||
}
|
||||
const u = new URL(req.url);
|
||||
let p = join(m.cfg.flutter_frontend, u.pathname.slice(8));
|
||||
if (!(await exists(p)) || p === m.cfg.flutter_frontend) {
|
||||
p = join(m.cfg.flutter_frontend, "/index.html");
|
||||
}
|
||||
const opts: GetFileResponseOptions = {};
|
||||
opts.range = req.headers.get("range");
|
||||
opts.if_modified_since = req.headers.get("If-Modified-Since");
|
||||
opts.if_unmodified_since = req.headers.get("If-Unmodified-Since");
|
||||
return await get_file_response(p, opts);
|
||||
}
|
||||
const res = await ctx.next();
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
import { MiddlewareHandlerContext } from "$fresh/server.ts";
|
||||
import { get_task_manager } from "../../server.ts";
|
||||
import { join } from "std/path/mod.ts";
|
||||
import { exists } from "std/fs/exists.ts";
|
||||
import {
|
||||
get_file_response,
|
||||
GetFileResponseOptions,
|
||||
} from "../../server/get_file_response.ts";
|
||||
|
||||
export async function handler(req: Request, _ctx: MiddlewareHandlerContext) {
|
||||
const m = get_task_manager();
|
||||
if (!m.cfg.flutter_frontend) {
|
||||
return new Response("Flutter frontend is not enabled", { status: 404 });
|
||||
}
|
||||
const u = new URL(req.url);
|
||||
let p = join(m.cfg.flutter_frontend, u.pathname);
|
||||
if (!(await exists(p))) {
|
||||
p = join(m.cfg.flutter_frontend, "/index.html");
|
||||
}
|
||||
const opts: GetFileResponseOptions = {};
|
||||
opts.range = req.headers.get("range");
|
||||
opts.if_modified_since = req.headers.get("If-Modified-Since");
|
||||
opts.if_unmodified_since = req.headers.get("If-Unmodified-Since");
|
||||
return await get_file_response(p, opts);
|
||||
}
|
||||
Reference in New Issue
Block a user