HumanBreak/src/ui/bgmList.vue

90 lines
2.0 KiB
Vue
Raw Normal View History

2023-03-01 22:50:43 +08:00
<template>
<Colomn @close="exit" :width="60" :height="80" :left="30" :right="70"
><template #left>
<div id="bgm-list">
<span
v-for="(bgm, i) of list"
class="selectable"
:selected="selected === i"
2023-03-04 20:21:12 +08:00
@click="select(i)"
2023-03-01 22:50:43 +08:00
>
2023-03-04 20:21:12 +08:00
{{ bgm!.area }}
2023-03-01 22:50:43 +08:00
</span>
</div></template
>
<template #right
><div>
<div id="bgm-name">
2023-03-04 20:21:12 +08:00
<img id="bgm-image" :src="list[selected]!.img" />
2023-03-01 22:50:43 +08:00
<span>{{ name }}</span>
2023-03-04 20:21:12 +08:00
<span v-if="list[selected]!.from"
2023-03-01 22:50:43 +08:00
>出自&nbsp;&nbsp;&nbsp;&nbsp;{{
2023-03-04 20:21:12 +08:00
list[selected]!.from
2023-03-01 22:50:43 +08:00
}}</span
>
</div>
<span v-html="content"></span></div></template
></Colomn>
</template>
<script lang="ts" setup>
import { computed, onMounted, ref } from 'vue';
import Colomn from '../components/colomn.vue';
import bgm from '../data/bgm.json';
import { splitText } from '../plugin/utils';
2023-11-05 10:54:26 +08:00
const props = defineProps<{
num: number;
}>();
2023-03-01 22:50:43 +08:00
interface Bgm {
img: string;
area: string;
name: string;
desc: string[];
from?: string;
}
2023-03-04 20:21:12 +08:00
const list = bgm as Partial<Record<BgmIds, Bgm>>;
2023-03-01 22:50:43 +08:00
2023-03-04 20:21:12 +08:00
const selected = ref<BgmIds>('title.mp3');
2023-03-01 22:50:43 +08:00
const content = computed(() => {
2023-03-04 20:21:12 +08:00
return eval('`' + splitText(list[selected.value]!.desc) + '`');
2023-03-01 22:50:43 +08:00
});
2023-03-04 20:21:12 +08:00
const name = computed(() => list[selected.value]!.name);
2023-03-01 22:50:43 +08:00
function exit() {
2023-11-05 10:54:26 +08:00
mota.ui.main.close(props.num);
2023-03-01 22:50:43 +08:00
}
2023-03-04 20:21:12 +08:00
function select(id: BgmIds) {
selected.value = id;
}
2023-03-01 22:50:43 +08:00
</script>
<style lang="less" scoped>
#bgm-list {
display: flex;
flex-direction: column;
}
#bgm-name {
display: flex;
flex-direction: column;
align-items: center;
}
#bgm-image {
margin-top: 5%;
border: 1px solid #fff;
width: 33vw;
}
@media screen and (max-width: 600px) {
#bgm-image {
width: 70vw;
}
}
</style>