add: 新增登出 command
This commit is contained in:
parent
d0d68743d3
commit
4281346993
|
@ -4,7 +4,7 @@
|
|||
"description": "iBiz建模工场",
|
||||
"publisher": "ibizlab",
|
||||
"preview": true,
|
||||
"version": "0.0.4",
|
||||
"version": "0.0.5",
|
||||
"engines": {
|
||||
"vscode": "^1.62.0"
|
||||
},
|
||||
|
@ -27,6 +27,11 @@
|
|||
"title": "%command.ibiz-modeling-studio.user.login%",
|
||||
"category": "%command.ibiz-modeling-studio.category%"
|
||||
},
|
||||
{
|
||||
"command": "ibiz-modeling-studio.user.logout",
|
||||
"title": "%command.ibiz-modeling-studio.user.logout%",
|
||||
"category": "%command.ibiz-modeling-studio.category%"
|
||||
},
|
||||
{
|
||||
"command": "ibiz-modeling-studio.open-ibiz-modeling",
|
||||
"title": "%command.ibiz-modeling-studio.open-ibiz-modeling%",
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
"global.ibiz-modeling-studio.title": "IBiz Modeling Studio",
|
||||
"command.ibiz-modeling-studio.category": "iBizModeling",
|
||||
"command.ibiz-modeling-studio.user.login": "Login",
|
||||
"command.ibiz-modeling-studio.user.logout": "Logout",
|
||||
"command.ibiz-modeling-studio.open-ibiz-modeling": "Open iBizModeling Tool",
|
||||
"command.ibiz-modeling-studio.system-info-terminal.show": "Open Information Terminal",
|
||||
"command.ibiz-modeling-studio.system.publish.code": "Publish Code",
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
"global.ibiz-modeling-studio.title": "iBiz建模工场",
|
||||
"command.ibiz-modeling-studio.category": "iBiz建模工场",
|
||||
"command.ibiz-modeling-studio.user.login": "登录",
|
||||
"command.ibiz-modeling-studio.user.logout": "登出",
|
||||
"command.ibiz-modeling-studio.open-ibiz-modeling": "打开 iBizModeling 工具",
|
||||
"command.ibiz-modeling-studio.system-info-terminal.show": "打开信息终端",
|
||||
"command.ibiz-modeling-studio.system.publish.code": "发布代码",
|
||||
|
|
|
@ -10,6 +10,7 @@ import { SystemInfoTerminalShowCommand } from './system-info-terminal/show';
|
|||
import { SystemPublishCommand } from './system/publish';
|
||||
import { TemplatePublishCommand } from './template/publish';
|
||||
import { UserLoginCommand } from './user/login';
|
||||
import { UserLogoutCommand } from './user/logout';
|
||||
|
||||
/**
|
||||
* 安装命令处理程序
|
||||
|
@ -34,4 +35,5 @@ export function installCommands(_context: ExtensionContext): void {
|
|||
new SystemInfoTerminalShowCommand();
|
||||
new TemplatePublishCommand();
|
||||
new UserLoginCommand();
|
||||
new UserLogoutCommand();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,14 @@ import { commands } from 'vscode';
|
|||
import { CommandConst } from '../../constants';
|
||||
import { login } from '../../service';
|
||||
|
||||
/**
|
||||
* 用户登录
|
||||
*
|
||||
* @author chitanda
|
||||
* @date 2021-12-08 15:12:46
|
||||
* @export
|
||||
* @class UserLoginCommand
|
||||
*/
|
||||
export class UserLoginCommand {
|
||||
constructor() {
|
||||
commands.registerCommand(CommandConst.USER.LOGIN, this.execute.bind(this));
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
import { commands } from 'vscode';
|
||||
import { CommandConst } from '../../constants';
|
||||
import { login } from '../../service';
|
||||
|
||||
/**
|
||||
* 用户登出
|
||||
*
|
||||
* @author chitanda
|
||||
* @date 2021-12-08 15:12:52
|
||||
* @export
|
||||
* @class UserLogoutCommand
|
||||
*/
|
||||
export class UserLogoutCommand {
|
||||
constructor() {
|
||||
commands.registerCommand(CommandConst.USER.LOGOUT, this.execute.bind(this));
|
||||
}
|
||||
|
||||
protected async execute(): Promise<void> {
|
||||
login.logout();
|
||||
}
|
||||
}
|
|
@ -15,6 +15,13 @@ export class UserConst {
|
|||
* @date 2021-12-01 15:12:23
|
||||
*/
|
||||
readonly LOGIN = 'ibiz-modeling-studio.user.login';
|
||||
/**
|
||||
* 用户登出
|
||||
*
|
||||
* @author chitanda
|
||||
* @date 2021-12-08 15:12:42
|
||||
*/
|
||||
readonly LOGOUT = 'ibiz-modeling-studio.user.logout';
|
||||
/**
|
||||
* 登录回转地址处理
|
||||
*
|
||||
|
|
|
@ -161,6 +161,19 @@ export class LoginService {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 登出当前用户
|
||||
*
|
||||
* @author chitanda
|
||||
* @date 2021-12-08 15:12:35
|
||||
* @return {*} {Promise<boolean>}
|
||||
*/
|
||||
async logout(): Promise<boolean> {
|
||||
ctx.setToken('');
|
||||
window.showInformationMessage('已登出当前用户');
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 未登录时调用,根据状态进行登录操作
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue