-
Notifications
You must be signed in to change notification settings - Fork 150
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 #255 from GuoXiCheng/dev-c
Dev
- Loading branch information
Showing
9 changed files
with
343 additions
and
4 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
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
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
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 |
---|---|---|
@@ -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.
Oops, something went wrong.