黄中银 1 месяц назад
Родитель
Сommit
19bd722bb0

+ 8 - 2
ApqInstaller/electron/modules/installer.ts

@@ -230,6 +230,10 @@ export async function checkInstalled(software: SoftwareType): Promise<InstalledI
       command = 'git'
       versionArgs = ['--version']
       break
+    case 'claudeCode':
+      command = 'claude'
+      versionArgs = ['--version']
+      break
     default:
       return { installed: false, version: null }
   }
@@ -250,13 +254,15 @@ export async function checkAllInstalled(): Promise<AllInstalledInfo> {
   const results = await Promise.allSettled([
     checkInstalled('nodejs'),
     checkInstalled('vscode'),
-    checkInstalled('git')
+    checkInstalled('git'),
+    checkInstalled('claudeCode')
   ])
 
   return {
     nodejs: results[0].status === 'fulfilled' ? results[0].value : { installed: false, version: null },
     vscode: results[1].status === 'fulfilled' ? results[1].value : { installed: false, version: null },
-    git: results[2].status === 'fulfilled' ? results[2].value : { installed: false, version: null }
+    git: results[2].status === 'fulfilled' ? results[2].value : { installed: false, version: null },
+    claudeCode: results[3].status === 'fulfilled' ? results[3].value : { installed: false, version: null }
   }
 }
 

+ 2 - 1
ApqInstaller/electron/modules/types.ts

@@ -1,6 +1,6 @@
 // electron/modules/types.ts - 类型定义
 
-export type SoftwareType = 'nodejs' | 'vscode' | 'git'
+export type SoftwareType = 'nodejs' | 'vscode' | 'git' | 'claudeCode'
 export type SoftwareTypeWithAll = SoftwareType | 'all'
 export type Platform = 'win32' | 'darwin' | 'linux'
 export type ToastType = 'success' | 'warning' | 'error' | 'info'
@@ -66,6 +66,7 @@ export interface AllInstalledInfo {
   nodejs: InstalledInfo
   vscode: InstalledInfo
   git: InstalledInfo
+  claudeCode: InstalledInfo
 }
 
 export interface InstallHistoryItem {

+ 3 - 7
ApqInstaller/src/App.vue

@@ -53,6 +53,7 @@ function bindInstallListeners() {
   window.electronAPI.onInstallComplete((data) => {
     installStore.setSuccess(data.software, data.message)
     installStore.addLog(data.message)
+    // 重新检测所有软件的安装状态(包括 claudeCode)
     installStore.checkInstalledSoftware()
   })
 
@@ -72,8 +73,7 @@ onMounted(async () => {
   await Promise.all([
     systemStore.initSystem(),
     versionsStore.loadAllVersions(),
-    installStore.checkInstalledSoftware(),
-    installStore.checkClaudeCode()
+    installStore.checkInstalledSoftware()
   ])
 
   // 显示系统状态警告
@@ -143,11 +143,7 @@ onUnmounted(() => {
           <SoftwareIcon :software="tab.id as any" :size="18" />
           <span class="tab-label">{{ t(tab.label) }}</span>
           <span
-            v-if="['nodejs', 'vscode', 'git'].includes(tab.id) && installStore.isInstalled(tab.id as SoftwareType)"
-            class="installed-dot"
-          ></span>
-          <span
-            v-if="tab.id === 'claudeCode' && installStore.isClaudeCodeInstalled()"
+            v-if="['nodejs', 'vscode', 'git', 'claudeCode'].includes(tab.id) && installStore.isInstalled(tab.id as SoftwareType)"
             class="installed-dot"
           ></span>
         </button>

+ 4 - 31
ApqInstaller/src/stores/install.ts

@@ -54,6 +54,7 @@ export const useInstallStore = defineStore('install', () => {
     nodejs: createDefaultStatus(),
     vscode: createDefaultStatus(),
     git: createDefaultStatus(),
+    claudeCode: createDefaultStatus(),
     all: createDefaultStatus()
   })
 
@@ -61,13 +62,8 @@ export const useInstallStore = defineStore('install', () => {
   const installedInfo = ref<AllInstalledInfo>({
     nodejs: { installed: false, version: null },
     vscode: { installed: false, version: null },
-    git: { installed: false, version: null }
-  })
-
-  // Claude Code 安装状态(单独管理,因为不是通过 checkInstalled('all') 检测)
-  const claudeCodeInfo = ref<{ installed: boolean; version: string | null }>({
-    installed: false,
-    version: null
+    git: { installed: false, version: null },
+    claudeCode: { installed: false, version: null }
   })
 
   // 安装选项
@@ -140,25 +136,6 @@ export const useInstallStore = defineStore('install', () => {
     }
   }
 
-  async function checkClaudeCode(): Promise<void> {
-    try {
-      const result = await window.electronAPI.checkClaudeCode()
-      claudeCodeInfo.value = result
-    } catch (error) {
-      const errorMsg = error instanceof Error ? error.message : String(error)
-      notifyError(`${t('common.error')}: ${errorMsg}`)
-      claudeCodeInfo.value = { installed: false, version: null }
-    }
-  }
-
-  function isClaudeCodeInstalled(): boolean {
-    return claudeCodeInfo.value.installed
-  }
-
-  function getClaudeCodeVersion(): string | null {
-    return claudeCodeInfo.value.version
-  }
-
   async function doInstall(software: SoftwareTypeWithAll, options: InstallOptions): Promise<void> {
     setInstalling(software, true)
     updateStatus(software, t('install.preparing'), 0)
@@ -233,7 +210,6 @@ export const useInstallStore = defineStore('install', () => {
   return {
     installStatus,
     installedInfo,
-    claudeCodeInfo,
     installOptions,
     installHistory,
     installLogs,
@@ -244,7 +220,6 @@ export const useInstallStore = defineStore('install', () => {
     setError,
     resetStatus,
     checkInstalledSoftware,
-    checkClaudeCode,
     doInstall,
     cancelInstall,
     uninstallSoftware,
@@ -253,8 +228,6 @@ export const useInstallStore = defineStore('install', () => {
     clearLogs,
     getStatus,
     isInstalled,
-    getInstalledVersion,
-    isClaudeCodeInstalled,
-    getClaudeCodeVersion
+    getInstalledVersion
   }
 })

+ 2 - 1
ApqInstaller/src/types/electron.d.ts

@@ -1,6 +1,6 @@
 // src/types/electron.d.ts - Electron API 类型声明
 
-export type SoftwareType = 'nodejs' | 'vscode' | 'git'
+export type SoftwareType = 'nodejs' | 'vscode' | 'git' | 'claudeCode'
 export type SoftwareTypeWithAll = SoftwareType | 'all'
 export type Platform = 'win32' | 'darwin' | 'linux'
 
@@ -60,6 +60,7 @@ export interface AllInstalledInfo {
   nodejs: InstalledInfo
   vscode: InstalledInfo
   git: InstalledInfo
+  claudeCode: InstalledInfo
 }
 
 export interface InstallHistoryItem {

+ 2 - 2
ApqInstaller/src/views/BatchInstallView.vue

@@ -20,7 +20,7 @@ const status = computed(() => installStore.getStatus('all'))
 const needInstallNodejs = computed(() => !installStore.isInstalled('nodejs'))
 const needInstallVscode = computed(() => !installStore.isInstalled('vscode'))
 const needInstallGit = computed(() => !installStore.isInstalled('git'))
-const needInstallClaudeCode = computed(() => !installStore.isClaudeCodeInstalled())
+const needInstallClaudeCode = computed(() => !installStore.isInstalled('claudeCode'))
 
 // 是否有需要安装的软件
 const hasAnythingToInstall = computed(() =>
@@ -200,7 +200,7 @@ async function handleCancel() {
               <SoftwareIcon software="claudeCode" :size="18" />
               <span>Claude Code</span>
             </span>
-            <el-tag v-if="installStore.isClaudeCodeInstalled()" type="success" size="small" style="margin-left: 8px">
+            <el-tag v-if="installStore.isInstalled('claudeCode')" type="success" size="small" style="margin-left: 8px">
               {{ t('common.installed') }}
             </el-tag>
           </el-checkbox>

+ 3 - 3
ApqInstaller/src/views/ClaudeCodeView.vue

@@ -16,8 +16,8 @@ const isChecking = ref(false)
 
 const nodejsInstalled = computed(() => installStore.isInstalled('nodejs'))
 const gitInstalled = computed(() => installStore.isInstalled('git'))
-const claudeCodeInstalled = computed(() => installStore.isClaudeCodeInstalled())
-const claudeCodeVersion = computed(() => installStore.getClaudeCodeVersion())
+const claudeCodeInstalled = computed(() => installStore.isInstalled('claudeCode'))
+const claudeCodeVersion = computed(() => installStore.getInstalledVersion('claudeCode'))
 
 // 启动按钮只有在 Claude Code 已安装时才可点击
 const canLaunch = computed(() => gitInstalled.value && claudeCodeInstalled.value && !isLaunching.value && !isChecking.value && !isInstalling.value)
@@ -41,7 +41,7 @@ const statusText = computed(() => {
 async function refreshStatus() {
   isChecking.value = true
   try {
-    await installStore.checkClaudeCode()
+    await installStore.checkInstalledSoftware()
   } finally {
     isChecking.value = false
   }