Skip to content

Commit

Permalink
Merge pull request #255 from GuoXiCheng/dev-c
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
GuoXiCheng authored Sep 26, 2024
2 parents 85bff99 + b12f277 commit 93341e3
Show file tree
Hide file tree
Showing 9 changed files with 343 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,5 @@ coverage
scripts/__tests__/examples/dist
!scripts/__tests__/examples/dist/.gitkeep
*.zip
!capture/*.zip
!capture/*.zip
!5f686585-c5d0-4057-93b2-c54832ffb393.zip
2 changes: 1 addition & 1 deletion docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default defineConfig(
{ text: "首页", link: "/" },
{ text: "指南", link: "/guide/intro/what-is-skip" },
{ text: "进阶", link: "/advance/layout-inspect/intro" },
// { text: "布局检查", link: "/inspect/index", target: "_blank" },
{ text: "布局检查", link: "/inspect/index", target: "_blank" },
],
sidebar: {
"/guide/": [
Expand Down
6 changes: 5 additions & 1 deletion docs/inspect/InspectContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
:style="{ width: `${nodeTreeWidth}px` }"
/>
<div class="bg-gray-400 w-2 cursor-col-resize hover:bg-blue-700 transition duration-300" ref="colResize"></div>
<NodeTable :node-data="nodeData" :raw-data="rawData" v-if="rawData" :style="{ width: `${nodeTableWidth}px` }" />
<div class="flex flex-col">
<NodeTable :node-data="nodeData" :raw-data="rawData" v-if="rawData" :style="{ width: `${nodeTableWidth}px` }" />
<NodeCode :node-data="nodeData" :raw-data="rawData" :current-node-key="currentNodeKey" />
</div>
</el-col>
</el-row>
</template>
Expand All @@ -28,6 +31,7 @@
import NodeTree from "./NodeTree.vue";
import NodeTable from "./NodeTable.vue";
import NodePic from "./NodePic.vue";
import NodeCode from "./inspect-node-container/NodeCode.vue";
import { ref, onMounted, onBeforeUnmount } from "vue";
import { AccessibilityNode, AccessibilityNodeTree, AccessibilityWindow } from "./types";
Expand Down
21 changes: 21 additions & 0 deletions docs/inspect/InspectHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<el-button v-loading.fullscreen.lock="fullscreenLoading">批量上传</el-button>
</el-upload>
<el-button @click="emits('onDelete')">批量删除</el-button>
<el-button @click="handleGetExample">获取示例</el-button>
</div>
</template>

Expand Down Expand Up @@ -50,6 +51,26 @@ const handleOnChange = async () => {
});
};
const handleGetExample = async () => {
const response = await fetch("/5f686585-c5d0-4057-93b2-c54832ffb393.zip");
const arrayBuffer = await response.arrayBuffer();
const { added, extractZip } = useZip(arrayBuffer);
await extractZip();
if (added.value === true) {
emits("uploadSuccess");
ElNotification({
title: "示例文件添加成功",
message: "示例文件添加成功",
type: "success",
});
} else
ElNotification({
title: "示例文件已存在",
message: "示例文件已存在,无需重复添加",
type: "warning",
});
};
onMounted(() => {
const el = document.querySelector<HTMLInputElement>(".el-upload__input")!;
el.oncancel = () => {
Expand Down
2 changes: 1 addition & 1 deletion docs/inspect/NodeTable.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div>
<div class="p-2">
<el-segmented v-model="segmentedValue" :options="options" block />
<el-table :data="tableData" style="width: 100%">
<el-table-column prop="key" label="属性" width="auto" />
Expand Down
94 changes: 94 additions & 0 deletions docs/inspect/inspect-node-container/NodeCode.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<template>
<div class="p-2" v-if="code">
<div class="relative">
<el-button size="small" @click="handleClickCopy" class="absolute top-2 right-2 z-50">{{
copyButtonText
}}</el-button>
<codemirror v-model="code" :extensions="extensions" class="z-0" />
</div>
</div>
</template>

<script lang="ts" setup>
import { oneDark } from "@codemirror/theme-one-dark";
import { yaml } from "@codemirror/lang-yaml";
import { Codemirror } from "vue-codemirror";
import { watch, ref } from "vue";
import { AccessibilityNode, AccessibilityWindow } from "../types";
import jsyaml from "js-yaml";
const copyButtonText = ref("复制");
const code = ref<string | null>(null);
const extensions = [yaml(), oneDark];
const props = defineProps<{
nodeData: AccessibilityNode | null;
rawData: AccessibilityWindow | null;
currentNodeKey: number;
}>();
watch(
() => props.currentNodeKey,
() => {
if (!props.nodeData || !props.rawData) return;
const { packageName, activityName, appName, fileId } = props.rawData;
const { viewIdResourceName, text, left, bottom, right, top } = props.nodeData;
const obj = {
appName,
packageName,
};
const file = `fileId=${fileId}&nodeId=${props.currentNodeKey}`;
const desc = "请填写描述";
if (viewIdResourceName) {
Object.assign(obj, {
skipIds: [
{
id: viewIdResourceName,
activityName,
file,
desc,
},
],
});
code.value = jsyaml.dump([obj]);
return;
} else if (text) {
Object.assign(obj, {
skipTexts: [
{
text,
length: text.length,
activityName,
file,
desc,
},
],
});
code.value = jsyaml.dump([obj]);
return;
} else {
Object.assign(obj, {
skipBounds: [
{
bound: [left, top, right, bottom].join(","),
activityName,
file,
desc,
},
],
});
code.value = jsyaml.dump([obj]);
return;
}
}
);
function handleClickCopy() {
if (!code.value) return;
copyButtonText.value = "已复制✔";
navigator.clipboard.writeText(code.value);
setTimeout(() => {
copyButtonText.value = "复制";
}, 1000);
}
</script>
Binary file not shown.
Loading

0 comments on commit 93341e3

Please sign in to comment.