Files
Folo/apps/desktop/layer/renderer/src/App.tsx
T
Innei 496b1d65b2 refactor: replace tipc to ipcServices (#3863)
* init

* refactor: remove @egoist/tipc integration and clean up IPC services

- Deleted references to @egoist/tipc, including related imports and methods.
- Refactored IPC services to utilize decorators for method registration.
- Updated renderer to use new IPC method calls directly.
- Cleaned up unused files and dependencies related to tipc.
- Enhanced the structure of IPC services for better maintainability.

Signed-off-by: Innei <tukon479@gmail.com>

* refactor: replace tipcClient with ipcServices and clean up IPC integration

- Removed all instances of tipcClient and replaced them with ipcServices for improved IPC method calls.
- Deleted the obsolete ipc-client.ts file and related references.
- Updated various components and hooks to utilize the new ipcServices structure.
- Enhanced type safety and maintainability of IPC service interactions.

Signed-off-by: Innei <tukon479@gmail.com>

---------

Signed-off-by: Innei <tukon479@gmail.com>
2025-06-03 23:12:48 +08:00

83 lines
2.2 KiB
TypeScript

import { isMobile } from "@follow/components/hooks/useMobile.js"
import { IN_ELECTRON } from "@follow/shared/constants"
import { tracker } from "@follow/tracker"
import { cn, getOS } from "@follow/utils/utils"
import { useEffect } 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 { 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()
useEffect(() => {
removeAppSkeleton()
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 entryColWidth = useUISettingKey("entryColWidth")
const feedColWidth = useUISettingKey("feedColWidth")
return (
<div className="flex size-full">
<div
className="h-full shrink-0"
style={{
width: `${feedColWidth}px`,
}}
/>
<div className="bg-theme-background relative size-full grow">
<div className="bg-border absolute inset-y-0 w-px" style={{ left: entryColWidth }} />
</div>
</div>
)
}
export { App as Component }