mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-30 04:42:45 +08:00
feat: 增加runVbs
This commit is contained in:
parent
36881442a8
commit
d0d39e94d8
@ -176,7 +176,7 @@ quickcommand = {
|
|||||||
item.text = ''
|
item.text = ''
|
||||||
Object.keys(s).forEach(k => item[k] = s[k])
|
Object.keys(s).forEach(k => item[k] = s[k])
|
||||||
item.id = i
|
item.id = i
|
||||||
s.icon && (item.text += `<div class="icon"><img src="${s.icon}" onerror="this.src='./logo.png'"></div>`)
|
s.icon && (item.text += `<div class="icon"><img src="${s.icon}" onerror="this.src='./logo/quickcommand.png'"></div>`)
|
||||||
s.title && (item.text += `<div class="title">${s.title}</div>`)
|
s.title && (item.text += `<div class="title">${s.title}</div>`)
|
||||||
s.description && (item.text += `<div class="description">${s.description}</div>`)
|
s.description && (item.text += `<div class="description">${s.description}</div>`)
|
||||||
} else {
|
} else {
|
||||||
@ -369,6 +369,22 @@ quickcommand = {
|
|||||||
let local = path.join(root, require('crypto').createHash('md5').update(url).digest('hex'))
|
let local = path.join(root, require('crypto').createHash('md5').update(url).digest('hex'))
|
||||||
if (forceUpdate || !fs.existsSync(local)) await this.downloadFile(remote, local)
|
if (forceUpdate || !fs.existsSync(local)) await this.downloadFile(remote, local)
|
||||||
return require(local)
|
return require(local)
|
||||||
|
},
|
||||||
|
|
||||||
|
// 运行vbs脚本
|
||||||
|
runVbs: function (script) {
|
||||||
|
if (process.platform != 'win32') return
|
||||||
|
return new Promise((reslove, reject) => {
|
||||||
|
var tempfile = path.join(os.tmpdir(), 'TempVBSScript.vbs')
|
||||||
|
fs.writeFile(tempfile, iconv.encode(script, 'gbk'), err => {
|
||||||
|
child_process.exec(`cscript.exe /nologo "${tempfile}"`, {
|
||||||
|
encoding: "buffer"
|
||||||
|
}, (err, stdout, stderr) => {
|
||||||
|
if (err) reject(iconv.decode(stderr, 'gbk'))
|
||||||
|
else reslove(iconv.decode(stdout, 'gbk'))
|
||||||
|
});
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user