# Conflicts:
#	.gitignore
#	data/history.json
#	modules/commons.lua
#	modules/jsonFormat.lua

v0.1.3-1
合并冲突
This commit is contained in:
sugood 2022-01-10 09:48:27 +08:00
commit d9f4446ce3
6 changed files with 42 additions and 177 deletions

2
.gitignore vendored
View File

@ -1,3 +1,3 @@
/.idea/
/*.zip
.idea
.idea/

View File

@ -87,6 +87,8 @@ https://github.com/greyby/hammerspoon
* <kbd></kbd><kbd></kbd> + <kbd>G</kbd> JSON格式化
自动复制选中的文本
### 自动同步时间
* <kbd></kbd><kbd></kbd> + <kbd>T</kbd> 自动同步时间
@ -101,10 +103,14 @@ https://github.com/greyby/hammerspoon
### 屏幕取色功能
* <kbd></kbd><kbd></kbd> + <kbd>P</kbd> 颜色拾取器
菜单栏点击屏幕取色,出现取色界面后点击颜色拾取器,就可以获取当前屏幕鼠标所在位置的颜色值
### 咖啡因
* <kbd></kbd><kbd></kbd> + <kbd>C</kbd> 咖啡因
菜单栏点击 咖啡因打开系统永不休眠功能,再点击一次就能关闭
### 状态栏显示输入法状态

View File

@ -100,10 +100,14 @@ Support baidu and youdao translation API. Baidu Translation can be used directly
### Screen color selection function
* <kbd></kbd><kbd></kbd> + <kbd>P</kbd> Screen color selection function
Click the screen color in the menu bar, click the color picker after the screen color picker interface appears, and the color value at the position of the mouse on the screen can be obtained
### caffeine
* <kbd></kbd><kbd></kbd> + <kbd>C</kbd> caffeine
On the menu bar, click caffeine to turn on the system's never sleep feature, and then click again to turn it off
### The status bar shows the status of the input method

View File

@ -47,6 +47,10 @@
"subText" : "cmd|diff file1 file2|比较并显示两个文件的差异",
"text" : "diff"
},
{
"subText" : "cmd|journalctl -f -u xx.service -n1000|显示日志",
"text" : "journalctl -f -u xx.service -n1000"
},
{
"subText" : "cmd|kill -9 pid|终止进程",
"text" : "kill"
@ -148,8 +152,12 @@
"text" : "\/** \n* @Title: ${file_name} \n* @Package ${package_name} \n* @Description: ${todo}(用一句话描述该文件做什么) \n* @author sugood\n* @date ${date} ${time} \n* @version V1.0 \n*\/"
},
{
"subText" : "flutter build apk --no-shrink",
"text" : "flutter build apk --no-shrink"
"subText" : "flutter build apk --release",
"text" : "flutter build apk --release"
},
{
"subText" : "flutter build ios --release",
"text" : "flutter build ios --release"
},
{
"subText" : "flutter clean",
@ -159,6 +167,14 @@
"subText" : "flutter packages pub run build_runner build --delete-conflicting-outputs",
"text" : "flutter packages pub run build_runner build --delete-conflicting-outputs"
},
{
"subText" : "flutter doctor",
"text" : "flutter doctor"
},
{
"subText" : "flutter run --debug",
"text" : "flutter run --debug"
},
{
"subText" : "ins|brew install node|安装node",
"text" : "brew install node"

View File

@ -124,7 +124,7 @@ function initMenu()
end },
{ title = "-" },
{ title = "屏幕取色", fn = function()
openColorDilog()
openColorDialog()
end },
{ title = "-" },
{ title = "咖啡因:" .. config[1].caffeine, fn = function()
@ -253,8 +253,7 @@ function isCopySuccess()
return numAfter > num
end
--打开取色器
function openColorDilog()
function openColorDialog()
hs.openConsole(true)
colorDialog.show()
colorDialog.mode("RGB")
@ -266,13 +265,12 @@ function openColorDilog()
hs.closeConsole()
end
--设置取色器快捷键
--设置颜色拾取快键键
hs.hotkey.bind(hyperCmd, "P", function ()
openColorDilog()
openColorDialog()
end)
--设置咖啡因快捷
--设置颜色拾取快键
hs.hotkey.bind(hyperCmd, "C", function ()
switchCaffeine()
end)

View File

@ -6,170 +6,6 @@
--
--
local function generateHtml()
local html = [[
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Json格式化高亮展示工具</title>
<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; position:fixed; top:0;}
.author { height: auto; width: 100%; font-size:12px; text-align:center; margin-top: 30px; margin-bottom: 20px;}
.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;}
pre .string { color: green; }
pre .number { color: darkorange; }
pre .boolean { color: blue; }
pre .null { color: magenta; }
.key { color: red; }
</style>
</head>
<body>
<div class="pdiv">
<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">
<textarea name = "jsonContent" id="jsonContent" ></textarea>
</td>
<td class="tdmid" valign="top"></td>
<td class="tdRight">
<pre id="container"></pre>
</td>
</tr>
</table>
<div class="author">
<a href="https://github.com/sugood" target="_blank">By: github.com/sugood</a>
</div>
<div class="tips" id="tips">
</div>
</div>
</body>
<script type="text/javascript">
function copySource(){
var obj = document.getElementById('jsonContent');
//
obj.select();
try{
if(document.execCommand("Copy","false",null)){
alert("复制成功!");
}
}catch(err){
alert("复制错误!");
}
}
function copyResult(){
var text = document.getElementById('container').innerText;
const input = document.createElement('textarea');
input.value = text;
input.setAttribute('readonly', 'readonly');
document.body.appendChild(input);
input.select();
try{
if(document.execCommand('Copy')){
alert('复制成功');
}
}catch(err){
alert("复制错误!");
}
document.body.removeChild(input);
}
function syntaxHighlight(json) {
if (typeof json != 'string') {
json = JSON.stringify(json, undefined, 4);
}
json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
var cls = 'number';
if (/^"/.test(match)) {
if (/:$/.test(match)) {
cls = 'key';
} else {
cls = 'string';
}
} else if (/true|false/.test(match)) {
cls = 'boolean';
} else if (/null/.test(match)) {
cls = 'null';
}
return '<span class="' + cls + '">' + match + '</span>';
});
}
function showJson(){
var text = document.getElementById('jsonContent').value
if (text!="" && text!=null){
try {
var result = JSON.stringify(JSON.parse(text), null, 4);//json对象
highLineResult = syntaxHighlight(result);
document.getElementById('container').innerHTML= highLineResult;
localStorage.setItem("jsonFormatSource",text);
localStorage.setItem("jsonFormatResult",highLineResult);
} catch(e) {
document.getElementById('container').innerText= '异常信息:'+e ;
}
}else{
document.getElementById("jsonContent").value = "请输入json文本";
document.getElementById('container').innerHTML= "显示Json格式化后的效果";
localStorage.setItem("jsonFormatSource","请输入json文本");
localStorage.setItem("jsonFormatResult","显示Json格式化后的效果");
}
  };
var jsonFormatSource = localStorage.getItem("jsonFormatSource");
if (jsonFormatSource!="" && jsonFormatSource!=null){
document.getElementById("jsonContent").value=localStorage.getItem("jsonFormatSource");
}else{
document.getElementById("jsonContent").value = "请输入json文本"
}
var jsonFormatResult = localStorage.getItem("jsonFormatResult");
if (jsonFormatResult!="" && jsonFormatResult!=null){
document.getElementById("container").innerHTML=localStorage.getItem("jsonFormatResult");
}else{
document.getElementById("jsonContent").value = "显示Json格式化后的效果"
}
</script>
</html>
]]
return html
end
--- KSheet:hide()
--- Method
--- Hide the cheatsheet view.
@ -205,10 +41,11 @@ end
--- Method
--- Show current application's keybindings in a view.
function show(time)
local webcontent = generateHtml()
bindCopyKey()
local str = hs.pasteboard.getContents()
-- local webcontent = generateHtml()
-- sheetView:html(webcontent, "http://localhost")
-- sheetView:url("https://www.jsonin.com/")
sheetView:url("https://c.runoob.com/front-end/53/")
sheetView:url("https://i.sugood.xyz/pages/jsonweb.html")
sheetView:show(time)
end
@ -222,6 +59,10 @@ end
init()
-- 按下添加快捷键时映射到复制快捷键
function bindCopyKey()
hs.eventtap.keyStroke({ "cmd" }, "C")
end
-- 添加片段(按下快捷键时做一个复制操作,并记录复制的内容到片段列表中)
hs.hotkey.bind(hyperCmd, "G", function ()
toggle()