1
1
<template >
2
2
<div >
3
3
<div v-if =" isSuccessfulAiSummaryData(summaryData)" >
4
- <!-- < button type="button" class="btn-close btn-close-white float-end" aria-label="Close" @click="$emit('removeData ')"></button> -- >
4
+ <button type =" button" class =" btn-close btn-close-white float-end" aria-label =" Close" @click =" $emit('removeAiSummary ')" ></button >
5
5
<div class =" summary-text-container" >
6
6
<div class =" summary-text" >{{ summaryData.summary }}</div >
7
- <button type =" button" class =" btn btn-sm btn-outline-success" @click =" $emit('acceptDescription ', summaryData.summary)" >
7
+ <button type =" button" class =" btn btn-sm btn-outline-success" @click =" $emit('updateDescription ', summaryData.summary)" >
8
8
{{ t("ai.summary.accept") }}
9
9
</button >
10
10
</div >
24
24
<div class =" row" >
25
25
<div class =" col-md-4" v-for =" prompt in summaryData.imagePrompts" v-bind:key =" prompt" >
26
26
<button class =" btn btn-sm btn-outline-success" @click =" acceptImagePrompt($event, prompt)" >
27
- <fa-icon :icon =" faImage" ></fa-icon >🪄
27
+ <fa-icon :icon =" faImage" ></fa-icon >< fa-icon :icon = " faWandMagicSparkles " ></ fa-icon >
28
28
{{ prompt }}
29
29
</button >
30
30
</div >
31
31
</div >
32
+ </div >
32
33
<div v-else class =" bg-danger" >
33
34
{{ summaryData.error }}
34
35
</div >
44
45
</style >
45
46
46
47
<script setup lang="ts">
47
- import { OpenAiEndpoints } from " @client/util/api-client.js" ;
48
48
import { t } from " @client/plugins/i18n.js" ;
49
+ import { OpenAiEndpoints } from " @client/util/api-client.js" ;
50
+ import { faImage , faWandMagicSparkles } from " @fortawesome/free-solid-svg-icons" ;
49
51
import type { AiSummaryData } from " @fumix/fu-blog-common" ;
50
52
import { isSuccessfulAiSummaryData } from " @fumix/fu-blog-common" ;
51
- import { onMounted } from " vue" ;
52
53
import type { PropType } from " vue" ;
53
- import { faImage , faWandSparkles } from " @fortawesome/free-solid-svg-icons " ;
54
+ import { onMounted } from " vue " ;
54
55
55
56
const props = defineProps ({
56
57
summaryData: { type: Object as PropType <AiSummaryData >, required: true },
57
- onAddTag: { type: Function as PropType <(tag : string ) => void > },
58
- onSetDescription: { type: Function as PropType <(description : string ) => void > },
59
58
});
60
59
61
60
function acceptDescription(e : MouseEvent , description : string ) {
62
61
e .preventDefault ();
63
- props . onSetDescription ?.( description );
62
+ emit ( " updateDescription " , description );
64
63
}
65
64
66
65
async function acceptImagePrompt(e : MouseEvent , prompt : string ) {
67
66
e .preventDefault ();
68
- alert (prompt ); // TODO: send event to parent
69
67
await OpenAiEndpoints .dallEGenerateImage (prompt )
70
68
.then ((it ) => {
71
69
alert (JSON .stringify (it ));
@@ -77,16 +75,16 @@ async function acceptImagePrompt(e: MouseEvent, prompt: string) {
77
75
78
76
function acceptTag(e : MouseEvent , tag : string ) {
79
77
e .preventDefault ();
80
- props . onAddTag ?.( tag );
78
+ emit ( " addTag " , tag );
81
79
}
82
80
83
- const emit = defineEmits ([" removeData " , " acceptDescription " ]);
81
+ const emit = defineEmits ([" updateDescription " , " addTag " , " removeAiSummary " ]);
84
82
85
83
onMounted (() => {
86
84
// auto remove if error
87
85
if (! isSuccessfulAiSummaryData (props .summaryData )) {
88
86
setTimeout (() => {
89
- emit (" removeData " );
87
+ emit (" removeAiSummary " );
90
88
}, 5000 );
91
89
}
92
90
});
0 commit comments