mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-08-09 22:29:33 +08:00
新增showWaitBtn
This commit is contained in:
parent
2b84ebdda3
commit
81147b02eb
@ -373,9 +373,8 @@ export default {
|
|||||||
runCurrentCommand() {
|
runCurrentCommand() {
|
||||||
let command = _.cloneDeep(this.quickcommandInfo);
|
let command = _.cloneDeep(this.quickcommandInfo);
|
||||||
command.output =
|
command.output =
|
||||||
this.$refs.sidebar?.currentCommand.output || command.program === "html"
|
this.$refs.sidebar?.currentCommand.output ||
|
||||||
? "html"
|
(command.program === "html" ? "html" : "text");
|
||||||
: "text";
|
|
||||||
command.cmdType = this.$refs.sidebar?.cmdType.name;
|
command.cmdType = this.$refs.sidebar?.cmdType.name;
|
||||||
this.$refs.result.runCurrentCommand(command);
|
this.$refs.result.runCurrentCommand(command);
|
||||||
},
|
},
|
||||||
|
44
src/components/quickcommandUI/WaitButton.vue
Normal file
44
src/components/quickcommandUI/WaitButton.vue
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<template>
|
||||||
|
<q-dialog
|
||||||
|
ref="dialog"
|
||||||
|
seamless
|
||||||
|
position="right"
|
||||||
|
@hide="onDialogHide"
|
||||||
|
>
|
||||||
|
<q-card>
|
||||||
|
<q-btn color="primary" :label="label" @click="onOKClick" v-close-popup />
|
||||||
|
</q-card>
|
||||||
|
</q-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
label: String,
|
||||||
|
},
|
||||||
|
mounted(){
|
||||||
|
console.log(this);
|
||||||
|
},
|
||||||
|
emits: ["ok", "hide"],
|
||||||
|
methods: {
|
||||||
|
show() {
|
||||||
|
this.$refs.dialog.show();
|
||||||
|
},
|
||||||
|
hide() {
|
||||||
|
this.$refs.dialog.hide();
|
||||||
|
},
|
||||||
|
|
||||||
|
onDialogHide() {
|
||||||
|
this.$emit("hide");
|
||||||
|
},
|
||||||
|
|
||||||
|
onOKClick() {
|
||||||
|
this.$emit("ok");
|
||||||
|
},
|
||||||
|
|
||||||
|
onCancelClick() {
|
||||||
|
this.hide();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
@ -11,6 +11,7 @@ import inputBox from "../components/quickcommandUI/InputBox"
|
|||||||
import buttonBox from "../components/quickcommandUI/ButtonBox"
|
import buttonBox from "../components/quickcommandUI/ButtonBox"
|
||||||
import TextArea from "../components/quickcommandUI/TextArea"
|
import TextArea from "../components/quickcommandUI/TextArea"
|
||||||
import SelectList from "../components/quickcommandUI/SelectList"
|
import SelectList from "../components/quickcommandUI/SelectList"
|
||||||
|
import WaitButton from "../components/quickcommandUI/waitButton"
|
||||||
|
|
||||||
const quickcommand = {
|
const quickcommand = {
|
||||||
showInputBox: (options = ["请输入"], title = "") => new Promise((reslove, reject) => {
|
showInputBox: (options = ["请输入"], title = "") => new Promise((reslove, reject) => {
|
||||||
@ -112,6 +113,19 @@ const quickcommand = {
|
|||||||
console.log('取消')
|
console.log('取消')
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
showWaitButton: (callback, label = "确定") => {
|
||||||
|
Dialog.create({
|
||||||
|
component: WaitButton,
|
||||||
|
componentProps: {
|
||||||
|
label
|
||||||
|
}
|
||||||
|
}).onOk(() => {
|
||||||
|
callback()
|
||||||
|
}).onCancel(() => {
|
||||||
|
console.log('取消')
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default quickcommand
|
export default quickcommand
|
13
src/plugins/monaco/types/quickcommand.api.d.ts
vendored
13
src/plugins/monaco/types/quickcommand.api.d.ts
vendored
@ -159,6 +159,19 @@ interface quickcommandApi {
|
|||||||
*/
|
*/
|
||||||
showConfirmBox(message?: string, title?: string): Promise<boolean>;
|
showConfirmBox(message?: string, title?: string): Promise<boolean>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 显示等待用户操作的按钮,用户点击后执行相关操作
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* quickcommand.showWaitButton(() => {
|
||||||
|
* stopRunning()
|
||||||
|
* }, "停止运行")
|
||||||
|
* ```
|
||||||
|
* @param callback 点击后的回调
|
||||||
|
* @param label 按钮的标题
|
||||||
|
*/
|
||||||
|
showWaitButton(callback, label?: string): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 同步等待,会阻塞进程
|
* 同步等待,会阻塞进程
|
||||||
* @param ms 等待的毫秒数
|
* @param ms 等待的毫秒数
|
||||||
|
Loading…
x
Reference in New Issue
Block a user