Skip to content

Commit 12ed241

Browse files
committed
feat: ui tree display more field
1 parent a05137e commit 12ed241

File tree

4 files changed

+35
-10
lines changed

4 files changed

+35
-10
lines changed

uiviewer/static/css/style.css

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ body, html {
4343
display: flex;
4444
flex-direction: column;
4545
height: 100%;
46+
width: 100%;
4647
}
4748
.header {
4849
height: 65px;
@@ -55,6 +56,7 @@ body, html {
5556
}
5657
.main {
5758
display: flex;
59+
width: 100%;
5860
height: calc(100% - 65px);
5961
}
6062

@@ -66,10 +68,9 @@ body, html {
6668
width: 25%;
6769
background-color: #212933;
6870
border-right: #333844 1px solid;
69-
overflow: auto;
7071
justify-content: center;
7172
align-items: center;
72-
position: relative; /* 确保子元素的绝对定位基于 .left */
73+
position: relative;
7374
}
7475
#screenshotCanvas, #hierarchyCanvas {
7576
position: absolute;
@@ -84,7 +85,9 @@ body, html {
8485
}
8586

8687
.right {
87-
flex: 1;
88+
/* flex: 1; */
89+
width: 45%;
90+
padding-right: 12px;
8891
background-color: #212933;
8992
}
9093

@@ -114,6 +117,7 @@ body, html {
114117

115118
.custom-tree {
116119
overflow: auto;
120+
white-space: nowrap;
117121
}
118122

119123
.custom-table .el-table__row {

uiviewer/static/favicon.ico

3.48 KB
Binary file not shown.

uiviewer/static/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>FastAPI + Vue</title>
6+
<title>UI Viewer</title>
77
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
88
<link rel="stylesheet" type="text/css" href="/static/cdn/unpkg.com/[email protected]/lib/index.css">
99
<link rel="stylesheet" type="text/css" href="/static/css/style.css?v=1.0">
@@ -146,7 +146,7 @@
146146
class="custom-tree"
147147
ref="treeRef"
148148
:data="treeData"
149-
:props="defaultProps"
149+
:props="defaultTreeProps"
150150
@node-click="handleTreeNodeClick"
151151
node-key="_id"
152152
default-expand-all

uiviewer/static/js/index.js

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ new Vue({
2828
selectedNode: null,
2929

3030
treeData: [],
31-
defaultProps: {
31+
defaultTreeProps: {
3232
children: 'children',
33-
label: '_type'
33+
label: this.getTreeLabel
3434
},
3535
nodeFilterText: '',
3636
centerWidth: 500,
@@ -87,7 +87,9 @@ new Vue({
8787
methods: {
8888
initPlatform() {
8989
this.serial = ''
90-
this.isConnected = false;
90+
this.isConnected = false
91+
this.selectedNode = null
92+
this.treeData = []
9193
},
9294
async fetchVersion() {
9395
try {
@@ -375,8 +377,27 @@ new Vue({
375377
},
376378
filterNode(value, data) {
377379
if (!value) return true;
378-
if (!data || !data._type) return false;
379-
return data._type.indexOf(value) !== -1;
380+
if (!data) return false;
381+
const { _type, resourceId, lable, text, id } = data;
382+
const filterMap = {
383+
android: [_type, resourceId, text],
384+
ios: [_type, lable],
385+
harmony: [_type, text, id]
386+
};
387+
const fieldsToFilter = filterMap[this.platform];
388+
const isFieldMatch = fieldsToFilter.some(field => field && field.indexOf(value) !== -1);
389+
const label = this.getTreeLabel(data);
390+
const isLabelMatch = label && label.indexOf(value) !== -1;
391+
return isFieldMatch || isLabelMatch;
392+
},
393+
getTreeLabel(node) {
394+
const { _type="", resourceId, lable, text, id } = node;
395+
const labelMap = {
396+
android: resourceId || text,
397+
ios: lable,
398+
harmony: text || id
399+
};
400+
return `${_type} - ${labelMap[this.platform] || ''}`;
380401
},
381402
copyToClipboard(value) {
382403
const success = copyToClipboard(value);

0 commit comments

Comments
 (0)