theia开发中,开发的widget如何在extension的installed里面显示
时间: 2024-05-04 12:16:09 浏览: 106
generator-theia-extension:Yeoman生成器,用于扩展Theia IDE
为了在 Theia extension 的 "installed" 列表中显示插件小部件,需要在插件的主要入口文件中将插件 ID 添加到 extensionPackages 数组中。该入口文件通常命名为 index.js。以下是一个例子:
```javascript
import { ContainerModule } from '@theia/core/shared/inversify';
import { FrontendApplicationContribution } from '@theia/core/lib/browser';
import { ExampleWidgetContribution } from './example-widget-contribution';
export default new ContainerModule(bind => {
bind<FrontendApplicationContribution>(FrontendApplicationContribution)
.to(ExampleWidgetContribution)
.inSingletonScope();
// 将插件 ID 添加到 extensionPackages 数组中
const extension = {id: 'example-extension'};
bind(extension).toConstantValue(extension);
bind(Array).toConstantValue([extension]).whenTargetNamed('extensionPackages');
});
```
此外,确保在 package.json 文件中包含正确的"theia.extension" 配置,指向插件入口文件的路径。参考以下示例:
```json
{
"name": "example-extension",
"main": "lib/node/example-widget-backend.js",
"theia": {
"frontend": "lib/browser/index.html",
"extension": {
"frontend": "lib/browser/index.js",
"backend": "lib/node/example-widget-backend.js"
}
},
"dependencies": {
"@theia/core": "latest",
"@theia/core/shared": "latest"
}
}
```
阅读全文