-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #207 from GuoXiCheng/dev-c
Dev
- Loading branch information
Showing
7 changed files
with
338 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
app/src/main/java/com/android/skip/dataclass/NodeRootSchema.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
package com.android.skip.dataclass | ||
|
||
data class NodeRootSchema( | ||
val uuid: String, | ||
val appName: String, | ||
val packageName: String, | ||
val className: String, | ||
val activityName: String, | ||
val screenHeight: Int, | ||
val screenWidth: Int, | ||
val createTime: Long, | ||
val nodes: MutableList<NodeChildSchema> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,87 @@ | ||
<template> | ||
<el-row class="h-screen"> | ||
<el-col :span="6"> | ||
<NodePic v-if="rawData" :raw-data="rawData" :img-src="imgSrc" :current-node-key="currentNodeKey" | ||
@handle-img-node-click="handleImgNodeClick" /> | ||
</el-col> | ||
<el-col :span="9" class="h-full overflow-y-auto"> | ||
<NodeTree v-if="treeData" :tree-data="treeData" :current-node-key="currentNodeKey" | ||
@handle-tree-node-click="handleTreeNodeClick" /> | ||
</el-col> | ||
<el-col :span="9"> | ||
<NodeTable :node-data="nodeData" /> | ||
</el-col> | ||
</el-row> | ||
<el-row class="h-screen"> | ||
<el-col :span="6"> | ||
<NodePic | ||
:raw-data="rawData" | ||
:img-src="imgSrc" | ||
:current-node-key="currentNodeKey" | ||
@handle-img-node-click="handleImgNodeClick" | ||
v-if="rawData" | ||
/> | ||
</el-col> | ||
<el-col :span="9" class="h-full overflow-y-auto"> | ||
<NodeTree | ||
:tree-data="treeData" | ||
:current-node-key="currentNodeKey" | ||
@handle-tree-node-click="handleTreeNodeClick" | ||
v-if="treeData" | ||
/> | ||
</el-col> | ||
<el-col :span="9"> | ||
<NodeTable :node-data="nodeData" :raw-data="rawData" v-if="rawData" /> | ||
</el-col> | ||
</el-row> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import NodeTree from './NodeTree.vue'; | ||
import NodeTable from './NodeTable.vue'; | ||
import NodePic from './NodePic.vue'; | ||
import { ref, onMounted } from 'vue'; | ||
import { AccessibilityNode, AccessibilityNodeTree, AccessibilityWindow } from './types'; | ||
import JSZip from 'jszip'; | ||
import NodeTree from "./NodeTree.vue"; | ||
import NodeTable from "./NodeTable.vue"; | ||
import NodePic from "./NodePic.vue"; | ||
import { ref, onMounted } from "vue"; | ||
import { AccessibilityNode, AccessibilityNodeTree, AccessibilityWindow } from "./types"; | ||
import JSZip from "jszip"; | ||
const treeData = ref<AccessibilityNodeTree[]>([]); | ||
const nodeData = ref<AccessibilityNode | null>(null); | ||
const rawData = ref<AccessibilityWindow | null>(null); | ||
const currentNodeKey = ref<number>(-1); | ||
const imgSrc = ref<string>(''); | ||
const imgSrc = ref<string>(""); | ||
onMounted(async () => { | ||
const response = await fetch('/1724297451246.zip'); | ||
const arrayBuffer = await response.arrayBuffer(); | ||
const zip = await JSZip.loadAsync(arrayBuffer); | ||
const response = await fetch("/94e04ea4-2502-4c24-a7f1-7574270fa921.zip"); | ||
const arrayBuffer = await response.arrayBuffer(); | ||
const zip = await JSZip.loadAsync(arrayBuffer); | ||
const pngFile = zip.filter((relativePath, file) => relativePath.endsWith('.png')); | ||
const blob = await pngFile[0].async('blob'); | ||
const imgUrl = URL.createObjectURL(blob); | ||
imgSrc.value = imgUrl; | ||
const pngFile = zip.filter((relativePath, file) => relativePath.endsWith(".png")); | ||
const blob = await pngFile[0].async("blob"); | ||
const imgUrl = URL.createObjectURL(blob); | ||
imgSrc.value = imgUrl; | ||
const jsonFile = zip.filter((relativePath, file) => relativePath.endsWith('.json')); | ||
const jsonText = await jsonFile[0].async('text'); | ||
const data = JSON.parse(jsonText) as AccessibilityWindow; | ||
rawData.value = data; | ||
treeData.value = buildTree(data.nodes, -1); | ||
const jsonFile = zip.filter((relativePath, file) => relativePath.endsWith(".json")); | ||
const jsonText = await jsonFile[0].async("text"); | ||
const data = JSON.parse(jsonText) as AccessibilityWindow; | ||
rawData.value = data; | ||
treeData.value = buildTree(data.nodes, -1); | ||
}); | ||
function buildTree(data: AccessibilityNode[], parentId: number): AccessibilityNodeTree[] { | ||
const children = data.filter(node => node.parentId === parentId); | ||
return children.map(node => { | ||
const { childCount, className, nodeId, text, viewIdResourceName, left, top, right, bottom } = node; | ||
return { | ||
label: childCount === 0 ? className : `${className} [${childCount}]`, | ||
children: buildTree(data, nodeId), | ||
text, | ||
className, | ||
childCount, | ||
viewIdResourceName, | ||
left, | ||
top, | ||
right, | ||
bottom, | ||
nodeId | ||
} | ||
}) | ||
const children = data.filter((node) => node.parentId === parentId); | ||
return children.map((node) => { | ||
const { childCount, className, nodeId, text, viewIdResourceName, left, top, right, bottom, isClickable } = node; | ||
return { | ||
label: childCount === 0 ? className : `${className} [${childCount}]`, | ||
children: buildTree(data, nodeId), | ||
text, | ||
className, | ||
childCount, | ||
viewIdResourceName, | ||
left, | ||
top, | ||
right, | ||
bottom, | ||
nodeId, | ||
isClickable, | ||
}; | ||
}); | ||
} | ||
const handleTreeNodeClick = (data: AccessibilityNode) => { | ||
nodeData.value = data; | ||
currentNodeKey.value = data.nodeId; | ||
} | ||
nodeData.value = data; | ||
currentNodeKey.value = data.nodeId; | ||
}; | ||
const handleImgNodeClick = (data: AccessibilityNode) => { | ||
nodeData.value = data; | ||
currentNodeKey.value = data.nodeId; | ||
} | ||
</script> | ||
nodeData.value = data; | ||
currentNodeKey.value = data.nodeId; | ||
}; | ||
</script> |
Oops, something went wrong.