mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-06-06 05:38:44 +08:00
Update
This commit is contained in:
@@ -25,6 +25,7 @@ export type ConfigType = {
|
||||
img_verify_secret?: string;
|
||||
meili_hosts?: Record<string, string>;
|
||||
cors_credentials_hosts: Array<string>;
|
||||
flutter_frontend?: string;
|
||||
};
|
||||
|
||||
export enum ThumbnailMethod {
|
||||
@@ -160,6 +161,9 @@ export class Config {
|
||||
}
|
||||
return [];
|
||||
}
|
||||
get flutter_frontend() {
|
||||
return this._return_string("flutter_frontend");
|
||||
}
|
||||
to_json(): ConfigType {
|
||||
return {
|
||||
cookies: typeof this.cookies === "string",
|
||||
@@ -185,6 +189,7 @@ export class Config {
|
||||
img_verify_secret: this.img_verify_secret,
|
||||
meili_hosts: this.meili_hosts,
|
||||
cors_credentials_hosts: this.cors_credentials_hosts,
|
||||
flutter_frontend: this.flutter_frontend,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
18
fresh.gen.ts
18
fresh.gen.ts
@@ -23,10 +23,11 @@ import * as $17 from "./routes/api/token.ts";
|
||||
import * as $18 from "./routes/api/user.ts";
|
||||
import * as $19 from "./routes/file/[id].ts";
|
||||
import * as $20 from "./routes/file/_middleware.ts";
|
||||
import * as $21 from "./routes/index.tsx";
|
||||
import * as $22 from "./routes/manifest.json.ts";
|
||||
import * as $23 from "./routes/thumbnail/[id].ts";
|
||||
import * as $24 from "./routes/thumbnail/_middleware.ts";
|
||||
import * as $21 from "./routes/flutter/_middleware.ts";
|
||||
import * as $22 from "./routes/index.tsx";
|
||||
import * as $23 from "./routes/manifest.json.ts";
|
||||
import * as $24 from "./routes/thumbnail/[id].ts";
|
||||
import * as $25 from "./routes/thumbnail/_middleware.ts";
|
||||
import * as $$0 from "./islands/Container.tsx";
|
||||
import * as $$1 from "./islands/Settings.tsx";
|
||||
import * as $$2 from "./islands/TaskManager.tsx";
|
||||
@@ -54,10 +55,11 @@ const manifest = {
|
||||
"./routes/api/user.ts": $18,
|
||||
"./routes/file/[id].ts": $19,
|
||||
"./routes/file/_middleware.ts": $20,
|
||||
"./routes/index.tsx": $21,
|
||||
"./routes/manifest.json.ts": $22,
|
||||
"./routes/thumbnail/[id].ts": $23,
|
||||
"./routes/thumbnail/_middleware.ts": $24,
|
||||
"./routes/flutter/_middleware.ts": $21,
|
||||
"./routes/index.tsx": $22,
|
||||
"./routes/manifest.json.ts": $23,
|
||||
"./routes/thumbnail/[id].ts": $24,
|
||||
"./routes/thumbnail/_middleware.ts": $25,
|
||||
},
|
||||
islands: {
|
||||
"./islands/Container.tsx": $$0,
|
||||
|
||||
25
routes/flutter/_middleware.ts
Normal file
25
routes/flutter/_middleware.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
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