9393 当前
9494 </span >
9595 </div >
96- <Button v-if =" environmentInfo.current_version !== version.version"
97- type =" primary"
98- size =" sm"
99- @click =" handleSwitchVersion(version.version)" >
100- 切换
101- </Button >
96+ <div class =" flex items-center space-x-2" >
97+ <Button v-if =" environmentInfo.current_version !== version.version"
98+ type =" primary"
99+ size =" sm"
100+ @click =" handleSwitchVersion(version.version)" >
101+ 切换
102+ </Button >
103+ <Button v-if =" environmentInfo.current_version !== version.version"
104+ type =" danger"
105+ size =" sm"
106+ :icon =" Trash2"
107+ @click =" handleUninstall(version.version)" >
108+ 卸载
109+ </Button >
110+ </div >
102111 </div >
103112 </div >
104113 </div >
147156
148157<script setup lang="ts">
149158import { computed , ref } from ' vue'
150- import { AlertCircle , CheckCircle , Download , Folder } from ' lucide-vue-next'
159+ import { AlertCircle , CheckCircle , Download , Folder , Trash2 } from ' lucide-vue-next'
151160import { useEnvironmentManager } from ' ../../composables/useEnvironmentManager'
152161import Label from ' ../../ui/Label.vue'
153162import Input from ' ../../ui/Input.vue'
@@ -171,7 +180,8 @@ const {
171180 isDownloading,
172181 error,
173182 downloadAndInstall,
174- switchVersion
183+ switchVersion,
184+ uninstallVersion
175185} = useEnvironmentManager (props .language )
176186
177187const activeVersionTab = ref (' installed' )
@@ -256,6 +266,17 @@ const handleSwitchVersion = async (version: string) => {
256266 }
257267}
258268
269+ // 卸载版本
270+ const handleUninstall = async (version : string ) => {
271+ try {
272+ await uninstallVersion (version )
273+ console .log (' 卸载版本成功:' , version )
274+ }
275+ catch (e ) {
276+ console .error (' 卸载版本失败:' , e )
277+ }
278+ }
279+
259280// 选择目录
260281const onSelectDirectory = () => {
261282 emit (' select-directory' )
0 commit comments