File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -6,10 +6,22 @@ const props = defineProps<{
66 reason: Reason
77}>()
88
9- const nonEmptyEntries = computed (() => Object .entries (props .reason ).filter (([_key , values ]) => !! values ))
9+ const nonEmptyEntries = computed (() => Object .entries (props .reason ).filter (([_key , values ]) => !! values ) as Array <[ keyof Reason , Reason [ keyof Reason ]]> )
1010
11- function isObject(entry ? : any ): boolean {
12- return entry && typeof entry === ' object' && ! Array .isArray (entry )
11+ function isObject(entry ? : Reason [keyof Reason ]): boolean {
12+ return !! entry && typeof entry === ' object' && ! Array .isArray (entry )
13+ }
14+
15+ function formatNumericValue(key : string , val : number | string ): number | string {
16+ switch (key ) {
17+ case ' score' :
18+ return ` ${Math .round (((1 - (val as number )) * 100 ))}% `
19+ case ' max_distance' :
20+ case ' min_distance' :
21+ return ` ${Math .round (val as number )}m `
22+ default :
23+ return val
24+ }
1325}
1426 </script >
1527
@@ -20,7 +32,7 @@ function isObject(entry?: any): boolean {
2032 <hr >
2133 <p v-if =" !isObject(values)" >{{ values }}</p >
2234 <p v-for =" [key2, value] in Object.entries(values)" v-else :key =" key2" >
23- <b >{{ key2 }}</b >: {{ value }}
35+ <b >{{ key2 }}</b >: {{ formatNumericValue(key2, value) }}
2436 </p >
2537 </span >
2638 </div >
You can’t perform that action at this time.
0 commit comments