File tree 2 files changed +12
-7
lines changed
views/HomeView/components 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import {
11
11
ignoredError ,
12
12
message ,
13
13
alert ,
14
+ sampleID ,
14
15
} from '@/utils'
15
16
import {
16
17
Download ,
@@ -43,6 +44,7 @@ export const useAppStore = defineStore('app', () => {
43
44
44
45
/* Actions */
45
46
interface CustomAction {
47
+ id ?: string
46
48
component : string
47
49
componentProps ?: Recordable
48
50
componentSlots ?: Recordable
@@ -57,15 +59,18 @@ export const useAppStore = defineStore('app', () => {
57
59
| string
58
60
| number
59
61
| boolean
60
- const customActions : { [ key : string ] : CustomAction [ ] } = {
62
+ const customActions = ref < { [ key : string ] : CustomAction [ ] } > ( {
61
63
core_state : [ ] ,
62
- }
64
+ } )
63
65
const addCustomActions = ( target : string , actions : CustomAction | CustomAction [ ] ) => {
64
- if ( ! customActions [ target ] ) throw new Error ( 'Target does not exist: ' + target )
66
+ if ( ! customActions . value [ target ] ) throw new Error ( 'Target does not exist: ' + target )
65
67
const _actions = Array . isArray ( actions ) ? actions : [ actions ]
66
- customActions [ target ] . push ( ..._actions )
68
+ _actions . forEach ( ( action ) => ( action . id = sampleID ( ) ) )
69
+ customActions . value [ target ] . push ( ..._actions )
67
70
const remove = ( ) => {
68
- customActions [ target ] = customActions [ target ] . filter ( ( a ) => ! _actions . includes ( a ) )
71
+ customActions . value [ target ] = customActions . value [ target ] . filter (
72
+ ( a ) => ! _actions . some ( ( added ) => added . id === a . id ) ,
73
+ )
69
74
}
70
75
return remove
71
76
}
Original file line number Diff line number Diff line change @@ -163,8 +163,8 @@ onUnmounted(() => {
163
163
{{ t('home.overview.tunMode') }}
164
164
</Switch >
165
165
<component
166
- v-for =" ( action, index) in appStore.customActions.core_state"
167
- :key =" index "
166
+ v-for =" action in appStore.customActions.core_state"
167
+ :key =" action.id "
168
168
:is =" action.component"
169
169
v-bind =" action.componentProps"
170
170
class =" ml-8"
You can’t perform that action at this time.
0 commit comments