巨量代码优化
This commit is contained in:
@@ -3,15 +3,17 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<title-bar title="收藏"></title-bar>
|
||||
<image style="position: absolute; margin-top: 245px" if="{{show_loading}}" src="{{anims.loading_src.value}}"></image>
|
||||
<image style="position: absolute; margin-top: 245px" if="{{show_loading}}" src="{{anims.loading_src.value}}">
|
||||
</image>
|
||||
<list style="margin-top: 20px; width: 77%; height: 100%" class="folderlist">
|
||||
<list-item type="folders" class="folder" for="{{folders}}" onclick="GoFolderVideosPage({{$item.id}}, {{$item.media_count}})">
|
||||
<list-item type="folders" class="folder" for="{{folders}}"
|
||||
onclick="GoFolderVideosPage({{$item.id}}, {{$item.media_count}})">
|
||||
<image src="{{$item.cover}}@121w_68h" alt="/common/fullblack.png" class="folderimg"></image>
|
||||
<div style="flex-direction: column">
|
||||
<div class="foldername">
|
||||
<text class="foldername_text">{{$item.title}}</text>
|
||||
<text class="foldername_text">{{ $item.title }}</text>
|
||||
</div>
|
||||
<text class="foldercount">数量:{{$item.media_count}}</text>
|
||||
<text class="foldercount">数量:{{ $item.media_count }}</text>
|
||||
</div>
|
||||
<image src="/common/arrow_right.png" style="margin-left: 30px"></image>
|
||||
</list-item>
|
||||
@@ -21,40 +23,45 @@
|
||||
|
||||
<script>
|
||||
import router from "@system.router"
|
||||
|
||||
export default {
|
||||
private: {
|
||||
folders: [],
|
||||
show_loading: true,
|
||||
anims: {
|
||||
loading: null,
|
||||
loading_src: {value: "/common/seqanims/loadingWhite/icons8-loading_颜色反转-1.png"}
|
||||
loading: null,
|
||||
loading_src: {value: "/common/seqanims/loadingWhite/icons8-loading_颜色反转-1.png"}
|
||||
}
|
||||
},
|
||||
public: {
|
||||
user_mid: null
|
||||
},
|
||||
GoFolderVideosPage(mlid, vidcount){
|
||||
GoFolderVideosPage(mlid, vidcount) {
|
||||
router.push({
|
||||
uri: "pages/foldervideos",
|
||||
params: {
|
||||
mlid: mlid,
|
||||
vidcount: vidcount
|
||||
}
|
||||
uri: "pages/foldervideos",
|
||||
params: {mlid, vidcount}
|
||||
})
|
||||
},
|
||||
async LoadFolders(){
|
||||
let folderlist = await this.$app.$def.biliclient.getUserFavouriteFolders(this.user_mid);
|
||||
folderlist.list.forEach(async(folder) => {
|
||||
console.log(folder)
|
||||
this.folders.push(await this.$app.$def.biliclient.getFavouriteFolderMetadata(folder.id))
|
||||
this.show_loading = false
|
||||
this.anims.loading.stop()
|
||||
});
|
||||
async LoadFolders() {
|
||||
try {
|
||||
const folderlist = await this.$app.$def.biliclient.getUserFavouriteFolders(this.user_mid)
|
||||
const folderPromises = folderlist.list.map((folder) =>
|
||||
this.$app.$def.biliclient.getFavouriteFolderMetadata(folder.id)
|
||||
)
|
||||
|
||||
this.folders = await Promise.all(folderPromises)
|
||||
} catch (error) {
|
||||
console.error("加载收藏夹时发生错误:", error)
|
||||
} finally {
|
||||
this.show_loading = false
|
||||
this.anims.loading.stop()
|
||||
}
|
||||
},
|
||||
onInit(){
|
||||
onInit() {
|
||||
const {loading_src} = this.anims
|
||||
this.anims.loading = new this.$app.$def.animengine.SequenceAnim(
|
||||
"favfoldersPage",
|
||||
this.anims.loading_src,
|
||||
loading_src,
|
||||
28,
|
||||
"/common/seqanims/loadingWhite/icons8-loading_颜色反转-*.png",
|
||||
1000,
|
||||
@@ -62,10 +69,9 @@ export default {
|
||||
)
|
||||
|
||||
this.anims.loading.start()
|
||||
|
||||
this.LoadFolders()
|
||||
},
|
||||
onDestroy(){
|
||||
onDestroy() {
|
||||
this.$app.$def.animengine.clearPageAnims("favfoldersPage")
|
||||
}
|
||||
}
|
||||
@@ -73,57 +79,57 @@ export default {
|
||||
|
||||
<style>
|
||||
.page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.folder {
|
||||
margin-top: 10px;
|
||||
width: 340px;
|
||||
height: 120px;
|
||||
background-color: #262626;
|
||||
border-radius: 40px;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
margin-top: 10px;
|
||||
width: 340px;
|
||||
height: 120px;
|
||||
background-color: #262626;
|
||||
border-radius: 40px;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.folderlist {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.folderimg {
|
||||
margin-left: 15px;
|
||||
border-radius: 30px;
|
||||
max-width: 121px;
|
||||
max-height: 68px;
|
||||
min-width: 121px;
|
||||
min-height: 68px;
|
||||
object-fit: contain;
|
||||
margin-left: 15px;
|
||||
border-radius: 30px;
|
||||
max-width: 121px;
|
||||
max-height: 68px;
|
||||
min-width: 121px;
|
||||
min-height: 68px;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.foldername {
|
||||
margin-left: 10px;
|
||||
height: 60px;
|
||||
width: 130px;
|
||||
margin-top: 10px;
|
||||
align-items: flex-start;
|
||||
margin-left: 10px;
|
||||
height: 60px;
|
||||
width: 130px;
|
||||
margin-top: 10px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.foldername_text {
|
||||
text-overflow: ellipsis;
|
||||
font-weight: 600;
|
||||
font-size: 24px;
|
||||
text-overflow: ellipsis;
|
||||
font-weight: 600;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.foldercount {
|
||||
font-weight: 600;
|
||||
font-size: 18px;
|
||||
margin-left: 10px;
|
||||
margin-bottom: 5px;
|
||||
font-weight: 600;
|
||||
font-size: 18px;
|
||||
margin-left: 10px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
</style>
|
||||
@@ -25,7 +25,7 @@
|
||||
<list class="foldervid_list">
|
||||
<list-item type="foldervid_videos" for="{{foldervid_vids}}" class="foldervid_listitem"
|
||||
style="height: {{calcSpace($item.title, true)}}" onclick="OpenVideo({{$item.bvid}})">
|
||||
<videoshow video={{$item}}></videoshow>
|
||||
<videoshow video="{{$item}}"></videoshow>
|
||||
<text style="margin-top: {{calcSpace($item.title, false)}}; height: 0px"></text>
|
||||
</list-item>
|
||||
</list>
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
<script>
|
||||
import router from "@system.router"
|
||||
|
||||
export default {
|
||||
private: {
|
||||
foldervid_vids: [],
|
||||
@@ -52,13 +53,13 @@ export default {
|
||||
vidcount: 0
|
||||
},
|
||||
NextPN() {
|
||||
if (this.current_pn != this.maxpn) {
|
||||
if (this.current_pn < this.maxpn) {
|
||||
this.current_pn++
|
||||
this.LoadVideos()
|
||||
}
|
||||
},
|
||||
BackPN() {
|
||||
if (this.current_pn != 1) {
|
||||
if (this.current_pn > 1) {
|
||||
this.current_pn--
|
||||
this.LoadVideos()
|
||||
}
|
||||
@@ -67,41 +68,39 @@ export default {
|
||||
console.log("openvid: " + bvid)
|
||||
router.push({
|
||||
uri: "pages/videodetail",
|
||||
params: {
|
||||
bvid: bvid
|
||||
}
|
||||
params: {bvid}
|
||||
})
|
||||
},
|
||||
calcSpace(vid_title, isListItem) {
|
||||
if (vid_title == this.foldervid_vids[this.foldervid_vids.length - 1].title) {
|
||||
if (isListItem) {
|
||||
return "270px"
|
||||
}
|
||||
return "80px"
|
||||
}
|
||||
const isLastItem = vid_title === this.foldervid_vids[this.foldervid_vids.length - 1]?.title
|
||||
if (isListItem) {
|
||||
return "170px"
|
||||
return isLastItem ? "270px" : "170px"
|
||||
}
|
||||
return "0px"
|
||||
return isLastItem ? "80px" : "0px"
|
||||
},
|
||||
async LoadVideos() {
|
||||
this.show_loading = true
|
||||
this.foldervid_vids.length = 0 // Clear Array
|
||||
|
||||
this.foldervid_vids = [] // Clear Array
|
||||
this.anims.loading.start()
|
||||
|
||||
let medialist = await this.$app.$def.biliclient.getFavouriteFolderContent(
|
||||
this.mlid,
|
||||
this.current_pn,
|
||||
5
|
||||
)
|
||||
medialist.medias.forEach(async (media) => {
|
||||
var mediainfo = await this.$app.$def.biliclient.getVideoInfoByBVID(media.bvid)
|
||||
this.foldervid_vids.push(mediainfo)
|
||||
})
|
||||
try {
|
||||
const medialist = await this.$app.$def.biliclient.getFavouriteFolderContent(
|
||||
this.mlid,
|
||||
this.current_pn,
|
||||
5
|
||||
)
|
||||
const videoInfoPromises = medialist.medias.map((media) =>
|
||||
this.$app.$def.biliclient.getVideoInfoByBVID(media.bvid)
|
||||
)
|
||||
|
||||
this.show_loading = false
|
||||
this.anims.loading.stop()
|
||||
// 并行获取所有视频信息
|
||||
this.foldervid_vids = await Promise.all(videoInfoPromises)
|
||||
} catch (error) {
|
||||
console.error("加载视频时发生错误:", error)
|
||||
} finally {
|
||||
this.show_loading = false
|
||||
this.anims.loading.stop()
|
||||
}
|
||||
},
|
||||
onInit() {
|
||||
this.maxpn = Math.ceil(this.vidcount / 5)
|
||||
|
||||
+32
-27
@@ -16,6 +16,7 @@
|
||||
<script>
|
||||
import prompt from "@system.prompt"
|
||||
import router from "@system.router"
|
||||
|
||||
export default {
|
||||
private: {
|
||||
qr_value: "",
|
||||
@@ -30,53 +31,57 @@ export default {
|
||||
}
|
||||
},
|
||||
async PollQR() {
|
||||
var result = await this.$app.$def.biliclient.login(true, this.qrpoll_interval)
|
||||
if (result.success) {
|
||||
console.log("登录成功")
|
||||
prompt.showToast({
|
||||
message: "登录成功"
|
||||
})
|
||||
router.replace({
|
||||
uri: "pages/main"
|
||||
})
|
||||
} else {
|
||||
if (result.message.includes("登录失败")) {
|
||||
prompt.showToast({
|
||||
message: result.message,
|
||||
duration: 5000
|
||||
})
|
||||
try {
|
||||
const result = await this.$app.$def.biliclient.login(true, this.qrpoll_interval)
|
||||
if (result.success) {
|
||||
console.log("登录成功")
|
||||
prompt.showToast({message: "登录成功"})
|
||||
router.replace({uri: "pages/main"})
|
||||
clearInterval(this.qrpoll_interval)
|
||||
} else if (result.message.includes("登录失败")) {
|
||||
prompt.showToast({message: result.message, duration: 5000})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("轮询QR登录时出错:", error)
|
||||
}
|
||||
},
|
||||
async GetQR() {
|
||||
var get_result = await this.$app.$def.biliclient.login_qr()
|
||||
this.qr_value = get_result.url
|
||||
console.log(get_result)
|
||||
this.show_qr = true
|
||||
this.show_loading = false
|
||||
this.qrpoll_interval = setInterval(async() => {
|
||||
await this.PollQR()
|
||||
}, 1500);
|
||||
try {
|
||||
const get_result = await this.$app.$def.biliclient.login_qr()
|
||||
this.qr_value = get_result.url
|
||||
console.log(get_result)
|
||||
this.show_qr = true
|
||||
this.show_loading = false
|
||||
|
||||
this.qrpoll_interval = setInterval(() => this.PollQR(), 1500)
|
||||
} catch (error) {
|
||||
console.error("获取QR码时出错:", error)
|
||||
prompt.showToast({message: "无法获取QR码,请重试", duration: 3000})
|
||||
this.show_loading = false
|
||||
}
|
||||
},
|
||||
onReady() {
|
||||
const {pagediv_mgt, loading_img_src} = this.anims
|
||||
|
||||
this.anims.pagediv = new this.$app.$def.animengine.DomAnim(
|
||||
"loginPage",
|
||||
{value: "0"},
|
||||
this.anims.pagediv_mgt,
|
||||
pagediv_mgt,
|
||||
0,
|
||||
0,
|
||||
250
|
||||
)
|
||||
this.anims.pagediv.start()
|
||||
if (this.anims.pagediv) this.anims.pagediv.start()
|
||||
|
||||
this.anims.loading_img = new this.$app.$def.animengine.SequenceAnim(
|
||||
"loginPage",
|
||||
this.anims.loading_img_src,
|
||||
loading_img_src,
|
||||
28,
|
||||
"/common/seqanims/loading/icons8-loading-*.png",
|
||||
1000,
|
||||
true
|
||||
)
|
||||
this.anims.loading_img.start()
|
||||
if (this.anims.loading_img) this.anims.loading_img.start()
|
||||
|
||||
this.GetQR()
|
||||
}
|
||||
|
||||
+53
-49
@@ -21,12 +21,17 @@
|
||||
</list>
|
||||
</div>
|
||||
</scroll>
|
||||
<div style="position: absolute; bottom: 0px;" @click="Refresh()">
|
||||
<div style="position: absolute; bottom: 0px" @click="Refresh()">
|
||||
<image src="/common/main_floatingrefresh.png"></image>
|
||||
</div>
|
||||
<text style="position: absolute; color: rgba(0, 0, 0, 0); width: 0px; top: 50px">{{ anims.refresh_bottom.value }}</text>
|
||||
<text style="position: absolute; color: rgba(0, 0, 0, 0); width: 0px; top: 50px">{{ ambientlight.rotatedeg }}</text>
|
||||
<image if={{anims.showRefreshFX}} style="position: absolute; bottom: {{anims.refresh_bottom.value}}px" src="/common/TranslateFX/refreshFX.png"></image>
|
||||
<text style="position: absolute; color: rgba(0, 0, 0, 0); width: 0px; top: 50px">
|
||||
{{ anims.refresh_bottom.value }}
|
||||
</text>
|
||||
<text style="position: absolute; color: rgba(0, 0, 0, 0); width: 0px; top: 50px">
|
||||
{{ ambientlight.rotatedeg }}
|
||||
</text>
|
||||
<image if="{{anims.showRefreshFX}}" style="position: absolute; bottom: {{anims.refresh_bottom.value}}px"
|
||||
src="/common/TranslateFX/refreshFX.png"></image>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -34,6 +39,7 @@
|
||||
import router from "@system.router"
|
||||
import prompt from "@system.prompt"
|
||||
import folme from "@system.folme"
|
||||
|
||||
export default {
|
||||
private: {
|
||||
recommend_vids: [],
|
||||
@@ -54,104 +60,102 @@ export default {
|
||||
ambientlightObj: null
|
||||
},
|
||||
OpenVideo(bvid) {
|
||||
console.log("openvid: " + bvid)
|
||||
console.log("openvid:", bvid)
|
||||
router.push({
|
||||
uri: "pages/videodetail",
|
||||
params: {
|
||||
bvid: bvid
|
||||
}
|
||||
params: {bvid}
|
||||
})
|
||||
},
|
||||
async Refresh(){
|
||||
if(!this.anims.showRefreshFX){
|
||||
async Refresh() {
|
||||
if (!this.anims.showRefreshFX) {
|
||||
this.recommend_vids = []
|
||||
this.anims.loading.start()
|
||||
this.show_loading = true
|
||||
this.show_recommend_div = false
|
||||
this.anims.showRefreshFX = true
|
||||
|
||||
setTimeout(() => {
|
||||
this.anims.refresh.start()
|
||||
}, 200)
|
||||
this.anims.loading.start()
|
||||
|
||||
setTimeout(async() => {
|
||||
setTimeout(() => this.anims.refresh.start(), 200)
|
||||
|
||||
setTimeout(async () => {
|
||||
this.anims.refresh_bottom.value = "-350px"
|
||||
this.anims.refresh.stop()
|
||||
this.anims.showRefreshFX = false
|
||||
await this.GetVids()
|
||||
}, 1200)
|
||||
}
|
||||
else{
|
||||
prompt.showToast({
|
||||
message: "你先别急。"
|
||||
})
|
||||
} else {
|
||||
prompt.showToast({message: "你先别急。"})
|
||||
}
|
||||
},
|
||||
async GetVids() {
|
||||
this.recommend_vids = await this.$app.$def.biliclient.getMainPageRecommendVideos(
|
||||
this.$app.$def.settings.SETTINGS.fresh_type,
|
||||
this.$app.$def.settings.SETTINGS.home_vid_count
|
||||
)
|
||||
this.anims.loading.stop()
|
||||
this.show_loading = false
|
||||
this.show_recommend_div = true
|
||||
try {
|
||||
const {fresh_type, home_vid_count} = this.$app.$def.settings.SETTINGS
|
||||
this.recommend_vids = await this.$app.$def.biliclient.getMainPageRecommendVideos(
|
||||
fresh_type,
|
||||
home_vid_count
|
||||
)
|
||||
} catch (error) {
|
||||
console.error("获取推荐视频时出错:", error)
|
||||
prompt.showToast({message: "获取推荐视频失败,请重试。"})
|
||||
} finally {
|
||||
this.anims.loading.stop()
|
||||
this.show_loading = false
|
||||
this.show_recommend_div = true
|
||||
}
|
||||
},
|
||||
calcSpace(vid_title, isListItem) {
|
||||
// 如果传入的视频标题是最后一个视频 就让占位文本占据20px的高度可供用户下滑
|
||||
// 这样算是较为硬核的一种针对圆形屏幕的适配
|
||||
if (vid_title == this.recommend_vids[this.recommend_vids.length - 1].title) {
|
||||
if (isListItem) {
|
||||
return "270px"
|
||||
}
|
||||
return "80px"
|
||||
}
|
||||
const isLastItem = vid_title === this.recommend_vids[this.recommend_vids.length - 1]?.title
|
||||
if (isListItem) {
|
||||
return "170px"
|
||||
return isLastItem ? "270px" : "170px"
|
||||
}
|
||||
return "0px"
|
||||
return isLastItem ? "80px" : "0px"
|
||||
},
|
||||
async checkUpdates() {
|
||||
var result = await this.$app.$def.biliclient.checkHyperbilibiliUpdates()
|
||||
if (result.update) {
|
||||
prompt.showToast({
|
||||
message: result.msg,
|
||||
duration: 6000
|
||||
})
|
||||
try {
|
||||
const result = await this.$app.$def.biliclient.checkHyperbilibiliUpdates()
|
||||
if (result.update) {
|
||||
prompt.showToast({message: result.msg, duration: 6000})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("检查更新时出错:", error)
|
||||
}
|
||||
},
|
||||
onInit() {
|
||||
this.GetVids()
|
||||
this.funnytip = this.$app.$def.funnytips.getTips()
|
||||
|
||||
this.checkUpdates()
|
||||
},
|
||||
onReady() {
|
||||
const {loading_src, refresh_bottom} = this.anims
|
||||
|
||||
this.anims.loading = new this.$app.$def.animengine.SequenceAnim(
|
||||
"mainPage",
|
||||
this.anims.loading_src,
|
||||
loading_src,
|
||||
28,
|
||||
"/common/seqanims/loadingWhite/icons8-loading_颜色反转-*.png",
|
||||
1000,
|
||||
true
|
||||
)
|
||||
|
||||
this.anims.loading.start()
|
||||
|
||||
this.anims.refresh = new this.$app.$def.animengine.DomAnim(
|
||||
"mainPage",
|
||||
{value: "0px"},
|
||||
this.anims.refresh_bottom,
|
||||
refresh_bottom,
|
||||
0,
|
||||
450,
|
||||
1000
|
||||
)
|
||||
|
||||
this.ambientlightObj = new this.$app.$def.ambientlight.AmbientLightRunner(this.ambientlight, this.$app.$def.settings.SETTINGS)
|
||||
this.ambientlightObj = new this.$app.$def.ambientlight.AmbientLightRunner(
|
||||
this.ambientlight,
|
||||
this.$app.$def.settings.SETTINGS
|
||||
)
|
||||
this.ambientlightObj.start()
|
||||
},
|
||||
onDestroy() {
|
||||
this.$app.$def.animengine.clearPageAnims("mainPage")
|
||||
this.ambientlightObj.stop()
|
||||
this.ambientlightObj?.stop()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
+62
-72
@@ -18,14 +18,15 @@
|
||||
</list-item>
|
||||
</list>
|
||||
<floating-page-changer current_pn="{{current_pn}}" @backpn="BackPN" @nextpn="NextPN"></floating-page-changer>
|
||||
<full-screen-input input_text={{input_text}} if="{{replymode}}" @complete="InputComplete" @delete="InputDelete" @send="SendReply"
|
||||
@exit="ExitInput"></full-screen-input>
|
||||
<full-screen-input input_text="{{input_text}}" if="{{replymode}}" @complete="InputComplete" @delete="InputDelete"
|
||||
@send="SendReply" @exit="ExitInput"></full-screen-input>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import router from "@system.router"
|
||||
import prompt from "@system.prompt"
|
||||
|
||||
export default {
|
||||
public: {
|
||||
type: 1,
|
||||
@@ -47,45 +48,46 @@ export default {
|
||||
replymode: false,
|
||||
reply_target: null,
|
||||
input_text: {
|
||||
// 使用Object,保持子组件和父组件的数据传递
|
||||
content: ""
|
||||
}
|
||||
},
|
||||
async SendReply() {
|
||||
this.replymode = false
|
||||
var result = null
|
||||
if (this.input_text.content.length > 0) {
|
||||
if (this.secmode) {
|
||||
result = await this.$app.$def.biliclient.GiveTreeReply(
|
||||
this.type,
|
||||
this.oid,
|
||||
this.reply_target,
|
||||
this.rootrpid,
|
||||
this.input_text.content
|
||||
)
|
||||
} else {
|
||||
result = await this.$app.$def.biliclient.GiveSecReply(
|
||||
this.type,
|
||||
this.oid,
|
||||
this.reply_target,
|
||||
this.input_text.content
|
||||
)
|
||||
}
|
||||
if (result.code == 0) {
|
||||
prompt.showToast({
|
||||
message: "发送成功"
|
||||
})
|
||||
const {content} = this.input_text
|
||||
|
||||
if (content.length === 0) {
|
||||
prompt.showToast({message: "评论内容不得为空!", duration: 2000})
|
||||
return
|
||||
}
|
||||
|
||||
let result
|
||||
try {
|
||||
result = this.secmode
|
||||
? await this.$app.$def.biliclient.GiveTreeReply(
|
||||
this.type,
|
||||
this.oid,
|
||||
this.reply_target,
|
||||
this.rootrpid,
|
||||
content
|
||||
)
|
||||
: await this.$app.$def.biliclient.GiveSecReply(
|
||||
this.type,
|
||||
this.oid,
|
||||
this.reply_target,
|
||||
content
|
||||
)
|
||||
|
||||
if (result.code === 0) {
|
||||
prompt.showToast({message: "发送成功"})
|
||||
} else {
|
||||
prompt.showToast({
|
||||
message: "发送失败,错误代码:" + result.code + " 原因:" + result.message,
|
||||
message: `发送失败,错误代码:${result.code} 原因:${result.message}`,
|
||||
duration: 4000
|
||||
})
|
||||
}
|
||||
} else {
|
||||
prompt.showToast({
|
||||
message: "评论内容不得为空!",
|
||||
duration: 2000
|
||||
})
|
||||
} catch (error) {
|
||||
console.error("发送评论时发生错误:", error)
|
||||
prompt.showToast({message: "发送失败,请重试。", duration: 4000})
|
||||
}
|
||||
},
|
||||
ExitInput() {
|
||||
@@ -103,39 +105,24 @@ export default {
|
||||
this.reply_target = evt.detail.rpid
|
||||
},
|
||||
ShowTools(evt) {
|
||||
if (!this.secmode) {
|
||||
router.push({
|
||||
uri: "pages/replytools",
|
||||
params: {
|
||||
type: this.type,
|
||||
oid: this.oid,
|
||||
reply: evt.detail.reply
|
||||
}
|
||||
})
|
||||
} else {
|
||||
router.push({
|
||||
uri: "pages/textdetail",
|
||||
params: {
|
||||
text: evt.detail.reply.content.message,
|
||||
titletext: "评论详情"
|
||||
}
|
||||
})
|
||||
}
|
||||
const uri = this.secmode ? "pages/textdetail" : "pages/replytools"
|
||||
const params = this.secmode
|
||||
? {text: evt.detail.reply.content.message, titletext: "评论详情"}
|
||||
: {type: this.type, oid: this.oid, reply: evt.detail.reply}
|
||||
|
||||
router.push({uri, params})
|
||||
},
|
||||
PlaceHolderShowCheck(rpid) {
|
||||
if (rpid == this.replies[this.replies.length - 1].rpid) {
|
||||
return "315px"
|
||||
}
|
||||
return "200px"
|
||||
return rpid === this.replies[this.replies.length - 1]?.rpid ? "315px" : "200px"
|
||||
},
|
||||
NextPN() {
|
||||
if (this.current_pn != this.maxpn) {
|
||||
if (this.current_pn < this.maxpn) {
|
||||
this.current_pn++
|
||||
this.LoadReplies()
|
||||
}
|
||||
},
|
||||
BackPN() {
|
||||
if (this.current_pn != 1) {
|
||||
if (this.current_pn > 1) {
|
||||
this.current_pn--
|
||||
this.LoadReplies()
|
||||
}
|
||||
@@ -144,27 +131,30 @@ export default {
|
||||
this.replies = []
|
||||
this.show_loading = true
|
||||
this.anims.loading.start()
|
||||
if (this.secmode) {
|
||||
this.replies = (
|
||||
await this.$app.$def.biliclient.getSecReplies(
|
||||
this.type,
|
||||
this.oid,
|
||||
this.rootrpid,
|
||||
this.current_pn
|
||||
)
|
||||
).replies
|
||||
} else {
|
||||
this.replies = (
|
||||
await this.$app.$def.biliclient.getReplies(this.type, this.oid, this.current_pn)
|
||||
).replies
|
||||
|
||||
try {
|
||||
const replyData = this.secmode
|
||||
? await this.$app.$def.biliclient.getSecReplies(
|
||||
this.type,
|
||||
this.oid,
|
||||
this.rootrpid,
|
||||
this.current_pn
|
||||
)
|
||||
: await this.$app.$def.biliclient.getReplies(this.type, this.oid, this.current_pn)
|
||||
|
||||
this.replies = replyData.replies
|
||||
} catch (error) {
|
||||
console.error("加载评论时发生错误:", error)
|
||||
prompt.showToast({message: "加载评论失败,请重试。", duration: 4000})
|
||||
} finally {
|
||||
this.anims.loading.stop()
|
||||
this.show_loading = false
|
||||
global.runGC()
|
||||
}
|
||||
this.anims.loading.stop()
|
||||
this.show_loading = false
|
||||
global.runGC()
|
||||
},
|
||||
onInit() {
|
||||
this.maxpn = Math.ceil(this.replycount / 10)
|
||||
console.log("maxpn=" + this.maxpn)
|
||||
console.log("maxpn=", this.maxpn)
|
||||
|
||||
this.anims.loading = new this.$app.$def.animengine.SequenceAnim(
|
||||
"replysPage",
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<import name="title-bar" src="../../components/TitleBar/TitleBar.ux"></import>
|
||||
<import name="full-screen-input" src="../../components/FullScreenInput/FullScreenInput.ux"></import>
|
||||
|
||||
<template>
|
||||
<div class="page">
|
||||
@@ -43,14 +42,13 @@
|
||||
</div>
|
||||
<image src="/common/featurebtn_replyarea.png" style="margin-top: 15px" @click="GoReplyArea()"></image>
|
||||
</div>
|
||||
<full-screen-input input_text="{{input_text}}" if="{{replymode}}" @complete="InputComplete" @delete="InputDelete"
|
||||
@send="SendReply" @exit="ExitInput"></full-screen-input>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import router from "@system.router"
|
||||
import prompt from "@system.prompt"
|
||||
|
||||
export default {
|
||||
public: {
|
||||
bvid: 1 // 视频BVID
|
||||
@@ -64,30 +62,47 @@ export default {
|
||||
coinsrc: "/common/vidtool_coin.png",
|
||||
starsrc: "/common/vidtool_star.png",
|
||||
replymode: false,
|
||||
input_text: {
|
||||
content: ""
|
||||
}
|
||||
input_text: {content: ""}
|
||||
},
|
||||
onInit() {
|
||||
this.GetVideoDetail()
|
||||
this.UpdateVideoToolbarStatus()
|
||||
},
|
||||
async GetVideoDetail() {
|
||||
this.vid = await this.$app.$def.biliclient.getVideoInfoByBVID(this.bvid)
|
||||
},
|
||||
async UpdateVideoToolbarStatus() {
|
||||
this.stared = await this.$app.$def.biliclient.isVideoStaredByBVID(this.bvid)
|
||||
this.UpdateToolBarIconSrc()
|
||||
},
|
||||
UpdateToolBarIconSrc() {
|
||||
this.likesrc = this.liked ? "/common/vidtool_liked.png" : "/common/vidtool_like.png"
|
||||
this.coinsrc = this.coined ? "/common/vidtool_coined.png" : "/common/vidtool_coin.png"
|
||||
this.starsrc = this.stared ? "/common/vidtool_stared.png" : "/common/vidtool_star.png"
|
||||
},
|
||||
formatNumber(num) {
|
||||
return this.$app.$def.tools.formatNumber(num)
|
||||
},
|
||||
async SendReply() {
|
||||
this.replymode = false
|
||||
if (this.input_text.content.length > 0) {
|
||||
var result = this.$app.$def.biliclient.GiveReply(1, this.vid.aid, this.input_text.content)
|
||||
if (result.code == 0) {
|
||||
prompt.showToast({
|
||||
message: "发送成功"
|
||||
})
|
||||
} else {
|
||||
prompt.showToast({
|
||||
message: "发送失败,错误代码:" + result.code + " 原因:" + result.message,
|
||||
duration: 4000
|
||||
})
|
||||
}
|
||||
} else {
|
||||
prompt.showToast({
|
||||
if (this.input_text.content.length === 0) {
|
||||
return prompt.showToast({
|
||||
message: "评论内容不得为空!",
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
|
||||
const result = await this.$app.$def.biliclient.GiveReply(
|
||||
1,
|
||||
this.vid.aid,
|
||||
this.input_text.content
|
||||
)
|
||||
const message =
|
||||
result.code === 0 ? "发送成功" : `发送失败,错误代码:${result.code} 原因:${result.message}`
|
||||
prompt.showToast({
|
||||
message,
|
||||
duration: result.code === 0 ? 2000 : 4000
|
||||
})
|
||||
},
|
||||
ExitInput() {
|
||||
this.replymode = false
|
||||
@@ -99,13 +114,14 @@ export default {
|
||||
this.input_text.content = this.input_text.content.slice(0, -1)
|
||||
},
|
||||
Reply() {
|
||||
/*
|
||||
this.replymode = true
|
||||
this.input_text.content = ""
|
||||
},
|
||||
GenerateVideoManifest() {
|
||||
prompt.showToast({
|
||||
message: "该功能暂未开放"
|
||||
})
|
||||
*/
|
||||
prompt.showToast({
|
||||
message: "暂时仅支持回复其它用户的评论",
|
||||
duration: 2000
|
||||
})
|
||||
},
|
||||
DisabledFeaturesWarning() {
|
||||
prompt.showToast({
|
||||
@@ -113,37 +129,22 @@ export default {
|
||||
})
|
||||
},
|
||||
async AISummary() {
|
||||
var summary = await this.$app.$def.biliclient.getVideoAISummaryByBVID(
|
||||
this.vid.bvid,
|
||||
this.vid.cid,
|
||||
this.vid.owner.mid
|
||||
)
|
||||
if (!summary) {
|
||||
summary =
|
||||
"该视频没有摘要,可能是其内容中包含敏感信息(如涉政、涉军、涉企、或其它容易被误解或引起歧义、多人意见不一、容易引起争论的内容),或是视频没有可以被识别的音频"
|
||||
}
|
||||
const summary =
|
||||
(await this.$app.$def.biliclient.getVideoAISummaryByBVID(
|
||||
this.vid.bvid,
|
||||
this.vid.cid,
|
||||
this.vid.owner.mid
|
||||
)) || "该视频没有摘要,可能是其内容中包含敏感信息或没有可识别的音频"
|
||||
router.push({
|
||||
uri: "pages/textdetail",
|
||||
params: {
|
||||
text: summary
|
||||
}
|
||||
params: {text: summary}
|
||||
})
|
||||
},
|
||||
async AddToFav() {
|
||||
var result = await this.$app.$def.biliclient.starVideoToDefaultFavFolderByBVID(this.bvid)
|
||||
console.log(result)
|
||||
if (!result) {
|
||||
prompt.showToast({
|
||||
message: "收藏成功"
|
||||
})
|
||||
} else {
|
||||
prompt.showToast({
|
||||
message: "收藏失败,请重试,或重新登录后再试"
|
||||
})
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.UpdateVideoToolbarStatus()
|
||||
}, 500)
|
||||
const result = await this.$app.$def.biliclient.starVideoToDefaultFavFolderByBVID(this.bvid)
|
||||
const message = result ? "收藏失败,请重试,或重新登录后再试" : "收藏成功"
|
||||
prompt.showToast({message})
|
||||
this.UpdateVideoToolbarStatus()
|
||||
},
|
||||
GoReplyArea() {
|
||||
router.push({
|
||||
@@ -154,32 +155,6 @@ export default {
|
||||
replycount: this.vid.stat.reply
|
||||
}
|
||||
})
|
||||
},
|
||||
async UpdateVideoToolbarStatus() {
|
||||
this.stared = await this.$app.$def.biliclient.isVideoStaredByBVID(this.bvid)
|
||||
|
||||
this.UpdateToolBarIconSrc()
|
||||
},
|
||||
UpdateToolBarIconSrc() {
|
||||
this.likesrc = "/common/vidtool_like.png"
|
||||
if (this.liked) {
|
||||
this.likesrc = "/common/vidtool_liked.png"
|
||||
}
|
||||
this.coinsrc = "/common/vidtool_coin.png"
|
||||
if (this.coined) {
|
||||
this.coinsrc = "/common/vidtool_coined.png"
|
||||
}
|
||||
this.starsrc = "/common/vidtool_star.png"
|
||||
if (this.stared) {
|
||||
this.starsrc = "/common/vidtool_stared.png"
|
||||
}
|
||||
},
|
||||
async GetVideoDetail() {
|
||||
this.vid = await this.$app.$def.biliclient.getVideoInfoByBVID(this.bvid)
|
||||
},
|
||||
onInit() {
|
||||
this.GetVideoDetail()
|
||||
this.UpdateVideoToolbarStatus()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user