mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-08 22:51:25 +08:00
feat: 屏蔽新增的接口
This commit is contained in:
parent
e36963aead
commit
9927d2f8d3
@ -52,17 +52,17 @@ ctlKey = utools.isMacOs() ? 'command' : 'control'
|
|||||||
|
|
||||||
quickcommand = {
|
quickcommand = {
|
||||||
// 模拟复制操作
|
// 模拟复制操作
|
||||||
simulateCopy: function() {
|
simulateCopy: function () {
|
||||||
utools.simulateKeyboardTap('c', ctlKey);
|
utools.simulateKeyboardTap('c', ctlKey);
|
||||||
},
|
},
|
||||||
|
|
||||||
// 模拟粘贴操作
|
// 模拟粘贴操作
|
||||||
simulatePaste: function() {
|
simulatePaste: function () {
|
||||||
utools.simulateKeyboardTap('v', ctlKey);
|
utools.simulateKeyboardTap('v', ctlKey);
|
||||||
},
|
},
|
||||||
|
|
||||||
// setTimout 不能在 vm2 中使用,同时在 electron 中有 bug
|
// setTimout 不能在 vm2 中使用,同时在 electron 中有 bug
|
||||||
sleep: function(ms) {
|
sleep: function (ms) {
|
||||||
var start = new Date().getTime()
|
var start = new Date().getTime()
|
||||||
try {
|
try {
|
||||||
// node 16.13.1
|
// node 16.13.1
|
||||||
@ -73,7 +73,7 @@ quickcommand = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// 重写 setTimeout
|
// 重写 setTimeout
|
||||||
setTimeout: function(callback, ms) {
|
setTimeout: function (callback, ms) {
|
||||||
var start = new Date().getTime()
|
var start = new Date().getTime()
|
||||||
child_process.exec(getSleepCodeByShell(ms), { timeout: ms }, (err, stdout, stderr) => {
|
child_process.exec(getSleepCodeByShell(ms), { timeout: ms }, (err, stdout, stderr) => {
|
||||||
var end = new Date().getTime()
|
var end = new Date().getTime()
|
||||||
@ -180,7 +180,7 @@ quickcommand = {
|
|||||||
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 {
|
||||||
item = {id: i, text: s}
|
item = { id: i, text: s }
|
||||||
}
|
}
|
||||||
data.push(item)
|
data.push(item)
|
||||||
})
|
})
|
||||||
@ -217,9 +217,9 @@ quickcommand = {
|
|||||||
$('#selectBox').select2('open')
|
$('#selectBox').select2('open')
|
||||||
$("#quickselect .select2-search__field").focus()
|
$("#quickselect .select2-search__field").focus()
|
||||||
$('#quickselect .select2').hide()
|
$('#quickselect .select2').hide()
|
||||||
opt.optionType == 'plaintext' && $('.select2-results').css({'line-height': '40px'})
|
opt.optionType == 'plaintext' && $('.select2-results').css({ 'line-height': '40px' })
|
||||||
modWindowHeight($('.select2-results').outerHeight())
|
modWindowHeight($('.select2-results').outerHeight())
|
||||||
opt.enableSearch && utools.setSubInput(({text})=>{
|
opt.enableSearch && utools.setSubInput(({ text }) => {
|
||||||
$("#quickselect .select2-search__field").val(text).trigger('input')
|
$("#quickselect .select2-search__field").val(text).trigger('input')
|
||||||
modWindowHeight($('.select2-results').outerHeight())
|
modWindowHeight($('.select2-results').outerHeight())
|
||||||
}, opt.placeholder)
|
}, opt.placeholder)
|
||||||
@ -244,7 +244,7 @@ quickcommand = {
|
|||||||
|
|
||||||
// 更新选项列表
|
// 更新选项列表
|
||||||
updateSelectList: function (opt, id) {
|
updateSelectList: function (opt, id) {
|
||||||
if(!$('#selectBox').length) throw '当前没有选择列表, 请结合 quickcommand.showSelectList 使用'
|
if (!$('#selectBox').length) throw '当前没有选择列表, 请结合 quickcommand.showSelectList 使用'
|
||||||
let data = $('#selectBox').data('options')
|
let data = $('#selectBox').data('options')
|
||||||
let num = data.length
|
let num = data.length
|
||||||
typeof id == 'undefined' && (id = num)
|
typeof id == 'undefined' && (id = num)
|
||||||
@ -332,7 +332,7 @@ quickcommand = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// 上传文件
|
// 上传文件
|
||||||
uploadFile: function(url, file = {}, name = 'file', formData = {}) {
|
uploadFile: function (url, file = {}, name = 'file', formData = {}) {
|
||||||
return new Promise((reslove, reject) => {
|
return new Promise((reslove, reject) => {
|
||||||
var objfile
|
var objfile
|
||||||
if (file instanceof File) {
|
if (file instanceof File) {
|
||||||
@ -373,7 +373,7 @@ quickcommand = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 运行vbs脚本
|
// 运行vbs脚本
|
||||||
if (process.platform == 'win32') quickcommand.runVbs = function (script) {
|
if (process.platform == 'win32') quickcommand.runVbs = function (script) {
|
||||||
return new Promise((reslove, reject) => {
|
return new Promise((reslove, reject) => {
|
||||||
var tempfile = path.join(os.tmpdir(), 'TempVBSScript.vbs')
|
var tempfile = path.join(os.tmpdir(), 'TempVBSScript.vbs')
|
||||||
fs.writeFile(tempfile, iconv.encode(script, 'gbk'), err => {
|
fs.writeFile(tempfile, iconv.encode(script, 'gbk'), err => {
|
||||||
@ -443,7 +443,7 @@ let GetFilePath = (Path, File) => {
|
|||||||
if (isDev()) {
|
if (isDev()) {
|
||||||
return path.join(__dirname, Path, File)
|
return path.join(__dirname, Path, File)
|
||||||
} else {
|
} else {
|
||||||
return path.join(__dirname.replace(/([a-zA-Z0-9\-]+\.asar)/,'$1.unpacked'), Path, File)
|
return path.join(__dirname.replace(/([a-zA-Z0-9\-]+\.asar)/, '$1.unpacked'), Path, File)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -465,9 +465,16 @@ let modWindowHeight = height => {
|
|||||||
// 屏蔽危险函数
|
// 屏蔽危险函数
|
||||||
getuToolsLite = () => {
|
getuToolsLite = () => {
|
||||||
var utoolsLite = Object.assign({}, utools)
|
var utoolsLite = Object.assign({}, utools)
|
||||||
|
// 数据库相关接口
|
||||||
delete utoolsLite.db
|
delete utoolsLite.db
|
||||||
|
delete utoolsLite.dbStorage
|
||||||
delete utoolsLite.removeFeature
|
delete utoolsLite.removeFeature
|
||||||
delete utoolsLite.setFeature
|
delete utoolsLite.setFeature
|
||||||
|
// 支付相关接口
|
||||||
|
delete utoolsLite.fetchUserServerTemporaryToken
|
||||||
|
delete utoolsLite.getUser
|
||||||
|
delete utoolsLite.openPayment
|
||||||
|
delete utoolsLite.fetchUserPayments
|
||||||
return utoolsLite
|
return utoolsLite
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -567,7 +574,7 @@ runCodeInVm = (cmd, cb, enterData = {}) => {
|
|||||||
try {
|
try {
|
||||||
vm.run(cmd, path.join(__dirname, 'preload.js'));
|
vm.run(cmd, path.join(__dirname, 'preload.js'));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error: ',e)
|
console.log('Error: ', e)
|
||||||
cb(null, liteErr(e))
|
cb(null, liteErr(e))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -579,7 +586,7 @@ runCodeInVm = (cmd, cb, enterData = {}) => {
|
|||||||
|
|
||||||
let cbUnhandledRejection = e => {
|
let cbUnhandledRejection = e => {
|
||||||
removeAllListener()
|
removeAllListener()
|
||||||
console.log('UnhandledRejection: ',e)
|
console.log('UnhandledRejection: ', e)
|
||||||
cb(null, liteErr(e.reason))
|
cb(null, liteErr(e.reason))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -601,7 +608,7 @@ getShellCommand = () => {
|
|||||||
var shellCommands = localStorage['shellCommands']
|
var shellCommands = localStorage['shellCommands']
|
||||||
if (shellCommands) return
|
if (shellCommands) return
|
||||||
localStorage['shellCommands'] = '[]'
|
localStorage['shellCommands'] = '[]'
|
||||||
if(utools.isWindows()) return
|
if (utools.isWindows()) return
|
||||||
process.env.PATH.split(':').forEach(d => {
|
process.env.PATH.split(':').forEach(d => {
|
||||||
fs.readdir(d, (err, files) => {
|
fs.readdir(d, (err, files) => {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
@ -617,7 +624,7 @@ getCmdCommand = () => {
|
|||||||
var cmdCommands = localStorage['cmdCommands']
|
var cmdCommands = localStorage['cmdCommands']
|
||||||
if (cmdCommands) return
|
if (cmdCommands) return
|
||||||
localStorage['cmdCommands'] = '[]'
|
localStorage['cmdCommands'] = '[]'
|
||||||
if(!utools.isWindows()) return
|
if (!utools.isWindows()) return
|
||||||
process.env.Path.split(';').forEach(d => {
|
process.env.Path.split(';').forEach(d => {
|
||||||
fs.readdir(d, (err, files) => {
|
fs.readdir(d, (err, files) => {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
@ -659,11 +666,11 @@ dirPythonMod = (mod, cb) => {
|
|||||||
getNodeJsCommand = () => {
|
getNodeJsCommand = () => {
|
||||||
var obj = getSandboxFuns()
|
var obj = getSandboxFuns()
|
||||||
obj.Buffer = Buffer
|
obj.Buffer = Buffer
|
||||||
obj.quickcommand.enterData = {code: '', type: '', payload: ''}
|
obj.quickcommand.enterData = { code: '', type: '', payload: '' }
|
||||||
return obj
|
return obj
|
||||||
}
|
}
|
||||||
|
|
||||||
htmlEncode = (value, raw=true) => {
|
htmlEncode = (value, raw = true) => {
|
||||||
return raw ? String(value).replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<").replace(/"/g, """) : value
|
return raw ? String(value).replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<").replace(/"/g, """) : value
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -789,38 +796,38 @@ clipboardReadText = () => {
|
|||||||
return electron.clipboard.readText()
|
return electron.clipboard.readText()
|
||||||
},
|
},
|
||||||
|
|
||||||
special = cmd => {
|
special = cmd => {
|
||||||
// 判断是否 windows 系统
|
// 判断是否 windows 系统
|
||||||
if (cmd.includes('{{isWin}}')) {
|
if (cmd.includes('{{isWin}}')) {
|
||||||
let repl = utools.isWindows() ? 1 : 0;
|
let repl = utools.isWindows() ? 1 : 0;
|
||||||
cmd = cmd.replace(/\{\{isWin\}\}/mg, repl)
|
cmd = cmd.replace(/\{\{isWin\}\}/mg, repl)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取本机唯一ID
|
// 获取本机唯一ID
|
||||||
if (cmd.includes('{{LocalId}}')) {
|
if (cmd.includes('{{LocalId}}')) {
|
||||||
let repl = utools.getLocalId();
|
let repl = utools.getLocalId();
|
||||||
cmd = cmd.replace(/\{\{LocalId\}\}/mg, repl)
|
cmd = cmd.replace(/\{\{LocalId\}\}/mg, repl)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取浏览器当前链接
|
// 获取浏览器当前链接
|
||||||
if (cmd.includes('{{BrowserUrl}}')) {
|
if (cmd.includes('{{BrowserUrl}}')) {
|
||||||
let repl = utools.getCurrentBrowserUrl();
|
let repl = utools.getCurrentBrowserUrl();
|
||||||
cmd = cmd.replace(/\{\{BrowserUrl\}\}/mg, repl)
|
cmd = cmd.replace(/\{\{BrowserUrl\}\}/mg, repl)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取剪切板的文本
|
// 获取剪切板的文本
|
||||||
if (cmd.includes('{{ClipText}}')) {
|
if (cmd.includes('{{ClipText}}')) {
|
||||||
let repl = clipboardReadText();
|
let repl = clipboardReadText();
|
||||||
cmd = cmd.replace(/\{\{ClipText\}\}/mg, repl)
|
cmd = cmd.replace(/\{\{ClipText\}\}/mg, repl)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取选中的文本
|
// 获取选中的文本
|
||||||
// if (cmd.includes('{{SelectText}}')) {
|
// if (cmd.includes('{{SelectText}}')) {
|
||||||
// let repl = getSelectText();
|
// let repl = getSelectText();
|
||||||
// cmd = cmd.replace(/\{\{SelectText\}\}/mg, repl)
|
// cmd = cmd.replace(/\{\{SelectText\}\}/mg, repl)
|
||||||
// }
|
// }
|
||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
runCodeFile = (cmd, option, terminal, callback) => {
|
runCodeFile = (cmd, option, terminal, callback) => {
|
||||||
var bin = option.bin,
|
var bin = option.bin,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user