44
44
show-empty
45
45
:empty-text =" $t('Aucun texte détecté')"
46
46
/>
47
- <h4 >{{ $t("Histoires potentielles") }}</h4 >
48
- <template v-if =" firstPageStorySearchResult " >
49
- <b-table
50
- :fields =" [
51
- { key: 'storycode', label: $t('Code histoire') },
52
- { key: 'title', label: $t('Titre') },
53
- ]"
54
- show-empty
55
- :empty-text =" $t('Aucune histoire trouvée')"
56
- :items ="
57
- firstPageStorySearchResult.stories
58
- .filter(
59
- (
60
- possibleStory
61
- ): possibleStory is typeof possibleStory & {
62
- aiStorySuggestion: {
63
- storySuggestion: { storycode: string };
64
- };
65
- } => !!possibleStory.aiStorySuggestion?.storySuggestion
66
- )
67
- .map(
68
- ({
69
- aiStorySuggestion: {
70
- storySuggestion: { storycode },
71
- },
72
- }) => ({
73
- storycode,
74
- title: storyDetails[storycode].title,
75
- })
76
- )
77
- "
78
- >
79
- <template #cell (storycode)="row">
80
- <a
81
- class =" text-nowrap"
82
- :href =" `https://inducks.org/story.php?c=${encodeURIComponent(row.item.storycode)}`"
83
- target =" _blank"
84
- >{{ row.item.storycode }}</a
85
- ></template
86
- ></b-table
87
- ></template
88
- ><template v-else >{{ $t("Non calculé") }}</template ></template
89
- >
90
- <template v-else-if =" ! firstPage .image " >{{
47
+ </template >
48
+ <template v-if =" firstPageStorySearchResult " >
49
+ <h4 >{{ $t("Résultats de la recherche par image") }}</h4 >
50
+ <b-table
51
+ :fields =" [
52
+ { key: 'storycode', label: $t('Code histoire') },
53
+ { key: 'title', label: $t('Titre') },
54
+ ]"
55
+ show-empty
56
+ :empty-text =" $t('Aucune histoire trouvée')"
57
+ :items =" suggestedStories"
58
+ >
59
+ <template #cell (storycode)="row">
60
+ <a
61
+ class =" text-nowrap"
62
+ :href =" `https://inducks.org/story.php?c=${encodeURIComponent(row.item!.storycode)}`"
63
+ target =" _blank"
64
+ >{{ row.item!.storycode }}</a
65
+ ></template
66
+ ><template #cell (title)="row">
67
+ {{ storyDetails[row.item!.storycode].title }}
68
+ <b-col
69
+ cols =" 6"
70
+ class =" d-flex justify-content-center story-first-page"
71
+ :style =" {
72
+ backgroundImage: `url(${inducksCoverRoot.replace('f_auto', 'c_crop,h_0.5,x_0,w_1') + storyUrls[row.item!.storycode]})`,
73
+ }"
74
+ >
75
+ </b-col >
76
+ </template > </b-table
77
+ ></template >
78
+ <template v-if =" ! firstPage .image " >{{
91
79
$t("Non calculé car la première page de l'entrée n'a pas d'image")
92
80
}}</template >
93
- <template v-else >{{ $t("Non calculé") }}</template ></template
81
+ <template
82
+ v-else-if =" ! firstPageOcrResult && ! firstPageStorySearchResult "
83
+ >{{ $t("Non calculé") }}</template
84
+ ></template
94
85
><template v-else >{{
95
86
$t(
96
87
"Aucune suggestion car cette entrée n'est pas une histoire ni une couverture.",
@@ -110,7 +101,8 @@ const { entry } = defineProps<{
110
101
}>();
111
102
112
103
const { indexation } = storeToRefs (suggestions ());
113
- const { storyDetails } = storeToRefs (coa ());
104
+ const { storyUrls, storyDetails } = storeToRefs (coa ());
105
+ const { fetchStoryDetails } = coa ();
114
106
115
107
const { overlay } = storeToRefs (ui ());
116
108
@@ -120,4 +112,33 @@ const firstPageOcrResult = computed(() => firstPage.value.image?.aiOcrResult);
120
112
const firstPageStorySearchResult = computed (
121
113
() => firstPage .value .image ?.aiStorySearchResult ,
122
114
);
115
+
116
+ const inducksCoverRoot = ` https://res.cloudinary.com/${import .meta .env .VITE_CLOUDINARY_CLOUDNAME }/image/upload/f_auto/inducks-covers/ ` ;
117
+
118
+ const suggestedStories = computed (() =>
119
+ firstPageStorySearchResult .value ?.stories
120
+ .map ((possibleStory ) =>
121
+ entry .storySuggestions .find (
122
+ ({ aiStorySuggestionId }) =>
123
+ aiStorySuggestionId === possibleStory .aiStorySuggestion ?.id ,
124
+ ),
125
+ )
126
+ .filter (
127
+ (
128
+ possibleStory ,
129
+ ): possibleStory is typeof possibleStory & { storycode: string } =>
130
+ !! possibleStory ,
131
+ ),
132
+ );
133
+
134
+ watch (
135
+ suggestedStories ,
136
+ (value ) => {
137
+ const storycodes = value ?.map (({ storycode }) => storycode );
138
+ if (storycodes ) {
139
+ fetchStoryDetails (storycodes );
140
+ }
141
+ },
142
+ { immediate: true },
143
+ );
123
144
</script >
0 commit comments