| 30 | } |
| 31 | |
| 32 | async loadSearchIndex() { |
| 33 | return new Promise((resolve, reject) => { |
| 34 | console.log('🔄 Loading search index...'); |
| 35 | |
| 36 | this.db.all('SELECT * FROM issues', (err, rows) => { |
| 37 | if (err) { |
| 38 | console.error('❌ Failed to load search index:', err.message); |
| 39 | reject(err); |
| 40 | return; |
| 41 | } |
| 42 | |
| 43 | console.log(`📊 Loaded ${rows.length} articles`); |
| 44 | |
| 45 | const fuseOptions = { |
| 46 | keys: [ |
| 47 | { name: 'title', weight: 0.4 }, |
| 48 | { name: 'search_content', weight: 0.4 }, |
| 49 | { name: 'labels', weight: 0.2 } |
| 50 | ], |
| 51 | threshold: 0.3, |
| 52 | includeScore: true, |
| 53 | includeMatches: true |
| 54 | }; |
| 55 | |
| 56 | this.searchEngine = new Fuse(rows, fuseOptions); |
| 57 | this.isReady = true; |
| 58 | console.log('✅ Search index ready'); |
| 59 | resolve(); |
| 60 | }); |
| 61 | }); |
| 62 | } |
| 63 | |
| 64 | async testSearchFunction(query = "透明 边框") { |
| 65 | console.log(`\n🔍 Testing search for: "${query}"`); |