Commit 3a7270c 1 parent e71824a commit 3a7270c Copy full SHA for 3a7270c
File tree 5 files changed +24
-31
lines changed
5 files changed +24
-31
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { HBadge } from "@/ui/badge"
5
5
import { HInput } from " @/ui/input"
6
6
import { useThemeVars } from " @/ui/theme"
7
7
import { uniq } from " lodash-es"
8
+ import { stringArrayEqual } from " ~/utils/string"
8
9
const props = defineProps <{
9
10
availableCats: string []
10
11
categories: string []
@@ -18,29 +19,19 @@ const allCategories = computed(() => {
18
19
return uniq (categories .value .concat (props .availableCats )).sort ()
19
20
})
20
21
watch (
21
- () => props .categories ,
22
- (v ) => {
23
- categories .value = v
24
- },
25
- {
26
- deep: true ,
22
+ () => [... props .categories ],
23
+ (v , old ) => {
24
+ if (! stringArrayEqual (v , old )) categories .value = v
27
25
}
28
26
)
29
27
watch (
30
- () => categories .value ,
31
- (v ) => {
32
- emits (" update:categories" , v )
33
- },
34
- {
35
- deep: true ,
28
+ () => [... categories .value ],
29
+ (v , old ) => {
30
+ if (! stringArrayEqual (v , old )) emits (" update:categories" , v )
36
31
}
37
32
)
38
- // setTimeout(() => {
39
- // categories.value.push("1")
40
- // }, 1000)
41
33
const onNewCat = () => {
42
34
if (newCat .value ) {
43
- // categories.value = [newCat.value]
44
35
categories .value .push (newCat .value )
45
36
newCat .value = " "
46
37
}
Original file line number Diff line number Diff line change @@ -30,7 +30,8 @@ onMounted(() => {
30
30
31
31
resetModal ()
32
32
instance .onDidChangeModelContent (() => {
33
- emits (" update:value" , instance .getValue ())
33
+ const newValue = instance .getValue ()
34
+ if (newValue !== props .value ) emits (" update:value" , newValue )
34
35
})
35
36
36
37
setTimeout (() => {
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { HInput } from "@/ui/input"
5
5
import { HIcon , HIconName } from " @/ui/icon"
6
6
import { HBadge } from " @/ui/badge"
7
7
import { useThemeVars } from " @/ui/theme"
8
+
8
9
const props = defineProps <{
9
10
availableTags: string []
10
11
tags: string []
@@ -17,21 +18,15 @@ const newTag = ref("")
17
18
18
19
const tags = ref <string []>(props .tags )
19
20
watch (
20
- () => props .tags ,
21
- (ts ) => {
22
- tags .value = ts
23
- },
24
- {
25
- deep: true ,
21
+ () => [... props .tags ],
22
+ (ts , old ) => {
23
+ if (ts .join (" " ) !== old .join (" " )) tags .value = ts
26
24
}
27
25
)
28
26
watch (
29
- () => tags .value ,
30
- (ts ) => {
31
- emits (" update:tags" , ts )
32
- },
33
- {
34
- deep: true ,
27
+ () => [... tags .value ],
28
+ (ts , old ) => {
29
+ if (ts .join (" " ) !== old .join (" " )) emits (" update:tags" , ts )
35
30
}
36
31
)
37
32
const allTags = computed (() => {
Original file line number Diff line number Diff line change
1
+ export function stringArrayEqual ( n : string [ ] , o : string [ ] ) {
2
+ return n . join ( "" ) === o . join ( "" )
3
+ }
Original file line number Diff line number Diff line change @@ -20,8 +20,6 @@ import HToolbar from "@/HToolbar.vue"
20
20
import HLayoutEditor from " @/editors/HLayoutEditor.vue"
21
21
import HNavTitle from " @/ui/nav-list/src/HNavTitle.vue"
22
22
import ErroredView from " ./ErroredView.vue"
23
- import dayjs from " dayjs"
24
- import HDatePicker from " ~/components/ui/date-picker/src/HDatePicker.vue"
25
23
26
24
const [HMonacoEditor, monacoLoading] = useAsyncComponentWithLoading (
27
25
() => import (" @/editors/HMonacoEditor.vue" )
@@ -104,18 +102,23 @@ const updateFromObj = (obj: any) => {
104
102
setChanged ()
105
103
}
106
104
const updateTitle = (title : string = " " ) => {
105
+ console .log (" updateTitle" )
107
106
updateFromObj ({ title })
108
107
}
109
108
const updateContent = (_content : string ) => {
109
+ console .log (" updateContent" )
110
110
updateFromObj ({ _content })
111
111
}
112
112
const updateTags = (tags : string [] = []) => {
113
+ console .log (" updateTags" )
113
114
updateFromObj ({ tags })
114
115
}
115
116
const updateCategories = (categories : string [] = []) => {
117
+ console .log (" updateCategories" )
116
118
updateFromObj ({ categories })
117
119
}
118
120
const updateLayout = (layout : string = " " ) => {
121
+ console .log (" updateLayout" )
119
122
updateFromObj ({ layout })
120
123
}
121
124
// #endregion
You can’t perform that action at this time.
0 commit comments