Skip to content

Commit 7d78936

Browse files
committed
refactor(lock): 锁定插件重构
1 parent 5c8a5cd commit 7d78936

File tree

3 files changed

+16
-24
lines changed

3 files changed

+16
-24
lines changed

packages/core/plugin/LayerPlugin.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @Author: 秦少卫
33
* @Date: 2023-06-15 23:23:18
44
* @LastEditors: 秦少卫
5-
* @LastEditTime: 2024-04-10 17:33:28
5+
* @LastEditTime: 2024-07-06 18:22:46
66
* @Description: 图层调整插件
77
*/
88

@@ -12,7 +12,7 @@ type IEditor = Editor;
1212

1313
class LayerPlugin implements IPluginTempl {
1414
static pluginName = 'LayerPlugin';
15-
static apis = ['up', 'upTop', 'down', 'downTop'];
15+
static apis = ['up', 'down', 'toFront', 'toBack'];
1616
constructor(public canvas: fabric.Canvas, public editor: IEditor) {}
1717

1818
_getWorkspace() {
@@ -34,28 +34,27 @@ class LayerPlugin implements IPluginTempl {
3434
}
3535
}
3636

37-
upTop() {
37+
down() {
3838
const actives = this.canvas.getActiveObjects();
3939
if (actives && actives.length === 1) {
4040
const activeObject = this.canvas.getActiveObjects()[0];
41-
activeObject && activeObject.bringToFront();
41+
activeObject && activeObject.sendBackwards();
4242
this.canvas.renderAll();
43-
console.log(this);
4443
this._workspaceSendToBack();
4544
}
4645
}
4746

48-
down() {
47+
toFront() {
4948
const actives = this.canvas.getActiveObjects();
5049
if (actives && actives.length === 1) {
5150
const activeObject = this.canvas.getActiveObjects()[0];
52-
activeObject && activeObject.sendBackwards();
51+
activeObject && activeObject.bringToFront();
5352
this.canvas.renderAll();
5453
this._workspaceSendToBack();
5554
}
5655
}
5756

58-
downTop() {
57+
toBack() {
5958
const actives = this.canvas.getActiveObjects();
6059
if (actives && actives.length === 1) {
6160
const activeObject = this.canvas.getActiveObjects()[0];
@@ -75,22 +74,22 @@ class LayerPlugin implements IPluginTempl {
7574
subitems: [
7675
{
7776
text: '上一个',
78-
hotkey: 'key',
77+
hotkey: '',
7978
onclick: () => this.up(),
8079
},
8180
{
8281
text: '下一个',
83-
hotkey: 'key',
82+
hotkey: '',
8483
onclick: () => this.down(),
8584
},
8685
{
8786
text: '置顶',
88-
hotkey: 'key',
87+
hotkey: '',
8988
onclick: () => this.upTop(),
9089
},
9190
{
9291
text: '置底',
93-
hotkey: 'key',
92+
hotkey: '',
9493
onclick: () => this.downTop(),
9594
},
9695
],

packages/core/plugin/LockPlugin.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
1-
/*
2-
* @Author: 秦少卫
3-
* @Date: 2024-07-06 12:10:36
4-
* @LastEditors: 秦少卫
5-
* @LastEditTime: 2024-07-06 12:10:38
6-
* @Description: file content
7-
*/
81
/*
92
* @Author: 秦少卫
103
* @Date: 2024-07-04 14:27:05
114
* @LastEditors: 秦少卫
12-
* @LastEditTime: 2024-07-04 23:06:33
13-
* @Description: file content
5+
* @LastEditTime: 2024-07-06 17:49:01
6+
* @Description: 锁定文件
147
*/
158
import { fabric } from 'fabric';
169
import type Editor from '../Editor';

src/components/layer.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @Author: 秦少卫
33
* @Date: 2022-09-03 19:16:55
44
* @LastEditors: 秦少卫
5-
* @LastEditTime: 2024-05-21 08:59:36
5+
* @LastEditTime: 2024-07-06 17:59:51
66
* @Description: 图层面板
77
-->
88

@@ -115,13 +115,13 @@ const up = () => {
115115
canvasEditor.up();
116116
};
117117
const upTop = () => {
118-
canvasEditor.upTop();
118+
canvasEditor.toFront();
119119
};
120120
const down = () => {
121121
canvasEditor.down();
122122
};
123123
const downTop = () => {
124-
canvasEditor.downTop();
124+
canvasEditor.toBack();
125125
};
126126
127127
const getList = () => {

0 commit comments

Comments
 (0)