Sfoglia il codice sorgente

feat: 功能8完成 | 分享功能 - 分享卡片生成

- 完善后端分享卡片生成(添加audioId/wordCount/audioDuration字段)
- 后端✅ 前端✅
- 测试验证:微信好友分享、朋友圈分享
MyFramework User 5 mesi fa
parent
commit
9d7db01521
3 ha cambiato i file con 37 aggiunte e 6 eliminazioni
  1. 16 0
      agent-progress.txt
  2. 3 3
      feature_list.json
  3. 18 3
      server/src/modules/share/share.service.ts

+ 16 - 0
agent-progress.txt

@@ -10,3 +10,19 @@
 状态更新为 frontend-testing
 前端测试通过!Playwright验证:打开player页面,点击分享按钮,分享面板正常弹出,显示标题、封面、简介
 功能7完成!状态更新为 done
+
+=== 功能8开始 ===
+选择功能8:分享功能 - 分享卡片生成
+状态更新为 start
+完善后端分享卡片生成,添加更多字段(audioId, wordCount, audioDuration)
+状态更新为 compiling
+后端TypeScript编译通过,状态更新为 running
+后端服务运行中,状态更新为 db-checking
+数据库验证通过,状态更新为 backend-testing
+后端接口测试通过!GET /api/share?audioId=7 返回完整数据,包含audioId/wordCount/audioDuration字段
+状态更新为 frontend-testing
+前端测试通过!Playwright验证:
+  1. 打开player页面
+  2. 点击分享到微信好友 - 验证分享内容包含音频标题"你好"
+  3. 点击分享到朋友圈 - 验证朋友圈分享内容正确
+功能8完成!状态更新为 done

+ 3 - 3
feature_list.json

@@ -129,7 +129,7 @@
       "id": 8,
       "description": "分享功能 - 分享卡片生成",
       "backend_test_steps": [
-        "1. curl http://localhost:3000/api/share?audioId=audio-001 - 验证分享信息接口返回正确数据"
+        "1. curl http://localhost:3000/api/share?audioId=7 - 验证分享信息接口返回正确数据"
       ],
       "frontend_test_steps": [
         "1. 打开player页面",
@@ -138,8 +138,8 @@
         "4. 点击分享到朋友圈",
         "5. 验证朋友圈分享内容正确"
       ],
-      "status": "init",
-      "passes": false
+      "status": "done",
+      "passes": true
     },
     {
       "id": 9,

+ 18 - 3
server/src/modules/share/share.service.ts

@@ -27,16 +27,31 @@ export class ShareService {
    */
   async generateShareCard(audioId: string) {
     const audio = await prisma.audio.findUnique({ where: { id: parseInt(audioId) } });
-    
+
     if (!audio) {
       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 {
-      title: audio.title,
-      description: audio.summary || audio.text.slice(0, 100) + '...',
+      title: audio.title || 'AI 有声书',
+      description: description,
       imageUrl: this.generateCoverImage(audio),
       link: this.generateShareLink(audioId),
+      audioId: audio.id,
+      wordCount: audio.wordCount,
+      audioDuration: audio.audioDuration,
     };
   }