refactor: extension configure design

This commit is contained in:
buqiyuan 2022-05-31 16:48:57 +08:00
parent f5d9e93a68
commit 88100c0ab8
5 changed files with 10 additions and 8 deletions

View File

@ -6,7 +6,7 @@
"moduleID": "eoapi-common",
"author": "eoapi",
"publisher": "eoapi",
"contributes": {
"features": {
"configuration": {
"type": "object",
"title": "通用",

View File

@ -6,7 +6,7 @@
"moduleID": "Eoapi-Extensions",
"author": "eoapi",
"publisher": "eoapi",
"contributes": {
"features": {
"configuration": []
}
}

View File

@ -6,7 +6,7 @@
"moduleID": "Eoapi-Features",
"author": "eoapi",
"publisher": "eoapi",
"contributes": {
"features": {
"configuration": [
{
"type": "object",

View File

@ -6,7 +6,7 @@
"moduleID": "eoapi-theme",
"author": "eoapi",
"publisher": "eoapi",
"contributes": {
"features": {
"configuration": {
"type": "object",
"order": 1,

View File

@ -173,7 +173,7 @@ export class SettingComponent implements OnInit {
]);
// 所有配置
const allConfiguration = allSettings.map((n) => {
const configuration = n.contributes.configuration;
const configuration = n.features?.configuration || n.contributes?.configuration;
if (!Array.isArray(configuration)) {
configuration.moduleID ??= n.moduleID;
}
@ -182,11 +182,13 @@ export class SettingComponent implements OnInit {
// 第三方扩展
const extensionsModule = allSettings.find((n) => n.moduleID === 'Eoapi-Extensions');
extensitonConfigurations.forEach((item) => {
const configuration = item?.contributes?.configuration;
const configuration = item?.features?.configuration || item?.contributes?.configuration;
if (configuration) {
const extensionsConfiguration =
extensionsModule.features?.configuration || extensionsModule.contributes?.configuration;
configuration.title = item.moduleName ?? configuration.title;
configuration.moduleID = item.moduleID;
extensionsModule.contributes.configuration.push(configuration);
extensionsConfiguration.push(configuration);
}
});
// 给插件的属性前面追加模块ID
@ -226,7 +228,7 @@ export class SettingComponent implements OnInit {
// 所有设置项
const treeData = allSettings.reduce<TreeNode[]>((prev, curr) => {
let treeItem: TreeNode;
const configuration = curr.contributes.configuration;
const configuration = curr.features?.configuration || curr.contributes?.configuration;
if (Array.isArray(configuration)) {
treeItem = {
name: curr.name,