chore: added & optimized users tooltip data typings

This commit is contained in:
2025-07-11 14:46:02 +02:00
parent 1e6ab1c2d1
commit 8e713a5c6e
7 changed files with 97 additions and 22 deletions
+3 -1
View File
@@ -13,6 +13,7 @@ import BaseTooltip from './BaseTooltip.vue';
import SpawnsTooltip from './SpawnsTooltip.vue';
import UsersTooltip from './UsersTooltip.vue';
import HtmlTooltip from './HtmlTooltip.vue';
import TrainInfoTooltip from "./TrainInfoTooltip.vue";
const BOX_PADDING_PX = 20;
@@ -23,7 +24,8 @@ export default defineComponent({
BaseTooltip,
SpawnsTooltip,
UsersTooltip,
HtmlTooltip
HtmlTooltip,
TrainInfoTooltip
},
data() {
@@ -0,0 +1,46 @@
<template>
<div class="tooltip-content">
<span v-if="trainInfoObj">
{{ trainInfoObj.driverName }}
</span>
</div>
</template>
<script lang="ts" setup>
import { computed } from 'vue';
import { useTooltipStore } from '../../store/tooltipStore';
import { Train } from '../../typings/common';
const tooltipStore = useTooltipStore();
const trainInfoObj = computed(() => {
if (tooltipStore.content == '') return null;
try {
return (JSON.parse(tooltipStore.content) as Train) ?? null;
} catch (error) {
return null;
}
});
</script>
<style lang="scss" scoped>
.tooltip-content {
display: flex;
justify-content: center;
align-items: center;
gap: 0.5em;
white-space: pre-line;
padding: 0.25em 0.5em;
border-radius: 0.25em;
width: 100%;
background-color: #1f1f1f;
box-shadow: 0 0 5px 2px #aaa;
}
img {
height: 1em;
}
</style>
+2 -2
View File
@@ -10,7 +10,7 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { useTooltipStore } from '../../store/tooltipStore';
import { Train } from '../../typings/common';
import { TooltipUserTrain } from '../../typings/common';
export default defineComponent({
data() {
@@ -23,7 +23,7 @@ export default defineComponent({
trains() {
if (this.tooltipStore.content == '') return [];
const parsedTrains = JSON.parse(this.tooltipStore.content) as Train[];
const parsedTrains = JSON.parse(this.tooltipStore.content) as TooltipUserTrain[];
return (parsedTrains ?? []).sort((a, b) => a.trainNo - b.trainNo);
}
}