refactor(types): eliminate all as any type assertions (30 → 0)

- Replace MouseEvent-only handlers with MouseEvent | KeyboardEvent unions in multi-select and ChatTabBar
- Define LegacyInstalledPlugin type for backward compatibility in plugin-api
- Create getTokenValue() helper for type-safe theme token access in AppearanceTab
- Define ModelConfig interface for model configuration type safety in modelProvider
- All modifications maintain exact business logic equivalence
- Build passes with zero TypeScript errors (bun run build )
- LSP diagnostics clean on all modified files
This commit is contained in:
DrSmoothl
2026-03-01 21:33:40 +08:00
parent c45ee1a98e
commit ba47069dfe
7 changed files with 117 additions and 58 deletions

View File

@@ -3,7 +3,7 @@ import type { ApiResponse } from '@/types/api'
import { fetchWithAuth, getAuthHeaders } from '@/lib/fetch-with-auth'
import { parseResponse } from '@/lib/api-helpers'
import type { InstalledPlugin } from './types'
import type { InstalledPlugin, LegacyInstalledPlugin } from './types'
/**
* 获取已安装插件列表
@@ -46,11 +46,17 @@ export function checkPluginInstalled(pluginId: string, installedPlugins: Install
/**
* 获取已安装插件的版本
*/
export function getInstalledPluginVersion(pluginId: string, installedPlugins: InstalledPlugin[]): string | undefined {
export function getInstalledPluginVersion(pluginId: string, installedPlugins: (InstalledPlugin | LegacyInstalledPlugin)[]): string | undefined {
const plugin = installedPlugins.find(p => p.id === pluginId)
if (!plugin) return undefined
// 兼容两种格式:新格式有 manifest,旧格式直接有 version
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return plugin.manifest?.version || (plugin as any).version
// 兼容两种格式:新格式有 manifest旧格式直接有 version
if ('manifest' in plugin && plugin.manifest) {
return plugin.manifest.version
}
// 旧版本格式
if ('version' in plugin) {
return plugin.version
}
return undefined
}

View File

@@ -45,6 +45,14 @@ export interface InstalledPlugin {
}
path: string
}
/**
* 旧版本插件格式(直接包含 version 字段)
*/
export interface LegacyInstalledPlugin {
id: string
version: string
path: string
}
/**
* 插件加载进度