💄 角色持有适配差距

This commit is contained in:
目棃
2024-10-30 22:18:44 +08:00
parent a812e0781b
commit 9d08880c10
2 changed files with 101 additions and 33 deletions

View File

@@ -1,50 +1,108 @@
<template> <template>
<div class="hta-th-box"> <v-data-table :headers="headers" fixed-header :items="holdData" height="calc(100vh - 160px)">
<v-data-table :headers="headers" :items="props.modelValue">
<template v-slot:item="{ item }"> <template v-slot:item="{ item }">
<tr class="hta-th-tr"> <tr class="hta-th-tr">
<td class="hta-th-icon"> <td class="hta-th-icon">
<TibWikiAbyss2 v-model="item.AvatarId" /> <TibWikiAbyss2 v-model="item.AvatarId" />
</td> </td>
<td>{{ (item.HoldingRate * 100).toFixed(3) }}%</td> <td>
<span>{{ (item.HoldingRate.cur * 100).toFixed(3) }}%</span>
<span
v-if="item.HoldingRate.cur !== item.HoldingRate.last"
:class="getRateClass(item.HoldingRate.cur, item.HoldingRate.last)"
>
{{ getRateStr(item.HoldingRate.cur, item.HoldingRate.last) }}
</span>
</td>
<td v-for="rate in item.Constellations" :key="rate.Item"> <td v-for="rate in item.Constellations" :key="rate.Item">
{{ (rate.Rate * 100).toFixed(3) }}% <span>{{ (rate.RateCur * 100).toFixed(3) }}%</span>
<span
v-if="rate.RateCur !== rate.RateLast"
:class="getRateClass(rate.RateCur, rate.RateLast)"
:title="`${(rate.RateLast * 100).toFixed(3)}%`"
>
{{ getRateStr(rate.RateCur, rate.RateLast) }}
</span>
</td> </td>
</tr> </tr>
</template> </template>
</v-data-table> </v-data-table>
</div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted, ref } from "vue";
import { AbyssDataItem } from "../../pages/WIKI/Abyss.vue";
import TibWikiAbyss2 from "../itembox/tib-wiki-abyss-2.vue"; import TibWikiAbyss2 from "../itembox/tib-wiki-abyss-2.vue";
interface HtaTabHoldProps { interface HtaTabHoldProps {
modelValue: TGApp.Plugins.Hutao.Abyss.AvatarHold[]; data: AbyssDataItem<TGApp.Plugins.Hutao.Abyss.AvatarHold[]>;
}
interface HtaTabHoldConstellation {
Item: number;
RateCur: number;
RateLast: number;
}
interface HtaTabHoldData {
AvatarId: number;
HoldingRate: AbyssDataItem<number>;
Constellations: Array<HtaTabHoldConstellation>;
} }
const props = defineProps<HtaTabHoldProps>(); const props = defineProps<HtaTabHoldProps>();
const holdData = ref<HtaTabHoldData[]>([]);
const headers = [ const headers = [
{ title: "角色", align: "center", key: "AvatarId" }, { title: "角色", align: "center", key: "AvatarId" },
{ title: "持有", align: "center", key: "HoldingRate" }, { title: "持有", align: "center", key: "HoldingRate.cur" },
{ title: "0命", align: "center", key: "Constellations[0].Rate" }, { title: "0命", align: "center", key: "Constellations[0].RateCur" },
{ title: "1命", align: "center", key: "Constellations[1].Rate" }, { title: "1命", align: "center", key: "Constellations[1].RateCur" },
{ title: "2命", align: "center", key: "Constellations[2].Rate" }, { title: "2命", align: "center", key: "Constellations[2].RateCur" },
{ title: "3命", align: "center", key: "Constellations[3].Rate" }, { title: "3命", align: "center", key: "Constellations[3].RateCur" },
{ title: "4命", align: "center", key: "Constellations[4].Rate" }, { title: "4命", align: "center", key: "Constellations[4].RateCur" },
{ title: "5命", align: "center", key: "Constellations[5].Rate" }, { title: "5命", align: "center", key: "Constellations[5].RateCur" },
{ title: "6命", align: "center", key: "Constellations[6].Rate" }, { title: "6命", align: "center", key: "Constellations[6].RateCur" },
]; ];
</script>
<style lang="css" scoped> onMounted(() => {
.hta-th-box { for (const avatar of props.data.cur) {
height: 100%; const avatarLast = props.data.last.find((a) => a.AvatarId === avatar.AvatarId);
max-height: calc(100vh - 120px); if (!avatarLast) continue;
padding-right: 5px; const Rate: AbyssDataItem<number> = {
border-radius: 5px; cur: avatar.HoldingRate,
overflow-y: auto; last: avatarLast?.HoldingRate ?? 0,
};
const Constellations: Array<HtaTabHoldConstellation> = [];
for (const constellation of avatar.Constellations) {
const constellationLast = avatarLast?.Constellations.find(
(c) => c.Item === constellation.Item,
);
if (!constellationLast) continue;
Constellations.push({
Item: constellation.Item,
RateCur: constellation.Rate,
RateLast: constellationLast.Rate,
});
}
holdData.value.push({
AvatarId: avatar.AvatarId,
HoldingRate: Rate,
Constellations: Constellations,
});
}
});
function getRateClass(cur: number, last: number): string {
return cur > last ? "rate-up" : "rate-down";
} }
function getRateStr(cur: number, last: number): string {
const diff = Math.abs(cur - last) * 100;
return `(${cur > last ? "↑" : "↓"}${diff.toFixed(3)}%)`;
}
</script>
<style lang="css" scoped>
.hta-th-tr { .hta-th-tr {
height: 100px; height: 100px;
text-align: center; text-align: center;
@@ -53,4 +111,12 @@ const headers = [
.hta-th-icon { .hta-th-icon {
width: 100px; width: 100px;
} }
.rate-up {
color: var(--tgc-od-red);
}
.rate-down {
color: var(--tgc-od-green);
}
</style> </style>

View File

@@ -19,7 +19,7 @@ const box = computed<TItemBoxData>(() => {
return { return {
bg: `/icon/bg/${avatar.value?.star ?? 5}-Star.webp`, bg: `/icon/bg/${avatar.value?.star ?? 5}-Star.webp`,
clickable: false, clickable: false,
display: "outer", display: "inner",
height: "80px", height: "80px",
icon: `/WIKI/character/${props.modelValue}.webp`, icon: `/WIKI/character/${props.modelValue}.webp`,
innerHeight: 20, innerHeight: 20,
@@ -32,6 +32,8 @@ const box = computed<TItemBoxData>(() => {
: `/icon/weapon/${avatar.value.weapon}.webp`, : `/icon/weapon/${avatar.value.weapon}.webp`,
ltSize: "20px", ltSize: "20px",
size: "80px", size: "80px",
innerIcon: `/icon/weapon/${avatar.value?.weapon}.webp`,
innerBlur: "5px",
}; };
}); });