v0.1.3 补充

1、通过快捷键打开颜色取色器
2、通过快捷键打开咖啡因
3、json 解析器工具修改为菜鸟工具的解析器
4、优化一些BUG
This commit is contained in:
sugood
2022-01-08 18:38:39 +08:00
parent 53ee0e4030
commit 061b86795c
6 changed files with 108 additions and 31 deletions
+28 -12
View File
@@ -4,7 +4,7 @@
--- DateTime: 2020/10/24 14:13
---
local console = require("hs.console")
version = "v0.1.2"
version = "v0.1.3"
configPath= "~/.hammerspoon/data/config.json"
initConfigPath= "~/.hammerspoon/data/initConfig.json"
config = {}
@@ -124,15 +124,7 @@ function initMenu()
end },
{ title = "-" },
{ title = "屏幕取色", fn = function()
hs.openConsole(true)
colorDialog.show()
colorDialog.mode("RGB")
colorDialog.callback(function(a,b)
if b then
hs.closeConsole()
end
end)
hs.closeConsole()
openColorDilog()
end },
{ title = "-" },
{ title = "咖啡因:" .. config[1].caffeine, fn = function()
@@ -170,7 +162,7 @@ function initData()
initMenu()
-- 修改全局alert样式
hs.alert.defaultStyle.strokeColor = {white = 1, alpha = 0}
hs.alert.defaultStyle.fillColor = {white = 0.05, alpha = 0.75}
hs.alert.defaultStyle.fillColor = {white = 0.05, alpha = 0.50}
hs.alert.defaultStyle.radius = 10
--清空打印信息
console.clearConsole()
@@ -259,4 +251,28 @@ function isCopySuccess()
local numAfter = hs.pasteboard.changeCount()
print("复制后数量:"..numAfter)
return numAfter > num
end
end
--打开取色器
function openColorDilog()
hs.openConsole(true)
colorDialog.show()
colorDialog.mode("RGB")
colorDialog.callback(function(a,b)
if b then
hs.closeConsole()
end
end)
hs.closeConsole()
end
--设置取色器快捷键
hs.hotkey.bind(hyperCmd, "P", function ()
openColorDilog()
end)
--设置咖啡因快捷键
hs.hotkey.bind(hyperCmd, "C", function ()
switchCaffeine()
end)
+2 -2
View File
@@ -71,7 +71,7 @@ function initData()
else
hs.hid.led.set('caps',false)
hs.alert.closeAll(0)
hs.alert.show("键盘小写 🔤- OFF")
hs.alert.show("键盘小写 🔤- OFF", 0.5)
if(isChinese()) then
if(reverse) then
macMenubar:setIcon(imgInputCn)
@@ -86,7 +86,7 @@ function initData()
if hs.hid.capslock.get() then
hs.hid.led.set('caps',true)
hs.alert.closeAll(0)
hs.alert.show("键盘大写 🅰️- ON")
hs.alert.show("键盘大写 🅰️- ON", 0.5)
macMenubar:setIcon(imgInputU)
else
--print("小写2")
+34 -14
View File
@@ -18,12 +18,16 @@ local function generateHtml()
<style>
body { height: 100%; margin:0; font-family:"微软雅黑"; font-size:12px; }
.pdiv { height: 85%; position: absolute; }
.title { height: auto; font-size:20px; text-align:center; margin-top: 5px; margin-bottom: 20px;}
.title { height: auto; font-size:20px; text-align:center; margin-top: 5px; margin-bottom: 20px; position:fixed; top:0;}
.author { height: auto; width: 100%; font-size:12px; text-align:center; margin-top: 30px; margin-bottom: 20px;}
table { height: 100%; width:100%; border-collapse:collapse; }
table .tdLeft { width:85%; text-align:left; padding-left: 10px;padding-right: 10px;}
table .tdmid { width:150px; text-align:center; margin: 0px; padding: 0px;}
table .tdRight { width:85%; padding-right: 30px;text-align:left; }
.tableContext{ height: 100%; width:100%; border-collapse:collapse; margin-top: 60px}
.tableTop { height: 20px; width:100%; border-collapse:collapse;}
table .tdLeft { width:30%; text-align:left; padding-left: 10px;padding-right: 10px; ;}
table .tdmid { width:10px; text-align:center; margin: 0px; padding: 0px; margin-top: 100px;}
table .tdRight { width:85%; padding-right: 30px;text-align:left; margin-top: 100px;}
table .tdTopLeft { width:20%; height:10%; text-align:left; padding-left: 10px;padding-right: 10px;}
table .tdTopMid { width:200px; height:10%; text-align:center; margin: 0px; padding: 0px;}
table .tdTopRight { width:85%; height:10%; padding-right: 30px;text-align:right; }
table textarea { width:100%; height:100%; font-size:14px; padding-top: 10px; padding-left: 10px; outline: none; border-radius: 15px; border: 2px solid #8AC007; }
#container { width:100%; height:100%; font-size:14px; padding-top: 10px; padding-left: 10px; border-radius: 15px; border: 2px solid #8AC007;}
pre{white-space:pre-wrap; white-space:-moz-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word; margin: 0px; padding: 5px;}
@@ -36,17 +40,29 @@ local function generateHtml()
</head>
<body>
<div class="pdiv">
<div class="title" >Json格式化高亮展示工具</div>
<table style="table-layout:fixed">
<div class="title" >
Json格式化高亮展示工具
<table class="tableTop">
<tr>
<td class="tdTopLeft">
<input style="width:auto; margin: 10px;" type="button" value="复制" onClick="copySource()">
</td>
<td class="tdTopMid" valign="top"><input style="width:100%;" type="button" value="格式化JSON >>" onClick="showJson()"></td>
<td class="tdTopRight">
<input style="width:auto; margin: 10px;" type="button" value="复制" onClick="copyResult()">
</td>
</tr>
</table>
</div>
<table class="tableContext" style="table-layout:fixed">
<tr>
<!-- <td class="tdLeft" nowrap>请输入要展示的Json:</td> -->
<td class="tdLeft">
<input style="width:auto; margin: 10px;" type="button" value="复制" onClick="copySource()">
<textarea name = "jsonContent" id="jsonContent" ></textarea>
</td>
<td class="tdmid"><input style="width:80%;" type="button" value="格式化JSON >>" onClick="showJson()"></td>
<td class="tdmid" valign="top"></td>
<td class="tdRight">
<input style="width:auto; margin: 10px;" type="button" value="复制" onClick="copyResult()">
<pre id="container"></pre>
</td>
</tr>
@@ -174,12 +190,14 @@ function init()
sheetView:windowStyle("utility")
sheetView:titleVisibility("hidden")
sheetView:allowGestures(true)
sheetView:allowNewWindows(false)
sheetView:allowNewWindows(true)
sheetView:allowTextEntry(true)
sheetView:closeOnEscape(true)
sheetView:bringToFront(false)
sheetView:darkMode(true)
sheetView:reload(false)
sheetView:shadow(true)
sheetView:alpha(1)
sheetView:level(hs.drawing.windowLevels.mainMenu)
end
@@ -188,15 +206,17 @@ end
--- Show current application's keybindings in a view.
function show(time)
local webcontent = generateHtml()
sheetView:html(webcontent, "http://localhost")
-- sheetView:html(webcontent, "http://localhost")
-- sheetView:url("https://www.jsonin.com/")
sheetView:url("https://c.runoob.com/front-end/53/")
sheetView:show(time)
end
function toggle()
if sheetView and sheetView:hswindow() and sheetView:hswindow():isVisible() then
hide(2)
hide(1)
else
show(2)
show(1)
end
end