-
-
Notifications
You must be signed in to change notification settings - Fork 250
Expand file tree
/
Copy pathstate.ts
More file actions
54 lines (49 loc) · 1.16 KB
/
state.ts
File metadata and controls
54 lines (49 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import type { DeepReadonly, Ref } from 'vue'
import { useLocalStorage } from '@vueuse/core'
import { readonly } from 'vue'
interface DevToolsFrameState {
width: number
height: number
top: number
left: number
open: boolean
route: string
position: string
isFirstVisit: boolean
closeOnOutsideClick: boolean
minimizePanelInactive: number
preferShowFloatingPanel: boolean
reduceMotion: boolean
flashUpdates: boolean
}
export interface UseFrameStateReturn {
state: DeepReadonly<Ref<DevToolsFrameState>>
updateState: (value: Partial<DevToolsFrameState>) => void
}
const state = useLocalStorage<DevToolsFrameState>('__vue-devtools-frame-state__', {
width: 80,
height: 60,
top: 0,
left: 50,
open: false,
route: '/',
position: 'bottom',
isFirstVisit: true,
closeOnOutsideClick: false,
minimizePanelInactive: 5000,
preferShowFloatingPanel: true,
reduceMotion: false,
flashUpdates: false,
})
export function useFrameState(): UseFrameStateReturn {
function updateState(value: Partial<DevToolsFrameState>) {
state.value = {
...state.value,
...value,
}
}
return {
state: readonly(state),
updateState,
}
}