GeezerVison is showing github.com — feat: added apis support resource tree in workspace mode · stantoxt/lowcode-engine@ea08173
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: docs/docs/api/index.md +4Lines changed: 4 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -44,3 +44,7 @@ sidebar_position: 0 | 44 | 44 | 2. 事件(events)的命名格式为:on[Will|Did]VerbNoun?,参考 [https://code.visualstudio.com/api/references/vscode-api#events](https://code.visualstudio.com/api/references/vscode-api#events) | 45 | 45 | 3. 基于 Disposable 模式,对于事件的绑定、快捷键的绑定函数,返回值则是解绑函数 | 46 | 46 | 4. 对于属性的导出,统一用 .xxx 的 getter 模式,(尽量)不使用 .getXxx() | | 47 | + | | 48 | +## experimental | | 49 | + | | 50 | +说明此模块处于公测阶段, API 可能会发生改变. |
Collapse file Copy file name to clipboardExpand all lines: docs/docs/api/model/plugin-instance.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | --- | 2 | | -title: plugin-instance | | 2 | +title: PluginInstance | 3 | 3 | sidebar_position: 12 | 4 | 4 | --- | 5 | 5 |
| |
Collapse file Copy file name to clipboard +26Lines changed: 26 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +--- | | 2 | +title: ResourceType | | 3 | +sidebar_position: 12 | | 4 | +--- | | 5 | + | | 6 | +> **[@experimental](./#experimental)**<br/> | | 7 | +> **@types** [IPublicModelWindow](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/resource-type.ts)<br/> | | 8 | +> **@since** v1.1.0 | | 9 | +
| | 10 | +## 变量 | | 11 | + | | 12 | +### description | | 13 | + | | 14 | +资源描述 | | 15 | + | | 16 | +`@type {string}` | | 17 | + | | 18 | +### icon | | 19 | + | | 20 | +资源 icon | | 21 | + | | 22 | +`@type {ReactElement}` | | 23 | + | | 24 | +### name | | 25 | + | | 26 | +`@type {string}` |
Collapse file Copy file name to clipboard +36Lines changed: 36 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +--- | | 2 | +title: Resource | | 3 | +sidebar_position: 12 | | 4 | +--- | | 5 | + | | 6 | +> **[@experimental](./#experimental)**<br/> | | 7 | +> **@types** [IPublicModelWindow](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/resource.ts)<br/> | | 8 | +> **@since** v1.1.0 | | 9 | +
| | 10 | +## 变量 | | 11 | + | | 12 | +### title | | 13 | + | | 14 | +资源标题 | | 15 | + | | 16 | +`@type {string}` | | 17 | + | | 18 | +### icon | | 19 | + | | 20 | +资源 icon | | 21 | + | | 22 | +`@type {ReactElement}` | | 23 | + | | 24 | +### options | | 25 | + | | 26 | +资源配置信息 | | 27 | + | | 28 | +`@type {Object}` | | 29 | + | | 30 | +### resourceType | | 31 | + | | 32 | +资源所属的资源类型 | | 33 | + | | 34 | +`@type {IPublicModelResourceType}` | | 35 | + | | 36 | +关联模型 [IPublicModelResourceType](./resource-type) |
Collapse file Copy file name to clipboardExpand all lines: docs/docs/api/model/window.md +15-2Lines changed: 15 additions & 2 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -3,6 +3,7 @@ title: Window | 3 | 3 | sidebar_position: 12 | 4 | 4 | --- | 5 | 5 |
| | 6 | +> **[@experimental](./#experimental)**<br/> | 6 | 7 | > **@types** [IPublicModelWindow](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/window.ts)<br/> | 7 | 8 | > **@since** v1.1.0 | 8 | 9 |
| @@ -17,13 +18,25 @@ sidebar_position: 12 | 17 | 18 |
| 18 | 19 | 窗口唯一 id | 19 | 20 |
| | 21 | +`@type {string}` | | 22 | + | 20 | 23 | ### title | 21 | 24 |
| 22 | 25 | 窗口标题 | 23 | 26 |
| 24 | | -### resourceName | | 27 | +`@type {string}` | | 28 | + | | 29 | +### icon | | 30 | + | | 31 | +`@type {ReactElement}` | | 32 | + | | 33 | +### resourceType | | 34 | + | | 35 | +窗口资源类型 | | 36 | + | | 37 | +`@type {IPublicModelResourceType}` | 25 | 38 |
| 26 | | -窗口资源名字 | | 39 | +关联模型 [IPublicModelResourceType](./resource-type) | 27 | 40 |
| 28 | 41 | ## 方法签名 | 29 | 42 |
| |
Collapse file Copy file name to clipboardExpand all lines: docs/docs/api/plugins.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -222,7 +222,7 @@ your-plugin/package.json | 222 | 222 | } | 223 | 223 | ``` | 224 | 224 | 转换后的结构: | 225 | | -```json | | 225 | +```typescript | 226 | 226 | const debug = (ctx: IPublicModelPluginContext, options: any) => { | 227 | 227 | return {}; | 228 | 228 | } | |
Collapse file Copy file name to clipboardExpand all lines: docs/docs/api/workspace.md +64-2Lines changed: 64 additions & 2 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -3,10 +3,10 @@ title: workspace - 应用级 API | 3 | 3 | sidebar_position: 12 | 4 | 4 | --- | 5 | 5 |
| | 6 | +> **[@experimental](./#experimental)**<br/> | 6 | 7 | > **@types** [IPublicApiWorkspace](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/workspace.ts)<br/> | 7 | 8 | > **@since** v1.1.0 | 8 | 9 |
| 9 | | - | 10 | 10 | ## 模块简介 | 11 | 11 |
| 12 | 12 | 通过该模块可以开发应用级低代码设计器。 | @@ -47,14 +47,24 @@ get window(): IPublicModelWindow[] | 47 | 47 |
| 48 | 48 | 关联模型 [IPublicModelWindow](./model/window) | 49 | 49 |
| | 50 | +### resourceList | | 51 | + | | 52 | +当前设计器的资源列表数据 | | 53 | + | | 54 | +``` | | 55 | +get resourceList(): IPublicModelResource; | | 56 | +``` | | 57 | + | | 58 | +关联模型 [IPublicModelResource](./model/resource) | | 59 | + | 50 | 60 | ## 方法签名 | 51 | 61 |
| 52 | 62 | ### registerResourceType | 53 | 63 | 注册资源 | 54 | 64 |
| 55 | 65 | ```typescript | 56 | 66 | /** 注册资源 */ | 57 | | -registerResourceType(resourceName: string, resourceType: 'editor', options: IPublicResourceOptions): void; | | 67 | +registerResourceType(name: string, type: 'editor', options: IPublicResourceOptions): void; | 58 | 68 | ``` | 59 | 69 |
| 60 | 70 | 相关类型:[IPublicResourceOptions](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/resource-options.ts) | @@ -74,3 +84,55 @@ active 窗口变更事件 | 74 | 84 | ```typescript | 75 | 85 | function onChangeActiveWindow(fn: () => void): void; | 76 | 86 | ``` | | 87 | + | | 88 | +### setResourceList | | 89 | + | | 90 | +设置设计器资源列表数据 | | 91 | + | | 92 | +```typescript | | 93 | +setResourceList(resourceList: IPublicResourceList) {} | | 94 | +``` | | 95 | + | | 96 | +相关类型:[IPublicResourceOptions](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/resource-options.ts) | | 97 | + | | 98 | +### onResourceListChange | | 99 | + | | 100 | +设计器资源列表数据变更事件 | | 101 | + | | 102 | +```typescript | | 103 | +onResourceListChange(fn: (resourceList: IPublicResourceList): void): (): void; | | 104 | +``` | | 105 | +
| | 106 | +相关类型:[IPublicResourceOptions](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/resource-options.ts) | | 107 | +
| | 108 | +### openEditorWindow | | 109 | +
| | 110 | +打开视图窗口 | | 111 | +
| | 112 | +```typescript | | 113 | +openEditorWindow(resourceName: string, title: string, options: Object, viewName?: string): void; | | 114 | +``` | | 115 | +
| | 116 | +### openEditorWindowById | | 117 | +
| | 118 | +通过视图 id 打开窗口 | | 119 | +
| | 120 | +```typescript | | 121 | +openEditorWindowById(id: string): void; | | 122 | +``` | | 123 | +
| | 124 | +### removeEditorWindow | | 125 | +
| | 126 | +移除视图窗口 | | 127 | +
| | 128 | +```typescript | | 129 | +removeEditorWindow(resourceName: string, title: string): void; | | 130 | +``` | | 131 | +
| | 132 | +### removeEditorWindowById | | 133 | +
| | 134 | +通过视图 id 移除窗口 | | 135 | +
| | 136 | +```typescript | | 137 | +removeEditorWindowById(id: string): void; | | 138 | +``` |
Collapse file Copy file name to clipboardExpand all lines: packages/shell/src/api/workspace.ts +18-5Lines changed: 18 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -import { IPublicApiWorkspace } from '@alilc/lowcode-types'; | | 1 | +import { IPublicApiWorkspace, IPublicResourceList, IPublicResourceOptions } from '@alilc/lowcode-types'; | 2 | 2 | import { Workspace as InnerWorkSpace } from '@alilc/lowcode-workspace'; | 3 | 3 | import { Plugins } from '@alilc/lowcode-shell'; | 4 | 4 | import { Window } from '../model/window'; | 5 | 5 | import { workspaceSymbol } from '../symbols'; | | 6 | +import { Resource } from '../model'; | 6 | 7 |
| 7 | 8 | export class Workspace implements IPublicApiWorkspace { | 8 | 9 | readonly [workspaceSymbol]: InnerWorkSpace; | @@ -11,6 +12,18 @@ export class Workspace implements IPublicApiWorkspace { | 11 | 12 | this[workspaceSymbol] = innerWorkspace; | 12 | 13 | } | 13 | 14 |
| | 15 | + get resourceList() { | | 16 | + return this[workspaceSymbol].getResourceList().map(d => new Resource(d)); | | 17 | + } | | 18 | + | | 19 | + setResourceList(resourceList: IPublicResourceList) { | | 20 | + this[workspaceSymbol].setResourceList(resourceList); | | 21 | + } | | 22 | + | | 23 | + onResourceListChange(fn: (resourceList: IPublicResourceList) => void): () => void { | | 24 | + return this[workspaceSymbol].onResourceListChange(fn); | | 25 | + } | | 26 | + | 14 | 27 | get isActive() { | 15 | 28 | return this[workspaceSymbol].isActive; | 16 | 29 | } | @@ -19,12 +32,12 @@ export class Workspace implements IPublicApiWorkspace { | 19 | 32 | return new Window(this[workspaceSymbol].window); | 20 | 33 | } | 21 | 34 |
| 22 | | - registerResourceType(resourceName: string, resourceType: 'editor', options: any): void { | 23 | | - this[workspaceSymbol].registerResourceType(resourceName, resourceType, options); | | 35 | + registerResourceType(name: string, type: 'editor', options: IPublicResourceOptions): void { | | 36 | + this[workspaceSymbol].registerResourceType(name, type, options); | 24 | 37 | } | 25 | 38 |
| 26 | | - openEditorWindow(resourceName: string, title: string, viewType?: string) { | 27 | | - this[workspaceSymbol].openEditorWindow(resourceName, title, viewType); | | 39 | + openEditorWindow(resourceName: string, title: string, extra: Object, viewName?: string) { | | 40 | + this[workspaceSymbol].openEditorWindow(resourceName, title, extra, viewName); | 28 | 41 | } | 29 | 42 |
| 30 | 43 | openEditorWindowById(id: string) { | |
Collapse file Copy file name to clipboardExpand all lines: packages/shell/src/model/index.ts +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -13,4 +13,6 @@ export * from './prop'; | 13 | 13 | export * from './props'; | 14 | 14 | export * from './selection'; | 15 | 15 | export * from './setting-prop-entry'; | 16 | | -export * from './setting-top-entry'; | | 16 | +export * from './setting-top-entry'; | | 17 | +export * from './resource'; | | 18 | +export * from './resource-type'; |
Collapse file Copy file name to clipboard +22Lines changed: 22 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +import { IPublicModelResourceType } from '@alilc/lowcode-types'; | | 2 | +import { ResourceType as InnerResourceType } from '@alilc/lowcode-workspace'; | | 3 | +import { resourceTypeSymbol } from '../symbols'; | | 4 | + | | 5 | +export class ResourceType implements IPublicModelResourceType { | | 6 | + readonly [resourceTypeSymbol]: InnerResourceType; | | 7 | + constructor(resourceType: InnerResourceType) { | | 8 | + this[resourceTypeSymbol] = resourceType; | | 9 | + } | | 10 | + | | 11 | + get name() { | | 12 | + return this[resourceTypeSymbol].name; | | 13 | + } | | 14 | + | | 15 | + get description() { | | 16 | + return this[resourceTypeSymbol].options.description; | | 17 | + } | | 18 | + | | 19 | + get icon() { | | 20 | + return this[resourceTypeSymbol].options.icon; | | 21 | + } | | 22 | +} |
|