feat: add notification for login and logout
This commit is contained in:
		@@ -40,8 +40,6 @@ export class DevStarExtension {
 | 
				
			|||||||
                const res = await this.user.login(access_token, devstar_username)
 | 
					                const res = await this.user.login(access_token, devstar_username)
 | 
				
			||||||
                if (res === 'ok') {
 | 
					                if (res === 'ok') {
 | 
				
			||||||
                  await this.remoteContainer.firstOpenProject(container_host, container_port, container_username, project_path)
 | 
					                  await this.remoteContainer.firstOpenProject(container_host, container_port, container_username, project_path)
 | 
				
			||||||
                } else {
 | 
					 | 
				
			||||||
                  console.error(res)
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
              } else if (devstar_username === this.user.getUsernameFromLocal()) {
 | 
					              } else if (devstar_username === this.user.getUsernameFromLocal()) {
 | 
				
			||||||
                // 如果同用户已经登录,则忽略;
 | 
					                // 如果同用户已经登录,则忽略;
 | 
				
			||||||
@@ -56,8 +54,6 @@ export class DevStarExtension {
 | 
				
			|||||||
                  const res = await this.user.login(access_token, devstar_username)
 | 
					                  const res = await this.user.login(access_token, devstar_username)
 | 
				
			||||||
                  if (res === 'ok') {
 | 
					                  if (res === 'ok') {
 | 
				
			||||||
                    await this.remoteContainer.firstOpenProject(container_host, container_port, container_username, project_path)
 | 
					                    await this.remoteContainer.firstOpenProject(container_host, container_port, container_username, project_path)
 | 
				
			||||||
                  } else {
 | 
					 | 
				
			||||||
                    console.error(res)
 | 
					 | 
				
			||||||
                  }
 | 
					                  }
 | 
				
			||||||
                } else if (selection === 'No') {
 | 
					                } else if (selection === 'No') {
 | 
				
			||||||
                  await openProjectWithoutLogging(container_host, container_port, container_username, project_path);
 | 
					                  await openProjectWithoutLogging(container_host, container_port, container_username, project_path);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,6 +3,7 @@ import * as path from 'path';
 | 
				
			|||||||
import * as os from 'os';
 | 
					import * as os from 'os';
 | 
				
			||||||
import * as fs from 'fs';
 | 
					import * as fs from 'fs';
 | 
				
			||||||
import DevstarAPIHandler from './devstar-api';
 | 
					import DevstarAPIHandler from './devstar-api';
 | 
				
			||||||
 | 
					import { showErrorNotification } from './utils';
 | 
				
			||||||
const {
 | 
					const {
 | 
				
			||||||
  generateKeyPairSync,
 | 
					  generateKeyPairSync,
 | 
				
			||||||
  createHash
 | 
					  createHash
 | 
				
			||||||
@@ -56,10 +57,12 @@ export default class User {
 | 
				
			|||||||
          throw new Error('Upload user public key failed')
 | 
					          throw new Error('Upload user public key failed')
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      vscode.window.showInformationMessage('用户已登录!')
 | 
				
			||||||
      return 'ok'
 | 
					      return 'ok'
 | 
				
			||||||
    } catch (error) {
 | 
					    } catch (error) {
 | 
				
			||||||
      console.error(error)
 | 
					      console.error(error)
 | 
				
			||||||
 | 
					      await showErrorNotification('用户登录失败!')
 | 
				
			||||||
      return 'login failed'
 | 
					      return 'login failed'
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -67,6 +70,7 @@ export default class User {
 | 
				
			|||||||
  public logout() {
 | 
					  public logout() {
 | 
				
			||||||
    this.setUserTokenToLocal("")
 | 
					    this.setUserTokenToLocal("")
 | 
				
			||||||
    this.setUsernameToLocal("")
 | 
					    this.setUsernameToLocal("")
 | 
				
			||||||
 | 
					    vscode.window.showInformationMessage('用户已登出!')
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  public isLogged() {
 | 
					  public isLogged() {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user