|
@@ -27,16 +27,31 @@ export class ShareService {
|
|
|
*/
|
|
*/
|
|
|
async generateShareCard(audioId: string) {
|
|
async generateShareCard(audioId: string) {
|
|
|
const audio = await prisma.audio.findUnique({ where: { id: parseInt(audioId) } });
|
|
const audio = await prisma.audio.findUnique({ where: { id: parseInt(audioId) } });
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (!audio) {
|
|
if (!audio) {
|
|
|
throw new Error('音频不存在');
|
|
throw new Error('音频不存在');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 生成更完整的描述
|
|
|
|
|
+ let description = '';
|
|
|
|
|
+ if (audio.summary) {
|
|
|
|
|
+ description = audio.summary;
|
|
|
|
|
+ } else if (audio.text && audio.text.length > 100) {
|
|
|
|
|
+ description = audio.text.slice(0, 100) + '...';
|
|
|
|
|
+ } else if (audio.text) {
|
|
|
|
|
+ description = audio.text;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ description = 'AI 有声书精彩内容';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return {
|
|
return {
|
|
|
- title: audio.title,
|
|
|
|
|
- description: audio.summary || audio.text.slice(0, 100) + '...',
|
|
|
|
|
|
|
+ title: audio.title || 'AI 有声书',
|
|
|
|
|
+ description: description,
|
|
|
imageUrl: this.generateCoverImage(audio),
|
|
imageUrl: this.generateCoverImage(audio),
|
|
|
link: this.generateShareLink(audioId),
|
|
link: this.generateShareLink(audioId),
|
|
|
|
|
+ audioId: audio.id,
|
|
|
|
|
+ wordCount: audio.wordCount,
|
|
|
|
|
+ audioDuration: audio.audioDuration,
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
|