新增showWaitBtn

This commit is contained in:
fofolee 2022-04-22 22:38:04 +08:00
parent 2b84ebdda3
commit 81147b02eb
4 changed files with 75 additions and 5 deletions

View File

@ -373,9 +373,8 @@ export default {
runCurrentCommand() {
let command = _.cloneDeep(this.quickcommandInfo);
command.output =
this.$refs.sidebar?.currentCommand.output || command.program === "html"
? "html"
: "text";
this.$refs.sidebar?.currentCommand.output ||
(command.program === "html" ? "html" : "text");
command.cmdType = this.$refs.sidebar?.cmdType.name;
this.$refs.result.runCurrentCommand(command);
},

View 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>

View File

@ -11,6 +11,7 @@ import inputBox from "../components/quickcommandUI/InputBox"
import buttonBox from "../components/quickcommandUI/ButtonBox"
import TextArea from "../components/quickcommandUI/TextArea"
import SelectList from "../components/quickcommandUI/SelectList"
import WaitButton from "../components/quickcommandUI/waitButton"
const quickcommand = {
showInputBox: (options = ["请输入"], title = "") => new Promise((reslove, reject) => {
@ -112,6 +113,19 @@ const quickcommand = {
console.log('取消')
})
}),
showWaitButton: (callback, label = "确定") => {
Dialog.create({
component: WaitButton,
componentProps: {
label
}
}).onOk(() => {
callback()
}).onCancel(() => {
console.log('取消')
})
}
}
export default quickcommand
export default quickcommand

View File

@ -157,7 +157,20 @@ interface quickcommandApi {
* @param message
* @param title
*/
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;
/**
*