mirror of
https://github.com/woodchen-ink/clash-and-dashboard.git
synced 2025-07-18 14:01:56 +08:00
Fix: jotai storage initial value
This commit is contained in:
parent
15fb59681f
commit
0f141b679c
@ -19,12 +19,16 @@ const clashxConfigAtom = atom(async () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// jotai v2 use initialValue first avoid hydration warning, but we don't want that
|
||||||
|
const hostsStorageOrigin = localStorage.getItem('externalControllers') ?? '[]'
|
||||||
|
const hostSelectIdxStorageOrigin = localStorage.getItem('externalControllerIndex') ?? '0'
|
||||||
|
|
||||||
export const hostsStorageAtom = atomWithStorage<Array<{
|
export const hostsStorageAtom = atomWithStorage<Array<{
|
||||||
hostname: string
|
hostname: string
|
||||||
port: string
|
port: string
|
||||||
secret: string
|
secret: string
|
||||||
}>>('externalControllers', [])
|
}>>('externalControllers', JSON.parse(hostsStorageOrigin))
|
||||||
export const hostSelectIdxStorageAtom = atomWithStorage<number>('externalControllerIndex', 0)
|
export const hostSelectIdxStorageAtom = atomWithStorage<number>('externalControllerIndex', parseInt(hostSelectIdxStorageOrigin))
|
||||||
|
|
||||||
export function useAPIInfo () {
|
export function useAPIInfo () {
|
||||||
const clashx = useAtomValue(clashxConfigAtom)
|
const clashx = useAtomValue(clashxConfigAtom)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user