Skip to content

perf: Optimize SDK Manager#34

Merged
HalfSweet merged 5 commits intomainfrom
feat/sdk-manage
Mar 17, 2026
Merged

perf: Optimize SDK Manager#34
HalfSweet merged 5 commits intomainfrom
feat/sdk-manage

Conversation

@HalfSweet
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings March 13, 2026 09:44
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI review requested due to automatic review settings March 13, 2026 10:18
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 51 out of 53 changed files in this pull request and generated 9 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +1 to +2
import { computed, ref } from '@vue/runtime-core';
import { defineStore } from 'pinia';
Comment on lines +1 to +2
import { computed, ref } from '@vue/runtime-core';
import { defineStore } from 'pinia';
if (fs.existsSync(shPath)) {
return shPath;
}
fs.renameSync(sdkPath, newPath);

<script setup lang="ts">
import { computed, onMounted } from 'vue';
import { RouterLink, useRoute } from 'vue-router';
Comment on lines +36 to +40
import { useTaskCenterStore } from '@/stores/taskCenter';

const route = useRoute();
const catalogStore = useSdkCatalogStore();
const taskCenterStore = useTaskCenterStore();
Comment on lines +1 to +2
import { computed, ref } from '@vue/runtime-core';
import { defineStore } from 'pinia';
Comment thread package.json
"github",
"sifli"
],
"description": "Toolchain download source for this SDK."
Comment on lines +259 to 279
const sanitizedName = newDirectoryName.trim();
if (
!sanitizedName ||
sanitizedName === '.' ||
sanitizedName === '..' ||
sanitizedName.includes('/') ||
sanitizedName.includes('\\')
) {
throw new Error('目录名称无效。');
}
}

/**
* 在终端中执行 SDK 激活脚本
*/
private async executeActivationScript(activationScript: {
scriptPath: string;
configPath: string;
command: string;
}): Promise<void> {
try {
this.logService.info(`Executing SDK activation script: ${activationScript.scriptPath}`);
const terminal = await this.terminalService.getOrCreateSiFliTerminalAndCdProject(false, { autoExport: false });

const scriptDir = path.dirname(activationScript.scriptPath);

// 获取当前SDK的工具链路径
const toolsPath = this.configService.getSdkToolsPath(scriptDir);

// 先设置 SIFLI_SDK_TOOLS_PATH 环境变量(如果有配置的话)
if (toolsPath && toolsPath.trim() !== '') {
await this.setEnvironmentVariable(terminal, 'SIFLI_SDK_TOOLS_PATH', toolsPath);
}
const parentDir = path.dirname(sdkPath);
const newPath = path.join(parentDir, sanitizedName);

// 直接执行导出脚本的绝对路径
let executeCommand: string;
if (process.platform === 'win32') {
// Windows PowerShell 使用配置的 PowerShell 路径和 -ExecutionPolicy Bypass 执行脚本
const powershellPath = this.terminalService.getPowerShellExecutablePath();
executeCommand = `& "${activationScript.scriptPath}"`;
} else {
// Unix-like 系统执行脚本
executeCommand = `. "${activationScript.scriptPath}"`;
}

// 显示并聚焦终端
terminal.show();

// 发送命令到终端
terminal.sendText(executeCommand);

this.terminalService.markSdkEnvironmentPrepared();

this.logService.info(`SDK activation script executed successfully: ${executeCommand}`);
} catch (error) {
this.logService.error('Error executing activation script:', error);
throw error;
if (sdkPath === newPath) {
return { oldPath: sdkPath, newPath };
}
}

/**
* 获取当前激活的 SDK
*/
public getCurrentSdk(): SdkVersion | undefined {
return this.configService.getCurrentSdk();
}

/**
* 根据 SDK 路径获取对应平台的 export 脚本路径
* @param sdkPath SDK 根目录路径,如果不传则使用当前激活的 SDK
* @returns export 脚本的完整路径,如果不存在则返回 undefined
*/
public getExportScriptPath(sdkPath?: string): string | undefined {
const targetSdkPath = sdkPath || this.configService.getCurrentSdkPath();
if (!targetSdkPath) {
return undefined;
if (fs.existsSync(newPath)) {
throw new Error(`目标目录已存在: ${newPath}`);
}
Comment on lines +24 to +26
{ value: 'branch', label: '分支分支 (Branch)' },
{ value: 'tag', label: '发布版本 (Release/Tag)' },
]"
@HalfSweet HalfSweet merged commit 8b00bb0 into main Mar 17, 2026
4 checks passed
@HalfSweet HalfSweet deleted the feat/sdk-manage branch March 17, 2026 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants