@meta2d/core 1.0.96 → 1.0.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/canvas/canvas.d.ts +3 -0
- package/src/canvas/canvas.js +121 -2
- package/src/canvas/canvas.js.map +1 -1
- package/src/core.d.ts +2 -2
- package/src/core.js +42 -17
- package/src/core.js.map +1 -1
- package/src/dialog/dialog.d.ts +6 -0
- package/src/dialog/dialog.js +29 -4
- package/src/dialog/dialog.js.map +1 -1
- package/src/pen/model.d.ts +2 -0
- package/src/pen/model.js.map +1 -1
- package/src/pen/render.js +22 -5
- package/src/pen/render.js.map +1 -1
- package/src/store/store.d.ts +1 -0
- package/src/store/store.js.map +1 -1
package/src/core.d.ts
CHANGED
|
@@ -345,7 +345,7 @@ export declare class Meta2d {
|
|
|
345
345
|
* 放大到屏幕尺寸,并居中
|
|
346
346
|
* @param fit true,填满但完整展示;false,填满,但长边可能截取(即显示不完整)
|
|
347
347
|
*/
|
|
348
|
-
fitView(fit?: boolean, viewPadding?: Padding): void;
|
|
348
|
+
fitView(fit?: boolean, viewPadding?: Padding, fill?: boolean): void;
|
|
349
349
|
fillView(): void;
|
|
350
350
|
trimPens(): void;
|
|
351
351
|
/**
|
|
@@ -353,7 +353,7 @@ export declare class Meta2d {
|
|
|
353
353
|
* @param fit true,填满但完整展示;false,填满,但长边可能截取(即显示不完整)
|
|
354
354
|
*/
|
|
355
355
|
fitTemplateView(fit?: boolean, viewPadding?: Padding): void;
|
|
356
|
-
fitSizeView(fit?: boolean | string, viewPadding?: Padding): void;
|
|
356
|
+
fitSizeView(fit?: boolean | string, viewPadding?: Padding, fill?: boolean): void;
|
|
357
357
|
centerSizeView(): void;
|
|
358
358
|
/**
|
|
359
359
|
* 宽度放大到屏幕尺寸,并滚动到最顶部
|
package/src/core.js
CHANGED
|
@@ -542,10 +542,18 @@ export class Meta2d {
|
|
|
542
542
|
window.parent.postMessage(JSON.stringify({ name: e.value, data: value }), '*');
|
|
543
543
|
return;
|
|
544
544
|
};
|
|
545
|
-
this.events[EventAction.Message] = (pen, e) => {
|
|
545
|
+
this.events[EventAction.Message] = (pen, e, params) => {
|
|
546
|
+
let theme = e.params;
|
|
547
|
+
let content = e.value;
|
|
548
|
+
if (!content && params && params.type === 'http') {
|
|
549
|
+
content = params.error.statusText;
|
|
550
|
+
if (!theme) {
|
|
551
|
+
theme = 'error';
|
|
552
|
+
}
|
|
553
|
+
}
|
|
546
554
|
this.message({
|
|
547
|
-
theme
|
|
548
|
-
content
|
|
555
|
+
theme,
|
|
556
|
+
content,
|
|
549
557
|
...e.extend,
|
|
550
558
|
});
|
|
551
559
|
};
|
|
@@ -782,6 +790,9 @@ export class Meta2d {
|
|
|
782
790
|
}
|
|
783
791
|
console.info('http消息发送成功');
|
|
784
792
|
}
|
|
793
|
+
else {
|
|
794
|
+
this.store.emitter.emit('error', { type: 'http', error: res });
|
|
795
|
+
}
|
|
785
796
|
}
|
|
786
797
|
else if (network.protocol === 'mqtt') {
|
|
787
798
|
const clients = this.mqttClients?.filter((client) => client.options.href === network.url);
|
|
@@ -2383,9 +2394,11 @@ export class Meta2d {
|
|
|
2383
2394
|
if (!this.store.data.cancelFirstConnect) {
|
|
2384
2395
|
this.requestHttp(http);
|
|
2385
2396
|
}
|
|
2386
|
-
|
|
2387
|
-
this.
|
|
2388
|
-
|
|
2397
|
+
if (net.interval !== 0) {
|
|
2398
|
+
this.updateTimerList[net.index] = setInterval(async () => {
|
|
2399
|
+
this.requestHttp(http);
|
|
2400
|
+
}, http.interval || 1000);
|
|
2401
|
+
}
|
|
2389
2402
|
}
|
|
2390
2403
|
else if (net.protocol === 'SSE') {
|
|
2391
2404
|
if (this.eventSources) {
|
|
@@ -2686,14 +2699,16 @@ export class Meta2d {
|
|
|
2686
2699
|
let _sql = sql.sql;
|
|
2687
2700
|
if (method === 'list') {
|
|
2688
2701
|
// _sql+= ` LIMIT ${sql.pageSize||20}`+(sql.current>1?(' OFFSET '+(sql.current-1)*sql.pageSize):'');
|
|
2689
|
-
if (sql.
|
|
2690
|
-
if (
|
|
2691
|
-
|
|
2702
|
+
if (sql.pageSize !== -1) {
|
|
2703
|
+
if (sql.dbType === "oracle") {
|
|
2704
|
+
if (!_sql.includes('OFFSET')) {
|
|
2705
|
+
_sql += ` OFFSET ${(sql.current || 1 - 1) * (sql.pageSize || 20)} ROWS FETCH NEXT ${sql.pageSize || 20} ROWS ONLY`;
|
|
2706
|
+
}
|
|
2692
2707
|
}
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2708
|
+
else {
|
|
2709
|
+
if (!_sql.includes('LIMIT')) {
|
|
2710
|
+
_sql += ` LIMIT ${sql.pageSize || 20}` + (sql.current > 1 ? (' OFFSET ' + (sql.current - 1) * (sql.pageSize || 20)) : '');
|
|
2711
|
+
}
|
|
2697
2712
|
}
|
|
2698
2713
|
}
|
|
2699
2714
|
}
|
|
@@ -4265,7 +4280,7 @@ export class Meta2d {
|
|
|
4265
4280
|
* 放大到屏幕尺寸,并居中
|
|
4266
4281
|
* @param fit true,填满但完整展示;false,填满,但长边可能截取(即显示不完整)
|
|
4267
4282
|
*/
|
|
4268
|
-
fitView(fit = true, viewPadding = 10) {
|
|
4283
|
+
fitView(fit = true, viewPadding = 10, fill = true) {
|
|
4269
4284
|
// 默认垂直填充,两边留白
|
|
4270
4285
|
if (!this.hasView())
|
|
4271
4286
|
return;
|
|
@@ -4295,7 +4310,7 @@ export class Meta2d {
|
|
|
4295
4310
|
this.scale(ratio * this.store.data.scale);
|
|
4296
4311
|
// 5. 居中
|
|
4297
4312
|
this.centerView();
|
|
4298
|
-
if (this.store.data.fits?.length) {
|
|
4313
|
+
if (fill && this.store.data.fits?.length) {
|
|
4299
4314
|
this.fillView();
|
|
4300
4315
|
}
|
|
4301
4316
|
}
|
|
@@ -4335,8 +4350,17 @@ export class Meta2d {
|
|
|
4335
4350
|
if (pen.image && pen.imageRatio) {
|
|
4336
4351
|
if (pen.calculative.worldRect.width / this.canvas.width > 0.1) {
|
|
4337
4352
|
pen.imageRatio = false;
|
|
4353
|
+
pen.ratio = false;
|
|
4338
4354
|
}
|
|
4339
4355
|
}
|
|
4356
|
+
if (pen.name === 'tablePlus') {
|
|
4357
|
+
pen.colWidth = (pen.colWidth ?? 150) * ratio;
|
|
4358
|
+
pen.styles.forEach((style) => {
|
|
4359
|
+
if (style.width) {
|
|
4360
|
+
style.width = style.width * ratio;
|
|
4361
|
+
}
|
|
4362
|
+
});
|
|
4363
|
+
}
|
|
4340
4364
|
pen.calculative.worldRect.x =
|
|
4341
4365
|
rect.x -
|
|
4342
4366
|
wGap / 2 +
|
|
@@ -4450,6 +4474,7 @@ export class Meta2d {
|
|
|
4450
4474
|
if (pen.image && pen.imageRatio) {
|
|
4451
4475
|
if (pen.calculative.worldRect.height / this.canvas.height > 0.1) {
|
|
4452
4476
|
pen.imageRatio = false;
|
|
4477
|
+
pen.ratio = false;
|
|
4453
4478
|
}
|
|
4454
4479
|
}
|
|
4455
4480
|
pen.calculative.worldRect.y =
|
|
@@ -4584,7 +4609,7 @@ export class Meta2d {
|
|
|
4584
4609
|
});
|
|
4585
4610
|
this.centerView();
|
|
4586
4611
|
}
|
|
4587
|
-
fitSizeView(fit = true, viewPadding = 10) {
|
|
4612
|
+
fitSizeView(fit = true, viewPadding = 10, fill = true) {
|
|
4588
4613
|
// 默认垂直填充,两边留白
|
|
4589
4614
|
// if (!this.hasView()) return;
|
|
4590
4615
|
// 1. 重置画布尺寸为容器尺寸
|
|
@@ -4623,7 +4648,7 @@ export class Meta2d {
|
|
|
4623
4648
|
this.scale(ratio * this.store.data.scale);
|
|
4624
4649
|
// 5. 居中
|
|
4625
4650
|
this.centerSizeView();
|
|
4626
|
-
if (this.store.data.fits?.length) {
|
|
4651
|
+
if (fill && this.store.data.fits?.length) {
|
|
4627
4652
|
this.fillView();
|
|
4628
4653
|
}
|
|
4629
4654
|
}
|