mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-10 15:34:05 +08:00
showInputBox更新
This commit is contained in:
parent
f6b8bb2a8d
commit
4d07847196
@ -29,13 +29,14 @@
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
results: new Array(this.labels.length),
|
||||
results: this.values,
|
||||
};
|
||||
},
|
||||
props: {
|
||||
labels: Array,
|
||||
title: String,
|
||||
hints: Array
|
||||
hints: Array,
|
||||
values: Array
|
||||
},
|
||||
emits: ["ok", "hide"],
|
||||
methods: {
|
||||
|
33
src/js/quickcommand.js
Normal file
33
src/js/quickcommand.js
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 通过quickcommand的api,快速生成可交互的UI界面
|
||||
* UI界面基于quasar
|
||||
*/
|
||||
|
||||
import {
|
||||
Dialog
|
||||
} from 'quasar'
|
||||
import inputBox from "../components/InputBox"
|
||||
|
||||
let showInputBox = (options = [], title = "") => {
|
||||
return new Promise((reslove, reject) => {
|
||||
let props = {}
|
||||
if (!(options instanceof Object)) return reject(new TypeError("必须为数组或对象"))
|
||||
if (options instanceof Array) props.labels = options
|
||||
else props = options
|
||||
if (!props.values) props.values = options.map(() => "")
|
||||
if (!props.hints) props.hints = options.map(() => "")
|
||||
Dialog.create({
|
||||
component: inputBox,
|
||||
componentProps: props
|
||||
}).onOk(results => {
|
||||
reslove(Array.from(results))
|
||||
}).onCancel(() => {
|
||||
console.log('取消')
|
||||
}).onDismiss(() => {
|
||||
console.log('对话框被关闭')
|
||||
})
|
||||
})
|
||||
};
|
||||
export default {
|
||||
showInputBox,
|
||||
};
|
10
src/plugins/monaco/types/quickcommand.api.d.ts
vendored
10
src/plugins/monaco/types/quickcommand.api.d.ts
vendored
@ -21,12 +21,18 @@ interface quickcommandApi {
|
||||
* quickcommand.showInputBox(["输入框1", "输入框2", "输入框3"]).then(values => {
|
||||
* console.log(`输入的内容分别为${values}`)
|
||||
* })
|
||||
*
|
||||
* quickcommand.showInputBox({labels:["输入框标签"],values:["默认值"],hints:["输入框提示"]}).then(values => {
|
||||
* console.log(`输入的内容分别为${values}`)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* @param labels 每一个输入框的标签名
|
||||
*
|
||||
*
|
||||
* @param options 数组时,为每一个输入框的标签名;对象时,为每一个输入框的属性
|
||||
* @param title 窗口标题,默认为空
|
||||
*/
|
||||
showInputBox(labels: array, title?: string): Promise<array>;
|
||||
showInputBox(options: array | { labels: array, values: array, hints: array }, title?: string): Promise<array>;
|
||||
|
||||
/**
|
||||
* 显示一个支持搜索的且可以动态更新的选项列表,并返回用户点击选项的索引及名称
|
||||
|
Loading…
x
Reference in New Issue
Block a user