插件接口 定义插件必须实现的结构和生命周期钩子
import { Plugin, PluginManifest, PluginContext } from 'webcad-lib-ts';const myPlugin: Plugin = { manifest: { id: 'my-plugin', name: 'My Plugin', version: '1.0.0' }, async onLoad(context) { console.log('Plugin loaded'); }, async onActivate(context) { context.registerCommand('MYCOMMAND', MyCommand); }, async onDeactivate(context) { context.unregisterCommand('MYCOMMAND'); }, async onUnload(context) { console.log('Plugin unloaded'); }};export default myPlugin; Copy
import { Plugin, PluginManifest, PluginContext } from 'webcad-lib-ts';const myPlugin: Plugin = { manifest: { id: 'my-plugin', name: 'My Plugin', version: '1.0.0' }, async onLoad(context) { console.log('Plugin loaded'); }, async onActivate(context) { context.registerCommand('MYCOMMAND', MyCommand); }, async onDeactivate(context) { context.unregisterCommand('MYCOMMAND'); }, async onUnload(context) { console.log('Plugin unloaded'); }};export default myPlugin;
插件清单信息
Optional
插件加载时调用 在此阶段可以进行初始化,但不应该激活功能
插件上下文
插件激活时调用 在此阶段注册命令、菜单、面板等
插件停用时调用 在此阶段应该清理已注册的资源
插件卸载时调用 在此阶段进行最终清理
插件接口 定义插件必须实现的结构和生命周期钩子
Example