File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed
modules/layout/components Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -29,9 +29,13 @@ function setLocalStorage(key: string, payload: any) {
29
29
localStorage . setItem ( key , value )
30
30
}
31
31
32
- function getLocalStorage < T = any > ( key : string ) {
32
+ function getLocalStorage < T = any > ( key : string , defaultValue ?: any ) {
33
33
let value : any = localStorage . getItem ( key )
34
34
35
+ if ( value === null ) {
36
+ return defaultValue
37
+ }
38
+
35
39
if ( [ 'true' , 'false' ] . includes ( value ) ) {
36
40
value = value === 'true'
37
41
}
@@ -45,7 +49,7 @@ function getLocalStorage<T = any>(key: string) {
45
49
46
50
export function useState < T = any > ( key : string , defaultValue ?: T , options ?: Options ) {
47
51
if ( options ?. localStorage && ! states . value . has ( key ) ) {
48
- states . value . set ( key , getLocalStorage ( key ) || defaultValue )
52
+ states . value . set ( key , getLocalStorage ( key , defaultValue ) )
49
53
}
50
54
51
55
if ( ! states . value . has ( key ) ) {
Original file line number Diff line number Diff line change 1
1
<script setup lang="ts">
2
2
import { computed } from ' vue'
3
3
4
- import { useState } from ' @/composables/state'
5
4
import { useStore as useMenu } from ' @/modules/menu/store'
6
5
import { useStore as useWorkspace } from ' @/modules/workspace/store'
7
6
8
7
import LDrawerItem from ' ./LDrawerItem.vue'
9
8
import { useI18n } from ' vue-i18n'
10
9
import Menu from ' @core/entities/menu'
10
+ import { useToggleDrawer } from ' ../composables/drawer'
11
11
12
- const drawer = useState (' app:drawer' , true , {
13
- localStorage: true ,
14
- })
12
+ const drawer = useToggleDrawer ()
15
13
16
14
// menu
17
15
const tm = useI18n ()
You can’t perform that action at this time.
0 commit comments