feat: 大纲树埋点

This commit is contained in:
wuyue.xht 2020-06-22 09:50:55 +08:00
parent 51025f01f1
commit fa2482151d
3 changed files with 43 additions and 2 deletions

View File

@ -12,7 +12,9 @@ export interface ITreeBoard {
export class TreeMaster {
constructor(readonly designer: Designer) {
let startTime: any;
designer.dragon.onDragstart(() => {
startTime = Date.now() / 1000;
// needs?
this.toVision();
});
@ -33,6 +35,25 @@ export class TreeMaster {
board.scrollToNode(treeNode, detail);
});
});
designer.dragon.onDragend(() => {
const endTime: any = Date.now() / 1000;
const editor = designer?.editor;
const nodes = designer.currentSelection?.getNodes();
editor?.emit('outlinePane.drag', {
selected: nodes
?.map((n) => {
if (!n) {
return;
}
const npm = n?.componentMeta?.npm;
return (
[npm?.package, npm?.componentName].filter((item) => !!item).join('-') || n?.componentMeta?.componentName
);
})
.join('&'),
time: (endTime - startTime).toFixed(2),
});
});
}
private toVision() {

View File

@ -1,6 +1,6 @@
import { Component, KeyboardEvent, FocusEvent, Fragment } from 'react';
import classNames from 'classnames';
import { observer, Title, Tip } from '@ali/lowcode-editor-core';
import { observer, Title, Tip, globalContext, Editor } from '@ali/lowcode-editor-core';
import { IconArrowRight } from '../icons/arrow-right';
import { IconEyeClose } from '../icons/eye-close';
import { IconLock } from '../icons/lock';
@ -165,6 +165,16 @@ class HideBtn extends Component<{ treeNode: TreeNode }> {
onClick={(e) => {
e.stopPropagation();
treeNode.setHidden(!treeNode.hidden);
const editor = globalContext.get(Editor);
const node = treeNode?.node;
const npm = node?.componentMeta?.npm;
const selected =
[npm?.package, npm?.componentName].filter((item) => !!item).join('-') ||
node?.componentMeta?.componentName ||
'';
editor?.emit('outlinePane.hide', {
selected,
});
}}
>
{treeNode.hidden ? <IconEyeClose /> : <IconEye />}

View File

@ -1,5 +1,5 @@
import { Component, MouseEvent as ReactMouseEvent } from 'react';
import { observer } from '@ali/lowcode-editor-core';
import { observer, Editor, globalContext } from '@ali/lowcode-editor-core';
import { isRootNode, Node, DragObjectType, isShaken } from '@ali/lowcode-designer';
import { isFormEvent } from '@ali/lowcode-utils';
import { Tree } from '../tree';
@ -60,6 +60,16 @@ export default class TreeView extends Component<{ tree: Tree }> {
}
} else {
selection.select(id);
const editor = globalContext.get(Editor);
const selectedNode = designer.currentSelection?.getNodes()?.[0];
const npm = selectedNode?.componentMeta?.npm;
const selected =
[npm?.package, npm?.componentName].filter((item) => !!item).join('-') ||
selectedNode?.componentMeta?.componentName ||
'';
editor?.emit('outlinePane.select', {
selected,
});
}
};