update: hooks, web

This commit is contained in:
Vick Scarlet
2026-08-11 02:17:31 +08:00
parent 727fe5de77
commit 5353edd6a1
67 changed files with 2339 additions and 2243 deletions
+19
View File
@@ -0,0 +1,19 @@
import { useCallback } from 'react'
import { atom, useAtom, useSetAtom } from 'jotai'
import type { ProfileState } from '@remake/core'
const profileAtom = atom<ProfileState | null>(null)
export const useProfile = () => {
const [profile, setProfile] = useAtom(profileAtom)
if (!profile) throw new Error('Profile is not loaded')
return [profile, setProfile] as const
}
export const useProfileInject = () => {
const setProfile = useSetAtom(profileAtom)
return useCallback(
(profile: ProfileState) => setProfile(profile),
[setProfile],
)
}