样式调整

This commit is contained in:
fofolee 2020-07-05 10:54:42 +08:00
parent ddacf5f031
commit 03a1f3bba5

View File

@ -49,17 +49,6 @@ const shortCodes = [
} }
] ]
let getSleepCodeByShell = ms => {
var cmd, tempFilePath
if (utools.isWindows()) {
tempFilePath = getQuickCommandScriptFile('vbs')
cmd = `echo set ws=CreateObject("Wscript.Shell") > ${tempFilePath} && echo Wscript.sleep ${ms} >> ${tempFilePath} && cscript /nologo ${tempFilePath}`
} else {
cmd = `sleep ${ms / 1000}`
}
return cmd
}
quickcommand = { quickcommand = {
// 模拟复制操作 // 模拟复制操作
simulateCopy: function() { simulateCopy: function() {
@ -109,9 +98,14 @@ quickcommand = {
} }
var result = [] var result = []
var options = { var options = {
onBeforeOpen: () => {
document.getElementById(`inputBox0`).focus()
$(".output").is(":parent") && utools.setExpendHeight(600) || modWindowHeight($('.swal2-popup').outerHeight() + 20)
},
html: html, html: html,
focusConfirm: false, focusConfirm: false,
backdrop: utools.isDarkColors() ? '#464646' : '#bbb', showCancelButton: true,
backdrop: utools.isDarkColors() ? '#fff0' : '#bbb',
preConfirm: () => { preConfirm: () => {
for (let i = 0; i < inputBoxNumbers; i++) { for (let i = 0; i < inputBoxNumbers; i++) {
result.push(document.getElementById(`inputBox${i}`).value) result.push(document.getElementById(`inputBox${i}`).value)
@ -144,25 +138,28 @@ quickcommand = {
callback({ index: i, text: buttons[i] }) callback({ index: i, text: buttons[i] })
swal.clickConfirm() swal.clickConfirm()
} }
$(".output").is(":parent") && utools.setExpendHeight(600) || modWindowHeight($('.swal2-popup').outerHeight() + 20)
}, },
html: html, html: html,
backdrop: utools.isDarkColors() ? '#464646' : '#bbb', backdrop: utools.isDarkColors() ? '#fff0' : '#bbb',
showConfirmButton: false showConfirmButton: false
} }
swalOneByOne(options) swalOneByOne(options)
}, },
// 显示自动消失的提示框 // 显示自动消失的提示框
showMessageBox: function (title, icon = "success") { showMessageBox: function (title, icon = "success", time = 3000) {
var options = { var options = {
icon: icon, icon: icon,
title: title, title: title,
toast: true, toast: true,
position: 'top', position: 'top',
timer: 3000, // timer: time,
onOpen: (toast) => { showConfirmButton: false,
toast.addEventListener('mouseenter', Swal.stopTimer) onOpen: toast => {
toast.addEventListener('mouseleave', Swal.resumeTimer) // toast.addEventListener('mouseenter', Swal.stopTimer)
// toast.addEventListener('mouseleave', Swal.resumeTimer)
setTimeout(() => { Swal.clickConfirm() }, time);
} }
} }
swalOneByOne(options) swalOneByOne(options)
@ -181,11 +178,6 @@ quickcommand = {
opt.placeholder || (opt.placeholder = "搜索,支持拼音") opt.placeholder || (opt.placeholder = "搜索,支持拼音")
opt.enableHTML || (opt.enableHTML = false) opt.enableHTML || (opt.enableHTML = false)
typeof opt.closeOnSelect == 'undefined' && (opt.closeOnSelect = true) typeof opt.closeOnSelect == 'undefined' && (opt.closeOnSelect = true)
// 调整插件高度
let modWindowHeight = () => {
var height = $('.select2-results').height()
if ($('#options').is(':hidden')) utools.setExpendHeight(height > 600 ? 600 : height);
}
if ($('#quickselect').length) $('#quickselect').remove() if ($('#quickselect').length) $('#quickselect').remove()
$("body").append(`<div id="quickselect"><select id="selectBox"></select></div>`) $("body").append(`<div id="quickselect"><select id="selectBox"></select></div>`)
var selectBoxNumbers = selects.length var selectBoxNumbers = selects.length
@ -220,10 +212,11 @@ quickcommand = {
$('#selectBox').val(null).trigger('change') $('#selectBox').val(null).trigger('change')
$('#selectBox').select2('open') $('#selectBox').select2('open')
$('#quickselect .select2').hide() $('#quickselect .select2').hide()
modWindowHeight() opt.enableHTML || $('.select2-results').css({'line-height': '50px'})
modWindowHeight($('.select2-results').height())
utools.setSubInput(({text})=>{ utools.setSubInput(({text})=>{
$("#quickselect .select2-search__field").val(text).trigger('input') $("#quickselect .select2-search__field").val(text).trigger('input')
modWindowHeight() modWindowHeight($('.select2-results').height())
}, opt.placeholder) }, opt.placeholder)
$('#selectBox').on('select2:select', function (e) { $('#selectBox').on('select2:select', function (e) {
callback({ index: $(this).val(), text: $(`option[value="${$(this).val()}"]`).text() }) callback({ index: $(this).val(), text: $(`option[value="${$(this).val()}"]`).text() })
@ -267,8 +260,8 @@ quickcommand = {
}, },
// 关闭进程 // 关闭进程
kill: function (pid) { kill: function (pid, signal = 'SIGTERM') {
process.kill(pid) process.kill(pid, signal)
}, },
// dom 解析 // dom 解析
@ -301,6 +294,21 @@ swalOneByOne = options => {
swal.getQueueStep() && Swal.insertQueueStep(options) || Swal.queue([options]) swal.getQueueStep() && Swal.insertQueueStep(options) || Swal.queue([options])
} }
let getSleepCodeByShell = ms => {
var cmd, tempFilePath
if (utools.isWindows()) {
tempFilePath = getQuickCommandScriptFile('vbs')
cmd = `echo set ws=CreateObject("Wscript.Shell") > ${tempFilePath} && echo Wscript.sleep ${ms} >> ${tempFilePath} && cscript /nologo ${tempFilePath}`
} else {
cmd = `sleep ${ms / 1000}`
}
return cmd
}
let modWindowHeight = height => {
$('#options').is(':hidden') && utools.setExpendHeight(height > 600 ? 600 : height);
}
// 屏蔽危险函数 // 屏蔽危险函数
var getuToolsLite = () => { var getuToolsLite = () => {
var utoolsLite = Object.assign({}, utools) var utoolsLite = Object.assign({}, utools)
@ -523,6 +531,16 @@ getFileInfo = options => {
return information return information
} }
getCurrentFolderPathFix = () => {
let pwd = utools.getCurrentFolderPath()
if(typeof pwd == 'undefined'){
pwd = path.join(utools.getPath('home'), 'desktop')
}else{
pwd = pwd.replace(/\\/g, '\\\\')
}
return pwd
}
saveFile = (options, content) => { saveFile = (options, content) => {
var filename = utools.showSaveDialog(options) var filename = utools.showSaveDialog(options)
filename && fs.writeFile(filename, content, 'utf8', err => { filename && fs.writeFile(filename, content, 'utf8', err => {