From 3ec7e7a784c162799bd9d08ba550f18af6489f68 Mon Sep 17 00:00:00 2001 From: UUBulb <35923940+uubulb@users.noreply.github.com> Date: Sun, 15 Dec 2024 19:38:35 +0800 Subject: [PATCH] fix install commands (#57) * fix install commands * allow disabling animated man * chore: auto-fix linting and formatting issues --------- Co-authored-by: uubulb --- src/components/header.tsx | 17 +++++++---- src/components/install-commands.tsx | 4 +-- src/routes/root.tsx | 2 +- src/routes/settings.tsx | 44 ++++++++++++++--------------- 4 files changed, 36 insertions(+), 31 deletions(-) diff --git a/src/components/header.tsx b/src/components/header.tsx index 0ce8bea..111f185 100644 --- a/src/components/header.tsx +++ b/src/components/header.tsx @@ -64,14 +64,19 @@ export default function Header() { const navigate = useNavigate() + // @ts-expect-error DisableAnimatedMan is a global variable + const disableAnimatedMan = window.DisableAnimatedMan === true + return isDesktop ? (
- {"animated-man"} + {!disableAnimatedMan && ( + {"animated-man"} + )}
void, delay?: number | null) => { - const savedCallback = useRef<() => void>(() => { }) + const savedCallback = useRef<() => void>(() => {}) useEffect(() => { savedCallback.current = callback }) diff --git a/src/components/install-commands.tsx b/src/components/install-commands.tsx index a7f6821..b0446ab 100644 --- a/src/components/install-commands.tsx +++ b/src/components/install-commands.tsx @@ -29,8 +29,8 @@ export const InstallCommandsMenu = forwardRef((p if (!copy) { try { setCopy(true) - if (!settings) throw new Error("Settings is not found.") - await copyToClipboard(generateCommand(type, settings) || "") + if (!settings.data) throw new Error("Settings is not found.") + await copyToClipboard(generateCommand(type, settings.data) || "") } catch (e: Error | any) { console.error(e) toast(t("Error"), { diff --git a/src/routes/root.tsx b/src/routes/root.tsx index 437e02c..2cf0416 100644 --- a/src/routes/root.tsx +++ b/src/routes/root.tsx @@ -42,7 +42,7 @@ export default function Root() { Array.from(tempDiv.childNodes).forEach((node) => { if (node.nodeType === Node.ELEMENT_NODE) { const element = node as HTMLElement - ; (handlers[element.tagName] || handlers.DEFAULT)(element) + ;(handlers[element.tagName] || handlers.DEFAULT)(element) } else if (node.nodeType === Node.TEXT_NODE) { document.body.appendChild(document.createTextNode(node.textContent || "")) } diff --git a/src/routes/settings.tsx b/src/routes/settings.tsx index 3d21384..6e53105 100644 --- a/src/routes/settings.tsx +++ b/src/routes/settings.tsx @@ -57,21 +57,21 @@ export default function SettingsPage() { resolver: zodResolver(settingFormSchema), defaultValues: config ? { - ...config, - language: config.language, - site_name: config.site_name || "", - user_template: - config.user_template || - Object.keys(config.frontend_templates.filter((t) => !t.is_admin) || {})[0] || - "user-dist", - } + ...config, + language: config.language, + site_name: config.site_name || "", + user_template: + config.user_template || + Object.keys(config.frontend_templates.filter((t) => !t.is_admin) || {})[0] || + "user-dist", + } : { - ip_change_notification_group_id: 0, - cover: 1, - site_name: "", - language: "", - user_template: "user-dist", - }, + ip_change_notification_group_id: 0, + cover: 1, + site_name: "", + language: "", + user_template: "user-dist", + }, resetOptions: { keepDefaultValues: false, }, @@ -219,15 +219,15 @@ export default function SettingsPage() { {!config?.frontend_templates?.find( (t) => t.path === field.value, )?.is_official && ( -
-
- {t("CommunityThemeWarning")} -
-
- {t("CommunityThemeDescription")} -
+
+
+ {t("CommunityThemeWarning")}
- )} +
+ {t("CommunityThemeDescription")} +
+
+ )} )} />