Skip to content

Commit c2191fc

Browse files
committed
impr
1 parent 00caa51 commit c2191fc

16 files changed

+60
-102
lines changed

src/modules/render/RenderQueue.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,10 @@ export default class RenderQueue implements IRenderQueue {
6262
await task.destroy();
6363
}
6464
task = null;
65-
this.queue = null;
66-
this.running = false;
67-
return;
6865
}
6966
}
67+
this.queue = null;
68+
this.running = false;
7069
}
7170
}
7271

src/modules/render/mask/task/MaskTaskBase.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,20 @@ export default abstract class MaskTaskBase extends RenderTaskBase implements IMa
66
// 模型
77
model: IMaskModel;
88
// 画布
9-
protected _canvas: HTMLCanvasElement;
10-
11-
get data(): IMaskModel {
12-
return this.model;
13-
}
14-
15-
get canvas(): HTMLCanvasElement {
16-
return this._canvas;
17-
}
9+
canvas: HTMLCanvasElement;
1810

1911
constructor(model: IMaskModel, params?: any) {
2012
super();
2113
this.model = model;
2214
if (params) {
23-
this._canvas = params.canvas as HTMLCanvasElement;
15+
this.canvas = params.canvas as HTMLCanvasElement;
2416
}
2517
}
18+
19+
destroy(): Promise<void> {
20+
this.model = null;
21+
this.id = null;
22+
this.canvas = null;
23+
return Promise.resolve();
24+
}
2625
}

src/modules/render/mask/task/MaskTaskCircleTransformer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ export default class MaskTaskCircleTransformer extends MaskTaskBase {
88
* 运行任务
99
*/
1010
async run(): Promise<void> {
11-
if (!this.canvas || !this.data) return;
11+
if (!this.canvas || !this.model) return;
1212

13-
let { point } = this.data;
13+
let { point } = this.model;
1414

1515
if (!point) return;
16-
let { radius } = this.data;
16+
let { radius } = this.model;
1717
const strokeStyle = { ...ControllerStyle.strokes[0] };
1818
const fillStyle = { ...ControllerStyle.fills[0] };
1919
radius /= CanvasUtils.scale;

src/modules/render/mask/task/MaskTaskCursorPosition.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ export default class MaskTaskCursorPosition extends MaskTaskBase {
77
* 运行绘制任务
88
*/
99
async run(): Promise<void> {
10-
if (!this.canvas || !this.data) return;
10+
if (!this.canvas || !this.model) return;
1111

12-
let { text, point } = this.data;
12+
let { text, point } = this.model;
1313
await CanvasUtils.drawRotateTextWithScale(this.canvas, text, point, CursorPositionStyle, CursorPositionStyle.fills[0]);
1414
}
1515
}

src/modules/render/mask/task/MaskTaskIconCursor.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@ import RotateNE from "@/assets/svg/rotate-ne.svg";
1212
export default class MaskTaskIconCursor extends MaskTaskBase {
1313
type: CursorTypes = CursorTypes.vertices;
1414

15-
/**
16-
* 获取模型
17-
*
18-
* @returns
19-
*/
20-
get data(): IIconModel {
21-
return this.model as IIconModel;
22-
}
23-
2415
/**
2516
* 获取图标
2617
*
@@ -58,14 +49,14 @@ export default class MaskTaskIconCursor extends MaskTaskBase {
5849
* 运行绘制任务
5950
*/
6051
async run(): Promise<void> {
61-
if (!this.canvas || !this.data) return;
52+
if (!this.canvas || !this.model) return;
6253

6354
let {
6455
point: { x, y },
6556
width,
6657
height,
6758
scale,
68-
} = this.data;
59+
} = this.model as IIconModel;
6960
await CanvasUtils.drawImgLike(
7061
this.canvas,
7162
this.img,
@@ -76,7 +67,7 @@ export default class MaskTaskIconCursor extends MaskTaskBase {
7667
height,
7768
},
7869
{
79-
angle: this.data.angle,
70+
angle: this.model.angle,
8071
},
8172
);
8273
}

src/modules/render/mask/task/MaskTaskIndicator.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ export default class MaskTaskIndicator extends MaskTaskBase {
88
* 运行任务
99
*/
1010
async run(): Promise<void> {
11-
if (!this.canvas || !this.data) return;
11+
if (!this.canvas || !this.model) return;
1212

13-
let { text, point } = this.data;
13+
let { text, point } = this.model;
1414
point = ElementUtils.calcStageRelativePoint(point);
1515

1616
CanvasUtils.drawRotateTextWithScale(this.canvas, text, point, SelectionIndicatorStyle, SelectionIndicatorStyle.fills[0], {
17-
angle: this.data.angle,
17+
angle: this.model.angle,
1818
});
1919
}
2020
}

src/modules/render/mask/task/MaskTaskPath.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ export default class MaskTaskPath extends MaskTaskBase {
1010
* 运行任务
1111
*/
1212
async run(): Promise<void> {
13-
if (!this.canvas || !this.data) return;
13+
if (!this.canvas || !this.model) return;
1414

1515
const { width } = SelectionStyle.strokes[0];
1616
const specialStyles: ElementStyles = {};
17-
let { points } = this.data;
17+
let { points } = this.model;
1818
points = ElementUtils.calcStageRelativePoints(points);
1919

20-
if ([DrawerMaskModelTypes.selection, DrawerMaskModelTypes.path].includes(this.data.type)) {
20+
if ([DrawerMaskModelTypes.selection, DrawerMaskModelTypes.path].includes(this.model.type)) {
2121
specialStyles.fills = [
2222
{
2323
colorOpacity: 0,
@@ -31,10 +31,10 @@ export default class MaskTaskPath extends MaskTaskBase {
3131
{},
3232
{
3333
...SelectionStyle.strokes[0],
34-
width: width * this.data.scale,
34+
width: width * this.model.scale,
3535
},
3636
{
37-
isFold: typeof this.data.element?.isFold === "undefined" ? true : this.data.element?.isFold,
37+
isFold: typeof this.model.element?.isFold === "undefined" ? true : this.model.element?.isFold,
3838
},
3939
);
4040
}

src/modules/render/mask/task/MaskTaskRotate.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
import MaskTaskBase from "@/modules/render/mask/task/MaskTaskBase";
22
import CanvasUtils from "@/utils/CanvasUtils";
33
import RotateSvg from "@/assets/svg/rotate.svg";
4-
import { IRotationModel } from "@/types/IModel";
54
import ElementUtils from "@/modules/elements/utils/ElementUtils";
5+
import { IRotationModel } from "@/types/IModel";
66

77
export default class MaskTaskRotate extends MaskTaskBase {
8-
get data(): IRotationModel {
9-
return this.model as IRotationModel;
10-
}
11-
128
get svg() {
139
return RotateSvg;
1410
}
@@ -17,8 +13,8 @@ export default class MaskTaskRotate extends MaskTaskBase {
1713
* 运行绘制任务
1814
*/
1915
async run(): Promise<void> {
20-
if (!this.canvas || !this.data) return;
21-
let { point, width, height, scale } = this.data;
16+
if (!this.canvas || !this.model) return;
17+
let { point, width, height, scale } = this.model as IRotationModel;
2218
point = ElementUtils.calcStageRelativePoint(point);
2319

2420
await CanvasUtils.drawImgLike(
@@ -31,7 +27,7 @@ export default class MaskTaskRotate extends MaskTaskBase {
3127
height,
3228
},
3329
{
34-
angle: this.data.angle,
30+
angle: this.model.angle,
3531
},
3632
);
3733
}

src/modules/render/mask/task/MaskTaskTransformer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ export default class MaskTaskTransformer extends MaskTaskBase {
99
* 运行任务
1010
*/
1111
async run(): Promise<void> {
12-
if (!this.canvas || !this.data) return;
12+
if (!this.canvas || !this.model) return;
1313
const { width } = ControllerStyle.strokes[0];
14-
let { scale, point, leanYAngle, actualAngle } = this.data;
14+
let { scale, point, leanYAngle, actualAngle } = this.model;
1515
point = ElementUtils.calcStageRelativePoint(point);
1616

1717
CanvasUtils.drawPathWithScale(

src/modules/render/shield/task/ElementTaskArbitrary.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
11
import ElementTaskBase from "@/modules/render/shield/task/ElementTaskBase";
22
import CanvasUtils from "@/utils/CanvasUtils";
3-
import { IElementRect } from "@/types/IElement";
43
import { DefaultLineMeterLimit } from "@/styles/ElementStyles";
54
import ElementUtils from "@/modules/elements/utils/ElementUtils";
65

76
export default class ElementTaskArbitrary extends ElementTaskBase {
8-
get node() {
9-
return this.element as IElementRect;
10-
}
11-
127
/**
138
* 运行任务
149
*/
1510
async run(): Promise<void> {
16-
if (!this.canvas || !this.node) return;
17-
11+
if (!this.canvas || !this.element) return;
12+
1813
let {
1914
innermostStrokeCoordIndex,
2015
strokeCoords,
2116
model: { styles, isFold },
22-
} = this.node;
17+
} = this.element;
2318
const strokePoints = ElementUtils.batchCalcStageRelativePoints(strokeCoords);
2419

2520
if (isFold) {

0 commit comments

Comments
 (0)