Skip to content

Commit 4fd3af1

Browse files
JackLianliujuping
authored andcommitted
fix(shell/model): fix lint issues in shell/model
1 parent 0d388a3 commit 4fd3af1

File tree

14 files changed

+56
-44
lines changed

14 files changed

+56
-44
lines changed

docs/docs/api/model/drop-location.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ sidebar_position: 13
1717

1818
拖拽放置位置目标
1919

20-
`@type {IPublicModelNode}`
20+
`@type {IPublicModelNode | null}`
2121

2222
相关类型:[IPublicModelNode](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/node.ts)
2323

packages/designer/src/designer/active-tracker.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,22 @@ import {
66
} from '@alilc/lowcode-types';
77
import { isNode } from '@alilc/lowcode-utils';
88

9-
export interface IActiveTracker extends Omit< IPublicModelActiveTracker, 'track' > {
10-
track(originalTarget: IPublicTypeActiveTarget | INode): void;
9+
export interface IActiveTracker extends Omit< IPublicModelActiveTracker, 'track' | 'onChange' > {
10+
track(originalTarget: ActiveTarget | INode): void;
11+
12+
onChange(fn: (target: ActiveTarget) => void): () => void;
13+
}
14+
15+
export interface ActiveTarget extends Omit< IPublicTypeActiveTarget, 'node' > {
16+
node: INode;
1117
}
1218

1319
export class ActiveTracker implements IActiveTracker {
1420
private emitter: IEventBus = createModuleEventBus('ActiveTracker');
1521

16-
@obx.ref private _target?: IPublicTypeActiveTarget | INode;
22+
@obx.ref private _target?: ActiveTarget | INode;
1723

18-
track(originalTarget: IPublicTypeActiveTarget | INode) {
24+
track(originalTarget: ActiveTarget | INode) {
1925
let target = originalTarget;
2026
if (isNode(originalTarget)) {
2127
target = { node: originalTarget as INode };
@@ -25,11 +31,11 @@ export class ActiveTracker implements IActiveTracker {
2531
}
2632

2733
get currentNode() {
28-
return (this._target as IPublicTypeActiveTarget)?.node;
34+
return (this._target as ActiveTarget)?.node;
2935
}
3036

3137
get detail() {
32-
return (this._target as IPublicTypeActiveTarget)?.detail;
38+
return (this._target as ActiveTarget)?.detail;
3339
}
3440

3541
/**
@@ -41,10 +47,10 @@ export class ActiveTracker implements IActiveTracker {
4147
}
4248

4349
get instance() {
44-
return (this._target as IPublicTypeActiveTarget)?.instance;
50+
return (this._target as ActiveTarget)?.instance;
4551
}
4652

47-
onChange(fn: (target: IPublicTypeActiveTarget) => void): () => void {
53+
onChange(fn: (target: ActiveTarget) => void): () => void {
4854
this.emitter.addListener('change', fn);
4955
return () => {
5056
this.emitter.removeListener('change', fn);

packages/designer/src/designer/location.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import {
77
IPublicTypeRect,
88
IPublicTypeLocationDetail,
99
IPublicTypeLocationData,
10+
IPublicModelLocateEvent,
1011
} from '@alilc/lowcode-types';
1112

12-
1313
export interface Point {
1414
clientX: number;
1515
clientY: number;
@@ -99,11 +99,15 @@ function isDocument(elem: any): elem is Document {
9999
export function getWindow(elem: Element | Document): Window {
100100
return (isDocument(elem) ? elem : elem.ownerDocument!).defaultView!;
101101
}
102-
export interface IDropLocation extends IPublicModelDropLocation {
102+
export interface IDropLocation extends Omit< IPublicModelDropLocation, 'target' | 'clone' > {
103103

104104
readonly source: string;
105105

106+
get target(): INode;
107+
106108
get document(): IPublicModelDocumentModel;
109+
110+
clone(event: IPublicModelLocateEvent): IDropLocation;
107111
}
108112

109113
export class DropLocation implements IDropLocation {
@@ -126,7 +130,7 @@ export class DropLocation implements IDropLocation {
126130
this.event = event;
127131
}
128132

129-
clone(event: ILocateEvent): DropLocation {
133+
clone(event: ILocateEvent): IDropLocation {
130134
return new DropLocation({
131135
target: this.target,
132136
detail: this.detail,

packages/designer/src/designer/setting/setting-entry.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { IPublicModelSettingTarget } from '@alilc/lowcode-types';
2-
import { ComponentMeta } from '../../component-meta';
2+
import { IComponentMeta } from '../../component-meta';
33
import { Designer } from '../designer';
4-
import { Node } from '../../document';
4+
import { INode } from '../../document';
55

66
export interface SettingEntry extends IPublicModelSettingTarget {
7-
readonly nodes: Node[];
8-
readonly componentMeta: ComponentMeta | null;
7+
readonly nodes: INode[];
8+
readonly componentMeta: IComponentMeta | null;
99
readonly designer: Designer;
1010

1111
// 顶端

packages/designer/src/designer/setting/setting-prop-entry.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { obx, computed, makeObservable, runInAction, IEventBus, createModuleEven
22
import { GlobalEvent, IPublicModelEditor, IPublicTypeSetValueOptions } from '@alilc/lowcode-types';
33
import { uniqueId, isJSExpression, isSettingField } from '@alilc/lowcode-utils';
44
import { SettingEntry } from './setting-entry';
5-
import { Node } from '../../document';
6-
import { ComponentMeta } from '../../component-meta';
5+
import { INode } from '../../document';
6+
import { IComponentMeta } from '../../component-meta';
77
import { Designer } from '../designer';
88
import { Setters } from '@alilc/lowcode-shell';
99

@@ -19,9 +19,9 @@ export class SettingPropEntry implements SettingEntry {
1919

2020
readonly setters: Setters;
2121

22-
readonly nodes: Node[];
22+
readonly nodes: INode[];
2323

24-
readonly componentMeta: ComponentMeta | null;
24+
readonly componentMeta: IComponentMeta | null;
2525

2626
readonly designer: Designer;
2727

packages/designer/src/document/node/props/prop.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ export const UNSET = Symbol.for('unset');
1111
// eslint-disable-next-line no-redeclare
1212
export type UNSET = typeof UNSET;
1313

14-
export interface IProp extends Omit<IPublicModelProp, 'exportSchema' | 'node'> {
14+
export interface IProp extends Omit<IPublicModelProp, 'exportSchema' | 'node' | 'slotNode' > {
1515

1616
readonly props: Props;
1717

1818
readonly owner: INode;
1919

20+
get slotNode(): INode | null;
21+
2022
delete(prop: Prop): void;
2123

2224
export(stage: IPublicEnumTransformStage): IPublicTypeCompositeValue;
@@ -113,8 +115,8 @@ export class Prop implements IProp, IPropParent {
113115

114116
private _slotNode?: INode;
115117

116-
get slotNode(): INode | undefined | null {
117-
return this._slotNode;
118+
get slotNode(): INode | null {
119+
return this._slotNode || null;
118120
}
119121

120122
@obx.shallow private _items: Prop[] | null = null;

packages/shell/src/model/active-tracker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { IPublicModelActiveTracker, IPublicModelNode, IPublicTypeActiveTarget } from '@alilc/lowcode-types';
2-
import { IActiveTracker as InnerActiveTracker, INode as InnerNode } from '@alilc/lowcode-designer';
2+
import { IActiveTracker as InnerActiveTracker, ActiveTarget } from '@alilc/lowcode-designer';
33
import { Node as ShellNode } from './node';
44
import { nodeSymbol } from '../symbols';
55

@@ -16,9 +16,9 @@ export class ActiveTracker implements IPublicModelActiveTracker {
1616
if (!fn) {
1717
return () => {};
1818
}
19-
return this[activeTrackerSymbol].onChange((t: IPublicTypeActiveTarget) => {
19+
return this[activeTrackerSymbol].onChange((t: ActiveTarget) => {
2020
const { node: innerNode, detail, instance } = t;
21-
const publicNode = ShellNode.create(innerNode as InnerNode);
21+
const publicNode = ShellNode.create(innerNode);
2222
const publicActiveTarget = {
2323
node: publicNode!,
2424
detail,

packages/shell/src/model/drop-location.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
IDropLocation as InnerDropLocation,
33
} from '@alilc/lowcode-designer';
44
import { dropLocationSymbol } from '../symbols';
5-
import { Node } from './node';
5+
import { Node as ShellNode } from './node';
66
import { IPublicModelDropLocation, IPublicTypeLocationDetail, IPublicModelLocateEvent } from '@alilc/lowcode-types';
77

88
export class DropLocation implements IPublicModelDropLocation {
@@ -20,7 +20,7 @@ export class DropLocation implements IPublicModelDropLocation {
2020
}
2121

2222
get target() {
23-
return Node.create(this[dropLocationSymbol].target);
23+
return ShellNode.create(this[dropLocationSymbol].target);
2424
}
2525

2626
get detail(): IPublicTypeLocationDetail {

packages/shell/src/model/node.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ export class Node implements IPublicModelNode {
335335
}
336336
const shellNode = new Node(node);
337337
// @ts-ignore 挂载 shell node 实例
338+
// eslint-disable-next-line no-param-reassign
338339
node[shellNodeSymbol] = shellNode;
339340
return shellNode;
340341
}

packages/shell/src/model/resource.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { IPublicModelResource } from '@alilc/lowcode-types';
22
import { Resource as InnerResource } from '@alilc/lowcode-workspace';
33
import { resourceSymbol } from '../symbols';
4-
import { ResourceType } from './resource-type';
54

65
export class Resource implements IPublicModelResource {
76
readonly [resourceSymbol]: InnerResource;

0 commit comments

Comments
 (0)