(content)
| 863 | } |
| 864 | |
| 865 | analyzeCodePatterns(content) { |
| 866 | const patterns = []; |
| 867 | const codeBlocks = content.match(/```[^`]+```/g) || []; |
| 868 | |
| 869 | codeBlocks.forEach((block, index) => { |
| 870 | const cleanCode = block.replace(/```(css|html|javascript)?\n/g, '').replace(/```$/g, ''); |
| 871 | |
| 872 | // 分析动画模式 |
| 873 | if (cleanCode.includes('@keyframes') || cleanCode.includes('animation')) { |
| 874 | patterns.push({ |
| 875 | pattern_name: `animation_pattern_${index}`, |
| 876 | pattern_type: 'animation', |
| 877 | code_snippet: cleanCode, |
| 878 | explanation: this.analyzeAnimationPattern(cleanCode), |
| 879 | use_cases: JSON.stringify(['transitions', 'hover effects', 'loading indicators']), |
| 880 | performance_notes: this.analyzeAnimationPerformance(cleanCode), |
| 881 | browser_support: this.getAnimationBrowserSupport(cleanCode) |
| 882 | }); |
| 883 | } |
| 884 | |
| 885 | // 分析布局模式 |
| 886 | if (cleanCode.includes('grid') || cleanCode.includes('flex')) { |
| 887 | patterns.push({ |
| 888 | pattern_name: `layout_pattern_${index}`, |
| 889 | pattern_type: 'layout', |
| 890 | code_snippet: cleanCode, |
| 891 | explanation: this.analyzeLayoutPattern(cleanCode), |
| 892 | use_cases: JSON.stringify(['responsive layouts', 'card layouts', 'centering']), |
| 893 | performance_notes: this.analyzeLayoutPerformance(cleanCode), |
| 894 | browser_support: this.getLayoutBrowserSupport(cleanCode) |
| 895 | }); |
| 896 | } |
| 897 | }); |
| 898 | |
| 899 | return patterns; |
| 900 | } |
| 901 | |
| 902 | analyzeAnimationPattern(code) { |
| 903 | const analysis = []; |
nothing calls this directly
no test coverage detected