@netless/telebox-insider 0.3.0-beta.9 → 0.3.1-beta.0
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/dist/index.d.ts +73 -25
- package/dist/style.css +4 -1
- package/dist/telebox-insider.cjs.js +382 -122
- package/dist/telebox-insider.cjs.js.map +1 -1
- package/dist/telebox-insider.es.js +382 -122
- package/dist/telebox-insider.es.js.map +1 -1
- package/package.json +1 -1
- package/src/AppMenu/index.ts +0 -1
- package/src/TeleBox/constants.ts +2 -0
- package/src/TeleBox/index.ts +122 -20
- package/src/TeleBox/typings.ts +18 -2
- package/src/TeleBoxCollector/index.ts +2 -1
- package/src/TeleBoxManager/MaxTitleBar/index.ts +2 -2
- package/src/TeleBoxManager/MaxTitleBar/style.scss +1 -1
- package/src/TeleBoxManager/index.ts +475 -190
- package/src/TeleBoxManager/typings.ts +10 -3
- package/src/TeleTitleBar/DefaultTitleBar/index.ts +72 -22
- package/src/TeleTitleBar/DefaultTitleBar/style.scss +5 -0
- package/src/TeleTitleBar/typings.ts +6 -0
|
@@ -43,25 +43,27 @@ type ValConfig = {
|
|
|
43
43
|
readonly: Val<boolean, boolean>;
|
|
44
44
|
minimized: Val<boolean, boolean>;
|
|
45
45
|
maximized: Val<boolean, boolean>;
|
|
46
|
+
forceMaximized: Val<boolean, boolean>;
|
|
46
47
|
fence: Val<boolean, boolean>;
|
|
47
48
|
};
|
|
48
49
|
export interface TeleBoxManager extends ValEnhancedResult<ValConfig> {}
|
|
49
50
|
|
|
50
51
|
export class TeleBoxManager {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
static readonly kind = "TeleBoxManager";
|
|
53
|
+
protected boxesStatus$: Map<string, TeleBoxState>;
|
|
54
|
+
protected lastNotMinimizedBoxesStatus$: Map<string, NotMinimizedBoxState>;
|
|
55
|
+
protected appMenu: AppMenu | undefined;
|
|
56
|
+
protected useBoxesStatus: boolean;
|
|
57
|
+
protected effectBoxesStatusTimer?: {
|
|
56
58
|
skipUpdate: boolean;
|
|
57
59
|
timer: number | undefined;
|
|
58
60
|
resolve?: (skipUpdate: boolean) => void;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
+
};
|
|
62
|
+
protected effectLastNotMinimizedBoxStatusTimer?: {
|
|
61
63
|
skipUpdate: boolean;
|
|
62
64
|
timer: number | undefined;
|
|
63
65
|
resolve?: (skipUpdate: boolean) => void;
|
|
64
|
-
}
|
|
66
|
+
};
|
|
65
67
|
|
|
66
68
|
public constructor({
|
|
67
69
|
root = document.body,
|
|
@@ -78,6 +80,7 @@ export class TeleBoxManager {
|
|
|
78
80
|
collector,
|
|
79
81
|
namespace = "telebox",
|
|
80
82
|
readonly = false,
|
|
83
|
+
forceMaximized = false,
|
|
81
84
|
useBoxesStatus = false,
|
|
82
85
|
}: TeleBoxManagerConfig = {}) {
|
|
83
86
|
this._sideEffect = new SideEffectManager();
|
|
@@ -90,10 +93,15 @@ export class TeleBoxManager {
|
|
|
90
93
|
this.boxes$ = createVal<TeleBox[]>([]);
|
|
91
94
|
this.topBox$ = this.boxes$.derive((boxes) => {
|
|
92
95
|
if (boxes.length > 0) {
|
|
93
|
-
console.log("topBox===>topBox$===>000");
|
|
94
96
|
let currentTopBox: TeleBox | undefined = undefined;
|
|
95
97
|
const topBox = boxes.reduce((topBox, box) => {
|
|
96
|
-
if (box.
|
|
98
|
+
if (box.forceTop) {
|
|
99
|
+
return topBox;
|
|
100
|
+
}
|
|
101
|
+
if (
|
|
102
|
+
box.boxStatus &&
|
|
103
|
+
box.boxStatus === TELE_BOX_STATE.Minimized
|
|
104
|
+
) {
|
|
97
105
|
return topBox;
|
|
98
106
|
}
|
|
99
107
|
if (!topBox) {
|
|
@@ -101,14 +109,16 @@ export class TeleBoxManager {
|
|
|
101
109
|
return topBox;
|
|
102
110
|
}
|
|
103
111
|
return topBox.zIndex > box.zIndex ? topBox : box;
|
|
104
|
-
}, currentTopBox as
|
|
105
|
-
console.log("topBox===>topBox$===>end", topBox?.id);
|
|
112
|
+
}, currentTopBox as TeleBox | undefined);
|
|
106
113
|
return topBox;
|
|
107
114
|
}
|
|
108
115
|
return;
|
|
109
116
|
});
|
|
110
117
|
this.boxesStatus$ = new Map<string, TeleBoxState>();
|
|
111
|
-
this.lastNotMinimizedBoxesStatus$ = new Map<
|
|
118
|
+
this.lastNotMinimizedBoxesStatus$ = new Map<
|
|
119
|
+
string,
|
|
120
|
+
NotMinimizedBoxState
|
|
121
|
+
>();
|
|
112
122
|
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)");
|
|
113
123
|
const prefersDark$ = createVal(false);
|
|
114
124
|
|
|
@@ -158,6 +168,13 @@ export class TeleBoxManager {
|
|
|
158
168
|
const minimized$ = createVal(minimized);
|
|
159
169
|
|
|
160
170
|
const maximized$ = createVal(maximized);
|
|
171
|
+
const forceMaximized$ = createVal(forceMaximized);
|
|
172
|
+
forceMaximized$.reaction((forceMaximized, _, skipUpdate) => {
|
|
173
|
+
this.boxes.forEach((box) =>
|
|
174
|
+
box.setForceMaximized(forceMaximized, skipUpdate)
|
|
175
|
+
);
|
|
176
|
+
this.maxTitleBar?.setForceMaximized(forceMaximized);
|
|
177
|
+
});
|
|
161
178
|
maximized$.reaction((maximized, _, skipUpdate) => {
|
|
162
179
|
this.boxes.forEach((box) =>
|
|
163
180
|
box.setMaximized(maximized, skipUpdate)
|
|
@@ -203,7 +220,7 @@ export class TeleBoxManager {
|
|
|
203
220
|
new TeleBoxCollector({
|
|
204
221
|
visible: minimized,
|
|
205
222
|
readonly: readonly,
|
|
206
|
-
namespace
|
|
223
|
+
namespace,
|
|
207
224
|
}).mount(root)
|
|
208
225
|
);
|
|
209
226
|
collector$.subscribe((collector) => {
|
|
@@ -314,24 +331,39 @@ export class TeleBoxManager {
|
|
|
314
331
|
if (!this.useBoxesStatus) {
|
|
315
332
|
this.makeBoxTop(box);
|
|
316
333
|
} else {
|
|
317
|
-
if (
|
|
318
|
-
|
|
334
|
+
if (
|
|
335
|
+
box.boxStatus &&
|
|
336
|
+
box.boxStatus === TELE_BOX_STATE.Normal
|
|
337
|
+
) {
|
|
338
|
+
const maxNormalBoxZIndex =
|
|
339
|
+
this.getMaxNormalBoxZIndex();
|
|
319
340
|
if (maxNormalBoxZIndex > box.zIndex) {
|
|
320
|
-
this.setBox(
|
|
321
|
-
|
|
322
|
-
|
|
341
|
+
this.setBox(
|
|
342
|
+
box,
|
|
343
|
+
{
|
|
344
|
+
zIndex: maxNormalBoxZIndex + 1,
|
|
345
|
+
},
|
|
346
|
+
false
|
|
347
|
+
);
|
|
323
348
|
}
|
|
324
|
-
} else if(
|
|
325
|
-
|
|
349
|
+
} else if (
|
|
350
|
+
box.boxStatus &&
|
|
351
|
+
box.boxStatus === TELE_BOX_STATE.Maximized
|
|
352
|
+
) {
|
|
353
|
+
const maxMaximizedBoxZIndex =
|
|
354
|
+
this.getMaxMaximizedBoxZIndex();
|
|
326
355
|
if (maxMaximizedBoxZIndex > box.zIndex) {
|
|
327
|
-
this.setBox(
|
|
328
|
-
|
|
329
|
-
|
|
356
|
+
this.setBox(
|
|
357
|
+
box,
|
|
358
|
+
{
|
|
359
|
+
zIndex: maxMaximizedBoxZIndex + 1,
|
|
360
|
+
},
|
|
361
|
+
false
|
|
362
|
+
);
|
|
330
363
|
}
|
|
331
364
|
this.makeMaximizedTopBoxFocus();
|
|
332
365
|
}
|
|
333
|
-
}
|
|
334
|
-
console.log("checkFocusBox===>", box.id);
|
|
366
|
+
}
|
|
335
367
|
this.focusBox(box);
|
|
336
368
|
return;
|
|
337
369
|
}
|
|
@@ -357,6 +389,7 @@ export class TeleBoxManager {
|
|
|
357
389
|
readonly: readonly$.value,
|
|
358
390
|
namespace: this.namespace,
|
|
359
391
|
state: state$.value,
|
|
392
|
+
forceMaximized: forceMaximized$.value,
|
|
360
393
|
boxes: this.boxes$.value,
|
|
361
394
|
containerRect: containerRect$.value,
|
|
362
395
|
getBoxesStatus: () => {
|
|
@@ -365,20 +398,33 @@ export class TeleBoxManager {
|
|
|
365
398
|
onEvent: (event): void => {
|
|
366
399
|
switch (event.type) {
|
|
367
400
|
case TELE_BOX_DELEGATE_EVENT.Maximize: {
|
|
401
|
+
if (
|
|
402
|
+
forceMaximized$.value &&
|
|
403
|
+
this.state === TELE_BOX_STATE.Maximized
|
|
404
|
+
) {
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
368
407
|
if (this.hasBoxesStatus()) {
|
|
369
408
|
let targetBox = this.maxTitleBar.focusedBox;
|
|
370
409
|
if (!targetBox) {
|
|
371
|
-
|
|
410
|
+
targetBox = this.getMaximizedTopBox();
|
|
372
411
|
}
|
|
373
412
|
if (targetBox?.id) {
|
|
374
413
|
const box = this.getBox(targetBox.id);
|
|
375
414
|
if (box) {
|
|
376
|
-
this.setBox(
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
415
|
+
this.setBox(
|
|
416
|
+
box,
|
|
417
|
+
{
|
|
418
|
+
status: TELE_BOX_STATE.Normal,
|
|
419
|
+
zIndex:
|
|
420
|
+
this.getMaxNormalBoxZIndex() +
|
|
421
|
+
1,
|
|
422
|
+
},
|
|
423
|
+
false,
|
|
424
|
+
() => {
|
|
425
|
+
this.makeMaximizedTopBoxFocus();
|
|
426
|
+
}
|
|
427
|
+
);
|
|
382
428
|
}
|
|
383
429
|
}
|
|
384
430
|
} else {
|
|
@@ -390,9 +436,9 @@ export class TeleBoxManager {
|
|
|
390
436
|
if (this.hasBoxesStatus()) {
|
|
391
437
|
let targetBox = this.maxTitleBar.focusedBox;
|
|
392
438
|
if (!targetBox) {
|
|
393
|
-
|
|
439
|
+
targetBox = this.getMaximizedTopBox();
|
|
394
440
|
}
|
|
395
|
-
if(targetBox?.id){
|
|
441
|
+
if (targetBox?.id) {
|
|
396
442
|
const box = this.getBox(targetBox.id);
|
|
397
443
|
if (box) {
|
|
398
444
|
let isFocusChanged = false;
|
|
@@ -400,10 +446,14 @@ export class TeleBoxManager {
|
|
|
400
446
|
this.blurBox(box);
|
|
401
447
|
isFocusChanged = true;
|
|
402
448
|
}
|
|
403
|
-
this.setBox(
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
449
|
+
this.setBox(
|
|
450
|
+
box,
|
|
451
|
+
{
|
|
452
|
+
status: TELE_BOX_STATE.Minimized,
|
|
453
|
+
zIndex: -1,
|
|
454
|
+
},
|
|
455
|
+
false
|
|
456
|
+
);
|
|
407
457
|
if (isFocusChanged) {
|
|
408
458
|
this.focusTopBox();
|
|
409
459
|
} else {
|
|
@@ -420,7 +470,7 @@ export class TeleBoxManager {
|
|
|
420
470
|
if (this.hasBoxesStatus()) {
|
|
421
471
|
let targetBox = this.maxTitleBar.focusedBox;
|
|
422
472
|
if (!targetBox) {
|
|
423
|
-
|
|
473
|
+
targetBox = this.getMaximizedTopBox();
|
|
424
474
|
}
|
|
425
475
|
if (targetBox?.id) {
|
|
426
476
|
const box = this.getBox(targetBox.id);
|
|
@@ -469,6 +519,7 @@ export class TeleBoxManager {
|
|
|
469
519
|
fence: fence$,
|
|
470
520
|
minimized: minimized$,
|
|
471
521
|
maximized: maximized$,
|
|
522
|
+
forceMaximized: forceMaximized$,
|
|
472
523
|
};
|
|
473
524
|
|
|
474
525
|
withValueEnhancer(this, valConfig);
|
|
@@ -490,6 +541,23 @@ export class TeleBoxManager {
|
|
|
490
541
|
return this.topBox$.value;
|
|
491
542
|
}
|
|
492
543
|
|
|
544
|
+
public get forceTopBoxes(): TeleBox | undefined {
|
|
545
|
+
return this.boxes.find((box) => box.forceTop);
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
public get maxForceTopBox(): TeleBox | undefined {
|
|
549
|
+
return this.boxes.reduce<TeleBox | undefined>((maxTopBox, box) => {
|
|
550
|
+
if (box.forceTop && box.zIndex > (maxTopBox?.zIndex ?? 0)) {
|
|
551
|
+
return box;
|
|
552
|
+
}
|
|
553
|
+
return maxTopBox;
|
|
554
|
+
}, undefined);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
public get forceNormalBoxes(): TeleBox | undefined {
|
|
558
|
+
return this.boxes.find((box) => box.forceNormal);
|
|
559
|
+
}
|
|
560
|
+
|
|
493
561
|
public readonly events = new EventEmitter() as TeleBoxManagerEvents;
|
|
494
562
|
|
|
495
563
|
protected _sideEffect: SideEffectManager;
|
|
@@ -516,6 +584,9 @@ export class TeleBoxManager {
|
|
|
516
584
|
|
|
517
585
|
/** @deprecated use setMaximized and setMinimized instead */
|
|
518
586
|
public setState(state: TeleBoxState, skipUpdate = false): this {
|
|
587
|
+
if (state === TELE_BOX_STATE.Normal && this.forceMaximized) {
|
|
588
|
+
return this;
|
|
589
|
+
}
|
|
519
590
|
switch (state) {
|
|
520
591
|
case TELE_BOX_STATE.Maximized: {
|
|
521
592
|
this.setMinimized(false, skipUpdate);
|
|
@@ -536,13 +607,27 @@ export class TeleBoxManager {
|
|
|
536
607
|
return this;
|
|
537
608
|
}
|
|
538
609
|
|
|
539
|
-
public setBoxStatus(
|
|
610
|
+
public setBoxStatus(
|
|
611
|
+
boxId: string,
|
|
612
|
+
boxStatus?: TeleBoxState,
|
|
613
|
+
skipUpdate = false
|
|
614
|
+
): void {
|
|
540
615
|
if (boxStatus) {
|
|
541
616
|
const oldBoxStatus = this.boxesStatus$.get(boxId);
|
|
542
617
|
this.boxesStatus$.set(boxId, boxStatus);
|
|
543
|
-
if (
|
|
544
|
-
|
|
545
|
-
|
|
618
|
+
if (
|
|
619
|
+
boxStatus === TELE_BOX_STATE.Minimized &&
|
|
620
|
+
oldBoxStatus !== TELE_BOX_STATE.Minimized
|
|
621
|
+
) {
|
|
622
|
+
this.setLastNotMinimizedBoxStatus(
|
|
623
|
+
boxId,
|
|
624
|
+
oldBoxStatus,
|
|
625
|
+
skipUpdate
|
|
626
|
+
);
|
|
627
|
+
} else if (
|
|
628
|
+
oldBoxStatus === TELE_BOX_STATE.Minimized &&
|
|
629
|
+
boxStatus !== TELE_BOX_STATE.Minimized
|
|
630
|
+
) {
|
|
546
631
|
this.setLastNotMinimizedBoxStatus(boxId, undefined, skipUpdate);
|
|
547
632
|
}
|
|
548
633
|
} else {
|
|
@@ -550,7 +635,10 @@ export class TeleBoxManager {
|
|
|
550
635
|
this.setLastNotMinimizedBoxStatus(boxId, undefined, skipUpdate);
|
|
551
636
|
}
|
|
552
637
|
if (!skipUpdate) {
|
|
553
|
-
this.events.emit(TELE_BOX_MANAGER_EVENT.BoxStatus, {
|
|
638
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.BoxStatus, {
|
|
639
|
+
id: boxId,
|
|
640
|
+
boxStatus,
|
|
641
|
+
});
|
|
554
642
|
}
|
|
555
643
|
}
|
|
556
644
|
|
|
@@ -562,11 +650,17 @@ export class TeleBoxManager {
|
|
|
562
650
|
return this.boxesStatus$;
|
|
563
651
|
}
|
|
564
652
|
|
|
565
|
-
public get lastNotMinimizedBoxesStatus(): ReadonlyMap<
|
|
653
|
+
public get lastNotMinimizedBoxesStatus(): ReadonlyMap<
|
|
654
|
+
string,
|
|
655
|
+
NotMinimizedBoxState
|
|
656
|
+
> {
|
|
566
657
|
return this.lastNotMinimizedBoxesStatus$;
|
|
567
658
|
}
|
|
568
659
|
|
|
569
|
-
public setBoxesStatus(
|
|
660
|
+
public setBoxesStatus(
|
|
661
|
+
boxesStatus: Map<string, TeleBoxState>,
|
|
662
|
+
skipUpdate = false
|
|
663
|
+
) {
|
|
570
664
|
this.boxesStatus$ = boxesStatus;
|
|
571
665
|
this.effectBoxesStatusChange(skipUpdate);
|
|
572
666
|
}
|
|
@@ -575,13 +669,13 @@ export class TeleBoxManager {
|
|
|
575
669
|
return this.boxesStatus$;
|
|
576
670
|
}
|
|
577
671
|
|
|
578
|
-
|
|
672
|
+
protected effectBoxStatusChange() {
|
|
579
673
|
if (!this.useBoxesStatus) {
|
|
580
674
|
return;
|
|
581
675
|
}
|
|
582
|
-
if(this.collector){
|
|
676
|
+
if (this.collector) {
|
|
583
677
|
this.collector.updateBoxesStatus();
|
|
584
|
-
if(this.hasMinimizedBox()){
|
|
678
|
+
if (this.hasMinimizedBox()) {
|
|
585
679
|
this._setCollectorRect(this._calcCollectorRect());
|
|
586
680
|
}
|
|
587
681
|
}
|
|
@@ -593,52 +687,59 @@ export class TeleBoxManager {
|
|
|
593
687
|
}
|
|
594
688
|
}
|
|
595
689
|
|
|
596
|
-
|
|
690
|
+
protected effectBoxesStatusTimerFunc(skipUpdate: boolean) {
|
|
597
691
|
if (!this.useBoxesStatus) {
|
|
598
692
|
return;
|
|
599
693
|
}
|
|
600
|
-
let newTopBox:TeleBox | undefined;
|
|
694
|
+
let newTopBox: TeleBox | undefined;
|
|
601
695
|
const curTopBox = this.topBox;
|
|
602
696
|
this.boxes.forEach((box) => {
|
|
603
697
|
const boxStatus = this.boxesStatus$.get(box.id);
|
|
604
698
|
if (boxStatus) {
|
|
605
|
-
if (
|
|
699
|
+
if (
|
|
700
|
+
boxStatus !== TELE_BOX_STATE.Minimized &&
|
|
701
|
+
!this.isForceTop(box) &&
|
|
702
|
+
box.zIndex > (newTopBox?.zIndex ?? 0)
|
|
703
|
+
) {
|
|
606
704
|
newTopBox = box;
|
|
607
705
|
}
|
|
608
706
|
box.setBoxStatus(boxStatus, skipUpdate);
|
|
609
707
|
}
|
|
610
708
|
});
|
|
611
709
|
this.effectBoxStatusChange();
|
|
612
|
-
console.log("effectBoxesStatusTimerFunc===>newTopBox", newTopBox, curTopBox);
|
|
613
710
|
if (newTopBox && curTopBox !== newTopBox) {
|
|
614
711
|
this.topBox$.setValue(newTopBox);
|
|
615
712
|
}
|
|
616
713
|
if (!newTopBox && curTopBox) {
|
|
617
714
|
this.topBox$.setValue(undefined);
|
|
618
|
-
// this.blurBox(curTopBox, skipUpdate);
|
|
619
715
|
}
|
|
620
716
|
}
|
|
621
717
|
|
|
622
718
|
public async effectBoxesStatusChange(skipUpdate = false): Promise<void> {
|
|
623
719
|
if (!this.useBoxesStatus) {
|
|
624
|
-
if (
|
|
720
|
+
if (
|
|
721
|
+
this.effectBoxesStatusTimer &&
|
|
722
|
+
this.effectBoxesStatusTimer.timer
|
|
723
|
+
) {
|
|
625
724
|
clearTimeout(this.effectBoxesStatusTimer.timer);
|
|
626
725
|
if (this.effectBoxesStatusTimer.resolve) {
|
|
627
|
-
this.effectBoxesStatusTimer.resolve(
|
|
726
|
+
this.effectBoxesStatusTimer.resolve(
|
|
727
|
+
!!this.effectBoxesStatusTimer?.skipUpdate
|
|
728
|
+
);
|
|
628
729
|
}
|
|
629
730
|
}
|
|
630
|
-
this.effectBoxesStatusTimer=undefined;
|
|
731
|
+
this.effectBoxesStatusTimer = undefined;
|
|
631
732
|
return;
|
|
632
733
|
}
|
|
633
734
|
if (this.effectBoxesStatusTimer && this.effectBoxesStatusTimer.timer) {
|
|
634
735
|
if (this.effectBoxesStatusTimer.skipUpdate !== skipUpdate) {
|
|
635
736
|
clearTimeout(this.effectBoxesStatusTimer.timer);
|
|
636
737
|
if (this.effectBoxesStatusTimer.resolve) {
|
|
637
|
-
|
|
638
|
-
|
|
738
|
+
this.effectBoxesStatusTimer.resolve(
|
|
739
|
+
!!this.effectBoxesStatusTimer?.skipUpdate
|
|
740
|
+
);
|
|
639
741
|
}
|
|
640
742
|
this.effectBoxesStatusTimer.skipUpdate = skipUpdate;
|
|
641
|
-
console.log("effectBoxStatusTimerFunc===>2222", skipUpdate);
|
|
642
743
|
} else {
|
|
643
744
|
return;
|
|
644
745
|
}
|
|
@@ -651,25 +752,27 @@ export class TeleBoxManager {
|
|
|
651
752
|
} as {
|
|
652
753
|
skipUpdate: boolean;
|
|
653
754
|
timer: number | undefined;
|
|
654
|
-
}
|
|
755
|
+
};
|
|
655
756
|
}
|
|
656
757
|
if (this.effectBoxesStatusTimer) {
|
|
657
|
-
const _skipUpdate = await new Promise<boolean>((resolve)=>{
|
|
758
|
+
const _skipUpdate = await new Promise<boolean>((resolve) => {
|
|
658
759
|
this.effectBoxesStatusTimer!.resolve = resolve;
|
|
659
|
-
this.effectBoxesStatusTimer!.timer = setTimeout(()=>{
|
|
660
|
-
if (
|
|
661
|
-
|
|
662
|
-
this.effectBoxesStatusTimer.resolve
|
|
760
|
+
this.effectBoxesStatusTimer!.timer = setTimeout(() => {
|
|
761
|
+
if (
|
|
762
|
+
this.effectBoxesStatusTimer &&
|
|
763
|
+
this.effectBoxesStatusTimer.resolve
|
|
764
|
+
) {
|
|
765
|
+
this.effectBoxesStatusTimer.resolve(
|
|
766
|
+
this.effectBoxesStatusTimer!.skipUpdate
|
|
767
|
+
);
|
|
663
768
|
}
|
|
664
769
|
}, 100) as unknown as number;
|
|
665
|
-
})
|
|
666
|
-
|
|
667
|
-
this.effectBoxesStatusTimerFunc(_skipUpdate)
|
|
770
|
+
});
|
|
771
|
+
this.effectBoxesStatusTimerFunc(_skipUpdate);
|
|
668
772
|
this.effectBoxesStatusTimer = undefined;
|
|
669
|
-
console.log("effectBoxStatusTimerFunc===>000==>11", skipUpdate, {id:this.topBox$.value?.id, zIndex:this.topBox$.value?.zIndex}, this.boxes$.value.map((b)=>({id:b.id,focus:b.focus, boxStatus:b.boxStatus,zIndex:b.zIndex})));
|
|
670
773
|
}
|
|
671
774
|
}
|
|
672
|
-
|
|
775
|
+
|
|
673
776
|
public hasBoxesStatus(): boolean {
|
|
674
777
|
if (!this.useBoxesStatus) {
|
|
675
778
|
return false;
|
|
@@ -681,14 +784,19 @@ export class TeleBoxManager {
|
|
|
681
784
|
if (!this.useBoxesStatus) {
|
|
682
785
|
return false;
|
|
683
786
|
}
|
|
684
|
-
return this.boxes.some(
|
|
787
|
+
return this.boxes.some(
|
|
788
|
+
(box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized
|
|
789
|
+
);
|
|
685
790
|
}
|
|
686
791
|
|
|
687
792
|
public getMinimizedBoxesStatus(): Map<string, TELE_BOX_STATE.Minimized> {
|
|
688
793
|
const minimizedBoxes = new Map<string, TELE_BOX_STATE.Minimized>();
|
|
689
794
|
this.boxesStatus$.forEach((boxStatus, boxId) => {
|
|
690
795
|
if (boxStatus === TELE_BOX_STATE.Minimized) {
|
|
691
|
-
minimizedBoxes.set(
|
|
796
|
+
minimizedBoxes.set(
|
|
797
|
+
boxId,
|
|
798
|
+
boxStatus as TELE_BOX_STATE.Minimized
|
|
799
|
+
);
|
|
692
800
|
}
|
|
693
801
|
});
|
|
694
802
|
return minimizedBoxes;
|
|
@@ -708,7 +816,10 @@ export class TeleBoxManager {
|
|
|
708
816
|
const maximizedBoxes = new Map<string, TELE_BOX_STATE.Maximized>();
|
|
709
817
|
this.boxesStatus$.forEach((boxStatus, boxId) => {
|
|
710
818
|
if (boxStatus === TELE_BOX_STATE.Maximized) {
|
|
711
|
-
maximizedBoxes.set(
|
|
819
|
+
maximizedBoxes.set(
|
|
820
|
+
boxId,
|
|
821
|
+
boxStatus as TELE_BOX_STATE.Maximized
|
|
822
|
+
);
|
|
712
823
|
}
|
|
713
824
|
});
|
|
714
825
|
return maximizedBoxes;
|
|
@@ -724,47 +835,76 @@ export class TeleBoxManager {
|
|
|
724
835
|
return normalBoxes;
|
|
725
836
|
}
|
|
726
837
|
|
|
727
|
-
public getLastNotMinimizedBoxStatus(
|
|
838
|
+
public getLastNotMinimizedBoxStatus(
|
|
839
|
+
boxId: string
|
|
840
|
+
): NotMinimizedBoxState | undefined {
|
|
728
841
|
return this.lastNotMinimizedBoxesStatus$.get(boxId);
|
|
729
842
|
}
|
|
730
843
|
|
|
731
|
-
public setLastNotMinimizedBoxStatus(
|
|
844
|
+
public setLastNotMinimizedBoxStatus(
|
|
845
|
+
boxId: string,
|
|
846
|
+
lastNotMinimizedBoxStatus?: NotMinimizedBoxState,
|
|
847
|
+
skipUpdate = false
|
|
848
|
+
): void {
|
|
732
849
|
if (lastNotMinimizedBoxStatus) {
|
|
733
|
-
this.lastNotMinimizedBoxesStatus$.set(
|
|
850
|
+
this.lastNotMinimizedBoxesStatus$.set(
|
|
851
|
+
boxId,
|
|
852
|
+
lastNotMinimizedBoxStatus
|
|
853
|
+
);
|
|
734
854
|
} else {
|
|
735
855
|
this.lastNotMinimizedBoxesStatus$.delete(boxId);
|
|
736
856
|
}
|
|
737
857
|
if (!skipUpdate) {
|
|
738
|
-
this.events.emit(TELE_BOX_MANAGER_EVENT.LastNotMinimizedBoxStatus, {
|
|
858
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.LastNotMinimizedBoxStatus, {
|
|
859
|
+
id: boxId,
|
|
860
|
+
boxStatus: lastNotMinimizedBoxStatus,
|
|
861
|
+
});
|
|
739
862
|
}
|
|
740
863
|
}
|
|
741
864
|
|
|
742
|
-
public setLastNotMinimizedBoxesStatus(
|
|
865
|
+
public setLastNotMinimizedBoxesStatus(
|
|
866
|
+
lastNotMinimizedBoxesStatus: Map<string, NotMinimizedBoxState>,
|
|
867
|
+
skipUpdate = false
|
|
868
|
+
): void {
|
|
743
869
|
this.lastNotMinimizedBoxesStatus$ = lastNotMinimizedBoxesStatus;
|
|
744
870
|
this.effectLastNotMinimizedBoxStatusChange(skipUpdate);
|
|
745
871
|
}
|
|
746
872
|
|
|
747
|
-
|
|
873
|
+
protected async effectLastNotMinimizedBoxStatusChange(
|
|
874
|
+
skipUpdate = false
|
|
875
|
+
): Promise<void> {
|
|
748
876
|
if (!this.useBoxesStatus) {
|
|
749
|
-
if (
|
|
877
|
+
if (
|
|
878
|
+
this.effectLastNotMinimizedBoxStatusTimer &&
|
|
879
|
+
this.effectLastNotMinimizedBoxStatusTimer.timer
|
|
880
|
+
) {
|
|
750
881
|
clearTimeout(this.effectLastNotMinimizedBoxStatusTimer.timer);
|
|
751
882
|
if (this.effectLastNotMinimizedBoxStatusTimer.resolve) {
|
|
752
|
-
this.effectLastNotMinimizedBoxStatusTimer.resolve(
|
|
883
|
+
this.effectLastNotMinimizedBoxStatusTimer.resolve(
|
|
884
|
+
!!this.effectLastNotMinimizedBoxStatusTimer?.skipUpdate
|
|
885
|
+
);
|
|
753
886
|
}
|
|
754
887
|
}
|
|
755
|
-
this.effectLastNotMinimizedBoxStatusTimer=undefined;
|
|
888
|
+
this.effectLastNotMinimizedBoxStatusTimer = undefined;
|
|
756
889
|
return;
|
|
757
890
|
}
|
|
758
|
-
if (
|
|
891
|
+
if (
|
|
892
|
+
this.effectLastNotMinimizedBoxStatusTimer &&
|
|
893
|
+
this.effectLastNotMinimizedBoxStatusTimer.timer
|
|
894
|
+
) {
|
|
759
895
|
clearTimeout(this.effectLastNotMinimizedBoxStatusTimer.timer);
|
|
760
|
-
if (
|
|
896
|
+
if (
|
|
897
|
+
this.effectLastNotMinimizedBoxStatusTimer.skipUpdate !==
|
|
898
|
+
skipUpdate
|
|
899
|
+
) {
|
|
761
900
|
// this.effectLastNotMinimizedBoxStatusFunc(this.effectLastNotMinimizedBoxStatusTimer.skipUpdate)
|
|
762
901
|
if (this.effectLastNotMinimizedBoxStatusTimer.resolve) {
|
|
763
|
-
|
|
764
|
-
|
|
902
|
+
this.effectLastNotMinimizedBoxStatusTimer.resolve(
|
|
903
|
+
!!this.effectLastNotMinimizedBoxStatusTimer?.skipUpdate
|
|
904
|
+
);
|
|
765
905
|
}
|
|
766
|
-
this.effectLastNotMinimizedBoxStatusTimer.skipUpdate =
|
|
767
|
-
|
|
906
|
+
this.effectLastNotMinimizedBoxStatusTimer.skipUpdate =
|
|
907
|
+
skipUpdate;
|
|
768
908
|
} else {
|
|
769
909
|
return;
|
|
770
910
|
}
|
|
@@ -777,58 +917,58 @@ export class TeleBoxManager {
|
|
|
777
917
|
} as {
|
|
778
918
|
skipUpdate: boolean;
|
|
779
919
|
timer: number | undefined;
|
|
780
|
-
}
|
|
920
|
+
};
|
|
781
921
|
}
|
|
782
922
|
if (this.effectLastNotMinimizedBoxStatusTimer) {
|
|
783
|
-
const _skipUpdate = await new Promise<boolean>((resolve)=>{
|
|
923
|
+
const _skipUpdate = await new Promise<boolean>((resolve) => {
|
|
784
924
|
this.effectLastNotMinimizedBoxStatusTimer!.resolve = resolve;
|
|
785
|
-
this.effectLastNotMinimizedBoxStatusTimer!.timer = setTimeout(
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
925
|
+
this.effectLastNotMinimizedBoxStatusTimer!.timer = setTimeout(
|
|
926
|
+
() => {
|
|
927
|
+
if (
|
|
928
|
+
this.effectLastNotMinimizedBoxStatusTimer &&
|
|
929
|
+
this.effectLastNotMinimizedBoxStatusTimer.resolve
|
|
930
|
+
) {
|
|
931
|
+
this.effectLastNotMinimizedBoxStatusTimer.resolve(
|
|
932
|
+
this.effectLastNotMinimizedBoxStatusTimer!
|
|
933
|
+
.skipUpdate
|
|
934
|
+
);
|
|
935
|
+
}
|
|
936
|
+
},
|
|
937
|
+
100
|
|
938
|
+
) as unknown as number;
|
|
939
|
+
});
|
|
940
|
+
this.effectLastNotMinimizedBoxStatusFunc(_skipUpdate);
|
|
794
941
|
this.effectLastNotMinimizedBoxStatusTimer = undefined;
|
|
795
|
-
console.log("effectLastNotMinimizedBoxStatusFunc===>000==>11", skipUpdate, this.boxes$.value.map((b)=>({id:b.id,focus:b.focus, boxStatus:b.boxStatus,zIndex:b.zIndex, lastNotMinimizedBoxStatus:b._lastNotMinimizedBoxStatus$.value})));
|
|
796
942
|
}
|
|
797
943
|
}
|
|
798
944
|
|
|
799
|
-
|
|
945
|
+
protected effectLastNotMinimizedBoxStatusFunc(skipUpdate = false) {
|
|
800
946
|
if (!this.useBoxesStatus) {
|
|
801
947
|
return;
|
|
802
948
|
}
|
|
803
|
-
console.log("effectLastNotMinimizedBoxStatusFunc===>end", skipUpdate);
|
|
804
949
|
this.boxes.forEach((box) => {
|
|
805
950
|
const boxStatus = this.lastNotMinimizedBoxesStatus$.get(box.id);
|
|
806
|
-
if(boxStatus){
|
|
951
|
+
if (boxStatus) {
|
|
807
952
|
box.setLastNotMinimizedBoxStatus(boxStatus, skipUpdate);
|
|
808
953
|
}
|
|
809
954
|
});
|
|
810
955
|
}
|
|
811
956
|
|
|
812
|
-
|
|
957
|
+
protected getUnabledBoxesStatusZIndex(): number {
|
|
813
958
|
return this.topBox ? this.topBox.zIndex : 99;
|
|
814
959
|
}
|
|
815
960
|
|
|
816
|
-
// private getTopBoxZIndex(): number {
|
|
817
|
-
// if (!this.useBoxesStatus) {
|
|
818
|
-
// return this.getUnabledBoxesStatusZIndex();
|
|
819
|
-
// }
|
|
820
|
-
// return [...this.boxes].filter((box) => box.boxStatus !== TELE_BOX_STATE.Minimized).reduce((maxZIndex, box) => {
|
|
821
|
-
// return Math.max(maxZIndex, box.zIndex);
|
|
822
|
-
// }, 100);
|
|
823
|
-
// }
|
|
824
|
-
|
|
825
961
|
/** Maximized box zIndex range: 100-299 */
|
|
826
962
|
public getMaxMaximizedBoxZIndex(): number {
|
|
827
963
|
if (!this.useBoxesStatus) {
|
|
828
964
|
return this.getUnabledBoxesStatusZIndex();
|
|
829
965
|
}
|
|
830
966
|
return this.boxes.reduce((maxZIndex, box) => {
|
|
831
|
-
if (
|
|
967
|
+
if (
|
|
968
|
+
box.boxStatus &&
|
|
969
|
+
box.boxStatus === TELE_BOX_STATE.Maximized &&
|
|
970
|
+
!this.isForceTop(box)
|
|
971
|
+
) {
|
|
832
972
|
return Math.max(maxZIndex, box.zIndex);
|
|
833
973
|
}
|
|
834
974
|
return maxZIndex;
|
|
@@ -841,20 +981,45 @@ export class TeleBoxManager {
|
|
|
841
981
|
return this.getUnabledBoxesStatusZIndex();
|
|
842
982
|
}
|
|
843
983
|
return this.boxes.reduce((maxZIndex, box) => {
|
|
844
|
-
if (
|
|
984
|
+
if (
|
|
985
|
+
box.boxStatus &&
|
|
986
|
+
box.boxStatus === TELE_BOX_STATE.Normal &&
|
|
987
|
+
!this.isForceTop(box)
|
|
988
|
+
) {
|
|
845
989
|
return Math.max(maxZIndex, box.zIndex);
|
|
846
990
|
}
|
|
847
991
|
return maxZIndex;
|
|
848
992
|
}, 299);
|
|
849
993
|
}
|
|
850
994
|
|
|
995
|
+
public getMaxForceTopBoxZIndex(): number {
|
|
996
|
+
if (!this.useBoxesStatus) {
|
|
997
|
+
return this.getUnabledBoxesStatusZIndex();
|
|
998
|
+
}
|
|
999
|
+
return this.boxes.reduce((maxZIndex, box) => {
|
|
1000
|
+
if (box.boxStatus && this.isForceTop(box)) {
|
|
1001
|
+
return Math.max(maxZIndex, box.zIndex);
|
|
1002
|
+
}
|
|
1003
|
+
return maxZIndex;
|
|
1004
|
+
}, 699);
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
public isForceNormal(box: TeleBox): boolean {
|
|
1008
|
+
return box._forceNormal$.value;
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
public isForceTop(box: TeleBox): boolean {
|
|
1012
|
+
return box._forceTop$.value;
|
|
1013
|
+
}
|
|
1014
|
+
|
|
851
1015
|
public create(
|
|
852
1016
|
config: TeleBoxManagerCreateConfig = {},
|
|
853
1017
|
smartPosition = true
|
|
854
1018
|
): ReadonlyTeleBox {
|
|
855
|
-
console.log("create===>", config, this.topBox?.zIndex);
|
|
856
1019
|
const box = new TeleBox({
|
|
857
|
-
zIndex:
|
|
1020
|
+
zIndex: config.forceTop
|
|
1021
|
+
? this.getMaxForceTopBoxZIndex() + 1
|
|
1022
|
+
: this.getMaxNormalBoxZIndex() + 1,
|
|
858
1023
|
...(smartPosition ? this.smartPosition(config) : config),
|
|
859
1024
|
darkMode: this.darkMode,
|
|
860
1025
|
prefersColorScheme: this.prefersColorScheme,
|
|
@@ -864,6 +1029,7 @@ export class TeleBoxManager {
|
|
|
864
1029
|
namespace: this.namespace,
|
|
865
1030
|
containerRect: this.containerRect,
|
|
866
1031
|
readonly: this.readonly,
|
|
1032
|
+
forceMaximized: this.forceMaximized,
|
|
867
1033
|
collectorRect: this.collectorRect,
|
|
868
1034
|
});
|
|
869
1035
|
|
|
@@ -872,10 +1038,15 @@ export class TeleBoxManager {
|
|
|
872
1038
|
this.boxes$.setValue([...this.boxes, box]);
|
|
873
1039
|
|
|
874
1040
|
if (box.boxStatus && this.useBoxesStatus) {
|
|
875
|
-
this.setBox(
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
1041
|
+
this.setBox(
|
|
1042
|
+
box,
|
|
1043
|
+
{
|
|
1044
|
+
status: box.boxStatus,
|
|
1045
|
+
lastNotMinimizedBoxStatus:
|
|
1046
|
+
box._lastNotMinimizedBoxStatus$.value,
|
|
1047
|
+
},
|
|
1048
|
+
true
|
|
1049
|
+
);
|
|
879
1050
|
}
|
|
880
1051
|
|
|
881
1052
|
if (box.focus) {
|
|
@@ -887,42 +1058,68 @@ export class TeleBoxManager {
|
|
|
887
1058
|
|
|
888
1059
|
box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Maximize, () => {
|
|
889
1060
|
if (this.useBoxesStatus && box.boxStatus) {
|
|
1061
|
+
if (box._forceNormal$.value) {
|
|
1062
|
+
return;
|
|
1063
|
+
}
|
|
890
1064
|
if (box.boxStatus === TELE_BOX_STATE.Maximized) {
|
|
891
|
-
this.setBox(
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
1065
|
+
this.setBox(
|
|
1066
|
+
box.id,
|
|
1067
|
+
{
|
|
1068
|
+
status: TELE_BOX_STATE.Normal,
|
|
1069
|
+
zIndex: this.getMaxNormalBoxZIndex() + 1,
|
|
1070
|
+
},
|
|
1071
|
+
false
|
|
1072
|
+
);
|
|
895
1073
|
} else {
|
|
896
1074
|
// 所有normal box都最大化
|
|
897
|
-
[...this.boxes]
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
1075
|
+
[...this.boxes]
|
|
1076
|
+
.filter(
|
|
1077
|
+
(box) =>
|
|
1078
|
+
box.boxStatus === TELE_BOX_STATE.Normal &&
|
|
1079
|
+
!this.isForceNormal(box)
|
|
1080
|
+
)
|
|
1081
|
+
.sort((a, b) => a.zIndex - b.zIndex)
|
|
1082
|
+
.forEach((box) => {
|
|
1083
|
+
if (box.boxStatus === TELE_BOX_STATE.Normal) {
|
|
1084
|
+
this.setBox(
|
|
1085
|
+
box.id,
|
|
1086
|
+
{
|
|
1087
|
+
status: TELE_BOX_STATE.Maximized,
|
|
1088
|
+
zIndex:
|
|
1089
|
+
this.getMaxMaximizedBoxZIndex() + 1,
|
|
1090
|
+
},
|
|
1091
|
+
false
|
|
1092
|
+
);
|
|
1093
|
+
}
|
|
1094
|
+
});
|
|
906
1095
|
this.makeMaximizedTopBoxFocus();
|
|
907
1096
|
}
|
|
908
1097
|
} else {
|
|
909
|
-
|
|
1098
|
+
if (!(this.forceMaximized && this.maximized)) {
|
|
1099
|
+
this.setMaximized(!this.maximized);
|
|
1100
|
+
}
|
|
910
1101
|
}
|
|
911
|
-
|
|
912
1102
|
});
|
|
913
1103
|
box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Minimize, () => {
|
|
914
1104
|
if (box.boxStatus && this.useBoxesStatus) {
|
|
915
|
-
if(box.
|
|
1105
|
+
if (box._forceNormal$.value) {
|
|
1106
|
+
return;
|
|
1107
|
+
}
|
|
1108
|
+
if (box.focus) {
|
|
916
1109
|
this.blurBox(box);
|
|
917
1110
|
}
|
|
918
|
-
this.setBox(
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
1111
|
+
this.setBox(
|
|
1112
|
+
box,
|
|
1113
|
+
{
|
|
1114
|
+
status: TELE_BOX_STATE.Minimized,
|
|
1115
|
+
zIndex: -1,
|
|
1116
|
+
},
|
|
1117
|
+
false,
|
|
1118
|
+
() => {
|
|
1119
|
+
this.focusTopBox();
|
|
1120
|
+
}
|
|
1121
|
+
);
|
|
1122
|
+
} else {
|
|
926
1123
|
this.setMinimized(true);
|
|
927
1124
|
}
|
|
928
1125
|
});
|
|
@@ -960,10 +1157,15 @@ export class TeleBoxManager {
|
|
|
960
1157
|
});
|
|
961
1158
|
box._zIndex$.reaction((_, __, skipUpdate) => {
|
|
962
1159
|
if (this.boxes.length > 0) {
|
|
963
|
-
console.log("topBox===>_zIndex", this.boxes.map((box) => ({id: box.id, zIndex: box.zIndex, boxStatus: box.boxStatus})));
|
|
964
1160
|
let currentTopBox: TeleBox | undefined = undefined;
|
|
965
1161
|
const topBox = this.boxes.reduce((topBox, box) => {
|
|
966
|
-
if (
|
|
1162
|
+
if (this.isForceTop(box)) {
|
|
1163
|
+
return topBox;
|
|
1164
|
+
}
|
|
1165
|
+
if (
|
|
1166
|
+
box.boxStatus &&
|
|
1167
|
+
box.boxStatus === TELE_BOX_STATE.Minimized
|
|
1168
|
+
) {
|
|
967
1169
|
return topBox;
|
|
968
1170
|
}
|
|
969
1171
|
if (!topBox) {
|
|
@@ -971,8 +1173,7 @@ export class TeleBoxManager {
|
|
|
971
1173
|
return topBox;
|
|
972
1174
|
}
|
|
973
1175
|
return topBox.zIndex > box.zIndex ? topBox : box;
|
|
974
|
-
}, currentTopBox as
|
|
975
|
-
console.log("topBox===>_zIndex===>end", topBox?.id);
|
|
1176
|
+
}, currentTopBox as TeleBox | undefined);
|
|
976
1177
|
this.topBox$.setValue(topBox);
|
|
977
1178
|
}
|
|
978
1179
|
if (!skipUpdate) {
|
|
@@ -1018,14 +1219,19 @@ export class TeleBoxManager {
|
|
|
1018
1219
|
});
|
|
1019
1220
|
}
|
|
1020
1221
|
|
|
1021
|
-
public setBox(
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1222
|
+
public setBox(
|
|
1223
|
+
boxOrID: string | TeleBox,
|
|
1224
|
+
options: {
|
|
1225
|
+
status?: TeleBoxState;
|
|
1226
|
+
lastNotMinimizedBoxStatus?: NotMinimizedBoxState;
|
|
1227
|
+
zIndex?: number;
|
|
1228
|
+
},
|
|
1229
|
+
skipUpdate = false,
|
|
1230
|
+
effectFunc?: () => void
|
|
1231
|
+
) {
|
|
1232
|
+
const box = this.getBox(boxOrID);
|
|
1027
1233
|
if (box) {
|
|
1028
|
-
const {status, zIndex, lastNotMinimizedBoxStatus} = options;
|
|
1234
|
+
const { status, zIndex, lastNotMinimizedBoxStatus } = options;
|
|
1029
1235
|
if (status) {
|
|
1030
1236
|
this.setBoxStatus(box.id, status, skipUpdate);
|
|
1031
1237
|
box.setBoxStatus(status, skipUpdate);
|
|
@@ -1035,8 +1241,15 @@ export class TeleBoxManager {
|
|
|
1035
1241
|
box.setZIndex(zIndex, skipUpdate);
|
|
1036
1242
|
}
|
|
1037
1243
|
if (lastNotMinimizedBoxStatus) {
|
|
1038
|
-
this.setLastNotMinimizedBoxStatus(
|
|
1039
|
-
|
|
1244
|
+
this.setLastNotMinimizedBoxStatus(
|
|
1245
|
+
box.id,
|
|
1246
|
+
lastNotMinimizedBoxStatus,
|
|
1247
|
+
skipUpdate
|
|
1248
|
+
);
|
|
1249
|
+
box.setLastNotMinimizedBoxStatus(
|
|
1250
|
+
lastNotMinimizedBoxStatus,
|
|
1251
|
+
skipUpdate
|
|
1252
|
+
);
|
|
1040
1253
|
}
|
|
1041
1254
|
effectFunc && effectFunc();
|
|
1042
1255
|
}
|
|
@@ -1056,12 +1269,16 @@ export class TeleBoxManager {
|
|
|
1056
1269
|
deletedBoxes.forEach((box) => box.destroy());
|
|
1057
1270
|
if (box && this.useBoxesStatus) {
|
|
1058
1271
|
this.setBoxStatus(box.id, undefined, skipUpdate);
|
|
1059
|
-
this.setLastNotMinimizedBoxStatus(
|
|
1272
|
+
this.setLastNotMinimizedBoxStatus(
|
|
1273
|
+
box.id,
|
|
1274
|
+
undefined,
|
|
1275
|
+
skipUpdate
|
|
1276
|
+
);
|
|
1060
1277
|
this.effectBoxStatusChange();
|
|
1061
1278
|
effectFunc && effectFunc();
|
|
1062
1279
|
}
|
|
1063
1280
|
if (!skipUpdate) {
|
|
1064
|
-
if (this.boxes.length <= 0) {
|
|
1281
|
+
if (this.boxes.length <= 0 && !this.forceMaximized) {
|
|
1065
1282
|
this.setMaximized(false);
|
|
1066
1283
|
this.setMinimized(false);
|
|
1067
1284
|
}
|
|
@@ -1086,7 +1303,7 @@ export class TeleBoxManager {
|
|
|
1086
1303
|
this.boxesStatus$.clear();
|
|
1087
1304
|
this.lastNotMinimizedBoxesStatus$.clear();
|
|
1088
1305
|
if (!skipUpdate) {
|
|
1089
|
-
if (this.boxes.length <= 0) {
|
|
1306
|
+
if (this.boxes.length <= 0 && !this.forceMaximized) {
|
|
1090
1307
|
this.setMaximized(false);
|
|
1091
1308
|
this.setMinimized(false);
|
|
1092
1309
|
}
|
|
@@ -1134,7 +1351,10 @@ export class TeleBoxManager {
|
|
|
1134
1351
|
});
|
|
1135
1352
|
if (!this.useBoxesStatus) {
|
|
1136
1353
|
this.maxTitleBar.focusBox(targetBox);
|
|
1137
|
-
} else if (
|
|
1354
|
+
} else if (
|
|
1355
|
+
this.useBoxesStatus &&
|
|
1356
|
+
this.maxTitleBar.hasMaximizedBoxInStatus()
|
|
1357
|
+
) {
|
|
1138
1358
|
this.makeMaximizedTopBoxFocus();
|
|
1139
1359
|
}
|
|
1140
1360
|
}
|
|
@@ -1241,11 +1461,24 @@ export class TeleBoxManager {
|
|
|
1241
1461
|
if (config.footer != null) {
|
|
1242
1462
|
box.mountFooter(config.footer);
|
|
1243
1463
|
}
|
|
1244
|
-
if (
|
|
1245
|
-
this.
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1464
|
+
if (
|
|
1465
|
+
this.useBoxesStatus &&
|
|
1466
|
+
(config.boxStatus || config.lastNotMinimizedBoxStatus)
|
|
1467
|
+
) {
|
|
1468
|
+
this.setBox(
|
|
1469
|
+
box,
|
|
1470
|
+
{
|
|
1471
|
+
status: config.boxStatus,
|
|
1472
|
+
lastNotMinimizedBoxStatus: config.lastNotMinimizedBoxStatus,
|
|
1473
|
+
},
|
|
1474
|
+
skipUpdate
|
|
1475
|
+
);
|
|
1476
|
+
}
|
|
1477
|
+
if (config.forceTop != null) {
|
|
1478
|
+
box.setForceTop(config.forceTop, skipUpdate);
|
|
1479
|
+
}
|
|
1480
|
+
if (config.forceNormal != null) {
|
|
1481
|
+
box.setForceNormal(config.forceNormal, skipUpdate);
|
|
1249
1482
|
}
|
|
1250
1483
|
}
|
|
1251
1484
|
|
|
@@ -1255,7 +1488,19 @@ export class TeleBoxManager {
|
|
|
1255
1488
|
|
|
1256
1489
|
if (x == null) {
|
|
1257
1490
|
let vx = 20;
|
|
1258
|
-
if (
|
|
1491
|
+
if (config.forceTop) {
|
|
1492
|
+
const forceTopBox = this.maxForceTopBox || this.topBox;
|
|
1493
|
+
if (forceTopBox) {
|
|
1494
|
+
vx = forceTopBox.intrinsicX * this.containerRect.width + 20;
|
|
1495
|
+
if (
|
|
1496
|
+
vx >
|
|
1497
|
+
this.containerRect.width -
|
|
1498
|
+
width * this.containerRect.width
|
|
1499
|
+
) {
|
|
1500
|
+
vx = 20;
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
} else if (this.topBox) {
|
|
1259
1504
|
vx = this.topBox.intrinsicX * this.containerRect.width + 20;
|
|
1260
1505
|
if (
|
|
1261
1506
|
vx >
|
|
@@ -1265,17 +1510,42 @@ export class TeleBoxManager {
|
|
|
1265
1510
|
}
|
|
1266
1511
|
} else if (this.hasMinimizedBox()) {
|
|
1267
1512
|
// 如果都最小化,则获取lastNotMinimizedBoxesStatus中normal box的最大x
|
|
1268
|
-
vx = [...this.boxes]
|
|
1269
|
-
|
|
1270
|
-
|
|
1513
|
+
vx = [...this.boxes]
|
|
1514
|
+
.filter(
|
|
1515
|
+
(box) =>
|
|
1516
|
+
box.boxStatus &&
|
|
1517
|
+
box.boxStatus === TELE_BOX_STATE.Minimized &&
|
|
1518
|
+
box.lastNotMinimizedBoxStatus &&
|
|
1519
|
+
box.lastNotMinimizedBoxStatus ===
|
|
1520
|
+
TELE_BOX_STATE.Normal
|
|
1521
|
+
)
|
|
1522
|
+
.reduce((maxX, box) => {
|
|
1523
|
+
return Math.max(
|
|
1524
|
+
maxX,
|
|
1525
|
+
box.intrinsicX * this.containerRect.width + 20
|
|
1526
|
+
);
|
|
1527
|
+
}, vx);
|
|
1271
1528
|
}
|
|
1272
1529
|
x = vx / this.containerRect.width;
|
|
1273
1530
|
}
|
|
1274
1531
|
|
|
1275
1532
|
if (y == null) {
|
|
1276
1533
|
let vy = 20;
|
|
1277
|
-
|
|
1278
|
-
|
|
1534
|
+
if (config.forceTop) {
|
|
1535
|
+
const forceTopBox = this.maxForceTopBox || this.topBox;
|
|
1536
|
+
if (forceTopBox) {
|
|
1537
|
+
vy =
|
|
1538
|
+
forceTopBox.intrinsicY * this.containerRect.height + 20;
|
|
1539
|
+
|
|
1540
|
+
if (
|
|
1541
|
+
vy >
|
|
1542
|
+
this.containerRect.height -
|
|
1543
|
+
height * this.containerRect.height
|
|
1544
|
+
) {
|
|
1545
|
+
vy = 20;
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
} else if (this.topBox) {
|
|
1279
1549
|
vy = this.topBox.intrinsicY * this.containerRect.height + 20;
|
|
1280
1550
|
|
|
1281
1551
|
if (
|
|
@@ -1287,9 +1557,21 @@ export class TeleBoxManager {
|
|
|
1287
1557
|
}
|
|
1288
1558
|
} else if (this.hasMinimizedBox()) {
|
|
1289
1559
|
// 如果都最小化,则获取lastNotMinimizedBoxesStatus中normal box的最大y
|
|
1290
|
-
vy = [...this.boxes]
|
|
1291
|
-
|
|
1292
|
-
|
|
1560
|
+
vy = [...this.boxes]
|
|
1561
|
+
.filter(
|
|
1562
|
+
(box) =>
|
|
1563
|
+
box.boxStatus &&
|
|
1564
|
+
box.boxStatus === TELE_BOX_STATE.Minimized &&
|
|
1565
|
+
box.lastNotMinimizedBoxStatus &&
|
|
1566
|
+
box.lastNotMinimizedBoxStatus ===
|
|
1567
|
+
TELE_BOX_STATE.Normal
|
|
1568
|
+
)
|
|
1569
|
+
.reduce((maxY, box) => {
|
|
1570
|
+
return Math.max(
|
|
1571
|
+
maxY,
|
|
1572
|
+
box.intrinsicY * this.containerRect.height + 20
|
|
1573
|
+
);
|
|
1574
|
+
}, vy);
|
|
1293
1575
|
}
|
|
1294
1576
|
|
|
1295
1577
|
y = vy / this.containerRect.height;
|
|
@@ -1308,18 +1590,22 @@ export class TeleBoxManager {
|
|
|
1308
1590
|
}
|
|
1309
1591
|
}
|
|
1310
1592
|
|
|
1311
|
-
|
|
1593
|
+
protected getMaximizedTopBox(): MaxTitleBarTeleBox | undefined {
|
|
1312
1594
|
if (!this.useBoxesStatus) {
|
|
1313
1595
|
return undefined;
|
|
1314
1596
|
}
|
|
1315
1597
|
let maximizedBox: MaxTitleBarTeleBox | undefined;
|
|
1316
1598
|
if (this.maxTitleBar.hasMaximizedBoxInStatus()) {
|
|
1317
|
-
maximizedBox = this.maxTitleBar.MaximizedBoxes.reduce(
|
|
1318
|
-
|
|
1319
|
-
|
|
1599
|
+
maximizedBox = this.maxTitleBar.MaximizedBoxes.reduce(
|
|
1600
|
+
(topBox, currentBox) => {
|
|
1601
|
+
if (!topBox) {
|
|
1602
|
+
return currentBox;
|
|
1603
|
+
}
|
|
1604
|
+
return topBox.zIndex > currentBox.zIndex
|
|
1605
|
+
? topBox
|
|
1606
|
+
: currentBox;
|
|
1320
1607
|
}
|
|
1321
|
-
|
|
1322
|
-
}, );
|
|
1608
|
+
);
|
|
1323
1609
|
}
|
|
1324
1610
|
return maximizedBox;
|
|
1325
1611
|
}
|
|
@@ -1328,10 +1614,9 @@ export class TeleBoxManager {
|
|
|
1328
1614
|
if (!this.useBoxesStatus) {
|
|
1329
1615
|
return;
|
|
1330
1616
|
}
|
|
1331
|
-
const maximizedBox: MaxTitleBarTeleBox | undefined =
|
|
1332
|
-
|
|
1617
|
+
const maximizedBox: MaxTitleBarTeleBox | undefined =
|
|
1618
|
+
this.getMaximizedTopBox();
|
|
1333
1619
|
this.maxTitleBar.focusBox(maximizedBox);
|
|
1334
|
-
console.log("makeMaximizedTopBoxFocus===>end", maximizedBox?.id);
|
|
1335
1620
|
}
|
|
1336
1621
|
|
|
1337
1622
|
protected getBoxIndex(boxOrID: TeleBox | string): number {
|
|
@@ -1346,15 +1631,15 @@ export class TeleBoxManager {
|
|
|
1346
1631
|
: boxOrID;
|
|
1347
1632
|
}
|
|
1348
1633
|
|
|
1349
|
-
public createMinimizedAppMenu():AppMenu | undefined {
|
|
1634
|
+
public createMinimizedAppMenu(): AppMenu | undefined {
|
|
1350
1635
|
if (this.collector?.$appMenuContainer) {
|
|
1351
1636
|
return new AppMenu({
|
|
1352
1637
|
manager: this,
|
|
1353
1638
|
container: this.collector?.$appMenuContainer,
|
|
1354
|
-
theme: this.prefersColorScheme ?
|
|
1639
|
+
theme: this.prefersColorScheme ? "dark" : "light",
|
|
1355
1640
|
getBoxesStatus: () => {
|
|
1356
1641
|
return this.boxesStatus$;
|
|
1357
|
-
}
|
|
1642
|
+
},
|
|
1358
1643
|
});
|
|
1359
1644
|
}
|
|
1360
1645
|
return;
|