File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
packages/app-frontend/src/features Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 1
1
<script >
2
- import { ref , computed } from ' @vue/composition-api'
2
+ import { ref , computed , watch } from ' @vue/composition-api'
3
3
import { useOrientation } from ' ./orientation'
4
4
5
5
export default {
@@ -23,13 +23,41 @@ export default {
23
23
type: String ,
24
24
default: ' center' ,
25
25
validator : value => [' before' , ' center' , ' after' ].includes (value)
26
+ },
27
+
28
+ saveId: {
29
+ type: String ,
30
+ default: null
26
31
}
27
32
},
28
33
29
34
setup (props ) {
30
35
const { orientation } = useOrientation ()
31
36
32
37
const split = ref (props .defaultSplit )
38
+
39
+ if (props .saveId ) {
40
+ const storageKey = ` split-pane-${ props .saveId } `
41
+
42
+ const savedValue = localStorage .getItem (storageKey)
43
+ if (savedValue != null ) {
44
+ let parsedValue
45
+ try {
46
+ parsedValue = JSON .parse (savedValue)
47
+ } catch (e) {
48
+ console .error (e)
49
+ }
50
+
51
+ if (typeof parsedValue === ' number' ) {
52
+ split .value = parsedValue
53
+ }
54
+ }
55
+
56
+ watch (split, value => {
57
+ localStorage .setItem (storageKey, JSON .stringify (value))
58
+ })
59
+ }
60
+
33
61
const boundSplit = computed (() => {
34
62
if (split .value < props .min ) {
35
63
return props .min
Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ export default {
69
69
<template >
70
70
<div >
71
71
<SplitPane
72
+ save-id =" timeline-left-main"
72
73
:default-split =" 25"
73
74
dragger-offset =" before"
74
75
>
@@ -96,6 +97,7 @@ export default {
96
97
97
98
<template #right >
98
99
<SplitPane
100
+ save-id =" timeline-right"
99
101
:default-split =" 70"
100
102
:max =" 85"
101
103
dragger-offset =" after"
You can’t perform that action at this time.
0 commit comments