123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- <template>
- <transition-group name="track-score" tag="div">
- <template v-for="track in trackList">
- <div
- v-if="store.shouldShowTrack"
- :key="`key-${track.mainNumber}-${track.subNumber}-${track.offsetY}-${track.offsetX}`"
- class="score-container"
- :class="[focusedTrack(track) && 'score-animation']"
- :style="computeTopAndLeft(track)"
- >
- <span
- :id="`a-${track.mainNumber}-${track.subNumber}-${track.offsetY}-${track.offsetX}`"
- class="tw-m-auto"
- >
- {{ track.unanswered ? "空" : track.score }}
- </span>
- </div>
- </template>
- </transition-group>
- <template v-for="(tag, index) in specialTagList" :key="index">
- <div class="score-container" :style="computeTopAndLeft(tag)">
- <span class="tw-m-auto">
- {{ tag.tagName }}
- </span>
- </div>
- </template>
- </template>
- <script setup lang="ts">
- import type { SpecialTag, Track } from "@/types";
- import { toRefs, watch, nextTick } from "vue";
- import { store } from "@/store/store";
- import { message } from "ant-design-vue";
- const props = defineProps<{
- trackList: Array<Track>;
- specialTagList: Array<SpecialTag>;
- sliceImageWidth: number;
- sliceImageHeight: number;
- dx: number;
- dy: number;
- }>();
- const { trackList } = toRefs(props);
- const computeTopAndLeft = (track: Track | SpecialTag) => {
- const topInsideSlice = track.offsetY - props.dy;
- const leftInsideSlice = track.offsetX - props.dx;
- const topInsideSliceRatio = topInsideSlice / props.sliceImageHeight;
- const leftInsideSliceRatio = leftInsideSlice / props.sliceImageWidth;
- if (
- topInsideSliceRatio < 0 ||
- topInsideSliceRatio > 1 ||
- leftInsideSliceRatio < 0 ||
- leftInsideSliceRatio > 1
- ) {
- /** 解决message提示死循环的问题 */
- void nextTick(() => {
- void message.error("轨迹坐标有误,可能是图片被修改过,请联系管理员!");
- });
- }
- return {
- color: track.color || 'red',
- top: topInsideSliceRatio * 100 + "%",
- left: leftInsideSliceRatio * 100 + "%",
- "font-size":
- (store.setting.uiSetting["score.fontSize.scale"] || 1) *
- store.setting.uiSetting["answer.paper.scale"] *
- 2.2 +
- "em",
- };
- };
- const focusedTrack = (track: Track) => {
- return store.focusTracks.includes(track);
- };
- watch(
- () => store.focusTracks,
- () => {
- if (store.focusTracks.length === 0) return;
- const minImageIndex = Math.min(
- ...store.focusTracks.map((t) => t.offsetIndex)
- );
- const minImageOffsetY = Math.min(
- ...store.focusTracks
- .filter((t) => t.offsetIndex === minImageIndex)
- .map((t) => t.offsetY)
- );
- const topTrack = store.focusTracks.find(
- (t) => t.offsetIndex === minImageIndex && t.offsetY === minImageOffsetY
- );
- if (topTrack) {
- document
- .querySelector(
- `#a-${topTrack.mainNumber}-${topTrack.subNumber}-${topTrack.offsetY}-${topTrack.offsetX}`
- )
- ?.scrollIntoView({ behavior: "smooth" });
- }
- },
- {
- deep: true
- }
- );
- </script>
- <style scoped>
- .score-container {
- position: absolute;
- display: flex;
- place-content: center;
- /* color: red; */
- /* to center score */
- width: 200px;
- height: 200px;
- margin-top: -100px;
- margin-left: -100px;
- /* to click through div */
- pointer-events: none;
- }
- .score-animation {
- animation: 2s ease-in-out 0s infinite alternate change_size;
- }
- @keyframes change_size {
- from {
- font-size: 2em;
- margin-top: -100px;
- margin-left: -100px;
- }
- to {
- font-size: 4em;
- margin-top: -80px;
- margin-left: -80px;
- }
- }
- .track-score-enter-active {
- transition: opacity 0.3s ease;
- }
- .track-score-leave-active {
- transition: opacity 0.6s ease;
- }
- .track-score-enter-from,
- .track-score-leave-to {
- opacity: 0;
- }
- </style>
|