mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-30 21:13:02 +08:00
选中文本时显示选项菜单
This commit is contained in:
parent
c4c4c2c803
commit
1e3042d7a0
@ -30,39 +30,15 @@
|
|||||||
</q-avatar>
|
</q-avatar>
|
||||||
<span class="text-weight-bold text-h6">运行结果</span>
|
<span class="text-weight-bold text-h6">运行结果</span>
|
||||||
</div>
|
</div>
|
||||||
<q-btn-group stretch class="no-shadow">
|
<ResultMenu
|
||||||
<q-btn
|
class="no-shadow"
|
||||||
flat
|
:stretch="true"
|
||||||
icon="image"
|
:content="runResult.join('')"
|
||||||
color="primary"
|
:closebtn="!fromUtools"
|
||||||
@click="dataUrlToImg"
|
:textbtn="!enableHtml"
|
||||||
v-show="isDataUrl && !enableHtml"
|
:imagebtn="!enableHtml && isDataUrl"
|
||||||
><q-tooltip>将 DataUrl 转为图片</q-tooltip></q-btn
|
@showImg="showBase64Img"
|
||||||
>
|
/>
|
||||||
<q-btn
|
|
||||||
flat
|
|
||||||
icon="content_paste"
|
|
||||||
color="primary"
|
|
||||||
@click="copyResult"
|
|
||||||
v-show="!enableHtml"
|
|
||||||
><q-tooltip>复制到剪贴板</q-tooltip></q-btn
|
|
||||||
>
|
|
||||||
<q-btn
|
|
||||||
flat
|
|
||||||
icon="send"
|
|
||||||
color="primary"
|
|
||||||
@click="sendResult"
|
|
||||||
v-show="!enableHtml"
|
|
||||||
><q-tooltip>发送到活动窗口</q-tooltip></q-btn
|
|
||||||
>
|
|
||||||
<q-btn
|
|
||||||
flat
|
|
||||||
icon="close"
|
|
||||||
color="negative"
|
|
||||||
v-close-popup
|
|
||||||
v-show="!fromUtools"
|
|
||||||
/>
|
|
||||||
</q-btn-group>
|
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
:style="{ maxHeight: maxHeight - headerHeight + 'px' }"
|
:style="{ maxHeight: maxHeight - headerHeight + 'px' }"
|
||||||
@ -76,9 +52,13 @@
|
|||||||
:runResultStatus="runResultStatus"
|
:runResultStatus="runResultStatus"
|
||||||
:runResult="runResult"
|
:runResult="runResult"
|
||||||
:key="timeStamp"
|
:key="timeStamp"
|
||||||
|
@mouseup="selectHandler"
|
||||||
/>
|
/>
|
||||||
<q-resize-observer @resize="autoHeight" debounce="0" />
|
<q-resize-observer @resize="autoHeight" debounce="0" />
|
||||||
</div>
|
</div>
|
||||||
|
<q-menu v-if="selectText" touch-position @before-hide="clearSelect">
|
||||||
|
<ResultMenu :dense="true" :content="selectText" :textbtn="true" />
|
||||||
|
</q-menu>
|
||||||
</q-card>
|
</q-card>
|
||||||
</q-dialog>
|
</q-dialog>
|
||||||
</div>
|
</div>
|
||||||
@ -90,12 +70,14 @@ import outputTypes from "../js/options/outputTypes.js";
|
|||||||
import specialVars from "../js/options/specialVars.js";
|
import specialVars from "../js/options/specialVars.js";
|
||||||
import commandTypes from "../js/options/commandTypes.js";
|
import commandTypes from "../js/options/commandTypes.js";
|
||||||
import ResultArea from "components/ResultArea.vue";
|
import ResultArea from "components/ResultArea.vue";
|
||||||
|
import ResultMenu from "components/popup/ResultMenu.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { ResultArea },
|
components: { ResultArea, ResultMenu },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
isResultShow: false,
|
isResultShow: false,
|
||||||
|
selectText: null,
|
||||||
runResult: [],
|
runResult: [],
|
||||||
runResultStatus: true,
|
runResultStatus: true,
|
||||||
subInputValue: "",
|
subInputValue: "",
|
||||||
@ -364,21 +346,14 @@ export default {
|
|||||||
}
|
}
|
||||||
return [html.documentElement.innerHTML];
|
return [html.documentElement.innerHTML];
|
||||||
},
|
},
|
||||||
copyResult() {
|
selectHandler() {
|
||||||
utools.copyText(this.runResult.join("\n"));
|
this.selectText = window.getSelection().toString().trim();
|
||||||
quickcommand.showMessageBox("已复制到剪贴板");
|
|
||||||
},
|
},
|
||||||
sendResult() {
|
clearSelect() {
|
||||||
utools.copyText(this.runResult.join("\n"));
|
window.getSelection().removeAllRanges();
|
||||||
utools.hideMainWindow();
|
this.selectText = null;
|
||||||
quickcommand.simulatePaste();
|
|
||||||
},
|
},
|
||||||
dataUrlToImg() {
|
showBase64Img(imgs) {
|
||||||
let imgs = this.runResult
|
|
||||||
.join("\n")
|
|
||||||
.match(/data:image\/.*?;base64,.*/g)
|
|
||||||
?.map((dataUrl) => `<img src="${dataUrl}"><br>`);
|
|
||||||
if (!imgs) return quickcommand.showMessageBox("dataUrl 格式不正确!");
|
|
||||||
this.runResult = [];
|
this.runResult = [];
|
||||||
this.enableHtml = true;
|
this.enableHtml = true;
|
||||||
this.showRunResult(imgs, true);
|
this.showRunResult(imgs, true);
|
||||||
|
55
src/components/popup/ResultMenu.vue
Normal file
55
src/components/popup/ResultMenu.vue
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<template>
|
||||||
|
<q-btn-group :stretch="stretch" class="text-primary">
|
||||||
|
<q-btn icon="image" @click="dataUrlToImg" v-show="imagebtn" :dense="dense"
|
||||||
|
><q-tooltip v-if="!dense">将 DataUrl 转为图片</q-tooltip></q-btn
|
||||||
|
>
|
||||||
|
<q-btn
|
||||||
|
icon="content_paste"
|
||||||
|
@click="copyResult"
|
||||||
|
v-show="textbtn"
|
||||||
|
:dense="dense"
|
||||||
|
><q-tooltip v-if="!dense">复制到剪贴板</q-tooltip></q-btn
|
||||||
|
>
|
||||||
|
<q-btn icon="send" @click="sendResult" v-show="textbtn" :dense="dense"
|
||||||
|
><q-tooltip v-if="!dense">发送到活动窗口</q-tooltip></q-btn
|
||||||
|
>
|
||||||
|
<q-btn
|
||||||
|
icon="close"
|
||||||
|
class="text-negative"
|
||||||
|
v-close-popup
|
||||||
|
v-show="closebtn"
|
||||||
|
:dense="dense"
|
||||||
|
/>
|
||||||
|
</q-btn-group>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
dense: Boolean,
|
||||||
|
stretch: Boolean,
|
||||||
|
textbtn: Boolean,
|
||||||
|
imagebtn: Boolean,
|
||||||
|
closebtn: Boolean,
|
||||||
|
content: String,
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
copyResult() {
|
||||||
|
utools.copyText(this.content);
|
||||||
|
quickcommand.showMessageBox("已复制到剪贴板");
|
||||||
|
},
|
||||||
|
sendResult() {
|
||||||
|
utools.copyText(this.content);
|
||||||
|
utools.hideMainWindow();
|
||||||
|
quickcommand.simulatePaste();
|
||||||
|
},
|
||||||
|
dataUrlToImg() {
|
||||||
|
let imgs = this.content
|
||||||
|
.match(/data:image\/.*?;base64,.*/g)
|
||||||
|
?.map((dataUrl) => `<img src="${dataUrl}"><br>`);
|
||||||
|
if (!imgs) return quickcommand.showMessageBox("dataUrl 格式不正确!");
|
||||||
|
this.$emit("showImg", imgs);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
Loading…
x
Reference in New Issue
Block a user