@@ -3,48 +3,57 @@ import { Brain, ChartColumn, CircleCheckBig, Flame } from 'lucide-vue-next'
3
3
import { reactive , ref , type Ref , watch } from ' vue'
4
4
import { useRoute } from ' vue-router'
5
5
import { useUIStore } from ' @/stores/ui'
6
- import { useFetch } from ' @vueuse/core'
7
- import { type AnalysisData , type GameData , type RoastingUserData } from ' @/types'
6
+ import {
7
+ type AnalysisData ,
8
+ type GameData ,
9
+ type RoastingUserData ,
10
+ type FileUploadData ,
11
+ } from ' @/types'
8
12
import StatusCardWithGamesAnalysis from ' @/components/StatusCardWithGamesAnalysis.vue'
9
13
import StatusCardWithRoast from ' @/components/StatusCardWithRoast.vue'
14
+ import StatusCardWithBasicInformation from ' @/components/StatusCardWithBasicInformation.vue'
10
15
11
16
const route = useRoute ()
12
17
const ui = useUIStore ()
13
- const analysisData: Ref <AnalysisData > = reactive ({})
14
18
const defaultSummaryCls: Ref <string > = ref (' flex items-center gap-2 p-3 rounded-lg' )
15
19
const categoryPresentCls: Ref <string > = ref (' bg-green-100 text-green-700' )
16
20
const defaultIconCls: Ref <string > = ref (' h-4 w-4' )
17
- const fileUploadData: Ref <string > = ref (' ' )
18
- const gameData: Ref <GameData > = ref ({})
19
- const roastData: Ref <RoastingUserData > = ref ({})
20
- const chessStyleData: Ref <Object > = ref ({})
21
- const progressBarData: Ref <number > = ref (0 )
22
21
22
+ const analysisData = reactive <AnalysisData >({
23
+ result: null ,
24
+ })
25
+ const fileUploadData: Ref <FileUploadData | null > = ref (null )
26
+ const gameData: Ref <GameData | null > = ref (null )
27
+ const roastData: Ref <RoastingUserData | null > = ref (null )
28
+ const chessStyleData: Ref <object | null > = ref (null )
29
+ const progressBarData: Ref <number > = ref (0 )
23
30
watch (analysisData , (_newData , _oldData ) => {
24
- progressBarData .value = (Object .keys (analysisData .value .result ).length * 100 ) / 4
25
- console .log (progressBarData .value )
31
+ progressBarData .value = (Object .keys (analysisData .result ).length * 100 ) / 4
26
32
})
27
33
28
34
getAnalysisData ()
29
35
30
36
async function getAnalysisData() {
31
- const { data, pending, error, refresh } = await useFetch (
32
- ` /server/analysis/status/${route .params .statusId } ` ,
33
- )
34
- if (error .value ) {
35
- ui .showMessage (' error' , ' Error' , error .value )
36
- } else {
37
- analysisData .value = JSON .parse (data .value )
38
- console .log (analysisData .value )
39
- fileUploadData .value = analysisData .value .result ?.file_upload
40
- gameData .value = analysisData .value .result ?.game
41
- roastData .value = analysisData .value .result ?.roasting_user
42
- chessStyleData .value = analysisData .value .result ?.chess_style
37
+ try {
38
+ const response = await fetch (` /server/analysis/status/${route .params .statusId } ` )
39
+ const data = await response .json ()
40
+ if (! response .ok ) {
41
+ ui .showMessage (' error' , ' Error' , data .detail )
42
+ } else {
43
+ analysisData .result = data .result
44
+ fileUploadData .value = analysisData .result ?.file_upload
45
+ gameData .value = analysisData .result ?.game
46
+ roastData .value = analysisData .result ?.roasting_user
47
+ chessStyleData .value = analysisData .result ?.chess_style
48
+ }
49
+ } catch (error ) {
50
+ ui .showMessage (' error' , ' Error' , error )
43
51
}
44
52
}
45
53
</script >
46
54
<template >
47
- <div class =" grid grid-cols-1 gap-6 w-2/3 mx-auto" >
55
+ <Toast />
56
+ <div v-if =" analysisData.result" class =" grid grid-cols-1 gap-6 w-2/3 mx-auto" >
48
57
<Card class =" w-full" >
49
58
<template #title >
50
59
<div class =" flex items-center gap-2" >
@@ -96,7 +105,15 @@ async function getAnalysisData() {
96
105
</div >
97
106
</template >
98
107
</Card >
99
- <StatusCardWithGamesAnalysis :gameObjects =" gameData" v-if =" gameData" />
100
- <StatusCardWithRoast :roastData =" roastData" v-if =" roastData" />
108
+ <StatusCardWithBasicInformation v-if =" fileUploadData" :informationObject =" fileUploadData" />
109
+ <StatusCardWithGamesAnalysis v-if =" gameData" :gameObjects =" gameData" />
110
+ <StatusCardWithRoast v-if =" roastData" :roastObjects =" roastData" />
111
+ </div >
112
+ <div v-else class =" grid grid-cols-1 gap-6 w-2/3 mx-auto" >
113
+ <Skeleton class =" mb-2" borderRadius =" 16px" ></Skeleton >
114
+ <Skeleton class =" mb-2" borderRadius =" 16px" ></Skeleton >
115
+ <Skeleton width =" 5rem" borderRadius =" 16px" class =" mb-2" ></Skeleton >
116
+ <Skeleton height =" 2rem" class =" mb-2" borderRadius =" 16px" ></Skeleton >
117
+ <Skeleton width =" 10rem" height =" 4rem" borderRadius =" 16px" ></Skeleton >
101
118
</div >
102
119
</template >
0 commit comments