62 lines
1.4 KiB
JavaScript
Executable File
62 lines
1.4 KiB
JavaScript
Executable File
export const ExtensionCommand={
|
||
toggleBlame : 'code.blame.toggleBlame',
|
||
linkToCommit : 'code.blame.linktocommit',
|
||
onActive : 'code.blame.extension.active',
|
||
setPerference : 'code.blame.setPerference',
|
||
acrToggleBlame : 'code.blame.acrToggleBlame',
|
||
getBlameData : 'code.blame.getBlameData',
|
||
}
|
||
|
||
export default class IDEPlugin {
|
||
// // @ts-ignore
|
||
// commands: IPluginAPI['commands'];
|
||
// onActivate: () => void;
|
||
// linkToCommit: (commitId: string) => void;
|
||
/**
|
||
* 插件 ID,用于唯一标识插件
|
||
*/
|
||
PLUGIN_ID = 'antcode-communication';
|
||
|
||
constructor(onActive, linkToCommit) {
|
||
this.onActivate = onActive;
|
||
this.linkToCommit = linkToCommit;
|
||
}
|
||
|
||
/**
|
||
* 激活插件
|
||
*/
|
||
activate = (ctx) => {
|
||
const { commands, context } = ctx;
|
||
this.commands = commands;
|
||
context.subscriptions.push(
|
||
commands.registerCommand(ExtensionCommand.onActive, () => {
|
||
this.onActivate();
|
||
}),
|
||
commands.registerCommand(ExtensionCommand.linkToCommit, (params) => {
|
||
const { commitId } = params;
|
||
this.linkToCommit(commitId);
|
||
})
|
||
);
|
||
};
|
||
|
||
/**
|
||
* 注销插件,可在此时机清理副作用
|
||
*/
|
||
deactivate() {}
|
||
|
||
/**
|
||
* 修改配置项
|
||
* @param name 配置项名称
|
||
* @param value 值
|
||
* @param global 是否全局生效
|
||
*/
|
||
setPerference(name, value, global) {
|
||
this.commands.executeCommand(
|
||
ExtensionCommand.setPerference,
|
||
name,
|
||
value,
|
||
!!global
|
||
);
|
||
}
|
||
}
|