mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-06-06 05:38:44 +08:00
Add port setting
This commit is contained in:
@@ -13,5 +13,6 @@
|
|||||||
"db_path": "./downloads",
|
"db_path": "./downloads",
|
||||||
"max_retry_count": 3,
|
"max_retry_count": 3,
|
||||||
"max_download_img_count": 3,
|
"max_download_img_count": 3,
|
||||||
"download_original_img": true
|
"download_original_img": true,
|
||||||
|
"port": 8000
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export type ConfigType = {
|
|||||||
max_retry_count: number;
|
max_retry_count: number;
|
||||||
max_download_img_count: number;
|
max_download_img_count: number;
|
||||||
download_original_img: boolean;
|
download_original_img: boolean;
|
||||||
|
port: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export class Config {
|
export class Config {
|
||||||
@@ -85,6 +86,9 @@ export class Config {
|
|||||||
get download_original_img() {
|
get download_original_img() {
|
||||||
return this._return_bool("download_original_img") || false;
|
return this._return_bool("download_original_img") || false;
|
||||||
}
|
}
|
||||||
|
get port() {
|
||||||
|
return this._return_number("port") || 8000;
|
||||||
|
}
|
||||||
to_json(): ConfigType {
|
to_json(): ConfigType {
|
||||||
return {
|
return {
|
||||||
cookies: typeof this.cookies === "string",
|
cookies: typeof this.cookies === "string",
|
||||||
@@ -97,6 +101,7 @@ export class Config {
|
|||||||
max_retry_count: this.max_retry_count,
|
max_retry_count: this.max_retry_count,
|
||||||
max_download_img_count: this.max_download_img_count,
|
max_download_img_count: this.max_download_img_count,
|
||||||
download_original_img: this.download_original_img,
|
download_original_img: this.download_original_img,
|
||||||
|
port: this.port,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,6 +178,14 @@ export default class Settings extends Component<SettingsProps> {
|
|||||||
description={t("settings.db_path")}
|
description={t("settings.db_path")}
|
||||||
helpertext={t("settings.db_path_help")}
|
helpertext={t("settings.db_path_help")}
|
||||||
/>
|
/>
|
||||||
|
<SettingsText
|
||||||
|
name="port"
|
||||||
|
value={settings.port}
|
||||||
|
description={t("settings.port")}
|
||||||
|
type="number"
|
||||||
|
min={0}
|
||||||
|
max={65535}
|
||||||
|
/>
|
||||||
</SettingsContext>
|
</SettingsContext>
|
||||||
<Button onClick={loadData}>{t("common.reload")}</Button>
|
<Button onClick={loadData}>{t("common.reload")}</Button>
|
||||||
<Button onClick={showDlg} disabled={disabled}>
|
<Button onClick={showDlg} disabled={disabled}>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Handlers } from "$fresh/server.ts";
|
|||||||
import { ConfigType, load_settings, save_settings } from "../../config.ts";
|
import { ConfigType, load_settings, save_settings } from "../../config.ts";
|
||||||
import { get_cfg_path, get_task_manager } from "../../server.ts";
|
import { get_cfg_path, get_task_manager } from "../../server.ts";
|
||||||
|
|
||||||
const UNSAFE_TYPE: (keyof ConfigType)[] = ["base", "db_path"];
|
const UNSAFE_TYPE: (keyof ConfigType)[] = ["base", "db_path", "port"];
|
||||||
const UNSAFE_TYPE2 = UNSAFE_TYPE as string[];
|
const UNSAFE_TYPE2 = UNSAFE_TYPE as string[];
|
||||||
|
|
||||||
export const handler: Handlers = {
|
export const handler: Handlers = {
|
||||||
|
|||||||
@@ -35,5 +35,6 @@ export async function startServer(path: string) {
|
|||||||
signal: task_manager.aborts,
|
signal: task_manager.aborts,
|
||||||
plugins: [twindPlugin(twindConfig)],
|
plugins: [twindPlugin(twindConfig)],
|
||||||
render: renderFn,
|
render: renderFn,
|
||||||
|
port: cfg.port,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,5 +17,6 @@
|
|||||||
"max_download_img_count": "Maximum number of parallel downloads of images: ",
|
"max_download_img_count": "Maximum number of parallel downloads of images: ",
|
||||||
"save_dlg": "Do you want to save settings?",
|
"save_dlg": "Do you want to save settings?",
|
||||||
"db_path": "The folder where the database is stored: ",
|
"db_path": "The folder where the database is stored: ",
|
||||||
"db_path_help": "If not set, the download location is used."
|
"db_path_help": "If not set, the download location is used.",
|
||||||
|
"port": "Listening port: "
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,5 +17,6 @@
|
|||||||
"max_download_img_count": "最大图片并行下载数:",
|
"max_download_img_count": "最大图片并行下载数:",
|
||||||
"save_dlg": "是否保存设置?",
|
"save_dlg": "是否保存设置?",
|
||||||
"db_path": "存放数据库的文件夹位置:",
|
"db_path": "存放数据库的文件夹位置:",
|
||||||
"db_path_help": "如果未设置,将使用下载位置。"
|
"db_path_help": "如果未设置,将使用下载位置。",
|
||||||
|
"port": "监听端口:"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user