(demoId)
| 508 | } |
| 509 | |
| 510 | async getCssDemo(demoId) { |
| 511 | debugLog(`🎯 Getting CSS demo #${demoId}`); |
| 512 | |
| 513 | return new Promise((resolve, reject) => { |
| 514 | // 获取基本信息 |
| 515 | this.db.get( |
| 516 | 'SELECT * FROM css_inspiration WHERE id = ?', |
| 517 | [demoId], |
| 518 | (err, row) => { |
| 519 | if (err) { |
| 520 | debugLog(`❌ Database error for demo #${demoId}:`, err); |
| 521 | reject(err); |
| 522 | return; |
| 523 | } |
| 524 | |
| 525 | if (!row) { |
| 526 | debugLog(`❌ Demo #${demoId} not found`); |
| 527 | reject(new Error(`CSS demo with ID ${demoId} not found`)); |
| 528 | return; |
| 529 | } |
| 530 | |
| 531 | // 获取完整的演示代码 |
| 532 | this.db.get( |
| 533 | 'SELECT * FROM demo_styles WHERE inspiration_id = ?', |
| 534 | [demoId], |
| 535 | (err, demoRow) => { |
| 536 | if (err) { |
| 537 | debugLog(`❌ Error getting demo styles for #${demoId}:`, err); |
| 538 | reject(err); |
| 539 | return; |
| 540 | } |
| 541 | |
| 542 | debugLog(`✅ Found demo #${demoId}: "${row.title}"`); |
| 543 | |
| 544 | const tags = JSON.parse(row.tags || '[]'); |
| 545 | const browserSupport = JSON.parse(row.browser_support || '{}'); |
| 546 | |
| 547 | resolve({ |
| 548 | content: [ |
| 549 | { |
| 550 | type: 'text', |
| 551 | text: `# ${row.title}\n\n` + |
| 552 | `**Category:** ${row.category} | **Difficulty:** ${row.difficulty_level}\n\n` + |
| 553 | `**Description:** ${row.description}\n\n` + |
| 554 | `**Tags:** ${tags.join(', ')}\n\n` + |
| 555 | `**Browser Support:**\n` + |
| 556 | Object.entries(browserSupport).map(([browser, support]) => |
| 557 | `- ${browser}: ${support}` |
| 558 | ).join('\n') + '\n\n' + |
| 559 | `## HTML Code\n\n\`\`\`html\n${row.html_content || '<div class="demo">Demo</div>'}\n\`\`\`\n\n` + |
| 560 | `## CSS Code\n\n\`\`\`css\n${row.css_content}\n\`\`\`\n\n` + |
| 561 | (demoRow ? `## Complete Demo\n\n\`\`\`html\n${demoRow.complete_html}\n\`\`\`\n\n` : '') + |
| 562 | `**Demo URL:** ${row.demo_url}\n` + |
| 563 | `**Source:** ${row.source_url}` |
| 564 | } |
| 565 | ] |
| 566 | }); |
| 567 | } |
no test coverage detected