增加了项目回读的功能
This commit is contained in:
@@ -31,6 +31,14 @@ interface Config {
|
||||
containerId: string;
|
||||
}
|
||||
|
||||
interface ProjectData {
|
||||
projects: Project[];
|
||||
aircrafts: Aircraft[];
|
||||
containers: Container[];
|
||||
configs: Config[];
|
||||
projectPaths: { [key: string]: string };
|
||||
}
|
||||
|
||||
export class ConfigPanel {
|
||||
private static currentPanel: ConfigPanel | undefined;
|
||||
private readonly panel: vscode.WebviewPanel;
|
||||
@@ -97,79 +105,92 @@ export class ConfigPanel {
|
||||
}
|
||||
|
||||
private setupMessageListener() {
|
||||
this.panel.webview.onDidReceiveMessage(async (data) => {
|
||||
switch (data.type) {
|
||||
case 'configureProject':
|
||||
const selectedPath = await this.selectProjectPath(data.projectId, data.projectName);
|
||||
if (selectedPath) {
|
||||
this.currentView = 'aircrafts';
|
||||
this.currentProjectId = data.projectId;
|
||||
this.updateWebview();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'openProject':
|
||||
// 已配置的项目直接打开
|
||||
this.panel.webview.onDidReceiveMessage(async (data) => {
|
||||
switch (data.type) {
|
||||
case 'openExistingProject':
|
||||
await this.openExistingProject();
|
||||
break;
|
||||
|
||||
case 'configureProject':
|
||||
const selectedPath = await this.selectProjectPath(data.projectId, data.projectName);
|
||||
if (selectedPath) {
|
||||
this.currentView = 'aircrafts';
|
||||
this.currentProjectId = data.projectId;
|
||||
this.updateWebview();
|
||||
break;
|
||||
|
||||
case 'openAircraftConfig':
|
||||
this.currentView = 'containers';
|
||||
this.currentProjectId = data.projectId;
|
||||
this.currentAircraftId = data.aircraftId;
|
||||
this.updateWebview();
|
||||
break;
|
||||
|
||||
case 'openContainerConfig':
|
||||
this.currentView = 'configs';
|
||||
this.currentContainerId = data.containerId;
|
||||
this.updateWebview();
|
||||
break;
|
||||
|
||||
// 修复返回按钮的消息处理
|
||||
case 'goBackToProjects':
|
||||
this.currentView = 'projects';
|
||||
this.updateWebview();
|
||||
break;
|
||||
|
||||
case 'goBackToAircrafts':
|
||||
this.currentView = 'aircrafts';
|
||||
this.updateWebview();
|
||||
break;
|
||||
|
||||
case 'goBackToContainers':
|
||||
this.currentView = 'containers';
|
||||
this.updateWebview();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'openProject':
|
||||
// 已配置的项目直接打开
|
||||
this.currentView = 'aircrafts';
|
||||
this.currentProjectId = data.projectId;
|
||||
this.updateWebview();
|
||||
break;
|
||||
|
||||
case 'openAircraftConfig':
|
||||
this.currentView = 'containers';
|
||||
this.currentProjectId = data.projectId;
|
||||
this.currentAircraftId = data.aircraftId;
|
||||
this.updateWebview();
|
||||
break;
|
||||
|
||||
case 'openContainerConfig':
|
||||
this.currentView = 'configs';
|
||||
this.currentContainerId = data.containerId;
|
||||
this.updateWebview();
|
||||
break;
|
||||
|
||||
// 修复返回按钮的消息处理
|
||||
case 'goBackToProjects':
|
||||
this.currentView = 'projects';
|
||||
// 清空当前选择的ID
|
||||
this.currentProjectId = '';
|
||||
this.currentAircraftId = '';
|
||||
this.currentContainerId = '';
|
||||
this.updateWebview();
|
||||
break;
|
||||
|
||||
case 'goBackToAircrafts':
|
||||
this.currentView = 'aircrafts';
|
||||
// 保持 currentProjectId,清空其他ID
|
||||
this.currentAircraftId = '';
|
||||
this.currentContainerId = '';
|
||||
this.updateWebview();
|
||||
break;
|
||||
|
||||
case 'goBackToContainers':
|
||||
this.currentView = 'containers';
|
||||
// 保持 currentProjectId 和 currentAircraftId,清空 currentContainerId
|
||||
this.currentContainerId = '';
|
||||
this.updateWebview();
|
||||
break;
|
||||
|
||||
case 'updateProjectName':
|
||||
this.updateProjectName(data.projectId, data.name);
|
||||
await this.updateProjectName(data.projectId, data.name);
|
||||
break;
|
||||
|
||||
case 'createProject':
|
||||
this.createProject(data.name);
|
||||
await this.createProject(data.name);
|
||||
break;
|
||||
|
||||
case 'updateAircraftName':
|
||||
this.updateAircraftName(data.aircraftId, data.name);
|
||||
await this.updateAircraftName(data.aircraftId, data.name);
|
||||
break;
|
||||
|
||||
case 'createAircraft':
|
||||
this.createAircraft(data.name);
|
||||
await this.createAircraft(data.name);
|
||||
break;
|
||||
|
||||
case 'updateContainerName':
|
||||
this.updateContainerName(data.containerId, data.name);
|
||||
await this.updateContainerName(data.containerId, data.name);
|
||||
break;
|
||||
|
||||
case 'createContainer':
|
||||
this.createContainer(data.name);
|
||||
await this.createContainer(data.name);
|
||||
break;
|
||||
|
||||
case 'updateConfigName':
|
||||
this.updateConfigName(data.configId, data.name);
|
||||
await this.updateConfigName(data.configId, data.name);
|
||||
break;
|
||||
|
||||
case 'updateConfigFileName':
|
||||
@@ -177,7 +198,7 @@ export class ConfigPanel {
|
||||
break;
|
||||
|
||||
case 'createConfig':
|
||||
this.createConfig(data.name);
|
||||
await this.createConfig(data.name);
|
||||
break;
|
||||
|
||||
case 'saveConfigFile':
|
||||
@@ -189,25 +210,186 @@ export class ConfigPanel {
|
||||
break;
|
||||
|
||||
case 'deleteProject':
|
||||
this.deleteProject(data.projectId);
|
||||
await this.deleteProject(data.projectId);
|
||||
break;
|
||||
|
||||
case 'deleteAircraft':
|
||||
this.deleteAircraft(data.aircraftId);
|
||||
await this.deleteAircraft(data.aircraftId);
|
||||
break;
|
||||
|
||||
case 'deleteContainer':
|
||||
this.deleteContainer(data.containerId);
|
||||
await this.deleteContainer(data.containerId);
|
||||
break;
|
||||
|
||||
case 'deleteConfig':
|
||||
this.deleteConfig(data.configId);
|
||||
await this.deleteConfig(data.configId);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ... 其余方法保持不变(selectProjectPath, updateProjectName, createProject等)
|
||||
// === 打开现有项目功能 ===
|
||||
private async openExistingProject(): Promise<void> {
|
||||
try {
|
||||
const result = await vscode.window.showOpenDialog({
|
||||
canSelectFiles: false,
|
||||
canSelectFolders: true,
|
||||
canSelectMany: false,
|
||||
openLabel: '选择项目文件夹',
|
||||
title: '选择包含项目数据的文件夹'
|
||||
});
|
||||
|
||||
if (result && result.length > 0) {
|
||||
const selectedPath = result[0].fsPath;
|
||||
await this.loadProjectData(selectedPath);
|
||||
}
|
||||
} catch (error) {
|
||||
vscode.window.showErrorMessage(`打开项目时出错: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
// === 数据持久化方法 ===
|
||||
|
||||
/**
|
||||
* 保存所有数据到项目路径
|
||||
*/
|
||||
private async saveAllData(): Promise<void> {
|
||||
try {
|
||||
console.log('开始保存数据...');
|
||||
console.log('当前项目ID:', this.currentProjectId);
|
||||
console.log('项目路径映射:', Array.from(this.projectPaths.entries()));
|
||||
|
||||
// 找到当前项目的路径
|
||||
let projectPath: string | undefined;
|
||||
|
||||
// 首先尝试使用当前项目ID
|
||||
if (this.currentProjectId) {
|
||||
projectPath = this.projectPaths.get(this.currentProjectId);
|
||||
}
|
||||
|
||||
// 如果没有找到,尝试使用第一个项目
|
||||
if (!projectPath && this.projects.length > 0) {
|
||||
projectPath = this.projectPaths.get(this.projects[0].id);
|
||||
}
|
||||
|
||||
if (!projectPath) {
|
||||
console.log('未找到项目路径,跳过保存数据');
|
||||
vscode.window.showWarningMessage('未找到项目存储路径,数据将不会保存');
|
||||
return;
|
||||
}
|
||||
|
||||
const dataUri = vscode.Uri.joinPath(vscode.Uri.file(projectPath), '.dcsp-data.json');
|
||||
|
||||
const data: ProjectData = {
|
||||
projects: this.projects,
|
||||
aircrafts: this.aircrafts,
|
||||
containers: this.containers,
|
||||
configs: this.configs,
|
||||
projectPaths: Object.fromEntries(this.projectPaths)
|
||||
};
|
||||
|
||||
console.log('要保存的数据:', {
|
||||
projects: this.projects.length,
|
||||
aircrafts: this.aircrafts.length,
|
||||
containers: this.containers.length,
|
||||
configs: this.configs.length,
|
||||
projectPaths: this.projectPaths.size
|
||||
});
|
||||
|
||||
const uint8Array = new TextEncoder().encode(JSON.stringify(data, null, 2));
|
||||
await vscode.workspace.fs.writeFile(dataUri, uint8Array);
|
||||
|
||||
console.log('项目数据已保存到:', dataUri.fsPath);
|
||||
vscode.window.showInformationMessage('项目数据已保存');
|
||||
} catch (error) {
|
||||
console.error('保存项目数据时出错:', error);
|
||||
vscode.window.showErrorMessage(`保存项目数据失败: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从项目路径加载数据
|
||||
*/
|
||||
private async loadProjectData(projectPath: string): Promise<boolean> {
|
||||
try {
|
||||
const dataUri = vscode.Uri.joinPath(vscode.Uri.file(projectPath), '.dcsp-data.json');
|
||||
|
||||
// 检查数据文件是否存在
|
||||
try {
|
||||
await vscode.workspace.fs.stat(dataUri);
|
||||
} catch {
|
||||
vscode.window.showErrorMessage('选择的文件夹中没有找到项目数据文件 (.dcsp-data.json)');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 读取数据文件
|
||||
const fileData = await vscode.workspace.fs.readFile(dataUri);
|
||||
const dataStr = new TextDecoder().decode(fileData);
|
||||
const data: ProjectData = JSON.parse(dataStr);
|
||||
|
||||
console.log('从文件加载的数据:', data);
|
||||
|
||||
// 清空现有数据
|
||||
this.projects = [];
|
||||
this.aircrafts = [];
|
||||
this.containers = [];
|
||||
this.configs = [];
|
||||
this.projectPaths = new Map();
|
||||
|
||||
// 验证数据格式并加载
|
||||
if (data.projects && Array.isArray(data.projects)) {
|
||||
this.projects = data.projects;
|
||||
}
|
||||
if (data.aircrafts && Array.isArray(data.aircrafts)) {
|
||||
this.aircrafts = data.aircrafts;
|
||||
}
|
||||
if (data.containers && Array.isArray(data.containers)) {
|
||||
this.containers = data.containers;
|
||||
}
|
||||
if (data.configs && Array.isArray(data.configs)) {
|
||||
this.configs = data.configs;
|
||||
}
|
||||
if (data.projectPaths && typeof data.projectPaths === 'object') {
|
||||
this.projectPaths = new Map(Object.entries(data.projectPaths));
|
||||
}
|
||||
|
||||
console.log('加载后的数据状态:', {
|
||||
projects: this.projects.length,
|
||||
aircrafts: this.aircrafts.length,
|
||||
containers: this.containers.length,
|
||||
configs: this.configs.length,
|
||||
projectPaths: this.projectPaths.size
|
||||
});
|
||||
|
||||
// 设置当前项目为第一个项目(如果有的话)
|
||||
if (this.projects.length > 0) {
|
||||
this.currentProjectId = this.projects[0].id;
|
||||
this.currentView = 'aircrafts';
|
||||
}
|
||||
|
||||
vscode.window.showInformationMessage(`项目数据已从 ${projectPath} 加载`);
|
||||
this.updateWebview();
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error('加载项目数据时出错:', error);
|
||||
vscode.window.showErrorMessage(`加载项目数据失败: ${error}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查项目路径是否已存在数据
|
||||
*/
|
||||
private async checkProjectPathHasData(projectPath: string): Promise<boolean> {
|
||||
try {
|
||||
const dataUri = vscode.Uri.joinPath(vscode.Uri.file(projectPath), '.dcsp-data.json');
|
||||
await vscode.workspace.fs.stat(dataUri);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// === 项目路径选择 ===
|
||||
private async selectProjectPath(projectId: string, projectName: string): Promise<string | null> {
|
||||
try {
|
||||
@@ -246,8 +428,38 @@ export class ConfigPanel {
|
||||
|
||||
if (result && result.length > 0) {
|
||||
const selectedPath = result[0].fsPath;
|
||||
|
||||
// 检查是否已存在数据
|
||||
const hasExistingData = await this.checkProjectPathHasData(selectedPath);
|
||||
if (hasExistingData) {
|
||||
const loadChoice = await vscode.window.showWarningMessage(
|
||||
`在路径 ${selectedPath} 中检测到现有项目数据,是否加载?`,
|
||||
{ modal: true },
|
||||
'是,加载现有数据',
|
||||
'否,创建新项目'
|
||||
);
|
||||
|
||||
if (loadChoice === '是,加载现有数据') {
|
||||
// 加载现有数据
|
||||
const success = await this.loadProjectData(selectedPath);
|
||||
if (success) {
|
||||
this.projectPaths.set(projectId, selectedPath);
|
||||
this.currentView = 'aircrafts';
|
||||
this.currentProjectId = projectId;
|
||||
this.updateWebview();
|
||||
vscode.window.showInformationMessage(`项目数据已从 ${selectedPath} 加载`);
|
||||
return selectedPath;
|
||||
}
|
||||
}
|
||||
// 如果选择不加载或加载失败,继续创建新项目
|
||||
}
|
||||
|
||||
this.projectPaths.set(projectId, selectedPath);
|
||||
vscode.window.showInformationMessage(`项目存储位置已设置: ${selectedPath}`);
|
||||
|
||||
// 保存初始数据
|
||||
await this.saveAllData();
|
||||
|
||||
return selectedPath;
|
||||
}
|
||||
} else {
|
||||
@@ -271,6 +483,10 @@ export class ConfigPanel {
|
||||
|
||||
this.projectPaths.set(projectId, pathInput);
|
||||
vscode.window.showInformationMessage(`项目存储位置已创建: ${pathInput}`);
|
||||
|
||||
// 保存初始数据
|
||||
await this.saveAllData();
|
||||
|
||||
return pathInput;
|
||||
} catch (error) {
|
||||
vscode.window.showErrorMessage(`创建目录失败: ${error}`);
|
||||
@@ -287,17 +503,18 @@ export class ConfigPanel {
|
||||
}
|
||||
|
||||
// 更新项目名
|
||||
private updateProjectName(projectId: string, newName: string) {
|
||||
private async updateProjectName(projectId: string, newName: string) {
|
||||
const project = this.projects.find(p => p.id === projectId);
|
||||
if (project) {
|
||||
project.name = newName;
|
||||
vscode.window.showInformationMessage(`项目名称更新: ${newName}`);
|
||||
await this.saveAllData();
|
||||
this.updateWebview();
|
||||
}
|
||||
}
|
||||
|
||||
// 创建新项目
|
||||
private createProject(name: string) {
|
||||
private async createProject(name: string) {
|
||||
const newId = 'p' + (this.projects.length + 1);
|
||||
const newProject: Project = {
|
||||
id: newId,
|
||||
@@ -306,11 +523,12 @@ export class ConfigPanel {
|
||||
this.projects.push(newProject);
|
||||
|
||||
vscode.window.showInformationMessage(`新建项目: ${name}`);
|
||||
await this.saveAllData();
|
||||
this.updateWebview();
|
||||
}
|
||||
|
||||
// 删除项目
|
||||
private deleteProject(projectId: string) {
|
||||
private async deleteProject(projectId: string) {
|
||||
const project = this.projects.find(p => p.id === projectId);
|
||||
if (!project) return;
|
||||
|
||||
@@ -328,21 +546,23 @@ export class ConfigPanel {
|
||||
this.projectPaths.delete(projectId);
|
||||
|
||||
vscode.window.showInformationMessage(`删除项目: ${project.name}`);
|
||||
await this.saveAllData();
|
||||
this.updateWebview();
|
||||
}
|
||||
|
||||
// 更新飞行器名
|
||||
private updateAircraftName(aircraftId: string, newName: string) {
|
||||
private async updateAircraftName(aircraftId: string, newName: string) {
|
||||
const aircraft = this.aircrafts.find(a => a.id === aircraftId);
|
||||
if (aircraft) {
|
||||
aircraft.name = newName;
|
||||
vscode.window.showInformationMessage(`飞行器名称更新: ${newName}`);
|
||||
await this.saveAllData();
|
||||
this.updateWebview();
|
||||
}
|
||||
}
|
||||
|
||||
// 创建新飞行器
|
||||
private createAircraft(name: string) {
|
||||
private async createAircraft(name: string) {
|
||||
if (!this.currentProjectId) {
|
||||
vscode.window.showErrorMessage('无法创建飞行器:未找到当前项目');
|
||||
return;
|
||||
@@ -357,11 +577,12 @@ export class ConfigPanel {
|
||||
this.aircrafts.push(newAircraft);
|
||||
|
||||
vscode.window.showInformationMessage(`新建飞行器: ${name}`);
|
||||
await this.saveAllData();
|
||||
this.updateWebview();
|
||||
}
|
||||
|
||||
// 删除飞行器
|
||||
private deleteAircraft(aircraftId: string) {
|
||||
private async deleteAircraft(aircraftId: string) {
|
||||
const aircraft = this.aircrafts.find(a => a.id === aircraftId);
|
||||
if (!aircraft) return;
|
||||
|
||||
@@ -373,30 +594,32 @@ export class ConfigPanel {
|
||||
this.configs = this.configs.filter(cfg => !containerIds.includes(cfg.containerId));
|
||||
|
||||
vscode.window.showInformationMessage(`删除飞行器: ${aircraft.name}`);
|
||||
await this.saveAllData();
|
||||
this.updateWebview();
|
||||
}
|
||||
|
||||
// 更新容器名
|
||||
private updateContainerName(containerId: string, newName: string) {
|
||||
private async updateContainerName(containerId: string, newName: string) {
|
||||
const container = this.containers.find(c => c.id === containerId);
|
||||
if (container) {
|
||||
container.name = newName;
|
||||
vscode.window.showInformationMessage(`容器名称更新: ${newName}`);
|
||||
await this.saveAllData();
|
||||
this.updateWebview();
|
||||
}
|
||||
}
|
||||
|
||||
// 创建新容器
|
||||
private createContainer(name: string) {
|
||||
// 创建新容器 - 修复版本
|
||||
private async createContainer(name: string) {
|
||||
console.log('创建容器,当前飞行器ID:', this.currentAircraftId);
|
||||
|
||||
|
||||
if (!this.currentAircraftId) {
|
||||
vscode.window.showErrorMessage('无法创建容器:未找到当前飞行器');
|
||||
return;
|
||||
}
|
||||
|
||||
const newId = 'c' + (this.containers.length + 1);
|
||||
|
||||
|
||||
const newContainer: Container = {
|
||||
id: newId,
|
||||
name: name,
|
||||
@@ -411,7 +634,7 @@ export class ConfigPanel {
|
||||
this.configs.push({
|
||||
id: 'cfg' + (configCount + 1),
|
||||
name: '配置1',
|
||||
fileName: 'config.sh',
|
||||
fileName: 'dockerfile',
|
||||
content: `# ${name} 的 Dockerfile\nFROM ubuntu:20.04\n\n# 设置工作目录\nWORKDIR /app\n\n# 复制文件\nCOPY . .\n\n# 安装依赖\nRUN apt-get update && apt-get install -y \\\n python3 \\\n python3-pip\n\n# 暴露端口\nEXPOSE 8080\n\n# 启动命令\nCMD ["python3", "app.py"]`,
|
||||
containerId: newId
|
||||
});
|
||||
@@ -420,17 +643,23 @@ export class ConfigPanel {
|
||||
this.configs.push({
|
||||
id: 'cfg' + (configCount + 2),
|
||||
name: '配置2',
|
||||
fileName: 'config.sh',
|
||||
fileName: 'docker-compose.yml',
|
||||
content: `# ${name} 的 Docker Compose 配置\nversion: '3.8'\n\nservices:\n ${name.toLowerCase().replace(/\\s+/g, '-')}:\n build: .\n container_name: ${name}\n ports:\n - "8080:8080"\n environment:\n - NODE_ENV=production\n volumes:\n - ./data:/app/data\n restart: unless-stopped`,
|
||||
containerId: newId
|
||||
});
|
||||
|
||||
console.log('创建容器后的数据状态:', {
|
||||
containers: this.containers.length,
|
||||
configs: this.configs.length
|
||||
});
|
||||
|
||||
vscode.window.showInformationMessage(`新建容器: ${name} (包含2个默认配置文件)`);
|
||||
await this.saveAllData();
|
||||
this.updateWebview();
|
||||
}
|
||||
|
||||
// 删除容器
|
||||
private deleteContainer(containerId: string) {
|
||||
private async deleteContainer(containerId: string) {
|
||||
const container = this.containers.find(c => c.id === containerId);
|
||||
if (!container) return;
|
||||
|
||||
@@ -441,15 +670,17 @@ export class ConfigPanel {
|
||||
this.configs = this.configs.filter(cfg => cfg.containerId !== containerId);
|
||||
|
||||
vscode.window.showInformationMessage(`删除容器: ${container.name}`);
|
||||
await this.saveAllData();
|
||||
this.updateWebview();
|
||||
}
|
||||
|
||||
// 更新配置名
|
||||
private updateConfigName(configId: string, newName: string) {
|
||||
private async updateConfigName(configId: string, newName: string) {
|
||||
const config = this.configs.find(c => c.id === configId);
|
||||
if (config) {
|
||||
config.name = newName;
|
||||
vscode.window.showInformationMessage(`配置名称更新: ${newName}`);
|
||||
await this.saveAllData();
|
||||
this.updateWebview();
|
||||
}
|
||||
}
|
||||
@@ -460,12 +691,13 @@ export class ConfigPanel {
|
||||
if (config) {
|
||||
config.fileName = fileName;
|
||||
vscode.window.showInformationMessage(`文件名更新: ${fileName}`);
|
||||
await this.saveAllData();
|
||||
this.updateWebview();
|
||||
}
|
||||
}
|
||||
|
||||
// 创建新配置文件
|
||||
private createConfig(name: string) {
|
||||
private async createConfig(name: string) {
|
||||
const newId = 'cfg' + (this.configs.length + 1);
|
||||
const newConfig: Config = {
|
||||
id: newId,
|
||||
@@ -477,15 +709,17 @@ export class ConfigPanel {
|
||||
this.configs.push(newConfig);
|
||||
|
||||
vscode.window.showInformationMessage(`新建配置: ${name}`);
|
||||
await this.saveAllData();
|
||||
this.updateWebview();
|
||||
}
|
||||
|
||||
// 删除配置文件
|
||||
private deleteConfig(configId: string) {
|
||||
private async deleteConfig(configId: string) {
|
||||
const config = this.configs.find(c => c.id === configId);
|
||||
if (config) {
|
||||
this.configs = this.configs.filter(c => c.id !== configId);
|
||||
vscode.window.showInformationMessage(`删除配置: ${config.name}`);
|
||||
await this.saveAllData();
|
||||
this.updateWebview();
|
||||
}
|
||||
}
|
||||
@@ -546,7 +780,13 @@ export class ConfigPanel {
|
||||
const uint8Array = new TextEncoder().encode(content);
|
||||
await vscode.workspace.fs.writeFile(fileUri, uint8Array);
|
||||
|
||||
// 更新配置内容
|
||||
config.content = content;
|
||||
|
||||
vscode.window.showInformationMessage(`配置文件已保存: ${fileUri.fsPath}`);
|
||||
|
||||
// 保存数据到JSON文件
|
||||
await this.saveAllData();
|
||||
} catch (error) {
|
||||
vscode.window.showErrorMessage(`保存文件时出错: ${error}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user