This commit is contained in:
syuilo 2022-01-04 23:37:26 +09:00
parent 773f38b171
commit f4010f78fc
4 changed files with 120 additions and 2 deletions

View File

@ -0,0 +1,108 @@
<template>
<div class="igpposuu _monospace">
<div v-if="value === null" class="null">null</div>
<div v-else-if="typeof value === 'boolean'" class="boolean">{{ value ? 'true' : 'false' }}</div>
<div v-else-if="typeof value === 'string'" class="string">"{{ value }}"</div>
<div v-else-if="typeof value === 'number'" class="number">{{ number(value) }}</div>
<div v-else-if="Array.isArray(value)" class="array">
<button @click="collapsed_ = !collapsed_">[ {{ collapsed_ ? '+' : '-' }} ]</button>
<template v-if="!collapsed_">
<div v-for="i in value.length" class="element">
{{ i }}: <XValue :value="value[i - 1]" collapsed/>
</div>
</template>
</div>
<div v-else-if="typeof value === 'object'" class="object">
<button @click="collapsed_ = !collapsed_">{ {{ collapsed_ ? '+' : '-' }} }</button>
<template v-if="!collapsed_">
<div v-for="k in Object.keys(value)" class="kv">
<div class="k">{{ k }}:</div>
<div class="v"><XValue :value="value[k]" collapsed/></div>
</div>
</template>
</div>
</div>
</template>
<script lang="ts">
import { computed, defineComponent, ref } from 'vue';
import number from '@/filters/number';
export default defineComponent({
name: 'XValue',
props: {
value: {
type: Object,
required: true,
},
collapsed: {
type: Boolean,
required: false,
default: false,
},
},
setup(props) {
const collapsed_ = ref(props.collapsed);
return {
number,
collapsed_,
};
}
});
</script>
<style lang="scss" scoped>
.igpposuu {
display: inline;
> .null {
display: inline;
opacity: 0.7;
}
> .boolean {
display: inline;
color: var(--codeBoolean);
}
> .string {
display: inline;
color: var(--codeString);
}
> .number {
display: inline;
color: var(--codeNumber);
}
> .array {
display: inline;
> .element {
display: block;
padding-left: 16px;
}
}
> .object {
display: inline;
> .kv {
display: block;
padding-left: 16px;
> .k {
display: inline;
margin-right: 8px;
}
> .v {
display: inline;
}
}
}
}
</style>

View File

@ -1,14 +1,18 @@
<template>
<div class="zhyxdalp">
<XValue :value="value" :collapsed="false"/>
</div>
</template>
<script lang="ts">
import { computed, defineComponent } from 'vue';
import number from '@/filters/number';
import XValue from './object-view.value.vue';
export default defineComponent({
components: {
XValue
},
props: {
value: {
type: Object,

View File

@ -69,6 +69,9 @@
success: '#86b300',
error: '#ec4137',
warn: '#ecb637',
codeString: '#ffb675',
codeNumber: '#cfff9e',
codeBoolean: '#c59eff',
htmlThemeColor: '@bg',
X2: ':darken<2<@panel',
X3: 'rgba(255, 255, 255, 0.05)',

View File

@ -69,6 +69,9 @@
success: '#86b300',
error: '#ec4137',
warn: '#ecb637',
codeString: '#b98710',
codeNumber: '#0fbbbb',
codeBoolean: '#62b70c',
htmlThemeColor: '@bg',
X2: ':darken<2<@panel',
X3: 'rgba(0, 0, 0, 0.05)',