Skip to content

Commit

Permalink
optimized code and update logo
Browse files Browse the repository at this point in the history
  • Loading branch information
hehuiqi committed Apr 25, 2024
1 parent 316f0b7 commit ea55a4f
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 9 deletions.
5 changes: 5 additions & 0 deletions css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
align-items: center;
}

.app-main h1 {
font: bold 50px/30px "Adobe 宋体 Std L";
text-shadow: -3px -3px 10px white, 3px 3px 10px black;
}

.qrcode-make {
display: flex;
width: 100%;
Expand Down
Binary file added icons/180x180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed icons/400x400.png
Binary file not shown.
Binary file modified icons/icon128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/icon16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/icon32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/icon48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/icon64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ <h1>二维码工具</h1>
</div>
</div>
<div class="app-side">
<h1>生成记录</h1>
<h2 style="margin-left: 0.5em;">生成记录</h2>
<ul id="make_code_record_list" class="make-code-record-list">
</ul>
</div>
Expand Down
30 changes: 22 additions & 8 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
const LOCAL_CODE_LIST_KEY = "hq_qrcodelist";

let codeList = [];
function remove(arr, value) {
const idx = arr.indexOf(value);
function remove(value) {
const idx = codeList.indexOf(value);
if (idx > -1) {
arr.splice(idx, 1);
codeList.splice(idx, 1);
}
updateLocalCodeList()
}
Expand All @@ -27,14 +27,23 @@ let qrcode_input = document.getElementById('qrcode_input');
// 输入完成,按下enter或失去焦点时,键触发
qrcode_input.onchange = function (e) {
let text = e.target.value;
makeCodeFromText(text)

}
function makeCodeFromText(text) {
if (text) {
if (codeList.indexOf(text) > -1) {
return;
}
makeCode(text);
addCodeToList(text);
saveCode(text);
saveCode(text)
}

}
function makeCode(text) {
if (text) {
console.log('input---:' + text);
qrcode_show_preview.style = 'display:none;'
qrcode.makeCode(text);
}
Expand All @@ -57,11 +66,16 @@ function updateLocalCodeList() {
console.log("update-codeList:", codeList)

}

//生成二维码
let qrcode_make_button = document.getElementById('qrcode_make_button');
qrcode_make_button.onclick = function () {
const text = qrcode_input.value;
makeCodeFromText(text);
}

//保存二维码
let qrcode_make_button = document.getElementById('qrcode_save_button');
qrcode_make_button.onclick = function () {
let qrcode_save_button = document.getElementById('qrcode_save_button');
qrcode_save_button.onclick = function () {
html2canvas(qrcode_show).then(canvas => {
// 创建一个链接元素
const link = document.createElement('a');
Expand Down Expand Up @@ -92,7 +106,7 @@ function addCodeToList(code) {
}

button.onclick = function (e) {
remove(codeList, code);
remove(code);
make_code_record_list.removeChild(li);
}
const lis = make_code_record_list.childNodes;
Expand Down

0 comments on commit ea55a4f

Please sign in to comment.