Files
Folo/apps/desktop/layer/renderer/src/App.tsx
T
Innei 0ede6fb2cd feat(dependencies): refactor ipc decorator
- Updated the version of electron-ipc-decorator in package.json files for both main and renderer processes to 0.2.0, ensuring compatibility with the latest features and improvements.
- Adjusted pnpm-lock.yaml to reflect the new version and its integrity hash.
- Refactored IPC service classes to utilize the new version, enhancing code organization and functionality.
- Removed deprecated constructor calls in IPC service classes, simplifying the implementation.

These changes improve dependency management and enhance the overall architecture of the IPC system.

Signed-off-by: Innei <tukon479@gmail.com>
2025-08-23 18:32:55 +08:00

87 lines
2.3 KiB
TypeScript

import { isMobile } from "@follow/components/hooks/useMobile.js"
import { IN_ELECTRON } from "@follow/shared/constants"
import { tracker } from "@follow/tracker"
import { nextFrame } from "@follow/utils"
import { cn, getOS } from "@follow/utils/utils"
import { useEffect, useLayoutEffect, useRef } from "react"
import { Outlet } from "react-router"
import { useAppIsReady } from "./atoms/app"
import { useUISettingKey } from "./atoms/settings/ui"
import { applyAfterReadyCallbacks } from "./initialize/queue"
import { removeAppSkeleton } from "./lib/app"
import { ipcServices } from "./lib/client"
import { appLog } from "./lib/log"
import { Titlebar } from "./modules/app/Titlebar"
import { RootProviders } from "./providers/root-providers"
function App() {
const windowsElectron = IN_ELECTRON && getOS() === "Windows"
return (
<RootProviders>
{IN_ELECTRON && (
<div
className={cn(
"drag-region fixed inset-x-0 top-0 h-12 shrink-0",
windowsElectron && "pointer-events-none z-[9999]",
)}
aria-hidden
>
{windowsElectron && <Titlebar />}
</div>
)}
<AppLayer />
</RootProviders>
)
}
const AppLayer = () => {
const appIsReady = useAppIsReady()
const onceReady = useRef(false)
useLayoutEffect(() => {
if (appIsReady && !onceReady.current) {
onceReady.current = true
ipcServices?.app.readyToShowMainWindow()
nextFrame(removeAppSkeleton)
}
}, [appIsReady])
useEffect(() => {
const doneTime = Math.trunc(performance.now())
tracker.uiRenderInit(doneTime)
appLog("App is ready", `${doneTime}ms`)
applyAfterReadyCallbacks()
if (isMobile()) {
const handler = (e: MouseEvent) => {
e.preventDefault()
}
document.addEventListener("contextmenu", handler)
return () => {
document.removeEventListener("contextmenu", handler)
}
}
}, [appIsReady])
return appIsReady ? <Outlet /> : <AppSkeleton />
}
const AppSkeleton = () => {
const feedColWidth = useUISettingKey("feedColWidth")
return (
<div className="flex size-full">
<div
className="bg-sidebar h-full shrink-0"
style={{
width: `${feedColWidth}px`,
}}
/>
</div>
)
}
export { App as Component }