主页图标增加文字

This commit is contained in:
sonichy 2024-03-21 00:08:47 +08:00
parent c0725c5b20
commit 10980bd750
2 changed files with 26 additions and 17 deletions

BIN
app.apk

Binary file not shown.

View File

@ -13,8 +13,8 @@ img { vertical-align:middle; }
.operation:hover { cursor:hand; color:black; } .operation:hover { cursor:hand; color:black; }
.menu { position:absolute; background:white; border:1px solid gray; width:100px; display:none; } .menu { position:absolute; background:white; border:1px solid gray; width:100px; display:none; }
.menu div:hover { background:#ddd; } .menu div:hover { background:#ddd; }
#list a { margin:20px; width:50px; height:50px; display: inline-block; } #list a { margin:10px; width:50px; height:75px; display:inline-block; text-align:center; white-space:nowrap; overflow:hidden; color:black; }
#list button { margin:20px; width:50px; height:50px; font-size:40px; vertical-align:bottom; } #list button { width:50px; height:50px; font-size:40px; }
</style> </style>
<body> <body>
<center><img src="logo.png"></center> <center><img src="logo.png"></center>
@ -33,7 +33,7 @@ img { vertical-align:middle; }
<dialog id="dialog"> <dialog id="dialog">
<h2 align="center" id="type"></h2> <h2 align="center" id="type"></h2>
<input type="text" id="title" placeholder="标题" value=""><p> <input type="text" id="title" placeholder="标题" value=""><p>
<input type="text" id="website" placeholder="https://" value="https://"><p> <input type="text" id="website" placeholder="https://" value=""><p>
<center><button id="button_confirm">确定</button> <button id="button_cancel">取消</button></center> <center><button id="button_confirm">确定</button> <button id="button_cancel">取消</button></center>
</dialog> </dialog>
<script> <script>
@ -74,8 +74,8 @@ function genList() {
//通过时间间隔区分点击和长按https://www.jianshu.com/p/b05d3d5d5e81 //通过时间间隔区分点击和长按https://www.jianshu.com/p/b05d3d5d5e81
(function(i){ (function(i){
img.addEventListener('mousedown', function(e){ img.addEventListener('mousedown', function(e){
timer = setTimeout(function(){ e.target.style.background = '#eee';
e.target.style.background = '#eee'; timer = setTimeout(function(){
menu.style.display = 'block'; menu.style.display = 'block';
menu.style.left = e.pageX + 'px'; menu.style.left = e.pageX + 'px';
menu.style.top = e.pageY + 'px'; menu.style.top = e.pageY + 'px';
@ -90,20 +90,22 @@ function genList() {
e.preventDefault(); e.preventDefault();
t = e.touches[0]; t = e.touches[0];
time = Date.now(); time = Date.now();
}); timer = setTimeout(function(){
img.addEventListener('touchend', function(e){ e.target.style.background = '#eee';
e.target.style.background = 'none';
var dt = Date.now() - time;
if (dt < 300)
window.location.href = json[i].website;
else {
menu.style.display = 'block'; menu.style.display = 'block';
menu.style.left = t.pageX + 'px'; menu.style.left = t.pageX + 'px';
menu.style.top = t.pageY + 'px'; menu.style.top = t.pageY + 'px';
id = i; id = i;
title1 = json[i].title; title1 = json[i].title;
website1 = json[i].website; website1 = json[i].website;
} }, 500);
});
img.addEventListener('touchend', function(e){
e.target.style.background = 'none';
clearTimeout(timer);
var dt = Date.now() - time;
if (dt < 300)
window.location.href = json[i].website;
}); });
})(i); })(i);
img.addEventListener('mouseup', function(e){ img.addEventListener('mouseup', function(e){
@ -111,18 +113,25 @@ function genList() {
clearTimeout(timer); clearTimeout(timer);
}); });
a.appendChild(img); a.appendChild(img);
list.appendChild(a); var br = document.createElement('br');
a.appendChild(br);
var text = document.createTextNode(json[i].title);
a.appendChild(text);
list.appendChild(a);
} }
var a = document.createElement('a');
var button = document.createElement('button'); var button = document.createElement('button');
button.textContent = '+'; button.textContent = '+';
button.onclick = function(){ button.onclick = function(){
type.textContent = '添加'; type.textContent = '添加';
type1 = 0; type1 = 0;
title.value = ''; title.value = '';
website.value = 'https://'; website.value = '';
dialog.showModal(); dialog.showModal();
}; };
list.appendChild(button); a.appendChild(button);
list.appendChild(a);
} }
text_search.addEventListener('keypress', function(e){ text_search.addEventListener('keypress', function(e){
@ -177,4 +186,4 @@ button_cancel.addEventListener('click', function(e){
genList(); genList();
</script> </script>
</body> </body>
</html> </html>