diff --git a/src/assets/index.js b/src/assets/index.js
index cd80057..669dec9 100644
--- a/src/assets/index.js
+++ b/src/assets/index.js
@@ -62,7 +62,7 @@
putDB({ cmd: cmd, program: program, scptarg: scptarg, customoptions: customoptions }, CFG_PREFIX + 'codeHistory')
}
// 初始化
- $("#options, #out").empty()
+ $("#options, #out, #quickpanel").empty()
$('body').children(':not(#wrapper)').remove()
$('body').css({overflow: 'hidden'})
if (handleEnter) document.removeEventListener('keydown', handleEnter)
@@ -86,11 +86,15 @@
if (qcparser.single) qc = qcparser.qc
}
editCurrentCommand(qc, false)
+ } else if (code.slice(0,6) == 'panel_') {
+ utools.setExpendHeight(600)
+ let features = getPanelFeatures(payload)
+ showPanel(features)
} else {
// console.log(new Date().getTime() - window.startTime);
$('body').css({overflow: 'auto'})
utools.setExpendHeight(0);
- $("#options").hide();
+ $("#options, #quickpanel").hide();
var db = getDB(QC_PREFIX + code),
cmd = db.cmd;
if (db.program == "custom") {
@@ -597,11 +601,22 @@
`
}
+ let getCurrentFts = () => {
+ let features = utools.getFeatures()
+ let currentFts = []
+ let quickpanels = []
+ features.forEach(x => x.code.slice(0, 6) == 'panel_' ? quickpanels.push(decodeURI(x.code.slice(6))) : currentFts.push(x))
+ return {
+ currentFts: currentFts,
+ quickpanels: quickpanels,
+ }
+ }
+
// 显示设置界面
let showOptions = (tag = "默认") => {
$("#options").empty().fadeIn();
- var currentFts = utools.getFeatures(),
- customFts = getAllQuickCommands();
+ var currentFts = getCurrentFts().currentFts
+ var customFts = getAllQuickCommands()
var allTags = ["默认"]
var featureList = `
@@ -616,11 +631,16 @@
}
})
featureList += `
`
- var sidebar = `
- `
+ var quickpanels = getCurrentFts().quickpanels
+ var sidebar =
+ ``
var footer = `
`
$("#options").append(sidebar + featureList + footer)
+ if (tag != '默认' || tag != '未分类') {
+ if (quickpanels.includes(tag)) $('#addToPanel').css({ "filter": "none" })
+ }
checkSharedQc()
}
@@ -746,6 +769,33 @@
})
}
+ let getPanelFeatures = tag => {
+ let activedCode = utools.getFeatures().map(x => x.code)
+ let features = utoolsFull.db.allDocs('qc_key_').filter(x => {
+ if (!x.data.tags) return false
+ if (!x.data.tags.includes(tag)) return false
+ if (x.data.features.platform && !x.data.features.platform.includes(window.processPlatform)) return false
+ if (!activedCode.includes(x.data.features.code)) return false
+ return true
+ })
+ return features
+ }
+
+ let showPanel = features => {
+ let panel = ''
+ let n = 0
+ features.forEach(p => {
+ if (n % 6 == 0) panel += ''
+ panel += `
+
+ ${p.data.features.explain}
+ | `
+ n += 1
+ if (n % 6 == 0) panel +='
'
+ });
+ $('#quickpanel').html(panel + '
').show()
+ }
+
let checkSharedQc = async () => {
let localShares = getDB(CFG_PREFIX + 'sharedQcCounts')[window.processPlatform] || 0
let remoteShares = await getDocsFromYuQue()
@@ -1039,9 +1089,34 @@
break;
case 'clear': clearAll();
break;
+ case 'addToPanel': addToPanel()
}
})
+ let addToPanel = () => {
+ let tag = $('.currentTag').text()
+ if (tag == '默认' || tag == '未分类') return quickcommand.showMessageBox('当前标签不支持', 'error')
+ let code = `panel_${encodeURI(tag)}`
+ if (!utoolsFull.removeFeature(code)) {
+ let features = getPanelFeatures(tag)
+ if (features.length == 0) return quickcommand.showMessageBox('快捷面板仅支持匹配模式为关键词的命令,当前标签不存在该类型命令或者该命令未启用', 'error', 8000)
+ let feature = {
+ code: code,
+ explain: `${tag}面板`,
+ cmds: [tag],
+ icon: "logo/quickpanel.png"
+ }
+ utoolsFull.setFeature(feature);
+ $('#addToPanel').css({ "filter": "none" })
+ $('.currentTag').addClass('panelTag')
+ quickcommand.showMessageBox(`已为当前标签启动快捷面板
utools 中直接输入${tag}即可进入`, 'success', 5000)
+ } else {
+ $('#addToPanel').attr("style", "")
+ $('.currentTag').removeClass('panelTag')
+ quickcommand.showMessageBox("已取消当前标签的快捷面板")
+ }
+ }
+
let editCurrentCommand = async (data, animate = true) => {
let features = data.features || {}
let code = features.code
@@ -1053,6 +1128,7 @@
fromShare: data.fromShare
}
if (data.tags && data.tags.includes("默认")) readonly = true
+ if($('#options').is(":empty")) showOptions()
showCustomize(readonly);
$('#customize').data('extraInfo', extraInfo)
data.tags && $('#tags').val(data.tags).trigger('change')
@@ -1802,14 +1878,14 @@
-
-
+ 运 行
+ 编码设置
-
-
-
+ 格式化
+
+ ?文档
@@ -1818,7 +1894,7 @@
createEditor()
$(".CodeMirror").addClass('CodeMirror-coderunner')
$("#customize").css({ top: '0px', padding: '0px' });
- $("span.customscript > input").css({"height": "30px"})
+ $("span.customscript > input").css({"height": "26px"})
var history = getDB(CFG_PREFIX + 'codeHistory')
createProgramSelect2(140, true)
if (file) {
@@ -1937,6 +2013,11 @@
}
})
+ $("#quickpanel").on('click', 'img', function () {
+ let cmd = $(this).attr('cmd')
+ utools.redirect(cmd)
+ })
+
Mousetrap.bind('ctrl+s', () => {
SaveCurrentCommand()
return false
diff --git a/src/index.html b/src/index.html
index ad56f7f..b236da6 100755
--- a/src/index.html
+++ b/src/index.html
@@ -22,6 +22,7 @@
diff --git a/src/logo/quickpanel.png b/src/logo/quickpanel.png
new file mode 100644
index 0000000..687f6d4
Binary files /dev/null and b/src/logo/quickpanel.png differ