mirror of
https://github.com/woodchen-ink/clash-and-dashboard.git
synced 2025-07-18 05:51: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<{
|
||||
hostname: string
|
||||
port: string
|
||||
secret: string
|
||||
}>>('externalControllers', [])
|
||||
export const hostSelectIdxStorageAtom = atomWithStorage<number>('externalControllerIndex', 0)
|
||||
}>>('externalControllers', JSON.parse(hostsStorageOrigin))
|
||||
export const hostSelectIdxStorageAtom = atomWithStorage<number>('externalControllerIndex', parseInt(hostSelectIdxStorageOrigin))
|
||||
|
||||
export function useAPIInfo () {
|
||||
const clashx = useAtomValue(clashxConfigAtom)
|
||||
|
Loading…
x
Reference in New Issue
Block a user