mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-08 22:51:25 +08:00
添加文档和帮助
This commit is contained in:
parent
3cffa4fdb7
commit
3e553f6453
247
src/helps/HELP.html
Normal file
247
src/helps/HELP.html
Normal file
File diff suppressed because one or more lines are too long
175
src/helps/HELP.md
Normal file
175
src/helps/HELP.md
Normal file
@ -0,0 +1,175 @@
|
||||
[TOC]
|
||||
|
||||
# 一、添加命令
|
||||
|
||||
## 基础
|
||||
|
||||
#### 常用动作
|
||||
|
||||
通过点击`+动作`按钮进行添加
|
||||
|
||||
- 打开文件/文件夹/软件 (实现在主输入框启动自定义的软件名称及路径 )
|
||||
- 在文件管理器中定位文件
|
||||
- 用默认浏览器打开网址(实现类似网页快开的功能)
|
||||
- 用 ubrowser 打开网址
|
||||
- 执行系统命令
|
||||
- 将内容写入剪贴板
|
||||
- 发送系统消息
|
||||
- 弹窗显示消息
|
||||
- 发送文本到活动窗口
|
||||
- 转至指定插件(实现自定义插件关键字)
|
||||
- 添加延时
|
||||
|
||||

|
||||
|
||||
#### 模拟按键
|
||||
|
||||
通过点击`+按键`按钮进行添加
|
||||
|
||||
## 进阶
|
||||
|
||||
#### 匹配
|
||||
|
||||
决定通过何种方式进入插件,不同的匹配模式也会影响插值变量的使用
|
||||
|
||||
##### 关键字
|
||||
|
||||
- 在主输入框输入对应关键字进入插件,最通用的一种模式,关键字可以设置多个
|
||||
|
||||
##### 正则/划词
|
||||
|
||||
- 正则匹配主输入框文本或唤出语音面板时选中的文本,可以获取输入框文本或选中文本作为变量
|
||||
|
||||
##### 窗口/进程
|
||||
|
||||
- 匹配呼出 uTools 前或唤出语音面板时的活动窗口,可以获取窗口的信息或文件夹路径作为变量
|
||||
|
||||
##### 复制/选中文件
|
||||
|
||||
- 匹配拖入主输入框的文件或唤出语音面板时选中的文件,可以获取复制及选中的文件信息作为变量
|
||||
|
||||

|
||||
|
||||
#### 环境
|
||||
|
||||
##### quickcommand
|
||||
|
||||
- 可以快速执行打开网址、软件、文件夹、模拟按键等高频动作的命令
|
||||
- 可以通过 quickcommand 的 api 来编写具有 UI 交互的脚本,详见[文档](./quickcommand.html)
|
||||
- 可以使用nodejs、electron、uTools 的 api, 其中 os、fs、path、child_process、util、axios、electron 已经预先 require 了, 无需再次 require ,详见[文档中的上下文一览](./quickcommand.html#上下文一览)
|
||||
|
||||
##### python、cmd、shell 、php 等环境
|
||||
|
||||
- 本机装了相应环境即可执行相应的脚本
|
||||
- 可以通过插值变量增强脚本的功能
|
||||
- 支持 10+ 语言
|
||||
- 可以通过 custom 手动设置解释器路径、参数、脚本后缀及编码方式
|
||||
|
||||

|
||||
|
||||
#### 插值变量
|
||||
|
||||
本插件内置了一些特殊的插值变量,可以获取一些特殊的值,能够加入到插件里的任意脚本中
|
||||
|
||||
##### 全模式可用
|
||||
|
||||
- `{{isWin}}` 是否Window系统, 返回1或0
|
||||
- `{{LocalId}}`本机唯一ID
|
||||
- `{{BrowserUrl}}` 浏览器的当前链接
|
||||
- `{{ClipText}}` 获取剪贴板的文本
|
||||
- `{{SelectText}}` 获取选中的文本 (已弃用)
|
||||
- `{{subinput}}`获取子输入框的文本,具有此变量时会在进入插件时自动启动子输入框
|
||||
|
||||
##### 匹配窗口/进程时可用
|
||||
|
||||
- `{{pwd}}` 资源管理器或访达的当前目录
|
||||
- `{{SelectFile}}` 文件管理器选中的文件,不支持 Linux
|
||||
- `{{WindowInfo}}`当前窗口信息,返回 JSON 格式字符串
|
||||
- 可以使用类似 `{{WindowInfo.id}}`的格式来直接读取相应的值
|
||||
|
||||
##### 匹配正则/划词时可用
|
||||
|
||||
- `{{input}} ` 获取主输入框的文本
|
||||
|
||||
##### 匹配复制/选中文件时可用
|
||||
|
||||
- `{{MatchedFiles}}` 匹配的文件,返回 JSON 格式字符串
|
||||
- 可以使用类似`{{MatchedFiles[0].path}}`的格式来直接读取相应的值
|
||||
|
||||

|
||||
|
||||
#### 输出
|
||||
|
||||
如果脚本有输出,则可以对输出内容做如下处理
|
||||
|
||||
- 隐藏并忽略输出
|
||||
- 显示纯文本输出 (不解析 html 内容)
|
||||
- 显示html格式的输出 (可以进一步编写简单的 GUI 界面,参考内置动作`特殊符号大全`)
|
||||
- 复制到剪贴板
|
||||
- 发送到活动窗口(可实现发送常用短语之类的功能)
|
||||
- 发送到系统通知
|
||||
- 在终端中显示
|
||||
|
||||

|
||||
|
||||
# 二、导出/分享/导入
|
||||
|
||||
#### 导出命令
|
||||
|
||||
点击命令旁的蓝色小箭头即可导出命令,支持
|
||||
|
||||
- 导出到剪贴板
|
||||
- 导出到文件
|
||||
|
||||

|
||||
|
||||
#### 分享命令
|
||||
|
||||
点击分享命令即可一键分享当前的命令,初次分享命令,需要按照以下步骤设置 token:
|
||||
|
||||
1.通过 [https://www.yuque.com/g/fofolee/em2rng/collaborator/join?token=6LZn2vc34dqfIQdC](https://www.yuque.com/g/fofolee/em2rng/collaborator/join?token=6LZn2vc34dqfIQdC) 成为知识库成员,如果没有语雀账号,需要先注册一个
|
||||
|
||||

|
||||
|
||||
2.生成一个具有编辑权限的 token
|
||||
|
||||

|
||||
|
||||
3.在插件内填入生成的 token,之后就可以尽情地分享命令啦
|
||||
|
||||

|
||||
|
||||
#### 导入命令
|
||||
|
||||
- 可以通过点击底部的`导入命令`来导入命令
|
||||
- 会优先识别剪贴板,如果剪贴板内有正确格式的命令会自动导入
|
||||
- 如果剪贴板内没有,则会弹出文件选择框
|
||||
- 支持自动识别是单个导出的命令还是全部导出的命令
|
||||
|
||||
#### 获取分享
|
||||
|
||||
点击设置界面底部的`获取分享`即可获取并导入在线分享的命令啦
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
# 三、关于
|
||||
|
||||
#### 作者
|
||||
|
||||
<img width="30px" src="https://s1.ax1x.com/2020/07/14/UaDkdg.png">[github @fofolee]( https://github.com/fofolee )
|
||||
|
||||
<img width="30px" src=" https://yuanliao.info/assets/avatars/frbg0owd6t3mmejs.png ">[猿料社区 @fofolee]( https://yuanliao.info/u/fofolee/discussions )
|
||||
|
||||
#### 赞赏码
|
||||
|
||||
鉴于之前某位可爱的同学捐赠的时候捐错了对象,此处献上我的捐赠码~
|
||||
|
||||
<img width="500px" src="https://s1.ax1x.com/2020/07/15/Uacgqx.png">
|
||||
|
||||
#### 所有插件
|
||||
|
||||
所有由我制作的插件如下表所示,有兴趣的童鞋可以试一试~
|
||||
|
||||
<table> <tbody> <tr> <td><img style="max-width:30px;max-height:30px" src="https://res.u-tools.cn/plugins/logo/c6e808470b6cbc778865e9ed1bebf339.png"></td> <td>快捷命令</td> <td><button onclick="utools.redirect(this.parentNode.parentNode.querySelector('td+td').innerText)">戳我</button></td> </tr> <tr> <td><img style="max-width:30px;max-height:30px" src="https://res.u-tools.cn/plugins/logo/11bf712cc79499549754586fff7c8db1.png"></td> <td>程序员手册</td> <td><button onclick="utools.redirect(this.parentNode.parentNode.querySelector('td+td').innerText)">戳我</button></td> </tr> <tr> <td><img style="max-width:30px;max-height:30px" src="https://res.u-tools.cn/plugins/logo/dd0977b7d74db32d7088795ef62a7769.png"></td> <td>bilibili</td> <td><button onclick="utools.redirect(this.parentNode.parentNode.querySelector('td+td').innerText)">戳我</button></td> </tr> <tr> <td><img style="max-width:30px;max-height:30px" src="https://res.u-tools.cn/plugins/logo/f26a31d11af3a54f9bddd7e781da46d5.png"></td> <td>关闭进程</td> <td><button onclick="utools.redirect(this.parentNode.parentNode.querySelector('td+td').innerText)">戳我</button></td> </tr> <tr> <td><img style="max-width:30px;max-height:30px" src="https://res.u-tools.cn/plugins/logo/80eae148109a4d7001232efebdd14aca.png"></td> <td>插件面板</td> <td><button onclick="utools.redirect(this.parentNode.parentNode.querySelector('td+td').innerText)">戳我</button></td> </tr> <tr> <td><img style="max-width:30px;max-height:30px" src="https://res.u-tools.cn/plugins/logo/223f27b647b184ffdb2cd9f05a99d50a.png"></td> <td>随机壁纸</td> <td><button onclick="utools.redirect(this.parentNode.parentNode.querySelector('td+td').innerText)">戳我</button></td> </tr> <tr> <td><img style="max-width:30px;max-height:30px" src="https://res.u-tools.cn/plugins/logo/480ac04e8ea522b7bb0dae6418e177a4.png"></td> <td>Github助手</td> <td><button onclick="utools.redirect(this.parentNode.parentNode.querySelector('td+td').innerText)">戳我</button></td> </tr> <tr> <td><img style="max-width:30px;max-height:30px" src="https://res.u-tools.cn/plugins/logo/0de374539c3c358d122ca652d26b5b6e.png"></td> <td>文件夹助手</td> <td><button onclick="utools.redirect(this.parentNode.parentNode.querySelector('td+td').innerText)">戳我</button></td> </tr> <tr> <td><img style="max-width:30px;max-height:30px" src="https://res.u-tools.cn/plugins/logo/5f9fd2f37445a462c0735b9dcca828cd.png"></td> <td>emoji搜索</td> <td><button onclick="utools.redirect(this.parentNode.parentNode.querySelector('td+td').innerText)">戳我</button></td> </tr> <tr> <td><img style="max-width:30px;max-height:30px" src="https://res.u-tools.cn/plugins/logo/50ef534638a9fc7fbed5274131afe503.png"></td> <td>😩能不能好好说话</td> <td><button onclick="utools.redirect(this.parentNode.parentNode.querySelector('td+td').innerText)">戳我</button></td> </tr> <tr> <td><img style="max-width:30px;max-height:30px" src="https://res.u-tools.cn/plugins/logo/9863ccc91f32b4ab660d6e58dd8b04ae.png"></td> <td>winget</td> <td><button onclick="utools.redirect(this.parentNode.parentNode.querySelector('td+td').innerText)">戳我</button></td> </tr> <tr> <td><img style="max-width:30px;max-height:30px" src="https://res.u-tools.cn/plugins/logo/6abb03b743259bd4c976d2a29da0a395.png"></td> <td>icons8搜索</td> <td><button onclick="utools.redirect(this.parentNode.parentNode.querySelector('td+td').innerText)">戳我</button></td> </tr> <tr> <td><img style="max-width:30px;max-height:30px" src="https://res.u-tools.cn/plugins/logo/527a20566499e7c3fb63e8705d60ccb7.png"></td> <td>kali 工具介绍</td> <td><button onclick="utools.redirect(this.parentNode.parentNode.querySelector('td+td').innerText)">戳我</button></td> </tr> <tr> <td><img style="max-width:30px;max-height:30px" src="https://res.u-tools.cn/plugins/logo/3ef0e794b7950193fc98289ea2b199e9.png"></td> <td>png转icon</td> <td><button onclick="utools.redirect(this.parentNode.parentNode.querySelector('td+td').innerText)">戳我</button></td> </tr> </tbody> </table>
|
File diff suppressed because one or more lines are too long
@ -2,57 +2,80 @@
|
||||
|
||||
## quickcommand
|
||||
|
||||
#### `showButtonBox(callback, buttons)`
|
||||
#### `showButtonBox(buttons)`
|
||||
|
||||
- callback: Function 回调函数
|
||||
- index: Integer 按钮的序号,从0开始
|
||||
- text: String 按钮的文本
|
||||
- buttons: Array 每一个元素对应一个按钮
|
||||
- 返回: Promise
|
||||
- id: Integer 按钮的序号,从0开始
|
||||
- text: String 按钮的文本
|
||||
|
||||
显示一个按钮对话框,用来接收用户的输入
|
||||
|
||||
**示例**
|
||||
|
||||
```js
|
||||
quickcommand.showButtonBox(({index, text})=>{
|
||||
console.log(`选择了第${index+1}个按钮`)
|
||||
// then 写法
|
||||
quickcommand.showButtonBox(["按钮1", "按钮2", "按钮3"]).then(({ id, text }) => {
|
||||
console.log(`选择了第${id+1}个按钮`)
|
||||
console.log(`按钮的文本为${text}`)
|
||||
},["按钮1", "按钮2", "按钮3"])
|
||||
})
|
||||
|
||||
// async 写法
|
||||
(async () =>{
|
||||
let button = await quickcommand.showButtonBox(["按钮1", "按钮2", "按钮3"])
|
||||
console.log(`选择了第${button.id+1}个按钮`)
|
||||
console.log(`按钮的文本为${button.text}`)
|
||||
})()
|
||||
|
||||
// 捕获错误
|
||||
quickcommand.showButtonBox().catch(e => {
|
||||
console.log(e)
|
||||
})
|
||||
```
|
||||
**实例**
|
||||
|
||||
```js
|
||||
# 截取自内置快捷命令: 文本处理
|
||||
quickcommand.showButtonBox(option => {
|
||||
var i = option.index
|
||||
console.log(textManipulation[i](text))
|
||||
message('结果已复制到剪贴板')
|
||||
}, ["字数统计", "词频统计", "文本逆转", "\\和/互转", "全部大写", "全部小写",
|
||||
"去除空格", "十六进制转字符", "字符转十六进制"
|
||||
])
|
||||
textManipulation = [ ... ]
|
||||
// 截取自内置快捷命令: 通过 find 查找文件
|
||||
quickcommand.showButtonBox(['打开文件', '在文件管理器中定位', '复制文件路径']).then(x => {
|
||||
switch (x.id) {
|
||||
case 0:
|
||||
utools.shellOpenItem(file);
|
||||
break;
|
||||
case 1:
|
||||
utools.shellShowItemInFolder(file);
|
||||
break;
|
||||
case 2:
|
||||
utools.copyText(file);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
####`showInputBox(callback, placeHolders)`
|
||||
####`showInputBox(placeHolders)`
|
||||
|
||||
- callback: Function 回调函数
|
||||
- values: Array 所以输入框的值
|
||||
- placeHolders: Array 每一个占位符对应一个输入框
|
||||
- 返回: Promise
|
||||
- values: Array 所以输入框的值
|
||||
|
||||
显示一个输入框界面,用来接用户的输入
|
||||
|
||||
**示例**
|
||||
|
||||
```js
|
||||
quickcommand.showInputBox(values => {
|
||||
quickcommand.showInputBox(["输入框1", "输入框2", "输入框3"]).then(values => {
|
||||
console.log(`输入的内容分别为${values}`)
|
||||
},["输入框1", "输入框2", "输入框3"])
|
||||
})
|
||||
```
|
||||
**实例**
|
||||
|
||||
```js
|
||||
# 截取自内置快捷命令: 文本替换
|
||||
quickcommand.showInputBox(inputs => {
|
||||
// 截取自内置快捷命令: 文本替换
|
||||
quickcommand.showInputBox(["要替换的内容,两边加 / 使用正则", "替换为的内容"]).then(inputs => {
|
||||
var search = inputs[0]
|
||||
var repl = inputs[1]
|
||||
...
|
||||
@ -63,91 +86,144 @@ quickcommand.showInputBox(inputs => {
|
||||
var source = electron.clipboard.readText()
|
||||
source = source.replace(search, repl)
|
||||
...
|
||||
}, ["要替换的内容,两边加 / 使用正则", "替换为的内容"])
|
||||
})
|
||||
```
|
||||
####`showSelectList(callback, selects, options)`
|
||||
####`showSelectList(selects, options)`
|
||||
|
||||
- callback: Function 回调函数
|
||||
- index: Integer 选择的序号,从0开始
|
||||
- text: String 选择的文本
|
||||
- selects: Array 每一个元素对应一个列表选项
|
||||
- options: Array | undefined 列表的选项
|
||||
- placeholder: String 搜索框占位符
|
||||
- enableHTML: Boolean 选项是否支持html,默认为false
|
||||
- closeOnSelect:Boolean 选择后是否关闭列表,默认为true
|
||||
- optionType: String 选项的格式,有`plaintext`、`html`、`json`三种,默认为`plaintext`
|
||||
- 返回: Promise
|
||||
- id: Integer 选择的序号,从0开始
|
||||
- text: String 选择的文本
|
||||
- title/description/[…]: 当`optionType`为`json`时,对应`json`里的每一个属性
|
||||
|
||||
显示一个支持搜索的选项列表,类似于列表模式,但原理不同
|
||||
显示一个支持搜索的且可以动态更新的选项列表
|
||||
|
||||
当指定`optionType`为`json`时,类似于插件开发的`列表模式`,`title`、`description`和`icon`分别表示标题、描述和图标,其中`title`为必备属性
|
||||
|
||||
**示例**
|
||||
|
||||
```js
|
||||
// plaintext
|
||||
var opt = []
|
||||
for (var i = 0; i < 15; i++) {
|
||||
// 每一个选项为文本格式
|
||||
opt.push(`选项` + i)
|
||||
}
|
||||
quickcommand.showSelectList(choise => {
|
||||
quickcommand.showSelectList(opt).then(choise => {
|
||||
console.log(`选择的选项为${choise.text}`)
|
||||
}, opt)
|
||||
})
|
||||
|
||||
// json
|
||||
var opt = []
|
||||
for (var i = 0; i < 15; i++) {
|
||||
// 每一个选项为 json 格式
|
||||
opt.push({title: `选项${i}`, description: `选项${i}的描述`, abcd: `选项${i}的自定义属性`})
|
||||
}
|
||||
quickcommand.showSelectList(opt, {optionType: 'json'}).then(choise => {
|
||||
console.log(`选择的选项为${choise.title}`)
|
||||
})
|
||||
|
||||
// html
|
||||
var opt = []
|
||||
for (var i = 0; i < 15; i++) {
|
||||
// 每一个选项为 html 格式
|
||||
opt.push(`<div style="color: red">选项${i}</div>`)
|
||||
}
|
||||
quickcommand.showSelectList(opt, {optionType: 'html'}).then(choise => {
|
||||
console.log(`选择的选项为${quickcommand.htmlParse(choise.text).body.innerText}`)
|
||||
})
|
||||
```
|
||||
**实例**
|
||||
|
||||
```js
|
||||
# 截取自内置快捷命令: 离线插件
|
||||
const api = 'https://api.u-tools.cn/Plugins/Developer/allPlugins'
|
||||
axios(api).then(res => {
|
||||
var document = quickcommand.htmlParse(res.data)
|
||||
var doms = document.querySelectorAll('div[style]')
|
||||
var divs = []
|
||||
doms.forEach(d => {
|
||||
d.querySelector('a').style.display = 'none'
|
||||
d.querySelector('h3+div').style.color = '#9e9e9e'
|
||||
d.querySelector('h3').style = "margin: 0; font-weight: normal"
|
||||
divs.push(d.innerHTML)
|
||||
// 截取自内置快捷命令: 文本处理
|
||||
let textManipulation = [ ... ]
|
||||
let text = quickcommand.payload
|
||||
let options = textManipulation.map(t => {
|
||||
return {
|
||||
title: t.name,
|
||||
description: t.func(text)
|
||||
}
|
||||
})
|
||||
|
||||
quickcommand.showSelectList(options, { optionType: 'json' })
|
||||
.then(choise => {
|
||||
console.log(choise.description)
|
||||
utools.copyText(choise.description)
|
||||
})
|
||||
quickcommand.showSelectList(x => {
|
||||
var dom = quickcommand.htmlParse(x.text)
|
||||
var href = dom.querySelector('a').href
|
||||
var file = dom.querySelector('h3').innerText + '.upx'
|
||||
var filepath = path.join(utools.getPath('downloads'), file)
|
||||
quickcommand.downloadFile(href, filepath).then(() => {
|
||||
utools.shellShowItemInFolder(filepath)
|
||||
})
|
||||
}, divs, { enableHTML: true, closeOnSelect: false })
|
||||
|
||||
axios.post('http://fy.iciba.com/ajax.php?a=fy', `f=auto&t=auto&w=${text}`)
|
||||
.then(res => {
|
||||
let content = res.data.content
|
||||
let trans = content.out ? content.out : content.word_mean
|
||||
let opt = textManipulation[0]
|
||||
opt.description = trans
|
||||
quickcommand.updateSelectList(opt, 0)
|
||||
})
|
||||
```
|
||||
|
||||
####`showTextAera(callback, placeholder)`
|
||||
#### `updateSelectList(opt, id)`
|
||||
|
||||
- opt: String 要更新的选项
|
||||
- id: Integer | undefined: 要更新的选项的序号,不赋值时则追加到最后一个选项后面
|
||||
|
||||
动态更新当前的选项列表的选项。
|
||||
|
||||
**示例**
|
||||
|
||||
```js
|
||||
// 初始状态只有 1、2、3 三个选项
|
||||
quickcommand.showSelectList(['1','2','3']).then(x=>{
|
||||
console.log(x)
|
||||
})
|
||||
|
||||
// 1s 后追加一个选项
|
||||
quickcommand.setTimeout(()=>{
|
||||
quickcommand.updateSelectList('4')
|
||||
}, 1000)
|
||||
|
||||
// 2s 后更新第二个选项的值
|
||||
quickcommand.setTimeout(()=>{
|
||||
quickcommand.updateSelectList('updated', 1)
|
||||
}, 2000)
|
||||
```
|
||||
|
||||
####`showTextAera(placeholder)`
|
||||
|
||||
- callback: Function 回调函数
|
||||
- text: String 文本框的文本
|
||||
- placeholder: String | undefined 文本框占位符
|
||||
- 返回: Promise
|
||||
- text: String 文本框的文本
|
||||
|
||||
显示一个文本框界面,用来接用户的输入
|
||||
|
||||
**示例**
|
||||
|
||||
```js
|
||||
quickcommand.showTextAera(text=>{
|
||||
quickcommand.showTextAera("请输入文本").then(text=>{
|
||||
console.log(`输入的文本为${text}`)
|
||||
}, "请输入文本")
|
||||
})
|
||||
```
|
||||
|
||||
**实例**
|
||||
|
||||
```js
|
||||
# 截取自内置快捷命令: vscode代码片段生成器
|
||||
// 截取自内置快捷命令: vscode代码片段生成器
|
||||
var snippet = {}
|
||||
quickcommand.showTextAera(code => {
|
||||
quickcommand.showTextAera("请输入代码片段").then(code => {
|
||||
snippet.body = code.split("\n")
|
||||
quickcommand.showInputBox(inputs => {
|
||||
quickcommand.showInputBox(["代码片段的描述", "触发代码片段的关键词"])
|
||||
.then(inputs => {
|
||||
snippet.prefix = inputs[1]
|
||||
snippet.description = inputs[0]
|
||||
var result = `"${inputs[0]}": ` + JSON.stringify(snippet, null, '\t')
|
||||
console.log(result)
|
||||
utools.copyText(result)
|
||||
quickcommand.showMessageBox('已复制')
|
||||
}, ["代码片段的描述", "触发代码片段的关键词"])
|
||||
}, ("请输入代码片段"))
|
||||
})
|
||||
})
|
||||
```
|
||||
####`showMessageBox(message, icon, time)`
|
||||
|
||||
@ -217,15 +293,15 @@ console.log(`解析出来的a标签地址为${href}`)
|
||||
下载文件,也可单纯用于`http`请求,无论`defaultPath`是否定义,都将得到响应内容的`Buffer`,当`showDialog`为`false`且定义了`defaultPath`时,会下载文件为``defaultPath`,当`showDialog`为`true`时,会弹出保存文件对话框,`defaultPath`为对话框默认显示的文件名
|
||||
|
||||
```js
|
||||
# 返回http响应内容
|
||||
// 返回http响应内容
|
||||
quickcommand.downloadFile('https://www.baidu.com').then(r=>{
|
||||
console.log(r.toString())
|
||||
})
|
||||
|
||||
# 下载文件到D:/
|
||||
// 下载文件到D:/
|
||||
quickcommand.downloadFile('https://res.u-tools.cn/currentversion/uTools-1.1.3.exe', 'D:/')
|
||||
|
||||
# 下载文件,并弹出对话框询问保存路径
|
||||
// 下载文件,并弹出对话框询问保存路径
|
||||
quickcommand.downloadFile('https://res.u-tools.cn/currentversion/uTools-1.1.3.exe', 'uTools.exe', true)
|
||||
```
|
||||
|
||||
@ -238,7 +314,7 @@ quickcommand.downloadFile('https://res.u-tools.cn/currentversion/uTools-1.1.3.ex
|
||||
**示例**
|
||||
|
||||
```js
|
||||
# 匹配模式为正则/划词时
|
||||
// 匹配模式为正则/划词时
|
||||
var text = quickcommand.payload
|
||||
console.log(`主输入框匹配的文本为${text}`)
|
||||
```
|
||||
@ -273,7 +349,7 @@ quickcommand.kill(16084)
|
||||
- path
|
||||
- child_process
|
||||
- util
|
||||
- axios [文档]( https://github.com/axios/axios )
|
||||
- axios [文档]( https://www.kancloud.cn/yunye/axios/234845)
|
||||
- electron [文档]( http://www.electronjs.org/docs )
|
||||
- clipboard
|
||||
- contextBridge
|
||||
@ -289,18 +365,19 @@ quickcommand.kill(16084)
|
||||
- ~~removeFeature~~
|
||||
- ~~setFeature~~
|
||||
- quickcommand
|
||||
- sleep: *ƒ (ms)*
|
||||
- setTimeout: *ƒ (callback, ms)*
|
||||
- showButtonBox: *ƒ (callback, buttons)*
|
||||
- showInputBox: *ƒ (callback, placeHolders)*
|
||||
- showMessageBox: *ƒ (title, icon = "success", time = 3000)*
|
||||
- showSelectList: *ƒ (callback, selects, opt = {})*
|
||||
- showTextAera: *ƒ (callback, placeholder = "")*
|
||||
- simulateCopy: *ƒ ()*
|
||||
- simulatePaste: *ƒ ()*
|
||||
- downloadFile: *ƒ (url, defaultPath = '', showDialog = false)*
|
||||
- htmlParse: *ƒ (html)*
|
||||
- kill: *ƒ (pid)*
|
||||
- payload
|
||||
- kill: *ƒ (pid, signal = 'SIGTERM')*
|
||||
- payload: ""
|
||||
- setTimeout: *ƒ (callback, ms)*
|
||||
- showButtonBox: *ƒ (buttons)*
|
||||
- showInputBox: *ƒ (placeHolders)*
|
||||
- showMessageBox: *ƒ (title, icon = "success", time = 3000)*
|
||||
- showSelectList: *ƒ (selects, opt = {})*
|
||||
- showTextAera: *ƒ (placeholder = "")*
|
||||
- simulateCopy: *ƒ ()*
|
||||
- simulatePaste: *ƒ ()*
|
||||
- sleep: *ƒ (ms)*
|
||||
- updateSelectList: *ƒ (opt, id)*
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user