mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-06-11 08:08:46 +08:00
add new settings redirect_to_flutter
This commit is contained in:
@@ -30,6 +30,7 @@ export type ConfigType = {
|
||||
fetch_timeout: number;
|
||||
download_timeout: number;
|
||||
ffprobe_path: string;
|
||||
redirect_to_flutter: boolean;
|
||||
};
|
||||
|
||||
export enum ThumbnailMethod {
|
||||
@@ -186,6 +187,9 @@ export class Config {
|
||||
get ffprobe_path() {
|
||||
return this._return_string("ffprobe_path") || "ffprobe";
|
||||
}
|
||||
get redirect_to_flutter() {
|
||||
return this._return_bool("redirect_to_flutter") ?? true;
|
||||
}
|
||||
to_json(): ConfigType {
|
||||
return {
|
||||
cookies: typeof this.cookies === "string",
|
||||
@@ -215,6 +219,7 @@ export class Config {
|
||||
fetch_timeout: this.fetch_timeout,
|
||||
download_timeout: this.download_timeout,
|
||||
ffprobe_path: this.ffprobe_path,
|
||||
redirect_to_flutter: this.redirect_to_flutter,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,10 @@ import { Handlers, PageProps } from "$fresh/server.ts";
|
||||
import GlobalContext from "../components/GlobalContext.tsx";
|
||||
import Container from "../islands/Container.tsx";
|
||||
import { get_i18nmap, i18n_handle_request } from "../server/i18ns.ts";
|
||||
import { get_task_manager } from "../server.ts";
|
||||
import { UserAgent } from "std/http/user_agent.ts";
|
||||
import { exists } from "std/fs/exists.ts";
|
||||
import { get_host } from "../server/utils.ts";
|
||||
|
||||
type Props = {
|
||||
lang: string;
|
||||
@@ -11,13 +14,28 @@ type Props = {
|
||||
};
|
||||
|
||||
export const handler: Handlers<Props> = {
|
||||
GET(req, ctx) {
|
||||
async GET(req, ctx) {
|
||||
const re = i18n_handle_request(req);
|
||||
const m = get_task_manager();
|
||||
if (typeof re === "string") {
|
||||
return ctx.render({
|
||||
lang: re,
|
||||
userAgent: req.headers.get("User-Agent"),
|
||||
});
|
||||
} else 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 re;
|
||||
}
|
||||
return Response.redirect(`${get_host(req)}/flutter/`);
|
||||
}
|
||||
return re;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user