From 935cf97d57a79963641a33908d640565f433f525 Mon Sep 17 00:00:00 2001 From: lifegpc Date: Tue, 30 May 2023 10:44:38 +0800 Subject: [PATCH] Add port setting --- config.example.jsonc | 3 ++- config.ts | 5 +++++ islands/Settings.tsx | 8 ++++++++ routes/api/config.ts | 2 +- server.ts | 1 + translation/en/settings.jsonc | 3 ++- translation/zh-cn/settings.jsonc | 3 ++- 7 files changed, 21 insertions(+), 4 deletions(-) diff --git a/config.example.jsonc b/config.example.jsonc index 1e3bfa2..708c1db 100644 --- a/config.example.jsonc +++ b/config.example.jsonc @@ -13,5 +13,6 @@ "db_path": "./downloads", "max_retry_count": 3, "max_download_img_count": 3, - "download_original_img": true + "download_original_img": true, + "port": 8000 } diff --git a/config.ts b/config.ts index 63c7aac..82a9951 100644 --- a/config.ts +++ b/config.ts @@ -12,6 +12,7 @@ export type ConfigType = { max_retry_count: number; max_download_img_count: number; download_original_img: boolean; + port: number; }; export class Config { @@ -85,6 +86,9 @@ export class Config { get download_original_img() { return this._return_bool("download_original_img") || false; } + get port() { + return this._return_number("port") || 8000; + } to_json(): ConfigType { return { cookies: typeof this.cookies === "string", @@ -97,6 +101,7 @@ export class Config { max_retry_count: this.max_retry_count, max_download_img_count: this.max_download_img_count, download_original_img: this.download_original_img, + port: this.port, }; } } diff --git a/islands/Settings.tsx b/islands/Settings.tsx index 0f4f060..85e9011 100644 --- a/islands/Settings.tsx +++ b/islands/Settings.tsx @@ -178,6 +178,14 @@ export default class Settings extends Component { description={t("settings.db_path")} helpertext={t("settings.db_path_help")} /> +