mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-09 15:04:06 +08:00
屏幕找图去掉从剪贴板获取图片按钮,添加直接截图获取按钮
This commit is contained in:
parent
daef39b02a
commit
89a2e07b13
@ -115,15 +115,15 @@ async function captureScreen(range = "fullscreen") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function captureScreenToFile(range = "fullscreen", path = null) {
|
async function captureScreenToFile(range = "fullscreen", path = null) {
|
||||||
if (!path) return null;
|
if (!path) return;
|
||||||
const result = await captureScreen(range);
|
const result = await captureScreen(range);
|
||||||
if (!result) return null;
|
if (!result) return;
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
path,
|
path,
|
||||||
result.replace("data:image/png;base64,", ""),
|
result.replace("data:image/png;base64,", ""),
|
||||||
"base64"
|
"base64"
|
||||||
);
|
);
|
||||||
return result;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function captureScreenToClipboard(range = "fullscreen") {
|
async function captureScreenToClipboard(range = "fullscreen") {
|
||||||
|
@ -26,9 +26,7 @@
|
|||||||
<template v-else>
|
<template v-else>
|
||||||
<div class="upload-placeholder">
|
<div class="upload-placeholder">
|
||||||
<q-icon name="add_photo_alternate" size="48px" color="grey-6" />
|
<q-icon name="add_photo_alternate" size="48px" color="grey-6" />
|
||||||
<div class="text-grey-6 q-mt-sm">
|
<div class="text-grey-6 q-mt-sm">点击上传或粘贴图片</div>
|
||||||
点击上传或粘贴图片<br />支持从剪贴板读取
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
@ -37,16 +35,16 @@
|
|||||||
<!-- 配置区域 -->
|
<!-- 配置区域 -->
|
||||||
<div class="col-12 col-sm-4">
|
<div class="col-12 col-sm-4">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<!-- 从剪贴板读取按钮 -->
|
<!-- 截图按钮 -->
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<q-btn
|
<q-btn
|
||||||
outline
|
outline
|
||||||
color="primary"
|
color="primary"
|
||||||
class="full-width"
|
class="full-width"
|
||||||
@click="pasteFromClipboard"
|
@click="getImgByCaptureScreen"
|
||||||
>
|
>
|
||||||
<q-icon name="content_paste" class="q-mr-sm" />
|
<q-icon name="crop" class="q-mr-sm" />
|
||||||
从剪贴板读取
|
截图查找
|
||||||
</q-btn>
|
</q-btn>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -157,7 +155,6 @@ export default defineComponent({
|
|||||||
try {
|
try {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onload = (e) => {
|
reader.onload = (e) => {
|
||||||
this.argvs.imagePreview = e.target.result;
|
|
||||||
this.updateArgvs("imagePreview", e.target.result);
|
this.updateArgvs("imagePreview", e.target.result);
|
||||||
};
|
};
|
||||||
reader.readAsDataURL(file);
|
reader.readAsDataURL(file);
|
||||||
@ -176,7 +173,6 @@ export default defineComponent({
|
|||||||
const blob = item.getAsFile();
|
const blob = item.getAsFile();
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onload = (e) => {
|
reader.onload = (e) => {
|
||||||
this.argvs.imagePreview = e.target.result;
|
|
||||||
this.updateArgvs("imagePreview", e.target.result);
|
this.updateArgvs("imagePreview", e.target.result);
|
||||||
};
|
};
|
||||||
reader.readAsDataURL(blob);
|
reader.readAsDataURL(blob);
|
||||||
@ -186,17 +182,16 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
// 从剪贴板读取
|
// 从剪贴板读取
|
||||||
async pasteFromClipboard() {
|
async getImgByCaptureScreen() {
|
||||||
const clipboardImage = quickcommand.readClipboardImage();
|
const img = await quickcomposer.simulate.captureScreenToClipboard({
|
||||||
if (!clipboardImage)
|
type: "area",
|
||||||
return quickcommand.showMessageBox("剪贴板中没有图片", "warning");
|
});
|
||||||
this.argvs.imagePreview = clipboardImage;
|
if (!img) return;
|
||||||
this.updateArgvs("imagePreview", clipboardImage);
|
this.updateArgvs("imagePreview", img);
|
||||||
},
|
},
|
||||||
|
|
||||||
// 清除图片
|
// 清除图片
|
||||||
clearImage() {
|
clearImage() {
|
||||||
this.argvs.imagePreview = "";
|
|
||||||
this.updateArgvs("imagePreview", "");
|
this.updateArgvs("imagePreview", "");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user