mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-08 14:34:13 +08:00
精简全局变量
This commit is contained in:
parent
0e8f95a0a1
commit
8df2305879
41
package-lock.json
generated
41
package-lock.json
generated
@ -12,6 +12,7 @@
|
|||||||
"core-js": "^3.6.5",
|
"core-js": "^3.6.5",
|
||||||
"monaco-editor": "^0.33.0",
|
"monaco-editor": "^0.33.0",
|
||||||
"monaco-editor-webpack-plugin": "^7.0.1",
|
"monaco-editor-webpack-plugin": "^7.0.1",
|
||||||
|
"pinyin-match": "^1.2.2",
|
||||||
"quasar": "^2.6.0",
|
"quasar": "^2.6.0",
|
||||||
"raw-loader": "^4.0.2",
|
"raw-loader": "^4.0.2",
|
||||||
"vue": "^3.0.0",
|
"vue": "^3.0.0",
|
||||||
@ -5801,7 +5802,6 @@
|
|||||||
"version": "2.3.2",
|
"version": "2.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
||||||
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
||||||
"dev": true,
|
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@ -8132,6 +8132,14 @@
|
|||||||
"url": "https://github.com/sponsors/jonschlinkert"
|
"url": "https://github.com/sponsors/jonschlinkert"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/pinyin-match": {
|
||||||
|
"version": "1.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/pinyin-match/-/pinyin-match-1.2.2.tgz",
|
||||||
|
"integrity": "sha512-C0yOq4LkToJMkDHiQFKOY69El2GRcwdS2lVEjgWjIV8go3wE4mloGFNkVicGHFGYHDg523m2/lKzW8Hh+JR9nw==",
|
||||||
|
"dependencies": {
|
||||||
|
"rollup": "^2.44.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/pkg-dir": {
|
"node_modules/pkg-dir": {
|
||||||
"version": "4.2.0",
|
"version": "4.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz",
|
||||||
@ -9253,6 +9261,20 @@
|
|||||||
"url": "https://github.com/sponsors/isaacs"
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/rollup": {
|
||||||
|
"version": "2.70.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.70.1.tgz",
|
||||||
|
"integrity": "sha512-CRYsI5EuzLbXdxC6RnYhOuRdtz4bhejPMSWjsFLfVM/7w/85n2szZv6yExqUXsBdz5KT8eoubeyDUDjhLHEslA==",
|
||||||
|
"bin": {
|
||||||
|
"rollup": "dist/bin/rollup"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.0.0"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"fsevents": "~2.3.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/rtlcss": {
|
"node_modules/rtlcss": {
|
||||||
"version": "3.5.0",
|
"version": "3.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/rtlcss/-/rtlcss-3.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/rtlcss/-/rtlcss-3.5.0.tgz",
|
||||||
@ -15748,7 +15770,6 @@
|
|||||||
"version": "2.3.2",
|
"version": "2.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
||||||
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
||||||
"dev": true,
|
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
"function-bind": {
|
"function-bind": {
|
||||||
@ -17484,6 +17505,14 @@
|
|||||||
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
|
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"pinyin-match": {
|
||||||
|
"version": "1.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/pinyin-match/-/pinyin-match-1.2.2.tgz",
|
||||||
|
"integrity": "sha512-C0yOq4LkToJMkDHiQFKOY69El2GRcwdS2lVEjgWjIV8go3wE4mloGFNkVicGHFGYHDg523m2/lKzW8Hh+JR9nw==",
|
||||||
|
"requires": {
|
||||||
|
"rollup": "^2.44.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"pkg-dir": {
|
"pkg-dir": {
|
||||||
"version": "4.2.0",
|
"version": "4.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz",
|
||||||
@ -18241,6 +18270,14 @@
|
|||||||
"glob": "^7.1.3"
|
"glob": "^7.1.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"rollup": {
|
||||||
|
"version": "2.70.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.70.1.tgz",
|
||||||
|
"integrity": "sha512-CRYsI5EuzLbXdxC6RnYhOuRdtz4bhejPMSWjsFLfVM/7w/85n2szZv6yExqUXsBdz5KT8eoubeyDUDjhLHEslA==",
|
||||||
|
"requires": {
|
||||||
|
"fsevents": "~2.3.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"rtlcss": {
|
"rtlcss": {
|
||||||
"version": "3.5.0",
|
"version": "3.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/rtlcss/-/rtlcss-3.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/rtlcss/-/rtlcss-3.5.0.tgz",
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
"core-js": "^3.6.5",
|
"core-js": "^3.6.5",
|
||||||
"monaco-editor": "^0.33.0",
|
"monaco-editor": "^0.33.0",
|
||||||
"monaco-editor-webpack-plugin": "^7.0.1",
|
"monaco-editor-webpack-plugin": "^7.0.1",
|
||||||
|
"pinyin-match": "^1.2.2",
|
||||||
"quasar": "^2.6.0",
|
"quasar": "^2.6.0",
|
||||||
"raw-loader": "^4.0.2",
|
"raw-loader": "^4.0.2",
|
||||||
"vue": "^3.0.0",
|
"vue": "^3.0.0",
|
||||||
|
60
public/package-lock.json
generated
60
public/package-lock.json
generated
@ -7,8 +7,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.24.0",
|
"axios": "^0.24.0",
|
||||||
"iconv-lite": "^0.6.3",
|
"iconv-lite": "^0.6.3",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21"
|
||||||
"pinyin-match": "^1.2.2"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/axios": {
|
"node_modules/axios": {
|
||||||
@ -38,19 +37,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/fsevents": {
|
|
||||||
"version": "2.3.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
|
||||||
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
|
||||||
"hasInstallScript": true,
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"darwin"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/iconv-lite": {
|
"node_modules/iconv-lite": {
|
||||||
"version": "0.6.3",
|
"version": "0.6.3",
|
||||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
|
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
|
||||||
@ -67,28 +53,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
||||||
},
|
},
|
||||||
"node_modules/pinyin-match": {
|
|
||||||
"version": "1.2.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/pinyin-match/-/pinyin-match-1.2.2.tgz",
|
|
||||||
"integrity": "sha512-C0yOq4LkToJMkDHiQFKOY69El2GRcwdS2lVEjgWjIV8go3wE4mloGFNkVicGHFGYHDg523m2/lKzW8Hh+JR9nw==",
|
|
||||||
"dependencies": {
|
|
||||||
"rollup": "^2.44.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/rollup": {
|
|
||||||
"version": "2.63.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.63.0.tgz",
|
|
||||||
"integrity": "sha512-nps0idjmD+NXl6OREfyYXMn/dar3WGcyKn+KBzPdaLecub3x/LrId0wUcthcr8oZUAcZAR8NKcfGGFlNgGL1kQ==",
|
|
||||||
"bin": {
|
|
||||||
"rollup": "dist/bin/rollup"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10.0.0"
|
|
||||||
},
|
|
||||||
"optionalDependencies": {
|
|
||||||
"fsevents": "~2.3.2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/safer-buffer": {
|
"node_modules/safer-buffer": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||||
@ -109,12 +73,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz",
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz",
|
||||||
"integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w=="
|
"integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w=="
|
||||||
},
|
},
|
||||||
"fsevents": {
|
|
||||||
"version": "2.3.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
|
||||||
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"iconv-lite": {
|
"iconv-lite": {
|
||||||
"version": "0.6.3",
|
"version": "0.6.3",
|
||||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
|
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
|
||||||
@ -128,22 +86,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
||||||
},
|
},
|
||||||
"pinyin-match": {
|
|
||||||
"version": "1.2.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/pinyin-match/-/pinyin-match-1.2.2.tgz",
|
|
||||||
"integrity": "sha512-C0yOq4LkToJMkDHiQFKOY69El2GRcwdS2lVEjgWjIV8go3wE4mloGFNkVicGHFGYHDg523m2/lKzW8Hh+JR9nw==",
|
|
||||||
"requires": {
|
|
||||||
"rollup": "^2.44.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"rollup": {
|
|
||||||
"version": "2.63.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.63.0.tgz",
|
|
||||||
"integrity": "sha512-nps0idjmD+NXl6OREfyYXMn/dar3WGcyKn+KBzPdaLecub3x/LrId0wUcthcr8oZUAcZAR8NKcfGGFlNgGL1kQ==",
|
|
||||||
"requires": {
|
|
||||||
"fsevents": "~2.3.2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"safer-buffer": {
|
"safer-buffer": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.24.0",
|
"axios": "^0.24.0",
|
||||||
"iconv-lite": "^0.6.3",
|
"iconv-lite": "^0.6.3",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21"
|
||||||
"pinyin-match": "^1.2.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,10 @@ const {
|
|||||||
VM
|
VM
|
||||||
} = require('./lib/vm2')
|
} = require('./lib/vm2')
|
||||||
const path = require("path")
|
const path = require("path")
|
||||||
const util = require("util")
|
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const pictureCompress = require("./lib/picture-compressor")
|
const pictureCompress = require("./lib/picture-compressor")
|
||||||
|
|
||||||
_ = require("lodash")
|
window._ = require("lodash")
|
||||||
pinyinMatch = require('pinyin-match').match;
|
|
||||||
|
|
||||||
// axios.defaults.adapter = require('axios/lib/adapters/http')
|
// axios.defaults.adapter = require('axios/lib/adapters/http')
|
||||||
|
|
||||||
@ -55,7 +53,7 @@ const shortCodes = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
ctlKey = utools.isMacOs() ? 'command' : 'control'
|
const ctlKey = utools.isMacOs() ? 'command' : 'control'
|
||||||
|
|
||||||
window.quickcommand = {
|
window.quickcommand = {
|
||||||
// 模拟复制操作
|
// 模拟复制操作
|
||||||
@ -180,7 +178,7 @@ if (process.platform == 'win32') quickcommand.runVbs = function(script) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// python -c
|
// python -c
|
||||||
runPythonCommand = py => {
|
window.runPythonCommand = py => {
|
||||||
try {
|
try {
|
||||||
return child_process.execFileSync("python", ["-c", py], {
|
return child_process.execFileSync("python", ["-c", py], {
|
||||||
windowsHide: true,
|
windowsHide: true,
|
||||||
@ -191,7 +189,6 @@ runPythonCommand = py => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 在终端中执行
|
// 在终端中执行
|
||||||
if (process.platform !== 'linux') quickcommand.runInTerminal = function(cmdline, dir) {
|
if (process.platform !== 'linux') quickcommand.runInTerminal = function(cmdline, dir) {
|
||||||
let command = getCommandToLaunchTerminal(cmdline, dir)
|
let command = getCommandToLaunchTerminal(cmdline, dir)
|
||||||
@ -231,11 +228,7 @@ let getCommandToLaunchTerminal = (cmdline, dir) => {
|
|||||||
return command
|
return command
|
||||||
}
|
}
|
||||||
|
|
||||||
swalOneByOne = options => {
|
window.pluginInfo = () => {
|
||||||
swal.getQueueStep() ? Swal.insertQueueStep(options) : Swal.queue([options])
|
|
||||||
}
|
|
||||||
|
|
||||||
pluginInfo = () => {
|
|
||||||
return JSON.parse(fs.readFileSync(path.join(__dirname, 'plugin.json')))
|
return JSON.parse(fs.readFileSync(path.join(__dirname, 'plugin.json')))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,7 +253,7 @@ let getSleepCodeByShell = ms => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 屏蔽危险函数
|
// 屏蔽危险函数
|
||||||
getuToolsLite = () => {
|
window.getuToolsLite = () => {
|
||||||
var utoolsLite = Object.assign({}, utools)
|
var utoolsLite = Object.assign({}, utools)
|
||||||
if (utools.isDev()) return utoolsLite
|
if (utools.isDev()) return utoolsLite
|
||||||
// 数据库相关接口
|
// 数据库相关接口
|
||||||
@ -282,15 +275,6 @@ let getSandboxFuns = () => {
|
|||||||
utools: getuToolsLite(),
|
utools: getuToolsLite(),
|
||||||
quickcommand: quickcommand,
|
quickcommand: quickcommand,
|
||||||
electron: electron,
|
electron: electron,
|
||||||
fs: fs,
|
|
||||||
path: path,
|
|
||||||
os: os,
|
|
||||||
child_process: child_process,
|
|
||||||
util: util,
|
|
||||||
TextDecoder: TextDecoder,
|
|
||||||
TextEncoder: TextEncoder,
|
|
||||||
URL: URL,
|
|
||||||
URLSearchParams: URLSearchParams,
|
|
||||||
axios: axios,
|
axios: axios,
|
||||||
Audio: Audio,
|
Audio: Audio,
|
||||||
fetch: fetch
|
fetch: fetch
|
||||||
@ -349,7 +333,7 @@ let parseItem = item => {
|
|||||||
return item.toString()
|
return item.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
convertFilePathToUtoolsPayload = files => files.map(file => {
|
window.convertFilePathToUtoolsPayload = files => files.map(file => {
|
||||||
let isFile = fs.statSync(file).isFile()
|
let isFile = fs.statSync(file).isFile()
|
||||||
return {
|
return {
|
||||||
isFile: isFile,
|
isFile: isFile,
|
||||||
@ -361,12 +345,12 @@ convertFilePathToUtoolsPayload = files => files.map(file => {
|
|||||||
|
|
||||||
let parseStdout = stdout => stdout.map(x => parseItem(x)).join("\n")
|
let parseStdout = stdout => stdout.map(x => parseItem(x)).join("\n")
|
||||||
|
|
||||||
VmEval = (cmd, sandbox = {}) => new VM({
|
window.VmEval = (cmd, sandbox = {}) => new VM({
|
||||||
sandbox: sandbox
|
sandbox: sandbox
|
||||||
}).run(cmd)
|
}).run(cmd)
|
||||||
|
|
||||||
// The vm module of Node.js is deprecated in the renderer process and will be removed
|
// The vm module of Node.js is deprecated in the renderer process and will be removed
|
||||||
runCodeInVm = (cmd, cb) => {
|
window.runCodeInVm = (cmd, cb) => {
|
||||||
const vm = createNodeVM()
|
const vm = createNodeVM()
|
||||||
//重定向 console
|
//重定向 console
|
||||||
vm.on('console.log', (...stdout) => {
|
vm.on('console.log', (...stdout) => {
|
||||||
@ -416,95 +400,20 @@ runCodeInVm = (cmd, cb) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// shell代码提示,当前环境变量下的所有命令
|
window.htmlEncode = (value) => {
|
||||||
getShellCommand = () => {
|
|
||||||
var shellCommands = localStorage['shellCommands']
|
|
||||||
if (shellCommands) return
|
|
||||||
localStorage['shellCommands'] = '[]'
|
|
||||||
if (utools.isWindows()) return
|
|
||||||
process.env.PATH.split(':').forEach(d => {
|
|
||||||
fs.readdir(d, (err, files) => {
|
|
||||||
if (!err) {
|
|
||||||
var commands = files.filter(x => x[0] != "." || x[0] != '[')
|
|
||||||
localStorage['shellCommands'] = JSON.stringify(JSON.parse(localStorage['shellCommands']).concat(commands))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// cmd代码提示,当前环境变量下的所有命令
|
|
||||||
getCmdCommand = () => {
|
|
||||||
var cmdCommands = localStorage['cmdCommands']
|
|
||||||
if (cmdCommands) return
|
|
||||||
localStorage['cmdCommands'] = '[]'
|
|
||||||
if (!utools.isWindows()) return
|
|
||||||
process.env.Path.split(';').forEach(d => {
|
|
||||||
fs.readdir(d, (err, files) => {
|
|
||||||
if (!err) {
|
|
||||||
var commands = []
|
|
||||||
files.forEach(x => (x.length > 4 && x.slice(-4) == '.exe') && commands.push(x.slice(0, -4)))
|
|
||||||
localStorage['cmdCommands'] = JSON.stringify(JSON.parse(localStorage['cmdCommands']).concat(commands))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// python 代码提示,已安装的模块以及脚本内导入的模块的属性(方法)
|
|
||||||
getPythonMods = () => {
|
|
||||||
var pyModules = localStorage['pyModules']
|
|
||||||
if (pyModules) return
|
|
||||||
localStorage['pyModules'] = '[]'
|
|
||||||
child_process.exec(`python -c "print(__import__('sys').path)"`, (err, stdout, stderr) => {
|
|
||||||
if (err) return
|
|
||||||
stdout = JSON.parse(stdout.replace(/'/g, `"`)).forEach(s => {
|
|
||||||
fs.readdir(s, (err, m) => {
|
|
||||||
if (!err) {
|
|
||||||
var mods = []
|
|
||||||
m.forEach(d => (/\.py$|^[^-.]+$/.test(d)) && (d = d.split('.py')[0]) && (!mods.includes(d)) && mods.push(d))
|
|
||||||
localStorage['pyModules'] = JSON.stringify(JSON.parse(localStorage['pyModules']).concat(mods))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
dirPythonMod = (mod, cb) => {
|
|
||||||
child_process.exec(`python -c "print(dir(__import__('${mod}')))"`, (err, stdout, stderr) => {
|
|
||||||
if (err) return cb([])
|
|
||||||
cb(JSON.parse(stdout.replace(/'/g, `"`)).filter(x => x.slice(0, 2) != '__'))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
htmlEncode = (value) => {
|
|
||||||
return String(value).replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<").replace(/"/g, """)
|
return String(value).replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<").replace(/"/g, """)
|
||||||
}
|
}
|
||||||
|
|
||||||
hexEncode = text => Buffer.from(text, 'utf8').toString('hex')
|
window.hexEncode = text => Buffer.from(text, 'utf8').toString('hex')
|
||||||
hexDecode = text => Buffer.from(text, 'hex').toString('utf8')
|
window.hexDecode = text => Buffer.from(text, 'hex').toString('utf8')
|
||||||
|
|
||||||
py_beautify = (code, cb) => {
|
window.processPlatform = process.platform
|
||||||
var file = getQuickcommandTempFile('py')
|
|
||||||
fs.writeFile(file, code, {
|
|
||||||
encoding: 'utf8'
|
|
||||||
}, err => {
|
|
||||||
var cmd = `python "${GetFilePath('assets/plugins', 'autopep8.py')}" "${file}"`
|
|
||||||
child_process.exec(cmd, {
|
|
||||||
encoding: "buffer"
|
|
||||||
}, (err, stdout, stderr) => {
|
|
||||||
var codec = utools.isWindows() ? 'cp936' : 'utf8'
|
|
||||||
cb(iconv.decode(stdout, codec).trim())
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
processPlatform = process.platform
|
window.getQuickcommandTempFile = ext => {
|
||||||
|
|
||||||
getQuickcommandTempFile = ext => {
|
|
||||||
return path.join(os.tmpdir(), `quickcommandTempFile.${ext}`)
|
return path.join(os.tmpdir(), `quickcommandTempFile.${ext}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
getBase64Ico = async (filepath, compressed = true) => {
|
window.getBase64Ico = async (filepath, compressed = true) => {
|
||||||
let sourceImage, ext = path.extname(filepath).slice(1)
|
let sourceImage, ext = path.extname(filepath).slice(1)
|
||||||
if (['png', 'jpg', 'jpeg', 'bmp', 'ico', 'gif', 'svg'].includes(ext)) {
|
if (['png', 'jpg', 'jpeg', 'bmp', 'ico', 'gif', 'svg'].includes(ext)) {
|
||||||
if (ext == 'svg') ext = 'svg+xml'
|
if (ext == 'svg') ext = 'svg+xml'
|
||||||
@ -519,7 +428,7 @@ getBase64Ico = async (filepath, compressed = true) => {
|
|||||||
return compressedImage
|
return compressedImage
|
||||||
}
|
}
|
||||||
|
|
||||||
getCompressedIco = async (img, width = 80) => {
|
let getCompressedIco = async (img, width = 80) => {
|
||||||
let compressedImage = await pictureCompress({
|
let compressedImage = await pictureCompress({
|
||||||
img: img,
|
img: img,
|
||||||
width: width,
|
width: width,
|
||||||
@ -530,16 +439,7 @@ getCompressedIco = async (img, width = 80) => {
|
|||||||
return compressedImage.img
|
return compressedImage.img
|
||||||
}
|
}
|
||||||
|
|
||||||
getDefaultCommands = () => {
|
window.getFileInfo = options => {
|
||||||
let baseDir = path.join(__dirname, 'defaults')
|
|
||||||
let defaultCommands = {}
|
|
||||||
fs.readdirSync(baseDir).forEach(f => {
|
|
||||||
defaultCommands[f.slice(0, -5)] = path.join(baseDir, f)
|
|
||||||
})
|
|
||||||
return defaultCommands
|
|
||||||
}
|
|
||||||
|
|
||||||
getFileInfo = options => {
|
|
||||||
var file
|
var file
|
||||||
if (options.type == 'file') {
|
if (options.type == 'file') {
|
||||||
file = options.argvs
|
file = options.argvs
|
||||||
@ -562,13 +462,13 @@ getFileInfo = options => {
|
|||||||
return information
|
return information
|
||||||
}
|
}
|
||||||
|
|
||||||
getCurrentFolderPathFix = () => {
|
window.getCurrentFolderPathFix = () => {
|
||||||
let pwd = utools.getCurrentFolderPath()
|
let pwd = utools.getCurrentFolderPath()
|
||||||
let pwdFix = pwd ? pwd : path.join(utools.getPath('home'), 'desktop')
|
let pwdFix = pwd ? pwd : path.join(utools.getPath('home'), 'desktop')
|
||||||
return pwdFix.replace(/\\/g, '\\\\')
|
return pwdFix.replace(/\\/g, '\\\\')
|
||||||
}
|
}
|
||||||
|
|
||||||
getMatchedFilesFix = payload => {
|
window.getMatchedFilesFix = payload => {
|
||||||
let MatchedFiles = payload
|
let MatchedFiles = payload
|
||||||
let Matched = cmd.match(/\{\{MatchedFiles(\[\d+\]){0,1}(\.\w{1,11}){0,1}\}\}/g)
|
let Matched = cmd.match(/\{\{MatchedFiles(\[\d+\]){0,1}(\.\w{1,11}){0,1}\}\}/g)
|
||||||
Matched && Matched.forEach(m => {
|
Matched && Matched.forEach(m => {
|
||||||
@ -578,23 +478,14 @@ getMatchedFilesFix = payload => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
saveFile = (content, file) => {
|
window.saveFile = (content, file) => {
|
||||||
if (file instanceof Object) {
|
if (file instanceof Object) {
|
||||||
file = utools.showSaveDialog(file)
|
file = utools.showSaveDialog(file)
|
||||||
}
|
}
|
||||||
file && fs.writeFileSync(file, content)
|
file && fs.writeFileSync(file, content)
|
||||||
}
|
}
|
||||||
|
|
||||||
yuQueClient = axios.create({
|
window.getSelectFile = hwnd => {
|
||||||
baseURL: 'https://www.yuque.com/api/v2/',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
// 只读权限
|
|
||||||
'X-Auth-Token': 'WNrd0Z4kfCZLFrGLVAaas93DZ7sbG6PirKq7VxBL'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
getSelectFile = hwnd => {
|
|
||||||
if (utools.isWindows()) {
|
if (utools.isWindows()) {
|
||||||
var cmd = `powershell.exe -NoProfile "(New-Object -COM 'Shell.Application').Windows() | Where-Object { $_.HWND -eq ${hwnd} } | Select-Object -Expand Document | select @{ n='SelectItems'; e={$_.SelectedItems()} } | select -Expand SelectItems | select -Expand Path "`;
|
var cmd = `powershell.exe -NoProfile "(New-Object -COM 'Shell.Application').Windows() | Where-Object { $_.HWND -eq ${hwnd} } | Select-Object -Expand Document | select @{ n='SelectItems'; e={$_.SelectedItems()} } | select -Expand SelectItems | select -Expand Path "`;
|
||||||
let result = child_process.execSync(cmd, {
|
let result = child_process.execSync(cmd, {
|
||||||
@ -621,9 +512,9 @@ getSelectFile = hwnd => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clipboardReadText = () => electron.clipboard.readText()
|
window.clipboardReadText = () => electron.clipboard.readText()
|
||||||
|
|
||||||
runCodeFile = (cmd, option, terminal, callback) => {
|
window.runCodeFile = (cmd, option, terminal, callback) => {
|
||||||
var bin = option.bin,
|
var bin = option.bin,
|
||||||
argv = option.argv,
|
argv = option.argv,
|
||||||
ext = option.ext,
|
ext = option.ext,
|
||||||
|
@ -60,6 +60,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import pinyinMatch from "pinyin-match"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -86,7 +88,7 @@ export default {
|
|||||||
matchedItems() {
|
matchedItems() {
|
||||||
let matchedItems = this.searchWords
|
let matchedItems = this.searchWords
|
||||||
? this.items.filter((x) =>
|
? this.items.filter((x) =>
|
||||||
window.pinyinMatch(x.title ? x.title : x, this.searchWords)
|
pinyinMatch.match(x.title ? x.title : x, this.searchWords)
|
||||||
)
|
)
|
||||||
: this.items;
|
: this.items;
|
||||||
this.setUtoolsHeight(this.itemHeight * matchedItems.length);
|
this.setUtoolsHeight(this.itemHeight * matchedItems.length);
|
||||||
|
@ -201,6 +201,7 @@ import CommandCard from "components/CommandCard";
|
|||||||
import ConfigurationMenu from "components/ConfigurationMenu.vue";
|
import ConfigurationMenu from "components/ConfigurationMenu.vue";
|
||||||
import CommandRunResult from "components/CommandRunResult.vue";
|
import CommandRunResult from "components/CommandRunResult.vue";
|
||||||
import importAll from "../js/common/importAll.js";
|
import importAll from "../js/common/importAll.js";
|
||||||
|
import pinyinMatch from "pinyin-match";
|
||||||
|
|
||||||
const CommandEditor = defineAsyncComponent(() =>
|
const CommandEditor = defineAsyncComponent(() =>
|
||||||
import("components/CommandEditor.vue")
|
import("components/CommandEditor.vue")
|
||||||
@ -262,7 +263,7 @@ export default {
|
|||||||
commands.forEach((cmd) => {
|
commands.forEach((cmd) => {
|
||||||
// 拼音搜索
|
// 拼音搜索
|
||||||
let explain = cmd.features.explain;
|
let explain = cmd.features.explain;
|
||||||
let matchedWordPositions = window.pinyinMatch(
|
let matchedWordPositions = pinyinMatch.match(
|
||||||
explain,
|
explain,
|
||||||
this.commandSearchKeyword
|
this.commandSearchKeyword
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user