@auto-mas/auto-mas-plugin-plugins 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,12 +4,21 @@ export default function createFeature() {
|
|
|
4
4
|
const manager = ctx.get('mas.plugins');
|
|
5
5
|
ui(ctx).scope(ctx, { id: 'plugins', title: '插件配置', icon: 'plugins', description: '按分组管理插件、运行状态与配置', components: [
|
|
6
6
|
{ type: 'plugin-manager', title: '插件配置' },
|
|
7
|
+
...(manager.workspaceOptions ? [{
|
|
8
|
+
type: 'form', title: '登记工作区插件', action: 'plugins.workspace-register',
|
|
9
|
+
fields: [
|
|
10
|
+
field('folder', '工作区插件', { kind: 'select', source: 'plugins.workspace-options', required: true }),
|
|
11
|
+
field('trusted', '信任此插件在后端执行', { kind: 'boolean' }),
|
|
12
|
+
],
|
|
13
|
+
submitLabel: '登记插件',
|
|
14
|
+
}] : []),
|
|
7
15
|
{ type: 'form', title: '登记本地插件', action: 'plugins.install', initial: { name: '新本地插件' }, fields: [field('name', '显示名称', { required: true }), field('source', '插件模块', { kind: 'hostpath', required: true, hint: '选择 JavaScript 或 Node.js 可直接运行的 TypeScript 模块。插件安装后初始停用。' }), field('trusted', '信任此模块在后端执行', { kind: 'boolean' })] },
|
|
8
16
|
{ type: 'form', title: '卸载本地插件', action: 'plugins.uninstall', fields: [field('id', '插件', { kind: 'select', source: 'plugins.externalOptions', required: true })] },
|
|
9
17
|
] }, {
|
|
10
18
|
'plugins.list': () => manager.list(),
|
|
11
19
|
'plugins.detail': input => manager.detail(text(input, 'id', '插件 ID')),
|
|
12
|
-
'plugins.
|
|
20
|
+
...(manager.workspaceOptions && { 'plugins.workspace-options': manager.workspaceOptions }),
|
|
21
|
+
'plugins.externalOptions': () => manager.list().filter(plugin => plugin.group === 'external' || plugin.id.startsWith('local:workspace:'))
|
|
13
22
|
.map(plugin => ({ value: plugin.id, label: `${plugin.packageName} · ${plugin.name}` })),
|
|
14
23
|
}, {
|
|
15
24
|
'plugins.toggle': input => manager.toggle(text(input, 'id', '插件 ID'), typeof input.enabled === 'boolean' ? input.enabled : undefined),
|
|
@@ -26,6 +35,13 @@ export default function createFeature() {
|
|
|
26
35
|
throw new Error('请确认信任此插件');
|
|
27
36
|
return manager.install(text(input, 'name', '名称'), text(input, 'source', '模块路径'));
|
|
28
37
|
},
|
|
38
|
+
'plugins.workspace-register': input => {
|
|
39
|
+
if (input.trusted !== true)
|
|
40
|
+
throw new Error('请确认信任此插件');
|
|
41
|
+
if (!manager.installWorkspace)
|
|
42
|
+
throw new Error('当前宿主未启用插件工作区');
|
|
43
|
+
return manager.installWorkspace(text(input, 'folder', '插件目录'));
|
|
44
|
+
},
|
|
29
45
|
'plugins.uninstall': input => manager.uninstall(text(input, 'id', '插件 ID')),
|
|
30
46
|
});
|
|
31
47
|
} } };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auto-mas/auto-mas-plugin-plugins",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -18,6 +18,14 @@
|
|
|
18
18
|
"access": "public"
|
|
19
19
|
},
|
|
20
20
|
"description": "AUTO-MAS plugins Cordis component",
|
|
21
|
+
"mas": {
|
|
22
|
+
"hidden": false,
|
|
23
|
+
"category": "core",
|
|
24
|
+
"description": {
|
|
25
|
+
"zh": "管理 Cordis 插件的启停、配置、本地登记和版本",
|
|
26
|
+
"en": "Manage Cordis plugin activation, configuration, local registration, and versions"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
21
29
|
"autoMas": {
|
|
22
30
|
"id": "plugins",
|
|
23
31
|
"abi": 1,
|