代码结构优化

This commit is contained in:
Searchstars
2024-03-01 20:30:26 +08:00
parent 4a2683c3c4
commit 79f6e62c3a
7 changed files with 97 additions and 66 deletions
Binary file not shown.
+3 -3
View File
@@ -19,7 +19,7 @@
"designWidth": 480
},
"router": {
"entry": "pages/main",
"entry": "pages/videoaisummary",
"pages": {
"pages/main": {
"component": "main"
@@ -36,8 +36,8 @@
"pages/videopush": {
"component": "videopush"
},
"pages/videodetail": {
"component": "videodetail"
"pages/videoaisummary": {
"component": "videoaisummary"
}
}
},
+34 -14
View File
@@ -60,6 +60,7 @@ export default {
user_name: "Loading...",
var_poll_check_interval: null,
network_ok: false,
login_wait_num: 0,
async MainInit(){
router.clear() //清内存
await this.$app.$def.bilirequest.InitBiliRequest(false)
@@ -80,27 +81,46 @@ export default {
router.push({
uri: "pages/videopush"
})
},
isValidUserName(obj){
if (obj === null || obj === undefined){
return false;
}
const str = String(obj);
if(str.includes("Loading") || str.includes("undefined")){
return false;
}
return true;
}
},
onInit(){
this.MainInit()
this.var_poll_check_interval = setInterval(() => {
if(this.login_info.data.isLogin){
this.network_ok = true;
console.log("logined")
if((this.login_info.data.wbi_img.img_url != void 0 && this.login_info.data.wbi_img.img_url != undefined) && this.login_info.data.wbi_img.img_url != ""){
this.$app.$def.bilirequest.InitBiliWbi(this.login_info.data.wbi_img)
clearInterval(this.var_poll_check_interval)
}
if(this.login_info === null || this.login_info === undefined){
console.log("trying to login")
}
else if((this.login_info.data.isLogin != void 0 && this.login_info.data.isLogin != undefined) && this.login_info.data.isLogin != true){
this.network_ok = true;
prompt.showToast({
message: "登录已失效,请退出后重新登录,否则各项功能将无法正常使用",
duration: 6000
})
clearInterval(this.var_poll_check_interval)
else{
if(this.isValidUserName(this.login_info.data.uname)){
this.network_ok = true;
console.log("logined")
if((this.login_info.data.wbi_img.img_url != void 0 && this.login_info.data.wbi_img.img_url != undefined) && this.login_info.data.wbi_img.img_url != ""){
this.$app.$def.bilirequest.InitBiliWbi(this.login_info.data.wbi_img)
clearInterval(this.var_poll_check_interval)
}
}
else{
if(this.login_wait_num > 6){
this.network_ok = true
prompt.showToast({
message: "登录已失效,请退出后重新登录,否则各项功能将无法正常使用",
duration: 6000
})
clearInterval(this.var_poll_check_interval)
}
console.log("wait")
this.login_wait_num ++
}
}
}, 500)
},
+5 -8
View File
@@ -1,17 +1,17 @@
<template>
<div class="login-page">
<div class="login-page" style="justify-content: center">
<text
style="
position: absolute;
justify-content: center;
align-items: center;
text-align: center;
margin-top: 50%;
margin-left: 55%;
font-size: 24px;
color: white;
height: 20%;
width: 80%;
"
>
使用哔哩哔哩APP扫描二维码以登录
使用哔哩哔哩APP扫描以登录
</text>
<qrcode
id="login_qr"
@@ -20,7 +20,6 @@
justify-content: center;
align-items: center;
margin-top: 130%;
margin-left: 100%;
width: 60%;
height: 60%;
"
@@ -30,8 +29,6 @@
<text
style="
position: absolute;
justify-content: center;
align-items: center;
margin-top: 100%;
text-align: center;
width: 100%;
@@ -0,0 +1,54 @@
<template>
<div class="videoaisummary-page">
<div style="background-color: gray; margin-top: 20px; width: 230px; height: 75px"></div>
<text style="width: 65%; color: white; position: absolute; margin-top: 100px">{{AI_TEXT}}</text>
</div>
</template>
<script>
export default{
public:{
img_src: "",
bv: "",
cid: "",
up_mid: ""
},
private: {
AI_TEXT: "加载中...若长时间未加载出来可以尝试重启应用程序",
AI_TEXT_TMP: "loading l-o-a-d*i@n#g",
SummaryUpdateInterval: null,
SummaryTypeFXInterval: null,
TypeFXIndex: 0,
async MainInit(){
var ai_ret = await this.$app.$def.bilirequest.SendWbiGET("https://api.bilibili.com/x/web-interface/view/conclusion/get","json",{
bvid: this.bv,
cid: this.cid,
up_mid: this.up_mid
})
this.AI_TEXT_TMP = ai_ret.data.model_result.summary + "\n \n \n \n \n "
}
},
onInit(){
this.MainInit()
this.SummaryUpdateInterval = setInterval(() => {
if(!this.AI_TEXT_TMP.includes("loading l-o-a-d*i@n#g") && this.AI_TEXT_TMP.length > 1){
this.AI_TEXT = ""
this.SummaryTypeFXInterval = setInterval(() => {
if(this.TypeFXIndex < this.AI_TEXT_TMP.length){
this.AI_TEXT = this.AI_TEXT + this.AI_TEXT_TMP[this.TypeFXIndex]
this.TypeFXIndex ++
}
}, 50)
clearInterval(this.SummaryUpdateInterval)
}
},500)
}
}
</script>
<style>
.videoaisummary-page{
justify-content: center;
position: absolute;
}
</style>
-38
View File
@@ -1,38 +0,0 @@
<template>
<div class="videodetail-page">
<text style="height: 300%; width: 80%; color: white; position: absolute; margin-top: 60px">{{AI_TEXT}}</text>
</div>
</template>
<script>
export default{
public:{
img_src: "",
bv: "",
cid: "",
up_mid: ""
},
private: {
AI_TEXT: "loading",
async MainInit(){
var ai_ret = await this.$app.$def.bilirequest.SendWbiGET("https://api.bilibili.com/x/web-interface/view/conclusion/get","json",{
bvid: this.bv,
cid: this.cid,
up_mid: this.up_mid
})
this.AI_TEXT = ai_ret.data.model_result.summary
}
},
onInit(){
this.MainInit()
}
}
</script>
<style>
.videodetail-page{
justify-content: center;
position: absolute;
align-items: center;
}
</style>
+1 -3
View File
@@ -77,7 +77,7 @@ export default{
},
jmp_to_detail(num){
router.push({
uri: "pages/videodetail",
uri: "pages/videoaisummary",
params: {
img_src: "",
bv: this.videolist.data.item[num].bvid,
@@ -152,7 +152,6 @@ export default{
.video_up_name{
color: white;
font-size: 14px;
text-align: left;
position: absolute;
top: 102px;
margin-left: 146px;
@@ -160,7 +159,6 @@ export default{
.video_stat_view{
color: white;
font-size: 14px;
text-align: left;
position: absolute;
top: 102px;
margin-left: 306px;