mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 13:28:11 +00:00
fix(profile): player avatar loading
This commit is contained in:
@@ -2,9 +2,10 @@
|
|||||||
<div class="player-avatar">
|
<div class="player-avatar">
|
||||||
<img
|
<img
|
||||||
v-if="avatarId"
|
v-if="avatarId"
|
||||||
|
v-show="avatarLoadingStatus == Status.Data.Loaded"
|
||||||
|
:src="avatarSrc"
|
||||||
class="player-avatar-image"
|
class="player-avatar-image"
|
||||||
ref="avatarImageRef"
|
ref="avatarImageRef"
|
||||||
:src="`https://td2.info.pl/index.php?action=dlattach;attach=${avatarId};type=avatar`"
|
|
||||||
alt="player image"
|
alt="player image"
|
||||||
@load="onAvatarLoadSuccess"
|
@load="onAvatarLoadSuccess"
|
||||||
@error="onAvatarLoadError"
|
@error="onAvatarLoadError"
|
||||||
@@ -22,16 +23,20 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { Status } from '../../typings/common';
|
import { Status } from '../../typings/common';
|
||||||
import Loading from '../Global/Loading.vue';
|
import Loading from '../Global/Loading.vue';
|
||||||
|
|
||||||
defineProps({
|
const props = defineProps({
|
||||||
avatarId: {
|
avatarId: {
|
||||||
type: Number
|
type: Number
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const avatarSrc = computed(
|
||||||
|
() => `https://td2.info.pl/index.php?action=dlattach;attach=${props.avatarId};type=avatar`
|
||||||
|
);
|
||||||
|
|
||||||
const avatarImageRef = ref<HTMLImageElement | null>(null);
|
const avatarImageRef = ref<HTMLImageElement | null>(null);
|
||||||
const avatarLoadingStatus = ref<Status.Data>(Status.Data.Loading);
|
const avatarLoadingStatus = ref<Status.Data>(Status.Data.Loading);
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onActivated, onDeactivated, ref } from 'vue';
|
import { onActivated, onDeactivated, ref } from 'vue';
|
||||||
import { onBeforeRouteUpdate, useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { useApiStore } from '../store/apiStore';
|
import { useApiStore } from '../store/apiStore';
|
||||||
import { API, Td2API } from '../typings/api';
|
import { API, Td2API } from '../typings/api';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
@@ -103,6 +103,9 @@ async function fetchPlayerData() {
|
|||||||
if (queryPlayerId != playerId.value) {
|
if (queryPlayerId != playerId.value) {
|
||||||
playerInfoStatus.value = Status.Data.Loading;
|
playerInfoStatus.value = Status.Data.Loading;
|
||||||
playerJournalStatus.value = Status.Data.Loading;
|
playerJournalStatus.value = Status.Data.Loading;
|
||||||
|
|
||||||
|
playerInfo.value = undefined;
|
||||||
|
playerJournal.value = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
playerId.value = queryPlayerId;
|
playerId.value = queryPlayerId;
|
||||||
|
|||||||
Reference in New Issue
Block a user