-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.vue
104 lines (97 loc) · 2.38 KB
/
App.vue
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<template>
<div class="app">
<KeDevtools
:items="devtoolsItems"
local-storage-key="ke-devtools-example"
@init="onInit"
@change="onChange"
>
<template #item-example-save="{ active }">
<span class="example" :class="{ active: active }">save local</span>
</template>
<template #item-example-not-save>
<span class="example">not save local</span>
</template>
<template #item-default-active-true="{ active }">
<span class="example" :class="{ active: active }">
default active true
</span>
</template>
</KeDevtools>
<div class="content">
example content
<div class="content" v-if="isVisibleSaveContent">
content if save flag true
</div>
</div>
</div>
</template>
<script lang="ts">
import Vue from "vue";
import KeDevtools from "./components/KeDevtools.vue";
import { TChangePayload, TDevtoolsItem } from "./components/types";
const enum EDevtoolsExample {
SAVE = "example-save",
NOT_SAVE = "example-not-save",
DEFAULT_ACTIVE_TRUE = "default-active-true",
}
const devtoolsItems: TDevtoolsItem<EDevtoolsExample>[] = [
{
key: EDevtoolsExample.SAVE,
},
{
key: EDevtoolsExample.NOT_SAVE,
saveLocal: false,
},
{
key: EDevtoolsExample.DEFAULT_ACTIVE_TRUE,
defaultActive: true,
},
];
export default Vue.extend({
name: "App",
components: {
KeDevtools,
},
data() {
return {
devtoolsItems,
isVisibleSaveContent: false,
};
},
methods: {
onInit(payload: EDevtoolsExample[]) {
this.isVisibleSaveContent = payload.includes(EDevtoolsExample.SAVE);
},
onChange(payload: TChangePayload<EDevtoolsExample>) {
switch (payload.key) {
case EDevtoolsExample.SAVE:
this.isVisibleSaveContent = payload.value;
console.log(EDevtoolsExample.SAVE, payload.value);
break;
case EDevtoolsExample.NOT_SAVE:
console.log(EDevtoolsExample.NOT_SAVE, payload.value);
break;
case EDevtoolsExample.DEFAULT_ACTIVE_TRUE:
console.log(EDevtoolsExample.DEFAULT_ACTIVE_TRUE, payload.value);
break;
default:
break;
}
},
},
});
</script>
<style scoped>
.content {
height: 100px;
border: 1px solid aquamarine;
cursor: pointer;
}
.example {
color: white;
}
.example.active {
color: aqua;
}
</style>