mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-06-06 05:38:44 +08:00
Fix redirect to flutter not works
This commit is contained in:
@@ -30,6 +30,7 @@ import * as $api_user from "./routes/api/user.ts";
|
||||
import * as $file_id_ from "./routes/file/[id].ts";
|
||||
import * as $file_verify_id_ from "./routes/file/[verify]/[id].ts";
|
||||
import * as $file_middleware from "./routes/file/_middleware.ts";
|
||||
import * as $index from "./routes/index.ts";
|
||||
import * as $thumbnail_id_ from "./routes/thumbnail/[id].ts";
|
||||
import * as $thumbnail_middleware from "./routes/thumbnail/_middleware.ts";
|
||||
import * as $upload from "./routes/upload.tsx";
|
||||
@@ -67,6 +68,7 @@ const manifest = {
|
||||
"./routes/file/[id].ts": $file_id_,
|
||||
"./routes/file/[verify]/[id].ts": $file_verify_id_,
|
||||
"./routes/file/_middleware.ts": $file_middleware,
|
||||
"./routes/index.ts": $index,
|
||||
"./routes/thumbnail/[id].ts": $thumbnail_id_,
|
||||
"./routes/thumbnail/_middleware.ts": $thumbnail_middleware,
|
||||
"./routes/upload.tsx": $upload,
|
||||
|
||||
26
routes/index.ts
Normal file
26
routes/index.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Handlers } from "$fresh/server.ts";
|
||||
import { get_task_manager } from "../server.ts";
|
||||
import { get_host } from "../server/utils.ts";
|
||||
import { exists } from "std/fs/exists.ts";
|
||||
|
||||
export const handler: Handlers = {
|
||||
async GET(req, _ctx) {
|
||||
const m = get_task_manager();
|
||||
if (m.cfg.redirect_to_flutter) {
|
||||
let flutter_base = import.meta.resolve("../static/flutter").slice(
|
||||
7,
|
||||
);
|
||||
if (Deno.build.os === "windows") {
|
||||
flutter_base = flutter_base.slice(1);
|
||||
}
|
||||
if (m.cfg.flutter_frontend) {
|
||||
flutter_base = m.cfg.flutter_frontend;
|
||||
}
|
||||
if (!await exists(flutter_base)) {
|
||||
return new Response("404 Not Found", {status: 404});
|
||||
}
|
||||
return Response.redirect(`${get_host(req)}/flutter/`);
|
||||
}
|
||||
return new Response("404 Not Found", {status: 404});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user