From 1292fd41aa04365de1dfae21c6cb9f15255f69db Mon Sep 17 00:00:00 2001 From: Innei Date: Wed, 9 Oct 2024 15:27:40 +0800 Subject: [PATCH] fix: `NotSupport` width reactive Signed-off-by: Innei --- apps/renderer/src/pages/(main)/layout.tsx | 73 ++++++++++--------- .../renderer/src/providers/event-provider.tsx | 2 - 2 files changed, 40 insertions(+), 35 deletions(-) diff --git a/apps/renderer/src/pages/(main)/layout.tsx b/apps/renderer/src/pages/(main)/layout.tsx index 529774225..0b7c472bb 100644 --- a/apps/renderer/src/pages/(main)/layout.tsx +++ b/apps/renderer/src/pages/(main)/layout.tsx @@ -79,49 +79,20 @@ const errorTypes = [ ErrorComponentType.FeedFoundCanBeFollow, ErrorComponentType.FeedNotFound, ] as ErrorComponentType[] + +const supportMinWidth = 1024 export function Component() { const isAuthFail = useLoginModalShow() const user = useWhoami() - const { t } = useTranslation() + const containerRef = useRef(null) useDailyTask() - const supportMinWidth = 1024 const isNotSupportWidth = useViewport((v) => v.w < supportMinWidth && v.w !== 0) && !IN_ELECTRON if (isNotSupportWidth) { - return ( -
- -
{t("notify.unSupportWidth", { app_name: APP_NAME })}
-
- , - }} - values={{ - width: `${window.innerWidth}px`, - minWidth: `${supportMinWidth}px`, - }} - /> -
-
- - {repository.url} - - ), - }} - values={{ app_name: APP_NAME }} - /> -
-
- ) + return } return ( @@ -332,3 +303,39 @@ const FeedResponsiveResizerContainer = ({ ) } + +const NotSupport = () => { + const { t } = useTranslation() + const w = useViewport((v) => v.w) + return ( +
+ +
{t("notify.unSupportWidth", { app_name: APP_NAME })}
+
+ , + }} + values={{ + width: `${w}px`, + minWidth: `${supportMinWidth}px`, + }} + /> +
+
+ + {repository.url} + + ), + }} + values={{ app_name: APP_NAME }} + /> +
+
+ ) +} diff --git a/apps/renderer/src/providers/event-provider.tsx b/apps/renderer/src/providers/event-provider.tsx index 19e38bf07..b666fced4 100644 --- a/apps/renderer/src/providers/event-provider.tsx +++ b/apps/renderer/src/providers/event-provider.tsx @@ -1,5 +1,3 @@ -"use client" - import { useIsomorphicLayoutEffect } from "foxact/use-isomorphic-layout-effect" import { throttle } from "lodash-es" import type { FC } from "react"