From c01a48cab974ec034eb2346aa06021bb9879bb2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=93=E9=BC=A0?= <71394853+hamster1963@users.noreply.github.com> Date: Sat, 7 Dec 2024 01:17:00 +0800 Subject: [PATCH] feat: add user_template setting (#36) --- src/locales/en/translation.json | 10 ++++- src/locales/it/translation.json | 10 ++++- src/locales/zh-CN/translation.json | 10 ++++- src/locales/zh-TW/translation.json | 10 ++++- src/routes/settings.tsx | 69 ++++++++++++++++++++++++++++++ src/types/api.ts | 11 +++++ 6 files changed, 116 insertions(+), 4 deletions(-) diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json index c8b866b..ad09879 100644 --- a/src/locales/en/translation.json +++ b/src/locales/en/translation.json @@ -152,5 +152,13 @@ "NewUser": "New user", "Count": "Count", "LastBlockReason": "Last Block Reason", - "LastBlockTime": "Last ban time" + "LastBlockTime": "Last ban time", + "Theme": "Theme", + "Author": "Author", + "Repository": "Repository", + "Community": "Community", + "Official": "Official", + "CommunityThemeWarning": "You are using a community theme", + "CommunityThemeDescription": "This theme is provided by the community, use it at your own risk", + "Cancel": "Cancel" } diff --git a/src/locales/it/translation.json b/src/locales/it/translation.json index b8e794a..65616bb 100644 --- a/src/locales/it/translation.json +++ b/src/locales/it/translation.json @@ -152,5 +152,13 @@ "NewUser": "Nuovo utente", "Count": "Contare", "LastBlockReason": "Motivo dell'ultimo divieto", - "LastBlockTime": "L'ultima volta che è stato vietato" + "LastBlockTime": "L'ultima volta che è stato vietato", + "Theme": "Tema", + "Author": "Autore", + "Repository": "Repository", + "Community": "Comunità", + "Official": "Ufficiale", + "CommunityThemeWarning": "Questo tema appartiene alla comunità", + "CommunityThemeDescription": "Questo tema viene fornito dalla comunità, utilizzalo a tuo rischio e pericolo", + "Cancel": "Annulla" } diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.json index 85264ac..4196c71 100644 --- a/src/locales/zh-CN/translation.json +++ b/src/locales/zh-CN/translation.json @@ -152,5 +152,13 @@ "NewUser": "新用户", "Count": "计数", "LastBlockReason": "最后封禁原因", - "LastBlockTime": "最后封禁时间" + "LastBlockTime": "最后封禁时间", + "Theme": "主题", + "Author": "作者", + "Repository": "仓库", + "Community": "社区", + "Official": "官方", + "CommunityThemeWarning": "正在使用社区主题", + "CommunityThemeDescription": "社区主题未经官方审计,需自行甄别风险。", + "Cancel": "取消" } diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.json index 7bd92e4..e282e43 100644 --- a/src/locales/zh-TW/translation.json +++ b/src/locales/zh-TW/translation.json @@ -152,5 +152,13 @@ "NewUser": "新用戶", "Count": "計數", "LastBlockReason": "最後封鎖原因", - "LastBlockTime": "最後封鎖時間" + "LastBlockTime": "最後封鎖時間", + "Theme": "主題", + "Author": "作者", + "Repository": "仓库", + "Community": "社区", + "Official": "官方", + "CommunityThemeWarning": "正在使用社區主題", + "CommunityThemeDescription": "社區主題未經官方審計,需自行甄別風險。", + "Cancel": "取消" } diff --git a/src/routes/settings.tsx b/src/routes/settings.tsx index 7471026..300aed9 100644 --- a/src/routes/settings.tsx +++ b/src/routes/settings.tsx @@ -38,6 +38,7 @@ const settingFormSchema = z.object({ cover: z.coerce.number().int().min(1), site_name: z.string().min(1), language: z.string().min(2), + user_template: z.string().min(1), install_host: asOptionalField(z.string()), custom_code: asOptionalField(z.string()), custom_code_dashboard: asOptionalField(z.string()), @@ -78,12 +79,14 @@ export default function SettingsPage() { ? { ...config, site_name: config.site_name || "", + user_template: config.user_template || Object.keys(config.user_templates || {})[0] || "user-dist", } : { ip_change_notification_group_id: 0, cover: 1, site_name: "", language: "", + user_template: "user-dist", }, resetOptions: { keepDefaultValues: false, @@ -158,6 +161,72 @@ export default function SettingsPage() { )} /> + ( + + {t("Theme")} + + + + + {config?.user_templates?.find(t => t.path === field.value)?.community && ( +
+
{t("CommunityThemeWarning")}
+
{t("CommunityThemeDescription")}
+
+ )} +
+ )} + />