feat: store local system name in global state

This commit is contained in:
Levi Yan
2025-04-29 19:03:52 +08:00
parent 414c0ee579
commit 98b64fd8cb
2 changed files with 19 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ import DSHome from './home';
import RemoteContainer, { openProjectWithoutLogging } from './remote-container'; import RemoteContainer, { openProjectWithoutLogging } from './remote-container';
import User from './user'; import User from './user';
import DevstarAPIHandler from './devstar-api'; import DevstarAPIHandler from './devstar-api';
import * as utils from './utils';
export class DevStarExtension { export class DevStarExtension {
user: User; user: User;
@@ -83,6 +84,14 @@ export class DevStarExtension {
this.registerGlobalCommands(context); this.registerGlobalCommands(context);
if (vscode.env.remoteName === undefined) {
// 如果处于local且localSystemName未存储则存储
const localSystemName = utils.getLocalSystemName(context)
if (localSystemName === undefined || localSystemName === "") {
utils.updateLocalSystemName(context)
}
}
this.startDevStarHome(); this.startDevStarHome();
} }

View File

@@ -115,4 +115,14 @@ export async function showErrorNotification(message: string): Promise<void> {
} else if (selection === 'Report a problem') { } else if (selection === 'Report a problem') {
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://gitee.com/SuperIDE/DevStar/issues')); vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://gitee.com/SuperIDE/DevStar/issues'));
} }
}
export function updateLocalSystemName(context: vscode.ExtensionContext) {
// win32, linux, darwin
const name = os.platform()
context.globalState.update('localSystemName', name)
}
export function getLocalSystemName(context: vscode.ExtensionContext): string | undefined {
return context.globalState.get('localSystemName')
} }