Skip to content

Commit 1ba96cb

Browse files
committedDec 30, 2022
feat(app): add mobile size and token button
- 新增 页面的移动设备尺寸支持 - 新增 手动更新 Token 按钮
1 parent 59cedea commit 1ba96cb

File tree

10 files changed

+115
-37
lines changed

10 files changed

+115
-37
lines changed
 

‎app/lib/core/biu.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@interRoot.bind("biu", "LIB_CORE")
1515
class CoreBiu(interRoot):
1616
def __init__(self):
17-
self.ver = 206000
17+
self.ver = 206001
1818
self.place = "local"
1919
self.sysPlc = platform.system()
2020
self.api_route = "direct"
@@ -236,15 +236,20 @@ def __show_ready_info(self):
236236

237237
def __pro_refresh_token(self):
238238
"""
239-
子线程,每 60*6 分钟刷新一次 token 以持久化登录状态。
239+
子线程,每 30 分钟刷新一次 token 以持久化登录状态。
240240
:return: none
241241
"""
242242
while True:
243-
time.sleep(3600 * 6)
244-
self.STATIC.localMsger.msg(
245-
f"{self.lang('others.hint_in_update_token')}: %s"
246-
% time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())))
247-
self.__login(refresh_token=self.api.refresh_token, silent=True)
243+
time.sleep(30 * 60)
244+
self.update_token()
245+
246+
def update_token(self):
247+
ori_access_token = self.api.access_token
248+
self.STATIC.localMsger.msg(
249+
f"{self.lang('others.hint_in_update_token')}: %s"
250+
% time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())))
251+
self.__login(refresh_token=self.api.refresh_token, silent=True)
252+
return self.api.access_token != ori_access_token
248253

249254
def update_status(self, type_, key, c):
250255
"""

‎app/plugin/do/update_token.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from altfe.interface.root import interRoot
2+
3+
4+
@interRoot.bind("api/biu/do/update_token/", "PLUGIN")
5+
class doUpdateToken(interRoot):
6+
def run(self, cmd):
7+
try:
8+
self.STATIC.arg.getArgs("update_token", li=["pass"], way="POST")
9+
except:
10+
return {"code": 0, "msg": "missing parameters"}
11+
return {
12+
"code": 1,
13+
"msg": self.CORE.biu.update_token(),
14+
}

‎app/plugin/sys/biu_outdated.py

-17
This file was deleted.
File renamed without changes.

‎app/plugin/sys/outdated.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import json
2+
3+
import requests
4+
5+
from altfe.interface.root import interRoot
6+
7+
8+
@interRoot.bind("api/biu/get/outdated/", "PLUGIN")
9+
class outdated(interRoot):
10+
def run(self, cmd):
11+
try:
12+
r = json.loads(requests.get("https://biu.tls.moe/d/biuinfo.json", timeout=6).text)
13+
except:
14+
r = self.CORE.biu.biuInfo
15+
return {
16+
"code": 1,
17+
"msg": {
18+
"latest": self.CORE.biu.ver >= r["version"],
19+
"current": self.CORE.biu.format_version(),
20+
"online": r,
21+
}
22+
}
File renamed without changes.

‎requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
certifi==2022.9.24
1+
certifi==2022.12.7
22
charset-normalizer==2.1.1
33
click==8.1.3
44
cloudscraper==1.2.66

‎usr/static/multiverse/assets/css/n.css

+40-7
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,29 @@
213213
display: none !important;
214214
}
215215

216+
.poptrox-popup .nav-previous,
217+
.poptrox-popup .nav-next {
218+
position: fixed;
219+
display: block !important;
220+
filter: drop-shadow(0 0 3px rgb(0, 0, 0));
221+
}
222+
216223
@media screen and (max-width: 1680px) {
217224
#main .thumb {
218225
width: 25% !important;
219226
}
220227
}
221228

229+
@media screen and (min-width: 1680px) {
230+
231+
body,
232+
input,
233+
select,
234+
textarea {
235+
font-size: 12pt;
236+
}
237+
}
238+
222239
@media screen and (max-width: 1280px) {
223240
#main .thumb {
224241
width: 33.333333% !important;
@@ -231,23 +248,39 @@
231248
}
232249
}
233250

234-
@media screen and (max-width: 736px) {
251+
@media screen and (max-width: 800px) {
235252
body {
236-
padding: 0 !important;
253+
padding: 5px !important;
237254
}
255+
238256
.search-area {
239257
padding: 100px 1em 3em 1em;
240258
}
259+
241260
.poptrox-popup .caption {
242261
display: block !important;
243-
font-size: .8em;
244-
line-height: 1.05em;
262+
font-size: .9em;
263+
background-color: rgba(0, 0, 0, .5);
264+
}
265+
266+
.poptrox-popup .caption p:first-child {
267+
max-width: 100% !important;
268+
}
269+
270+
.poptrox-popup .nav-previous,
271+
.poptrox-popup .nav-next {
272+
position: absolute;
273+
opacity: 1;
245274
}
246275
}
247276

248-
@media screen and (min-width: 1680px) {
249-
body, input, select, textarea {
250-
font-size: 12pt;
277+
@media screen and (min-width: 800px) {
278+
.poptrox-popup .nav-previous {
279+
transform: scale(-1.5);
280+
}
281+
282+
.poptrox-popup .nav-next {
283+
transform: scale(1.5);
251284
}
252285
}
253286

‎usr/static/multiverse/assets/js/biu/actions.js

+20
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,26 @@ function doDownloadStopPic(workID) {
427427
});
428428
}
429429

430+
function doUpdateToken() {
431+
const el = $("#btnUpdateToken");
432+
el.tooltipster("content", "更新中...");
433+
$.ajax({
434+
type: "POST",
435+
url: 'api/biu/do/update_token/',
436+
data: { pass: "on" },
437+
success: rep => {
438+
rep = jQuery.parseJSON(JSON.stringify(rep));
439+
if (rep.code !== 1)
440+
throw Error();
441+
el.tooltipster("content", rep.msg ? "更新 Token 状态成功" : "失败了,具体可以查看程序日志");
442+
},
443+
error: err => {
444+
console.log(err);
445+
el.tooltipster("content", "不知道为什么失败了");
446+
}
447+
});
448+
}
449+
430450
function grpActChon(type, grpIdx = -1, args = null) {
431451
if (args === null) {
432452
if (!tmpPageData || !tmpPageData['args']) return;

‎usr/templates/multiverse/index.html

+6-5
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ <h2>功能</h2>
175175
<input id="settingsIsR18" class="tooltip" placeholder="R18 内容" autocomplete="off"
176176
title="是否展示 R18 内容。on: 开启,off: 遮蔽,gone: 不显示">
177177
</div>
178-
<p>更多设置请于 <b>config.yml</b> 文件中修改。</p>
178+
<p>若所有操作都没有结果,可以尝试点击<a id="btnUpdateToken" class="tooltip" title="不要频繁点哦"
179+
href="javascript: doUpdateToken();">这里</a>以手动更新 Token 状态。</p>
179180
</section>
180181
</div>
181182
<div class="filters">
@@ -203,12 +204,12 @@ <h2>PixivBiu@<span id="hint-current-verson">Unknown</span></h2>
203204
<h2>一些链接</h2>
204205
<ul class="icons">
205206
<li>
206-
<a target="_blank" href="https://github.com/txperl/PixivBiu" class="icon
207-
brands fa-github"><span class="label">GitHub</span></a>
207+
<a target="_blank" href="https://github.com/txperl/PixivBiu"
208+
class="icon brands fa-github"><span class="label">GitHub</span></a>
208209
</li>
209210
<li>
210-
<a target="_blank" href="https://biu.tls.moe/" class="icon
211-
solid fa-air-freshener"><span class="label">Official</span></a>
211+
<a target="_blank" href="https://biu.tls.moe/" class="icon solid fa-air-freshener"><span
212+
class="label">Official</span></a>
212213
</li>
213214
<li>
214215
<a target="_blank" href="mailto:txperl@gmail.com" class="icon solid fa-envelope"><span

0 commit comments

Comments
 (0)
Failed to load comments.