-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.vue
86 lines (77 loc) · 1.63 KB
/
index.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<script setup lang="ts">
import { useFetch } from "@vueuse/core";
import type { IRatingIndex } from "@xcpcio/types";
const { t } = useI18n();
useTitle(RATING_TITLE_SUFFIX);
function genURL() {
return `${RATING_DATA_HOST.value}index/index.json`;
}
const url = ref(genURL());
const indexList = ref([] as IRatingIndex[]);
const {
error,
isFetching,
isFinished,
} = useFetch(url, {
refetch: true,
afterFetch: (ctx) => {
indexList.value = JSON.parse(ctx.data) as IRatingIndex[];
return ctx;
},
}).get();
</script>
<template>
<div
class="sm:w-[1024px] lg:w-screen"
lg:of-x-hidden
flex flex-col justify-center items-center
>
<div>
<div
v-if="isFetching || error"
mt-4 mb-4
class="sm:w-[1000px] lg:w-screen"
flex justify-center items-center
>
<div
v-if="isFetching"
>
{{ t("common.loading") }}...
</div>
<div
v-if="error"
>
{{ error }}
</div>
</div>
<div
v-if="isFinished"
class="sm:w-[1000px] lg:w-screen min-h-120"
flex flex-col items-center
>
<div
v-if="indexList.length"
mt-4
>
<template
v-for="item in indexList"
:key="item.id"
>
<RatingIndexUI
:rating-index="item"
/>
</template>
</div>
<div v-else p10>
<div op40 italic mb5>
No result found
</div>
</div>
</div>
</div>
</div>
</template>
<route lang="yaml">
meta:
layout: index-layout
</route>