98 lines
1.9 KiB
Vue
Raw Normal View History

2019-03-15 10:08:39 +08:00
<template>
2021-04-04 19:09:44 +08:00
<div id="prop">
<div v-for="(group, index) in allGroup" :key="index" class="group">
<div class="header" @click="onClickHeader(group)">
2021-06-17 22:35:37 +08:00
<div style="margin: 0 5px;">
<i v-if="group.fold" class="el-icon-caret-right"></i>
<i v-if="!group.fold" class="el-icon-caret-bottom"></i>
</div>
2021-04-04 19:09:44 +08:00
{{ group.name }}
</div>
<div class="content" v-show="!group.fold">
<ui-prop v-for="(item, index) in group.data" :key="index"
:name="item.name" :value="item.value">
</ui-prop>
2021-04-03 22:45:51 +08:00
</div>
2021-04-04 19:09:44 +08:00
</div>
2019-03-15 10:08:39 +08:00
</div>
</template>
2021-04-02 22:34:09 +08:00
<script lang="ts">
import Vue from "vue"
2021-04-06 18:50:58 +08:00
import {Component, Prop, Watch} from "vue-property-decorator"
2021-04-03 22:45:51 +08:00
import UiProp from "./ui-prop.vue"
2021-04-03 11:42:08 +08:00
2021-04-02 22:34:09 +08:00
@Component({
2021-04-03 11:42:08 +08:00
components: {UiProp},
2021-04-02 22:34:09 +08:00
})
2021-04-20 11:15:30 +08:00
export default class properties extends Vue {
name: string = "properties"
2021-04-03 19:31:47 +08:00
2021-04-07 17:26:16 +08:00
@Prop({default: () => [],})
2021-04-04 19:09:44 +08:00
allGroup: Array<Record<string, any>> | undefined;
2021-04-04 20:48:18 +08:00
onClickHeader(group: any) {
if (group && group.hasOwnProperty('fold')) {
group.fold = !group.fold;
}
2021-04-04 19:09:44 +08:00
}
2021-04-03 22:45:51 +08:00
@Prop({default: "label"})
private label?: string | undefined
2021-04-03 19:31:47 +08:00
setup() {
2021-04-06 18:50:58 +08:00
}
@Watch('allGroup')
watchAllGroup() {
this._initValue();
2021-04-03 19:31:47 +08:00
}
2021-04-02 22:34:09 +08:00
created() {
2021-04-06 18:50:58 +08:00
this._initValue();
}
_initValue() {
2021-04-04 20:48:18 +08:00
if (this.allGroup) {
this.allGroup.forEach(item => {
this.$set(item, 'fold', false);
})
}
2021-04-04 19:09:44 +08:00
}
2021-06-17 22:35:37 +08:00
2021-04-03 11:42:08 +08:00
_evalCode(code: string) {
2021-04-02 22:34:09 +08:00
if (chrome && chrome.devtools) {
chrome.devtools.inspectedWindow.eval(code);
} else {
console.log(code);
}
}
}
</script>
2021-04-04 19:09:44 +08:00
<style scoped lang="less">
#prop {
.group {
.header {
height: 40px;
display: flex;
flex-direction: row;
align-items: center;
user-select: none;
cursor: pointer;
border-bottom: 1px #6d6d6d solid;
}
2021-04-02 22:34:09 +08:00
2021-04-04 19:09:44 +08:00
.header:hover {
color: #6d6d6d;
}
2021-04-02 22:34:09 +08:00
2021-04-04 19:09:44 +08:00
.content {
padding: 0 5px;
}
}
2021-04-02 22:34:09 +08:00
}
2019-03-15 10:08:39 +08:00
</style>