| 479 | |
| 480 | // 保存搜索偏好(搜索词 -> 选中的指令) |
| 481 | async function saveSearchPreference( |
| 482 | query: string, |
| 483 | command: { path: string; featureCode?: string; name: string } |
| 484 | ): Promise<void> { |
| 485 | const key = query.trim().toLowerCase() |
| 486 | if (!key) return |
| 487 | |
| 488 | searchPreference.value[key] = { |
| 489 | path: command.path, |
| 490 | featureCode: command.featureCode, |
| 491 | name: command.name |
| 492 | } |
| 493 | try { |
| 494 | await window.ztools.dbPut( |
| 495 | 'search-preference', |
| 496 | JSON.parse(JSON.stringify(searchPreference.value)) |
| 497 | ) |
| 498 | } catch (error) { |
| 499 | console.error('保存搜索偏好失败:', error) |
| 500 | } |
| 501 | } |
| 502 | |
| 503 | // 从数据库加载所有数据(仅在初始化时调用一次) |
| 504 | async function initializeData(): Promise<void> { |