diff --git a/src/home.ts b/src/home.ts index c923747..04ba2db 100644 --- a/src/home.ts +++ b/src/home.ts @@ -11,10 +11,10 @@ export default class DSHome { private devstarHomePageUrl: string; private devstarDomain: string | undefined - constructor(context: vscode.ExtensionContext) { + constructor(context: vscode.ExtensionContext, user: User) { this.context = context; - this.user = new User(context); - this.remoteContainer = new RemoteContainer(this.user); + this.user = user; + this.remoteContainer = new RemoteContainer(user); this.devstarDomain = utils.getDevstarDomain() if (undefined == this.devstarDomain || "" == this.devstarDomain) { diff --git a/src/main.ts b/src/main.ts index c095347..ec16b18 100644 --- a/src/main.ts +++ b/src/main.ts @@ -12,8 +12,9 @@ export class DevStarExtension { constructor(private context: vscode.ExtensionContext) { this.user = new User(context); + // 只保持一个User实例 this.remoteContainer = new RemoteContainer(this.user); - this.dsHome = new DSHome(context); + this.dsHome = new DSHome(context, this.user); const handler = vscode.window.registerUriHandler({ handleUri: async (uri: vscode.Uri) => {