mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-12-18 01:44:36 +08:00
添加历史代码功能
This commit is contained in:
15
src/js/importAll.js
Normal file
15
src/js/importAll.js
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* 快速导入同一目录下的所有脚本
|
||||
*/
|
||||
|
||||
const importAll = context => {
|
||||
const map = {}
|
||||
for (const key of context.keys()) {
|
||||
const keyArr = key.split('/')
|
||||
keyArr.shift()
|
||||
map[keyArr.join('.').replace(/\.js$/g, '')] = context(key)
|
||||
}
|
||||
return map
|
||||
}
|
||||
|
||||
export default importAll
|
||||
107
src/js/programs.js
Normal file
107
src/js/programs.js
Normal file
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
* 所有支持的编程语言
|
||||
*/
|
||||
|
||||
const programs = {
|
||||
quickcommand: {
|
||||
name: "quickcommand",
|
||||
highlight: "javascript",
|
||||
bin: "",
|
||||
argv: "",
|
||||
ext: "",
|
||||
color: "#006e54",
|
||||
},
|
||||
shell: {
|
||||
name: "shell",
|
||||
bin: "bash",
|
||||
argv: "",
|
||||
ext: "sh",
|
||||
color: "#89e051",
|
||||
},
|
||||
applescript: {
|
||||
name: "applescript",
|
||||
bin: "osascript",
|
||||
argv: "",
|
||||
ext: "scpt",
|
||||
color: "#101F1F",
|
||||
},
|
||||
cmd: {
|
||||
name: "cmd",
|
||||
highlight: "bat",
|
||||
bin: "",
|
||||
argv: "",
|
||||
ext: "bat",
|
||||
color: "#C1F12E",
|
||||
},
|
||||
powershell: {
|
||||
name: "powershell",
|
||||
bin: "powershell",
|
||||
argv: "-NoProfile -File",
|
||||
ext: "ps1",
|
||||
color: "#012456",
|
||||
},
|
||||
python: {
|
||||
name: "python",
|
||||
bin: "python",
|
||||
argv: "-u",
|
||||
ext: "py",
|
||||
color: "#3572A5",
|
||||
},
|
||||
javascript: {
|
||||
name: "javascript",
|
||||
bin: "node",
|
||||
argv: "",
|
||||
ext: "js",
|
||||
color: "#f1e05a",
|
||||
},
|
||||
ruby: {
|
||||
name: "ruby",
|
||||
bin: "ruby",
|
||||
argv: "",
|
||||
ext: "rb",
|
||||
color: "#701516",
|
||||
},
|
||||
php: {
|
||||
name: "php",
|
||||
bin: "php",
|
||||
argv: "",
|
||||
ext: "php",
|
||||
color: "#4F5D95",
|
||||
},
|
||||
c: {
|
||||
name: "c",
|
||||
bin: "gcc",
|
||||
argv: "-o",
|
||||
ext: "c",
|
||||
color: "#555555",
|
||||
},
|
||||
csharp: {
|
||||
name: "csharp",
|
||||
bin: "C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\csc.exe",
|
||||
argv: "/Nologo",
|
||||
ext: "cs",
|
||||
color: "#178600",
|
||||
},
|
||||
lua: {
|
||||
name: "lua",
|
||||
bin: "lua",
|
||||
argv: "",
|
||||
ext: "lua",
|
||||
color: "#000080",
|
||||
},
|
||||
perl: {
|
||||
name: "perl",
|
||||
bin: "perl",
|
||||
argv: "",
|
||||
ext: "pl",
|
||||
color: "#0298c3",
|
||||
},
|
||||
custom: {
|
||||
name: "custom",
|
||||
bin: "",
|
||||
argv: "",
|
||||
ext: "",
|
||||
color: "#438eff",
|
||||
},
|
||||
};
|
||||
export default programs
|
||||
@@ -14,8 +14,8 @@ let showInputBox = (options = [], title = "") => {
|
||||
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(() => "")
|
||||
if (!props.values) props.values = options.labels.map(() => "")
|
||||
if (!props.hints) props.hints = options.labels.map(() => "")
|
||||
Dialog.create({
|
||||
component: inputBox,
|
||||
componentProps: props
|
||||
|
||||
51
src/js/utools.js
Normal file
51
src/js/utools.js
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* 阉割utools,同时返回一个满血版的UTOOLS
|
||||
* 防止输出html输出时,通过script标签调用utools执行危险函数
|
||||
*/
|
||||
|
||||
// 禁用危险函数
|
||||
let whole = window.utools
|
||||
if (!utools.isDev()) window.utools = window.getuToolsLite()
|
||||
|
||||
// 数据库前缀
|
||||
const DBPRE = {
|
||||
QC: 'qc_',
|
||||
CFG: 'cfg_',
|
||||
PAN: 'pan_'
|
||||
}
|
||||
|
||||
// 数据库函数封装
|
||||
let getDB = id => {
|
||||
let db = whole.db.get(id)
|
||||
return db ? db.data : {}
|
||||
}
|
||||
|
||||
let putDB = (value, id) => {
|
||||
let db = whole.db.get(id);
|
||||
if (db) whole.db.put({
|
||||
_id: id,
|
||||
data: value,
|
||||
_rev: db._rev
|
||||
})
|
||||
else whole.db.put({
|
||||
_id: id,
|
||||
data: value
|
||||
});
|
||||
}
|
||||
|
||||
let delDB = id => {
|
||||
return whole.db.remove(id)
|
||||
}
|
||||
|
||||
let getDocs = key => {
|
||||
return whole.db.allDocs(key)
|
||||
}
|
||||
|
||||
export default {
|
||||
whole,
|
||||
getDB,
|
||||
putDB,
|
||||
delDB,
|
||||
getDocs,
|
||||
DBPRE
|
||||
}
|
||||
Reference in New Issue
Block a user