Skip to content

Commit

Permalink
Features added.
Browse files Browse the repository at this point in the history
  • Loading branch information
RoderickQiu committed Apr 6, 2019
1 parent 6345c1f commit 00e2c0f
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 88 deletions.
102 changes: 20 additions & 82 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>

<head>
<title>FlowerPassword</title>
<title>花密</title>
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimal-ui" />
Expand All @@ -20,27 +20,19 @@
<div class="d-flex mx-auto justify-content-center align-items-center text-dark" id="main">
<div id="controller">
<a href="javascript:require('electron').shell.openExternal(require('./package.json').homepage)"
class="small flower"><i class="fa fa-info fa-fw" title="About"></i></a>&nbsp;&nbsp;
class="small flower"><i class="fa fa-info fa-fw" title="关于"></i></a>&nbsp;&nbsp;
<a href="settings.html" class="small flower"><i class="fa fa-cog fa-fw" title="设置"></i></a>&nbsp;&nbsp;
<a href="javascript:winhider()" class="small flower" id="win-hider"><i class="fa fa-sort-desc fa-fw"
title="Hide the window to system tray"></i></a><span id="no-use-space">&nbsp;&nbsp;</span>
<a href="javascript:window.close()" class="small flower"><i class="fa fa-times fa-fw" title="Exit"></i></a>
title="最小化到托盘"></i></a><span id="no-use-space">&nbsp;&nbsp;</span>
<a href="javascript:window.close()" class="small flower"><i class="fa fa-times fa-fw"
title="退出"></i></a>&nbsp;
</div>
<div id="set" class="justify-content-center">
<input name="password" id="password" placeholder="记忆密码" type="password" class="lead form"
autofocus /><br /><br />
<input name="key" id="key" placeholder="区分代号" type="text" class="lead form" /><br /><br />
<p id="code" class="small text-black-50">按下<b>Enter</b>键来查看代码</p>
</div>
<div id="settings" class="small flower align-content-center">
<input id="longmode-set" type="checkbox" onchange="longmodeset()" />
<label for="longmode-set">32位模式</label>&nbsp;
<input id="autocopy-set" type="checkbox" onchange="autocopyset()" />
<label for="autocopy-set">自动复制</label>&nbsp;
<span id="autohider"><input id="autohide-set" type="checkbox" onchange="autohideset()" />
<label for="autohide-set">复制后自动隐藏</label>&nbsp;</span>
<input id="autostart-set" type="checkbox" onchange="autostartset()" />
<label for="autostart-set">开机自启</label>&nbsp;
</div>
</div><br />
</div>
<script>
const Store = require('electron-store');
Expand Down Expand Up @@ -83,27 +75,33 @@
var code16 = "K" + code32.slice(1, 16);
}
if (store.get("longmode")) {
$("#code").text(code32);
if (store.get("autocopy")) {
clipboard.writeText(code32);
if (store.get("autohide")) {
winhider();
}
}
$("#password").val("");
$("#key").val("");
} else
$("#code").text(code32);
} else
$("#code").text(code32);
}
else {
$("#code").text(code16);
if (store.get("autocopy")) {
clipboard.writeText(code16);
if (store.get("autohide")) {
winhider();
}
}
$("#password").val("");
$("#key").val("");
} else
$("#code").text(code16);
} else
$("#code").text(code16);
}
//$("#code32").text(code32);
//$("#code6").text(password);
} else {
$('#code').html("<b>没有足够信息</b>");
$('#code').html("<b>没有足够信息,请输入完整</b>");
}
}
function keydown(e) {
Expand All @@ -123,66 +121,6 @@
e.preventDefault()
menu.popup({ window: remote.getCurrentWindow() })
}, false)//右键菜单

if (store.get("longmode") == undefined) store.set("longmode", false);
if (store.get("longmode") == true) document.getElementById("longmode-set").checked = true;
else document.getElementById("longmode-set").checked = false;
function longmodeset() {
if (document.getElementById("longmode-set").checked == true) store.set("longmode", true);
else store.set("longmode", false);
}

if (store.get("autocopy") == undefined) store.set("autocopy", true);
if (store.get("autocopy") == true) {
document.getElementById("autocopy-set").checked = true;
$("#autohider").css("display", "inline-block");
} else {
document.getElementById("autocopy-set").checked = false;
$("#autohider").css("display", "none");
}
function autocopyset() {
if (document.getElementById("autocopy-set").checked == true) {
store.set("autocopy", true);
$("#autohider").css("display", "inline-block");
} else {
store.set("autocopy", false);
$("#autohider").css("display", "none");
}
}

if (store.get("autohide") == undefined) store.set("autohide", false);
if (store.get("autohide") == true) document.getElementById("autohide-set").checked = true;
else document.getElementById("autohide-set").checked = false;
function autohideset() {
if (document.getElementById("autohide-set").checked == true) store.set("autohide", true);
else store.set("autohide", false);
}

if (store.get("autostart") == undefined) store.set("autostart", false);
if (store.get("autostart") == true) document.getElementById("autostart-set").checked = true;
else document.getElementById("autostart-set").checked = false;
function autostartset() {
if (document.getElementById("autostart-set").checked == true) {
store.set("autostart", true);
autoLauncher.isEnabled()
.then(function (isEnabled) {
if (isEnabled) {
return;
}
autoLauncher.enable();
})
}
else {
store.set("autostart", false);
autoLauncher.isEnabled()
.then(function (isEnabled) {
if (isEnabled) {
autoLauncher.disable();
}
return;
})
}
}
</script>
</body>

Expand Down
2 changes: 0 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ function createWindow() {
show: false,
hasShadow: true,
webPreferences: { nodeIntegration: true },
title: "FlowerPasswordElectron",
icon: "./res/icons/icon.png",
backgroundColor: "#fefefe"
});// 为跨平台优化

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flowerpassword-electron",
"version": "0.3.0",
"version": "0.4.0",
"description": "A modern cross-platform flowerpassword implement",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -51,4 +51,4 @@
"icon": "res/icons/icon.png"
}
}
}
}
126 changes: 126 additions & 0 deletions settings.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<!DOCTYPE html>
<html>

<head>
<title>设置</title>
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimal-ui" />
<script>if (typeof module === 'object') { window.module = module; module = undefined; }</script>
<!-- solve the electron-jquery conflict -->
<script src="res/lib/jquery-3.3.1.min.js"></script>
<script src="res/lib/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="res/lib/bootstrap.min.css" />
<script src="res/lib/all.js"></script>
<script src="res/lib/v4-shims.js"></script><!-- font-awesome 5 use as 4 -->
<link rel="stylesheet" type="text/css" href="style.css" />
</head>

<body>
<div class="d-flex mx-auto justify-content-center align-items-center text-dark" id="main">
<div id="controller">
<a href="javascript:require('electron').shell.openExternal(require('./package.json').homepage)"
class="small flower"><i class="fa fa-info fa-fw" title="关于"></i></a>&nbsp;&nbsp;
<a href="javascript:winhider()" class="small flower" id="win-hider"><i class="fa fa-sort-desc fa-fw"
title="最小化到托盘"></i></a><span id="no-use-space">&nbsp;&nbsp;</span>
<a href="index.html" class="small flower"><i class="fa fa-chevron-left" title="返回"></i></a>&nbsp;
</div>
<div id="set" class="flower align-content-center">
<div class="h3">
<i class="fa fa-cog fa-fw" id="settings" aria-hidden="true"></i>设置
<hr />
</div>
<input id="longmode-set" type="checkbox" onchange="longmodeset()" />
<label for="longmode-set">32位模式</label>&nbsp;
<input id="autocopy-set" type="checkbox" onchange="autocopyset()" />
<label for="autocopy-set">自动复制</label>&nbsp;
<br />
<span id="autohider"><input id="autohide-set" type="checkbox" onchange="autohideset()" />
<label for="autohide-set">复制后自动隐藏</label>&nbsp;</span>
<input id="autostart-set" type="checkbox" onchange="autostartset()" />
<label for="autostart-set">开机自启</label>&nbsp;
<br /><br />
<a href="index.html" class="flowerbtn">提交</a>
</div>
<div id="versioninfo" class="small text-black-50">
版本:
<script>document.write(require("./package.json").version);</script>
<br />
</div>
</div>
<script>
const Store = require('electron-store');
const store = new Store();
const remote = require('electron').remote;
const ipc = require('electron').ipcRenderer;
const md5 = require('blueimp-md5');

function winhider() {
ipc.send("winhider");
}

if (store.get("longmode") == undefined) store.set("longmode", false);
if (store.get("longmode") == true) document.getElementById("longmode-set").checked = true;
else document.getElementById("longmode-set").checked = false;
function longmodeset() {
if (document.getElementById("longmode-set").checked == true) store.set("longmode", true);
else store.set("longmode", false);
}

if (store.get("autocopy") == undefined) store.set("autocopy", true);
if (store.get("autocopy") == true) {
document.getElementById("autocopy-set").checked = true;
$("#autohider").css("display", "inline-block");
} else {
document.getElementById("autocopy-set").checked = false;
$("#autohider").css("display", "none");
}
function autocopyset() {
if (document.getElementById("autocopy-set").checked == true) {
store.set("autocopy", true);
$("#autohider").css("display", "inline-block");
} else {
store.set("autocopy", false);
$("#autohider").css("display", "none");
}
}

if (store.get("autohide") == undefined) store.set("autohide", false);
if (store.get("autohide") == true) document.getElementById("autohide-set").checked = true;
else document.getElementById("autohide-set").checked = false;
function autohideset() {
if (document.getElementById("autohide-set").checked == true) store.set("autohide", true);
else store.set("autohide", false);
}

if (store.get("autostart") == undefined) store.set("autostart", false);
if (store.get("autostart") == true) document.getElementById("autostart-set").checked = true;
else document.getElementById("autostart-set").checked = false;
function autostartset() {
var AutoLaunch = require('auto-launch');
var autoLauncher = new AutoLaunch({ name: 'flowerpassword-electron' });
if (document.getElementById("autostart-set").checked == true) {
store.set("autostart", true);
autoLauncher.isEnabled()
.then(function (isEnabled) {
if (isEnabled) {
return;
}
autoLauncher.enable();
})
}
else {
store.set("autostart", false);
autoLauncher.isEnabled()
.then(function (isEnabled) {
if (isEnabled) {
autoLauncher.disable();
}
return;
})
}
}
</script>
</body>

</html>
12 changes: 11 additions & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ html, body{
.flower{
color: #0099cc;
}
.flowerbtn{
background-color: #0099cc;
color: #fefefe;
border: 8px solid transparent;
}
.flowerbtn:hover{
background-color: #0099ccb0;
color: #fefefe;
text-decoration: none;
}
label{
display: inline-block;
vertical-align: middle;
Expand Down Expand Up @@ -55,7 +65,7 @@ input[type="checkbox"]:checked {
-webkit-app-region: no-drag;/* let it clickable */
-webkit-user-select: none;
}
#settings{
#versioninfo{
position: fixed;
bottom: 5px;
font-size: 12px;
Expand Down

0 comments on commit 00e2c0f

Please sign in to comment.