Skip to content

Commit

Permalink
build(二维码): 打包失败修复
Browse files Browse the repository at this point in the history
  • Loading branch information
nihaojob committed Jun 7, 2024
1 parent da5c9f0 commit 36f3207
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
16 changes: 12 additions & 4 deletions packages/core/ServersPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* @Author: 秦少卫
* @Date: 2023-06-20 12:52:09
* @LastEditors: June [email protected]
* @LastEditTime: 2024-05-23 17:56:15
* @LastEditors: 秦少卫
* @LastEditTime: 2024-06-07 11:24:12
* @Description: 内部插件
*/
import { v4 as uuid } from 'uuid';
Expand Down Expand Up @@ -43,6 +43,7 @@ class ServersPlugin {
'addImgByElement',
'getImageExtension',
'getSelectMode',
'getExtensionKey',
];
static events = [SelectMode.ONE, SelectMode.MULTI, SelectEvent.CANCEL];
// public hotkeys: string[] = ['left', 'right', 'down', 'up'];
Expand Down Expand Up @@ -139,14 +140,21 @@ class ServersPlugin {
}

getJson() {
return this.canvas.toJSON([
const keys = this.getExtensionKey();
return this.canvas.toJSON(keys);
}

getExtensionKey() {
return [
'id',
'gradientAngle',
'selectable',
'hasControls',
'linkData',
'editable',
]);
'extensionType',
'extension',
];
}

/**
Expand Down
8 changes: 5 additions & 3 deletions packages/core/plugin/CopyPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: 秦少卫
* @Date: 2023-06-20 12:38:37
* @LastEditors: 秦少卫
* @LastEditTime: 2024-04-11 12:36:03
* @LastEditTime: 2024-06-07 11:25:05
* @Description: 复制插件
*/

Expand Down Expand Up @@ -31,6 +31,7 @@ class CopyPlugin {
// 间距设置
const grid = 10;
const canvas = this.canvas;
const keys = this.editor.getExtensionKey();
activeObject?.clone((cloned: fabric.Object) => {
// 再次进行克隆,处理选择多个对象的情况
cloned.clone((clonedObj: fabric.ActiveSelection) => {
Expand All @@ -54,14 +55,15 @@ class CopyPlugin {
canvas.setActiveObject(clonedObj);
canvas.requestRenderAll();
});
});
}, keys);
}

// 单个对象复制
_copyObject(activeObject: fabric.Object) {
// 间距设置
const grid = 10;
const canvas = this.canvas;
const keys = this.editor.getExtensionKey();
activeObject?.clone((cloned: fabric.Object) => {
if (cloned.left === undefined || cloned.top === undefined) return;
canvas.discardActiveObject();
Expand All @@ -75,7 +77,7 @@ class CopyPlugin {
canvas.add(cloned);
canvas.setActiveObject(cloned);
canvas.requestRenderAll();
});
}, keys);
}

// 复制元素
Expand Down
3 changes: 2 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @Author: June
* @Date: 2023-04-24 00:25:39
* @LastEditors: 秦少卫
* @LastEditTime: 2024-02-06 15:40:37
* @LastEditTime: 2024-06-07 11:35:26
*/
import { defineConfig, loadEnv } from 'vite';
import vue from '@vitejs/plugin-vue';
Expand Down Expand Up @@ -56,6 +56,7 @@ const config = ({ mode }) => {
// sourcemap: !isProd,
emptyOutDir: true,
rollupOptions: {
external: ['JsBarcode'],
input: resolve(__dirname, 'index.html'),
output: {
chunkFileNames: 'js/[name].[hash].js',
Expand Down

0 comments on commit 36f3207

Please sign in to comment.