Skip to content

Commit

Permalink
feat(app): add mobile size and token button
Browse files Browse the repository at this point in the history
- 新增 页面的移动设备尺寸支持
- 新增 手动更新 Token 按钮
  • Loading branch information
txperl committed Dec 30, 2022
1 parent 59cedea commit 1ba96cb
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 37 deletions.
19 changes: 12 additions & 7 deletions app/lib/core/biu.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@interRoot.bind("biu", "LIB_CORE")
class CoreBiu(interRoot):
def __init__(self):
self.ver = 206000
self.ver = 206001
self.place = "local"
self.sysPlc = platform.system()
self.api_route = "direct"
Expand Down Expand Up @@ -236,15 +236,20 @@ def __show_ready_info(self):

def __pro_refresh_token(self):
"""
子线程,每 60*6 分钟刷新一次 token 以持久化登录状态。
子线程,每 30 分钟刷新一次 token 以持久化登录状态。
:return: none
"""
while True:
time.sleep(3600 * 6)
self.STATIC.localMsger.msg(
f"{self.lang('others.hint_in_update_token')}: %s"
% time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())))
self.__login(refresh_token=self.api.refresh_token, silent=True)
time.sleep(30 * 60)
self.update_token()

def update_token(self):
ori_access_token = self.api.access_token
self.STATIC.localMsger.msg(
f"{self.lang('others.hint_in_update_token')}: %s"
% time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())))
self.__login(refresh_token=self.api.refresh_token, silent=True)
return self.api.access_token != ori_access_token

def update_status(self, type_, key, c):
"""
Expand Down
14 changes: 14 additions & 0 deletions app/plugin/do/update_token.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from altfe.interface.root import interRoot


@interRoot.bind("api/biu/do/update_token/", "PLUGIN")
class doUpdateToken(interRoot):
def run(self, cmd):
try:
self.STATIC.arg.getArgs("update_token", li=["pass"], way="POST")
except:
return {"code": 0, "msg": "missing parameters"}
return {
"code": 1,
"msg": self.CORE.biu.update_token(),
}
17 changes: 0 additions & 17 deletions app/plugin/sys/biu_outdated.py

This file was deleted.

File renamed without changes.
22 changes: 22 additions & 0 deletions app/plugin/sys/outdated.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import json

import requests

from altfe.interface.root import interRoot


@interRoot.bind("api/biu/get/outdated/", "PLUGIN")
class outdated(interRoot):
def run(self, cmd):
try:
r = json.loads(requests.get("https://biu.tls.moe/d/biuinfo.json", timeout=6).text)
except:
r = self.CORE.biu.biuInfo
return {
"code": 1,
"msg": {
"latest": self.CORE.biu.ver >= r["version"],
"current": self.CORE.biu.format_version(),
"online": r,
}
}
File renamed without changes.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
certifi==2022.9.24
certifi==2022.12.7
charset-normalizer==2.1.1
click==8.1.3
cloudscraper==1.2.66
Expand Down
47 changes: 40 additions & 7 deletions usr/static/multiverse/assets/css/n.css
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,29 @@
display: none !important;
}

.poptrox-popup .nav-previous,
.poptrox-popup .nav-next {
position: fixed;
display: block !important;
filter: drop-shadow(0 0 3px rgb(0, 0, 0));
}

@media screen and (max-width: 1680px) {
#main .thumb {
width: 25% !important;
}
}

@media screen and (min-width: 1680px) {

body,
input,
select,
textarea {
font-size: 12pt;
}
}

@media screen and (max-width: 1280px) {
#main .thumb {
width: 33.333333% !important;
Expand All @@ -231,23 +248,39 @@
}
}

@media screen and (max-width: 736px) {
@media screen and (max-width: 800px) {
body {
padding: 0 !important;
padding: 5px !important;
}

.search-area {
padding: 100px 1em 3em 1em;
}

.poptrox-popup .caption {
display: block !important;
font-size: .8em;
line-height: 1.05em;
font-size: .9em;
background-color: rgba(0, 0, 0, .5);
}

.poptrox-popup .caption p:first-child {
max-width: 100% !important;
}

.poptrox-popup .nav-previous,
.poptrox-popup .nav-next {
position: absolute;
opacity: 1;
}
}

@media screen and (min-width: 1680px) {
body, input, select, textarea {
font-size: 12pt;
@media screen and (min-width: 800px) {
.poptrox-popup .nav-previous {
transform: scale(-1.5);
}

.poptrox-popup .nav-next {
transform: scale(1.5);
}
}

Expand Down
20 changes: 20 additions & 0 deletions usr/static/multiverse/assets/js/biu/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,26 @@ function doDownloadStopPic(workID) {
});
}

function doUpdateToken() {
const el = $("#btnUpdateToken");
el.tooltipster("content", "更新中...");
$.ajax({
type: "POST",
url: 'api/biu/do/update_token/',
data: { pass: "on" },
success: rep => {
rep = jQuery.parseJSON(JSON.stringify(rep));
if (rep.code !== 1)
throw Error();
el.tooltipster("content", rep.msg ? "更新 Token 状态成功" : "失败了,具体可以查看程序日志");
},
error: err => {
console.log(err);
el.tooltipster("content", "不知道为什么失败了");
}
});
}

function grpActChon(type, grpIdx = -1, args = null) {
if (args === null) {
if (!tmpPageData || !tmpPageData['args']) return;
Expand Down
11 changes: 6 additions & 5 deletions usr/templates/multiverse/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ <h2>功能</h2>
<input id="settingsIsR18" class="tooltip" placeholder="R18 内容" autocomplete="off"
title="是否展示 R18 内容。on: 开启,off: 遮蔽,gone: 不显示">
</div>
<p>更多设置请于 <b>config.yml</b> 文件中修改。</p>
<p>若所有操作都没有结果,可以尝试点击<a id="btnUpdateToken" class="tooltip" title="不要频繁点哦"
href="javascript: doUpdateToken();">这里</a>以手动更新 Token 状态。</p>
</section>
</div>
<div class="filters">
Expand Down Expand Up @@ -203,12 +204,12 @@ <h2>PixivBiu@<span id="hint-current-verson">Unknown</span></h2>
<h2>一些链接</h2>
<ul class="icons">
<li>
<a target="_blank" href="https://github.com/txperl/PixivBiu" class="icon
brands fa-github"><span class="label">GitHub</span></a>
<a target="_blank" href="https://github.com/txperl/PixivBiu"
class="icon brands fa-github"><span class="label">GitHub</span></a>
</li>
<li>
<a target="_blank" href="https://biu.tls.moe/" class="icon
solid fa-air-freshener"><span class="label">Official</span></a>
<a target="_blank" href="https://biu.tls.moe/" class="icon solid fa-air-freshener"><span
class="label">Official</span></a>
</li>
<li>
<a target="_blank" href="mailto:[email protected]" class="icon solid fa-envelope"><span
Expand Down

0 comments on commit 1ba96cb

Please sign in to comment.