1.0.5 标题栏和命令简化,可打开库函数json

This commit is contained in:
睿 安
2025-09-17 16:32:32 +08:00
parent 4bd8eaf683
commit 8150276da0
5 changed files with 32 additions and 70 deletions

View File

@@ -88,41 +88,24 @@ export function registerCommands(context: vscode.ExtensionContext, model: FileMo
}
});
// 刷新文件列表
const refreshCommand = vscode.commands.registerCommand('squirrel.refreshFiles', async () => {
if (!model.getIsConnected()) {
vscode.window.showErrorMessage('请先连接到 pvfUtility API');
return;
}
try {
await vscode.window.withProgress({
location: vscode.ProgressLocation.Notification,
title: '正在刷新文件列表...',
cancellable: false
}, async (progress) => {
const success = await model.refresh();
if (success) {
vscode.window.showInformationMessage('文件列表刷新成功');
provider.refresh();
} else {
vscode.window.showErrorMessage('刷新文件列表失败');
}
});
} catch (error) {
vscode.window.showErrorMessage(`刷新失败: ${error}`);
}
});
// 打开文件(单击或双击文件时调用)
const openFileCommand = vscode.commands.registerCommand('squirrel.openFile', async (entry: FileEntry) => {
await openFile(model, provider, entry);
});
// 保存文件(通过 VS Code 的保存事件处理,这个命令主要用于显示)
const saveFileCommand = vscode.commands.registerCommand('squirrel.saveFile', async () => {
vscode.window.showInformationMessage('使用 VS Code 的保存功能或 Ctrl+S 保存文件');
// 打开库函数文档文件夹
const openApiDocsCommand = vscode.commands.registerCommand('squirrel.openApiDocs', async () => {
// 获取扩展路径
const extensionPath = vscode.extensions.getExtension('local.squirrel-nut-explorer')?.extensionPath;
if (extensionPath) {
// 构建api-functions.json文件的URI
const apiDocsUri = vscode.Uri.file(extensionPath);
// 在资源管理器中打开文件夹
await vscode.env.openExternal(apiDocsUri);
} else {
vscode.window.showErrorMessage('无法找到扩展路径');
}
});
context.subscriptions.push(connectCommand, refreshCommand, openFileCommand, saveFileCommand);
context.subscriptions.push(connectCommand, openFileCommand, openApiDocsCommand);
}