HumanBreak/src/ui/desc.vue

59 lines
1.4 KiB
Vue
Raw Normal View History

2022-12-29 00:26:12 +08:00
<template>
2022-12-30 15:25:58 +08:00
<Colomn @close="exit" :width="80" :height="80" :left="30" :right="70"
><template #left
><div id="desc-list">
2022-12-31 18:24:21 +08:00
<div
2022-12-30 15:25:58 +08:00
v-for="(data, k) in desc"
2023-01-06 16:21:17 +08:00
class="selectable desc-item"
2022-12-30 15:25:58 +08:00
:selected="selected === k"
2023-01-06 16:21:17 +08:00
:show="show(data.condition)"
2022-12-31 18:24:21 +08:00
@click="click(k)"
2022-12-30 15:25:58 +08:00
>
2022-12-31 18:24:21 +08:00
<span v-if="show(data.condition)">{{ data.text }}</span>
</div>
2022-12-30 15:25:58 +08:00
</div></template
>
<template #right><span v-html="content"></span></template
></Colomn>
2022-12-29 00:26:12 +08:00
</template>
<script lang="ts" setup>
2022-12-30 00:55:03 +08:00
import { computed, ref } from 'vue';
import desc from '../data/desc.json';
2022-12-30 23:28:27 +08:00
import { has, splitText } from '../plugin/utils';
2022-12-30 15:25:58 +08:00
import Colomn from '../components/colomn.vue';
2022-12-30 00:55:03 +08:00
type DescKey = keyof typeof desc;
const selected = ref(Object.keys(desc)[0] as DescKey);
function exit() {
core.plugin.descOpened.value = false;
}
const content = computed(() => {
2023-01-06 16:21:17 +08:00
return eval('`' + splitText(desc[selected.value].desc) + '`');
2022-12-30 00:55:03 +08:00
});
2022-12-31 18:24:21 +08:00
function click(key: DescKey) {
if (!eval(desc[key].condition)) return;
selected.value = key;
}
function show(condition: string) {
return eval(condition);
}
2022-12-29 00:26:12 +08:00
</script>
<style lang="less" scoped>
2022-12-30 00:55:03 +08:00
#desc-list {
display: flex;
flex-direction: column;
}
2023-01-06 16:21:17 +08:00
.desc-item[show='false'] {
margin: 0;
padding: 0;
}
2022-12-29 00:26:12 +08:00
</style>