| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- // shared/types.ts - 共享类型定义
- // 此文件在 Electron 主进程和 Vue 渲染进程之间共享
- // ==================== 基础类型 ====================
- export type SoftwareType = 'nodejs' | 'pnpm' | 'vscode' | 'git' | 'claudeCode'
- export type SoftwareTypeWithAll = SoftwareType | 'all'
- export type Platform = 'win32' | 'darwin' | 'linux'
- export type ToastType = 'success' | 'warning' | 'error' | 'info'
- export type SystemStatusType = 'success' | 'warning' | 'error'
- // Tab ID 类型
- export type TabId = 'intro' | 'nodejs' | 'vscode' | 'git' | 'claudeCode' | 'all'
- // ==================== 版本相关 ====================
- export interface VersionItem {
- value: string
- label: string
- lts?: boolean
- disabled?: boolean
- separator?: boolean
- }
- export interface VersionResult {
- versions: VersionItem[]
- warning: string | null
- }
- // ==================== 安装相关 ====================
- export interface InstallOptions {
- version?: string
- installPnpm?: boolean
- installNodejs?: boolean
- nodejsVersion?: string
- nodejsPath?: string // Node.js 自定义安装路径 (仅 Windows)
- installVscode?: boolean
- vscodeVersion?: string
- vscodePath?: string // VS Code 自定义安装路径 (仅 Windows)
- installGit?: boolean
- gitVersion?: string
- gitPath?: string // Git 自定义安装路径 (仅 Windows)
- installClaudeCode?: boolean
- installClaudeCodeExt?: boolean // Claude Code for VS Code 扩展
- customPath?: string
- }
- export interface InstallStatus {
- software: SoftwareTypeWithAll
- message: string
- progress: number
- i18nKey?: string
- i18nParams?: Record<string, string>
- skipLog?: boolean
- }
- export interface InstallResult {
- software: SoftwareTypeWithAll
- message: string
- i18nKey?: string
- i18nParams?: Record<string, string>
- }
- export interface InstalledInfo {
- installed: boolean
- version: string | null
- }
- export interface AllInstalledInfo {
- nodejs: InstalledInfo
- pnpm: InstalledInfo
- vscode: InstalledInfo
- git: InstalledInfo
- claudeCode: InstalledInfo
- }
- export interface InstallHistoryItem {
- software: SoftwareTypeWithAll
- version: string
- options: InstallOptions
- success: boolean
- error?: string
- cancelled?: boolean
- duration?: number
- timestamp: number
- }
- // ==================== 系统相关 ====================
- export interface PackageManagerResult {
- exists: boolean
- manager: 'none' | 'brew' | 'apt'
- }
- export interface CommandResult {
- command: string
- args: string[]
- }
- export type LogCategory = 'app' | 'install'
- export interface LogEntry {
- level: 'DEBUG' | 'INFO' | 'WARN' | 'ERROR'
- message: string
- timestamp: string
- category?: LogCategory
- data?: unknown
- }
- // ==================== 镜像配置 ====================
- export type GitMirrorType = 'huaweicloud' | 'github'
- export type NodejsMirrorType = 'official' | 'npmmirror'
- export interface GitMirrorConfig {
- mirror: GitMirrorType
- }
- export interface NodejsMirrorConfig {
- mirror: NodejsMirrorType
- }
- // ==================== 自动更新 ====================
- export type UpdateStatus =
- | 'checking'
- | 'available'
- | 'not-available'
- | 'downloading'
- | 'downloaded'
- | 'error'
- export interface UpdateProgress {
- percent: number
- bytesPerSecond: number
- total: number
- transferred: number
- }
- export interface UpdateResult {
- status: UpdateStatus
- info?: {
- version: string
- releaseDate?: string
- releaseNotes?: string
- }
- progress?: UpdateProgress
- error?: string
- }
- // ==================== Electron API ====================
- export interface ElectronAPI {
- // 安装相关
- install: (software: SoftwareTypeWithAll, options: InstallOptions) => Promise<void>
- cancelInstall: () => Promise<boolean>
- checkInstalled: (software: SoftwareTypeWithAll) => Promise<InstalledInfo | AllInstalledInfo>
- uninstall: (software: SoftwareType) => Promise<boolean>
- // 系统检测
- checkAdmin: () => Promise<boolean>
- checkPackageManager: () => Promise<PackageManagerResult>
- installPackageManager: (manager: string) => Promise<{ success: boolean; error?: string }>
- getPlatform: () => Promise<Platform>
- checkNetwork: () => Promise<boolean>
- // 版本
- getVersions: (software: SoftwareType) => Promise<VersionResult>
- checkUpdate: (software: SoftwareType) => Promise<{ hasUpdate: boolean; latestVersion?: string }>
- // Git 镜像配置
- setGitMirror: (mirror: GitMirrorType) => Promise<void>
- getGitMirrorConfig: () => Promise<GitMirrorConfig>
- // Node.js 镜像配置
- setNodejsMirror: (mirror: NodejsMirrorType) => Promise<void>
- getNodejsMirrorConfig: () => Promise<NodejsMirrorConfig>
- // 历史和日志
- getInstallHistory: (limit?: number) => Promise<InstallHistoryItem[]>
- getLogs: () => Promise<LogEntry[]>
- writeInstallLog: (message: string, level?: 'info' | 'warn' | 'error') => Promise<void>
- getLogPaths: () => Promise<{ appLog: string; installLog: string }>
- // 文件夹选择
- selectDirectory: (defaultPath?: string) => Promise<{ canceled: boolean; path: string | null }>
- // 窗口操作
- setWindowTitle: (title: string) => Promise<void>
- windowMinimize: () => Promise<void>
- windowMaximize: () => Promise<boolean>
- windowClose: () => Promise<void>
- windowIsMaximized: () => Promise<boolean>
- // Claude Code
- checkClaudeCode: () => Promise<{ installed: boolean; version: string | null }>
- launchClaudeCode: () => Promise<{ success: boolean }>
- installClaudeCode: () => Promise<{ success: boolean; error?: string }>
- // VS Code Extensions
- checkVscodeExtension: (extensionId: string) => Promise<{ installed: boolean; version?: string }>
- installVscodeExtension: (extensionId: string) => Promise<{ success: boolean; error?: string }>
- // 事件监听
- onInstallStatus: (callback: (data: InstallStatus) => void) => void
- onInstallComplete: (callback: (data: InstallResult) => void) => void
- onInstallError: (callback: (data: InstallResult) => void) => void
- onNetworkChange: (callback: (online: boolean) => void) => void
- removeAllListeners: () => void
- // 自动更新
- updaterCheck: () => Promise<UpdateResult>
- updaterDownload: () => Promise<UpdateResult>
- updaterInstall: () => Promise<void>
- updaterVersion: () => Promise<string>
- updaterIsPortable: () => Promise<boolean>
- onUpdaterStatus: (callback: (data: UpdateResult) => void) => void
- }
- // Window.electronAPI 类型声明
- declare global {
- interface Window {
- electronAPI: ElectronAPI
- }
- }
|