Skip to content

Commit

Permalink
fix: 修改tree-node 组件
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBeard30 committed Mar 29, 2024
1 parent d502711 commit 8b54ccd
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/app/components/widgets/tree-node/tree-node.widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import {
Component,
Input,
OnChanges,
OnDestroy,
SimpleChanges,
ViewChild,
ViewContainerRef
} from '@angular/core';
import { TreeNode } from '@/app/core/models';
import { NgTemplateOutlet } from '@angular/common';
import { WidgetFactory } from '@/app/pages/home/register';
import { fromEvent, Subject, takeUntil } from 'rxjs';

@Component({
selector: 'app-tree-node-widget',
Expand All @@ -38,22 +40,32 @@ import { WidgetFactory } from '@/app/pages/home/register';
imports: [NgTemplateOutlet],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class TreeNodeWidget implements OnChanges, AfterViewInit {
export class TreeNodeWidget implements OnChanges, AfterViewInit, OnDestroy {
@Input() node: TreeNode;

@ViewChild('container', { read: ViewContainerRef }) container: ViewContainerRef;

component: string;

destroy$ = new Subject<void>();

constructor(
private factory: WidgetFactory,
private cdr: ChangeDetectorRef
) {}

ngOnDestroy(): void {
this.destroy$.next();
this.destroy$.complete();
}

ngAfterViewInit(): void {
setInterval(() => {
this.cdr.markForCheck();
}, 1000);
fromEvent(window, 'mouseup')
.pipe(takeUntil(this.destroy$))
.subscribe(ev => {
console.log('tree-node-widget>>>', ev);
this.cdr.markForCheck();
});
}

ngOnChanges(changes: SimpleChanges): void {
Expand Down

0 comments on commit 8b54ccd

Please sign in to comment.