Skip to content

Commit

Permalink
Merge pull request #39 from baidu/ui
Browse files Browse the repository at this point in the history
🐛 profiler 面板数据:时间区间判断出错
  • Loading branch information
ksky521 authored Jul 1, 2021
2 parents 77be5e6 + 6674f0c commit aeac8c9
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ChangeLog
- [Bugfix]
- Fix incorrect number of components.
- Fix incoreect layout of the san-devtools pannel(chrome extensions) in some special scenes.
- Fix data error in profiler pannel.

1.1.4
-------
Expand Down
2 changes: 1 addition & 1 deletion packages/extensions/src/contentScript/contentScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ if (__DEBUG__) {
console.log('content_script');
}

injector.fromExtensionUrlSync(chrome.runtime.getURL('js/san_devtools_backend.js'));
chrome.runtime && injector.fromExtensionUrlSync(chrome.runtime.getURL('js/san_devtools_backend.js'));
relay();
2 changes: 1 addition & 1 deletion packages/extensions/src/devtoolsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function createDevtoolPanelIfNeeded() {
return;
}
clearInterval(createdCheckInterval);
chrome.devtools.panels.create(
chrome.runtime && chrome.devtools.panels.create(
'San',
chrome.runtime.getURL('/icons/logo128.png'),
'panel.html'
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/components/layout/basicLayout.san
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
document.querySelector(`.${prefix}-right`).style = 'width: 100%';
let parent = document.querySelector(`.${prefix}-wrapper`);
let child = document.querySelector(`.gutter-${status}-wrapper`);
parent.removeChild(child);
child && parent && parent.removeChild(child);
}
}
</script>
Expand Down
9 changes: 4 additions & 5 deletions packages/frontend/src/store/setTreeData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ interface ComponentTreeInfo{
*/
function getIDListFromTreeData(treeData: ComponentTreeData[]) {
let ids: string[] = [];
if (!treeData) {
return ids;
if (treeData) {
treeData.forEach((data: any) => {
data.id && ids.push(data.id);
});
}
treeData.forEach((data: any) => {
data.id && ids.push(data.id);
});
return ids;
}

Expand Down
11 changes: 9 additions & 2 deletions packages/frontend/src/utils/flameJsonGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ function timeFragementCacheHandler(children: TimeFragement[], timeFragment: Time
default: break;
}
}
// 如果数组遍历完了,还是没有找到 case 0 的情况,则直接 push 到 curChildren,并结束深度遍历
if (index === len) {
// 1. 如果数组遍历完了,还是没有找到 case 0 的情况,则直接 push 到 curChildren
// 2. 如果找到了 case 0,并且当前位置的 children 为空,则直接添加到 children 中
if (index === len || curChildren.length === 0) {
curChildren.push(timeFragment);
return;
}
Expand All @@ -147,6 +148,12 @@ function getTimeSlotsRelation(timeSlotA: TimeFragement, timeSlotB: TimeFragement
// 包含关系: startDiff > 0 为 B 包含 A,startDiff < 0 为 A 包含 B
return startDiff < 0 ? 1 : 0;
}
else if (startDiff === 0) {
return endDiff < 0 ? 0 : 1;
}
else if (endDiff === 0) {
return startDiff < 0 ? 1 : 0;
}
else {
if (timeSlotA.start >= timeSlotB.end) {
// timeSlotA 在 timeSlotB 的右边
Expand Down

0 comments on commit aeac8c9

Please sign in to comment.