11.28提交

This commit is contained in:
zoujiandong 2025-11-28 10:43:13 +08:00
parent 91726b87c5
commit 9788e723a2
17 changed files with 1005 additions and 408 deletions

419
App.vue
View File

@ -1,226 +1,241 @@
<script>
export default {
globalData: {
plAd: true,
dotNumber: {},
apiHost: "https://dev-app.igandan.com/app",
//BASE_URL='https://dev-app.igandan.com/app'
},
onLaunch(options) {
//uni.setStorageSync('apiHost', 'value')
console.log("打印options");
console.log(options);
if (
options &&
options.referrerInfo.extraData &&
options.referrerInfo.extraData.token
) {
uni.setStorageSync(
"AUTH_TOKEN_App",
options.referrerInfo.extraData.token
);
uni.setStorageSync("userInfo", options.referrerInfo.extraData.userInfo);
//getApp({allowDefault: true}).globalData.apiHost = options.referrerInfo.extraData.apiHost;
}
if (
options &&
options.referrerInfo.extraData &&
options.referrerInfo.extraData.targetPath
) {
uni.navigateTo({
url: options.referrerInfo.extraData.targetPath,
});
}
export default {
globalData: {
plAd: true,
dotNumber: {
console.log("app传递登录信息onLaunch-------------------");
try {
// #ifdef APP
// uni.onNativeEventReceive((event, data) => {
// console.log("app-------------------");
// console.log("event");
// console.log(event);
// console.log("data");
// console.log(data);
// if (event.indexOf("loginInfo") > -1) {
// uni.setStorageSync("DEV_AUTH_TOKEN_App", data.token);
// uni.setStorageSync("userInfo", data.userInfo);
// console.log("token");
// console.log(uni.getStorageSync("DEV_AUTH_TOKEN_App"));
// }
// });
// #endif
} catch (error) {
console.log("app传递登录信息error-------------------");
console.log(error);
}
},
onShow() {
try {
// #ifdef APP
let checkTokenCallBackFlag = false;
console.log("执行onshow");
},
apiHost: 'https://dev-app.igandan.com/app',
//BASE_URL='https://dev-app.igandan.com/app'
},
onLaunch(options) {
//uni.setStorageSync('apiHost', 'value')
console.log('打印options');
console.log(options);
if (options && options.referrerInfo.extraData && options.referrerInfo.extraData.token) {
uni.setStorageSync("AUTH_TOKEN_App", options.referrerInfo.extraData.token);
uni.setStorageSync("userInfo", options.referrerInfo.extraData.userInfo);
//getApp({allowDefault: true}).globalData.apiHost = options.referrerInfo.extraData.apiHost;
};
if (options && options.referrerInfo.extraData && options.referrerInfo.extraData.targetPath) {
uni.navigateTo({
url: options.referrerInfo.extraData.targetPath
});
};
console.log("app传递登录信息onLaunch-------------------");
try {
// #ifdef APP
// uni.onNativeEventReceive((event, data) => {
// console.log("app-------------------");
// console.log("event");
// console.log(event);
// console.log("data");
// console.log(data);
// if (event.indexOf("loginInfo") > -1) {
// uni.setStorageSync("DEV_AUTH_TOKEN_App", data.token);
// uni.setStorageSync("userInfo", data.userInfo);
// console.log("token");
// console.log(uni.getStorageSync("DEV_AUTH_TOKEN_App"));
// }
// });
// #endif
} catch (error) {
console.log("app传递登录信息error-------------------");
console.log(error);
}
},
onShow() {
try {
// #ifdef APP
let checkTokenCallBackFlag = false
console.log("执行onshow")
uni.sendNativeEvent('checkToken', {
msg: 'checkToken'
}, ret => {
checkTokenCallBackFlag = true
console.log('check回调')
console.log(ret)
if (ret.code == 0) {
uni.showModal({
title: '提示',
uni.sendNativeEvent(
"checkToken",
{
msg: "checkToken",
},
(ret) => {
checkTokenCallBackFlag = true;
console.log("check回调");
console.log(ret);
if (ret.code == 0) {
uni.showModal({
title: "提示",
showCancel: false,
content: '您已退出登录!',
success: function (res) {
if (res.confirm) {
uni.sendNativeEvent('goTabbarPage', {
msg: 'home'
}, ret => {
console.log(ret);
})
plus.runtime.quit()
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
}
})
// setTimeout(function(){
// console.log(" setTimeout")
// if(!checkTokenCallBackFlag){
// uni.showModal({
// title: '',
// showCancel: false,
// content: '退',
// success: function (res) {
// if (res.confirm) {
// uni.sendNativeEvent('goTabbarPage', {
// msg: 'home'
// }, ret => {
// console.log(ret);
// })
// } else if (res.cancel) {
// console.log('');
// }
// }
// });
// }
// }, 1000)
uni.onNativeEventReceive((event, data) => {
console.log("event", event);
console.log("data", data);
if (event.indexOf("clearToken") > -1) {
uni.setStorageSync('AUTH_TOKEN_App', '')
plus.runtime.quit()
content: "您已退出登录!",
success: function (res) {
if (res.confirm) {
uni.sendNativeEvent(
"goTabbarPage",
{
msg: "home",
},
(ret) => {
console.log(ret);
}
);
plus.runtime.quit();
} else if (res.cancel) {
console.log("用户点击取消");
}
},
});
}
}
);
}
})
let main = plus.android.runtimeMainActivity();
//退quit
plus.runtime.quit = function() {
main.moveTaskToBack(false);
};
//toast 退 toast
plus.nativeUI.toast = (function(str) {
if (str == '再按一次退出应用') {
main.moveTaskToBack(false);
} else {
uni.showToast({
title: str,
icon: 'none',
})
}
});
// setTimeout(function(){
// console.log(" setTimeout")
// if(!checkTokenCallBackFlag){
// uni.showModal({
// title: '',
// showCancel: false,
// content: '退',
// success: function (res) {
// if (res.confirm) {
// uni.sendNativeEvent('goTabbarPage', {
// msg: 'home'
// }, ret => {
// console.log(ret);
// })
// } else if (res.cancel) {
// console.log('');
// }
// }
// });
// }
// }, 1000)
// uni.onNativeEventReceive((event, data) => {
// console.log("apponshow-------------------");
// console.log("event", event);
// console.log("data", data);
// if (event == "loginInfo") {
// uni.setStorageSync("DEV_AUTH_YX_TOKEN_App", data.token);
// uni.setStorageSync("userInfo", data.userInfo);
// }else if(event == "showRedDot"){
// console.log("showRedDot");
// console.log(data);
// getApp().globalData.dotNumber=data;
// }
// });
// #endif
uni.onNativeEventReceive((event, data) => {
console.log("event", event);
console.log("data", data);
if (event.indexOf("clearToken") > -1) {
uni.setStorageSync("AUTH_TOKEN_App", "");
plus.runtime.quit();
}
if(event.indexOf("goPage") > -1){
uni.navigateTo({
url: data,
});
}
});
let main = plus.android.runtimeMainActivity();
//退quit
plus.runtime.quit = function () {
main.moveTaskToBack(false);
};
//toast 退 toast
plus.nativeUI.toast = function (str) {
if (str == "再按一次退出应用") {
main.moveTaskToBack(false);
} else {
uni.showToast({
title: str,
icon: "none",
});
}
};
} catch (error) {
console.log('error');
console.log(error)
}
},
onHide() {},
methods: {},
};
// uni.onNativeEventReceive((event, data) => {
// console.log("apponshow-------------------");
// console.log("event", event);
// console.log("data", data);
// if (event == "loginInfo") {
// uni.setStorageSync("DEV_AUTH_YX_TOKEN_App", data.token);
// uni.setStorageSync("userInfo", data.userInfo);
// }else if(event == "showRedDot"){
// console.log("showRedDot");
// console.log(data);
// getApp().globalData.dotNumber=data;
// }
// });
// #endif
} catch (error) {
console.log("error");
console.log(error);
}
},
onHide() {},
methods: {},
};
</script>
<template>
<GlobalDialog />
<GlobalDialog />
</template>
<style lang="scss">
/*每个页面公共css */
@import "@/uni_modules/uni-scss/index.scss";
/* #ifndef APP-NVUE */
@import "@/static/customicons.css";
/*每个页面公共css */
@import "@/uni_modules/uni-scss/index.scss";
/* #ifndef APP-NVUE */
@import "@/static/customicons.css";
//
page {
background-color: #f5f5f5;
}
//
page {
background-color: #f5f5f5;
}
.uni-navbar__header-btns-right {
min-width: 120rpx;
width: auto !important;
}
.uni-navbar__header-btns-right {
min-width: 120rpx;
width: auto !important;
}
/* #endif */
.uni-nav-bar-text {
font-weight: bold;
font-size: 36rpx !important;
}
/* #endif */
.uni-nav-bar-text {
font-weight: bold;
font-size: 36rpx !important;
}
.example-info {
font-size: 14px;
color: #333;
padding: 10px;
}
.example-info {
font-size: 14px;
color: #333;
padding: 10px;
}
.twoline {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
}
.twoline {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
}
.oneline {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.oneline {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.uni-navbar .uniui-left {
font-weight: bold;
font-size: 50rpx !important;
}
.uni-navbar .uniui-left {
font-weight: bold;
font-size: 50rpx !important;
}
::-webkit-scrollbar {
display: none;
}
::-webkit-scrollbar {
display: none;
}
.status_bar {
height: var(--status-bar-height);
background-color: #eeeeee;
}
.status_bar {
height: var(--status-bar-height);
background-color: #eeeeee;
}
.navbox {
position: fixed;
top: 0;
left: 0;
right: 0;
height: calc(var(--status-bar-height) + 44px);
z-index: 9999;
}
.navbox {
position: fixed;
top: 0;
left: 0;
right: 0;
height: calc(var(--status-bar-height) + 44px);
z-index: 9999;
}
</style>

View File

@ -335,6 +335,38 @@
}
}
},
{
"path": "zhinan/zhinan",
"style": {
"navigationStyle": "custom",
"navigationBarTitleText": "uni-app分页",
"app": {
"bounce": "none"
}
}
},
{
"path": "zhinanList/zhinanList",
"style": {
"navigationStyle": "custom",
"navigationBarRightButton":{ "hide": true},
"navigationBarTitleText": "uni-app分页",
"app": {
"bounce": "none"
}
}
},
{
"path": "hot/hot",
"style": {
"navigationStyle": "custom",
"navigationBarRightButton":{ "hide": true},
"navigationBarTitleText": "uni-app分页",
"app": {
"bounce": "none"
}
}
},
{
"path": "login/login",
"style": {
@ -559,17 +591,7 @@
// }
// }
// },
// {
// "path": "hot/hot",
// "style": {
// "navigationStyle": "custom",
// "navigationBarRightButton":{ "hide": true},
// "navigationBarTitleText": "uni-app分页",
// "app": {
// "bounce": "none"
// }
// }
// },
// {
@ -727,16 +749,7 @@
// }
// }
// },
// {
// "path": "zhinan/zhinan",
// "style": {
// "navigationStyle": "custom",
// "navigationBarTitleText": "uni-app分页",
// "app": {
// "bounce": "none"
// }
// }
// },
// {
// "path": "caseRecord/caseRecord",
// "style": {

View File

@ -120,8 +120,8 @@
:data-item-id="item.id"
>
<template #error>
<image :src="lazyImg" class="poster-image" mode="aspectFill"></image>
</template>
<image :src="lazyImg" class="poster-image" mode="aspectFill"></image>
</template>
</up-image>
<view class="play-btn" v-if="item.status_code==1 || item.status_code==2 || item.status_code==4">
<up-image

View File

@ -102,7 +102,7 @@
<view class="video-progress-bar-inner" :style="{ width: item.progress + '%' }"></view>
</view> -->
<!-- <text>{{ item.progress + '%' }}</text> -->
<text>{{ formatSize(item.downloadSize) }} / {{ formatSize(item.totalSize) }}</text>
<view class="size-box">{{ formatSize(item.downloadSize) }}/{{ formatSize(item.totalSize) }}</view>
</view>
</view>
</view>
@ -596,13 +596,24 @@ onMounted(() => {
page{
background-color: #ffffff;
}
.size-box{
display: flex;
white-space: nowrap;
justify-content: flex-end;
white-space: nowrap;
font-size: 24rpx;
color:#8b2316
}
.box{
display: flex;
flex:1;
align-items: center;
white-space: nowrap;
justify-content: flex-end;
margin-left: 30rpx;
text{
width: 40rpx;
display: flex;
white-space: nowrap;
font-size: 24rpx;
color:#8b2316
}
@ -804,8 +815,8 @@ page{
}
.video-status{
display: flex;
align-items: center;
margin-right: 20rpx;
justify-content: space-between;
.status-icon{
display: flex;

View File

@ -1,7 +1,7 @@
<template>
<view class="zhinan-list-page">
<!-- 头部导航栏 -->
<uni-nav-bar
<!-- <uni-nav-bar
left-icon="left"
:title="title"
@clickLeft="goBack"
@ -12,7 +12,8 @@
backgroundColor="#eeeeee"
>
</uni-nav-bar>
</uni-nav-bar> -->
<navBar :title="title" />
<!-- 使用scroll-view实现列表 -->
<scroll-view
@ -39,20 +40,16 @@
<view class="item-date">{{ formatDate(item.releaseTime) }}</view>
<!-- 操作按钮 -->
<view class="item-action">
<view
class="download-btn"
@click.stop="viewGuideline(item)"
>
<up-icon name="download" color="#8D2316" size="28"></up-icon>
</view>
<!-- <view
v-else
class="view-btn"
@click.stop="viewGuideline(item)"
>
查看
</view> -->
</view>
<view class="download-btn" @click.stop="downLoad(item)" v-if="!downLoadtaskList.includes(item.uuid)">
<!-- <up-icon name="download" color="#8D2316" size="28" ></up-icon> -->
<uni-icons type="arrow-down" size="26" color="#8D2316"></uni-icons>
</view>
<view
v-else
class="view-btn"
@click.stop="viewGuideline(item)"
>查看</view>
</view>
</view>
</view>
</view>
@ -83,12 +80,13 @@
</template>
<script setup>
import { ref, onMounted} from 'vue'
import { ref, onMounted,computed,nextTick} from 'vue'
import api from '@/api/api.js'
import { onShow,onLoad } from "@dcloudio/uni-app";
import docUrl from "@/utils/docUrl.js"
import navTo from "@/utils/navTo.js"
import hotImg from "@/static/hot_booklist.png"
import navBar from "@/components/navBar/navBar.vue"
//
const guidelinesList = ref([])
const isLoading = ref(false)
@ -107,6 +105,13 @@ const from=ref('');
const name=ref('');
const showInnerSort=ref(false);
const innerSortTitle=ref('上传时间');
import downloadStore from "@/store/downloadStoreFile.js";
const downloadTasks=ref([]);
const downLoadtaskList=computed(()=>{
console.log('downLoadtaskList');
console.log(downloadTasks.value.map((item)=>item.id));
return downloadTasks.value.map((item)=>item.id);
});
const chooseInnerSort=(index)=>{
sort.value=index;
if(index==1){
@ -144,6 +149,14 @@ const toggleInnerSort=()=>{
showInnerSort.value=!showInnerSort.value;
}
onShow(() => {
syncTasksFromStore();
// store
downloadStore.addListener((tasks) => {
downloadTasks.value = tasks;
});
//
resumeDownloadingTasks();
//
if (guidelinesList.value.length === 0) {
if(from.value){
@ -359,66 +372,39 @@ const downloadGuideline = (item) => {
})
}
}
const downLoad = (item) => {
if(!item.path){
uni.showToast({
title: "暂无下载链接",
icon: "none",
});
return;
}
addDownloadTask({
url: docUrl + item.path,
title: item.title,
id: item.uuid,
});
};
// pdf/doc/docx/xls/xlsx/ppt/pptx/txt
const viewGuideline = (item) => {
const url = docUrl+item.path
if (url) {
const isPDF = /\.(pdf)(\?|$)/i.test(url)
const isOffice = /\.(docx?|xlsx?|pptx?)(\?|$)/i.test(url)
const isText = /\.(txt)(\?|$)/i.test(url)
// H5
// #ifdef H5
if (isPDF) {
try { window.open(url, '_blank') } catch (e) {
uni.navigateTo({ url: `/pages_app/webview/webview?url=${encodeURIComponent(url)}` })
}
return
}
if (isOffice) {
const officeUrl = `https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(url)}`
try { window.open(officeUrl, '_blank') } catch (e) {
uni.navigateTo({ url: `/pages_app/webview/webview?url=${encodeURIComponent(officeUrl)}` })
}
return
}
if (isText) {
uni.navigateTo({ url: `/pages_app/webview/webview?url=${encodeURIComponent(url)}` })
return
}
// webview
uni.navigateTo({ url: `/pages_app/webview/webview?url=${encodeURIComponent(url)}` })
return
// #endif
// H5 openDocument退 webview
// #ifndef H5
uni.showToast({ title: '正在打开...', icon: 'none' })
uni.downloadFile({
url,
success: (res) => {
if (res.statusCode === 200 && res.tempFilePath) {
uni.openDocument({
filePath: res.tempFilePath,
showMenu: true,
success: () => {},
fail: () => {
uni.navigateTo({ url: `/pages_app/webview/webview?url=${encodeURIComponent(url)}` })
}
})
} else {
uni.navigateTo({ url: `/pages_app/webview/webview?url=${encodeURIComponent(url)}` })
}
},
fail: () => {
uni.navigateTo({ url: `/pages_app/webview/webview?url=${encodeURIComponent(url)}` })
}
})
return
// #endif
}
// 退
const viewGuideline = (cell) => {
console.log(cell);
if (!cell.path) {
uni.showToast({
title: "暂无下载链接",
icon: "none",
});
return;
}
downloadTasks.value.forEach(item => {
if(item.id == cell.uuid) {
uni.openDocument({
filePath: item.localPath,
success: () => console.log('打开成功'),
fail: (err) => console.error('打开失败', err)
});
}
});
}
@ -463,6 +449,116 @@ const formatDate = (dateString) => {
return dateString
}
}
//
const addDownloadTask = (item) => {
// 使store
const taskIndex = downloadStore.addTask(item);
//
syncTasksFromStore();
//
startDownload(taskIndex);
};
//
const startDownload = (index) => {
const taskItem = downloadStore.getTask(index);
if (!taskItem) return;
if(taskItem.status == "loading"){
uni.showToast({
title: "正在下载",
icon: "none",
});
return false;
};
downloadStore.updateTask(index, {
status: "loading"
});
const task = uni.downloadFile({
url: taskItem.url,
success: (res1) => {
//console.log("res1:"+JSON.stringify(res1));
if (res1.statusCode === 200) {
downloadStore.updateTask(index, {
status: "completed",
filePath: res1.tempFilePath,
});
uni.showToast({
title: "下载成功",
icon: "none",
});
uni.saveFile({
tempFilePath: res1.tempFilePath,
success: function (res2) {
console.log("res2:"+JSON.stringify(res2));
uni.getSavedFileInfo({
filePath: res2.savedFilePath,
success: function (res) {
console.log("res:"+JSON.stringify(res));
console.log("size:"+res.size);
downloadStore.updateTask(index, {
status: "completed",
localPath: res2.savedFilePath,
});
},
});
},
});
} else {
downloadStore.updateTask(index, {
status: "failed",
});
uni.showToast({
title: "下载失败",
icon: "none",
});
}
},
fail: (err) => {
downloadStore.updateTask(index, {
status: "failed",
});
uni.showToast({
title: "下载失败: " + (err.errMsg || "未知错误"),
icon: "none",
duration: 2000,
});
},
});
//
task.onProgressUpdate((update) => {
const currentTask = downloadStore.getTask(index);
if (currentTask && currentTask.status === "downloading") {
downloadStore.updateTask(index, {
progress: update.progress
});
}
});
// taskstore/
downloadStore.updateTask(index, {
task: task,
});
};
const syncTasksFromStore = () => {
downloadTasks.value = downloadStore.getTasks();
};
//
const resumeDownloadingTasks = () => {
// 使 nextTick
nextTick(() => {
downloadStore.resumeDownloadingTasks((index) => {
// uni.downloadFile0
console.log("恢复下载任务:", downloadStore.getTask(index)?.url);
startDownload(index);
});
});
};
</script>
<style lang="scss" scoped>

View File

@ -1,5 +1,5 @@
<template>
<navBar title="肝胆回放" />
<navBar :title="from == 'video' ? '肝胆视频' : '肝胆回放'" />
<view class="page">
<!-- 筛选标签栏 -->
<view class="filter-bar">
@ -99,8 +99,8 @@
:data-item-id="item.id"
>
<template #error>
<image :src="lazyImg" class="poster-image" mode="aspectFill"></image>
</template>
<image :src="lazyImg" class="poster-image" mode="aspectFill"></image>
</template>
</up-image>
<view class="play-btn">
<up-image
@ -221,7 +221,7 @@
<script setup>
import { ref, nextTick, computed } from "vue";
import { onShow, onHide } from "@dcloudio/uni-app";
import { onShow, onHide,onLoad } from "@dcloudio/uni-app";
import CustomTabbar from "@/components/tabBar/tabBar.vue";
import api from "@/api/api.js";
import select from "@/static/triangle_normal.png";
@ -234,6 +234,12 @@ import navTo from "@/utils/navTo";
import navBar from "@/components/navBar/navBar.vue";
import empty from "@/components/empty/empty.vue";
import lazyImg from "@/static/default_news_iv.png";
const from=ref('');
onLoad((options)=>{
if(options.from){
from.value=options.from;
}
});
//
const isTimePopupShow = ref(false);
const isLocationPopupShow = ref(false);

View File

@ -5,9 +5,9 @@
@clickLeft="goBack" :title="name" color="#8B2316" :border="false" backgroundColor="#eeeeee">
<template #right>
<!-- <view class="nav-right" @click="goSelect">
<view class="nav-right" @click="goSelect">
精选
</view> -->
</view>
</template>
</uni-nav-bar>
</view>

View File

@ -11,7 +11,7 @@
:refresher-triggered="refreshing"
@refresherrefresh="onRefresh"
@scrolltolower="onLoadMore"
lower-threshold="1000"
lower-threshold="300"
>
<view class="meeting-list">
<view
@ -101,9 +101,7 @@
};
const loadVideoData = async (isRefresh = false) => {
if (loading.value && !isRefresh) return;
loading.value = true;
try {
const response = await api.videoByTypeNew({
page: currentPage.value,
@ -128,7 +126,7 @@
if (videoData && videoData.list) {
const { list, totalPage,pageNumber } = videoData;
console.log('视频列表数据:', list);
loading.value=false;
if (isRefresh) {
meetingList.value = list || [];
currentPage.value = 1;
@ -138,6 +136,10 @@
hasMoreData.value = totalPage>pageNumber;
loadMoreStatus.value = hasMoreData.value ? 'more' : 'noMore';
if(hasMoreData.value ){
onLoadMore();
}
} else {
throw new Error(response?.message || '获取数据失败');
}
@ -162,6 +164,8 @@
//
const onLoadMore = () => {
console.log('onLoadMore');
console.log('hasMoreData',hasMoreData.value);
console.log('loading',loading.value);
if (!hasMoreData.value || loading.value) return;
loadMoreStatus.value = 'loading';

View File

@ -1,5 +1,31 @@
<template>
<navBar title="肝胆视频" />
<view class="navbox">
<view class="status_bar"></view>
<uni-nav-bar
left-icon="left"
title="肝胆视频"
@clickLeft="goBack"
color="#8B2316"
:border="false"
backgroundColor="#eeeeee"
>
<template #right>
<view class="nav-actions" >
<view class="collect-img" @click="goSearch">
<image class="img-icon" :src="searchImg" mode="aspectFill" />
</view>
<view class="collect-img" @click="goMeet">
<image
class="img-icon"
:src="meetImg"
mode="aspectFill"
/>
</view>
</view>
</template>
</uni-nav-bar>
</view>
<view class="video-page">
<!-- Header -->
@ -31,11 +57,23 @@
@click="playBannerVideo(banner)"
>
<view class="banner-item">
<image
<up-image
class="banner-image"
:src="docUrl+banner.imgpath"
mode="aspectFill"
></image>
:loadingIcon="lazyVideoImg"
:errorIcon="lazyVideoImg"
:lazy-load="true"
width="100%"
height="400rpx"
>
<template #error>
<image :src="lazyVideoImg" class="banner-image" mode="aspectFill"></image>
</template>
<template #loading>
<image :src="lazyVideoImg" class="banner-image" mode="aspectFill"></image>
</template>
</up-image>
</view>
</swiper-item>
@ -97,7 +135,25 @@
@click="playVideo(video)"
>
<view class="video-thumbnail">
<image :src="docUrl + video.imgpath" mode="aspectFill"></image>
<up-image
:src="docUrl + video.imgpath"
class="poster-image"
mode="aspectFill"
:loadingIcon="lazyImg"
:errorIcon="lazyImg"
:lazy-load="true"
width="100%"
height="220rpx"
>
<template #error>
<image :src="lazyImg" class="poster-image" mode="aspectFill"></image>
</template>
<template #loading>
<image :src="lazyImg" class="poster-image" mode="aspectFill"></image>
</template>
</up-image>
</view>
<view class="video-info">
<view class="video-title">{{video.title || video.name}}</view>
@ -219,6 +275,10 @@
import videoImg from "@/static/patient_video.png"
import docUrl from '@/utils/docUrl';
import navTo from '@/utils/navTo';
import searchImg from "@/static/search.png"
import lazyImg from "@/static/default_video.png"
import lazyVideoImg from "@/static/videoPlaceholder.png";
import meetImg from "@/static/sfewm.png"
import formatNumber from '@/utils/formatNumber.js';
import navBar from '@/components/navBar/navBar.vue';
const isAllActive=ref(false)
@ -244,6 +304,18 @@
const showFilter = ref(false);
const yearList=ref([]);
const selectYearContent=reactive({})
const goSearch=()=>{
uni.sendNativeEvent('goHomeSearch', {
msg: 'goHomeSearch'
},ret => {
console.log(ret);
})
}
const goMeet=()=>{
uni.navigateTo({
url: '/pages_app/liveReplay/liveReplay?from=video'
});
}
//
const filterTags = ref([
{ name: '指南解读', selected: false },
@ -554,11 +626,11 @@
//
const goSearch = () => {
uni.navigateTo({
url: '/pages_app/search/search'
});
};
// const goSearch = () => {
// uni.navigateTo({
// url: '/pages_app/search/search'
// });
// };
//
const goPatientVideo = () => {
@ -777,6 +849,16 @@
$border-radius-small: 6px;
$padding: 15px;
$padding-small: 10px;
.img-icon{
width: 42rpx;
height: 42rpx;
}
.nav-actions{
display: flex;
align-items: center;
justify-content: center;
gap: 20rpx;
}
.video-page {
background-color: #f5f5f5;
height: 100vh;
@ -1138,7 +1220,7 @@
.popup-content {
width: 100%;
margin-top: calc(var(--status-bar-height) + 44px + 400rpx + 117rpx);
height: 80vh;
height: calc(100vh - var(--status-bar-height) - 44px - 400rpx - 117rpx);
background-color: #fff;
overflow: scroll;
@ -1167,7 +1249,7 @@
.popup-body {
display: flex;
height: 600rpx;
height: 100%;
}
.category-sidebar {

View File

@ -41,16 +41,17 @@
:src="videoSrc"
:videoHeight="220"
:seekTime="0"
@fullscreenchange="onFullscreenChange"
/>
<!-- 标签切换 -->
<cover-view class="tabs" v-if="from != 'download'">
<cover-view class="tabs" v-if="from != 'download'" :style="{ opacity: isFullScreen ? 0: 1 }">
<cover-view
class="tab"
:class="{ active: activeTab === 'info' }"
@click="switchTab('info')"
>
视频简介
<view-cover class="tab-line" v-if="activeTab === 'info'"></view-cover>
<cover-view class="tab-line" v-if="activeTab === 'info'"></cover-view>
</cover-view>
<cover-view
class="tab"
@ -58,7 +59,7 @@
@click="switchTab('comment')"
>
评论
<view-cover class="tab-line" v-if="activeTab === 'comment'"></view-cover>
<cover-view class="tab-line" v-if="activeTab === 'comment'"></cover-view>
</cover-view>
</cover-view>
<view class="video-detail-page" v-if="from != 'download'">
@ -132,7 +133,8 @@
<text v-if="!isVideoDownloadRecord && welfareNum > 0">(剩余免费下载{{ welfareNum }}次数)</text>
</text
>
<text class="download-text" v-else-if="downLoadStatus === 'loading'">视频缓存中</text>
<text class="download-text" v-else-if="downLoadStatus === 'loading' || downLoadStatus === 'failed'">视频缓存中</text>
<text class="download-text" v-else-if="downLoadStatus === 'completed'">查看缓存</text>
</view>
<view v-if="activeTab !== 'info' && from != 'download'" class="bottom-comment">
@ -226,6 +228,7 @@ const hasDownload = ref(false);
const downLoadStatus = ref('start');
let downList = uni.getStorageSync("downLoadVideo") || [];
const downLoadList = ref(downList);
const isFullScreen = ref(false);
//import DomVideoPlayer from 'uniapp-video-player'
import sunnyVideo from "@/uni_modules/sunny-video/components/sunny-video/sunny-video.vue";
import downloadStore from "@/store/downloadStoreVideo.js";
@ -239,6 +242,12 @@ const addDownloadTask = (item) => {
//
startDownload(taskIndex);
};
const onFullscreenChange = (e) => {
let { fullScreen, direction } = e;
nextTick(() => {
isFullScreen.value = fullScreen;
});
};
//
const startDownload = (index) => {
const taskItem = downloadStore.getTask(index);
@ -260,7 +269,7 @@ const startDownload = (index) => {
icon: "none",
});
downLoadStatus.value = 'completed';
uni.saveFile({
tempFilePath: res1.tempFilePath,
success: function (res2) {
@ -342,17 +351,11 @@ const toCollection = () => {
};
const networkConfirm = () => {
networkVisible.value = false;
pointVisible.value = true;
if(welfareNum.value > 0) {
useWelfareNum();
}else{
addDownloadTask({
url: videoSrc.value,
id: video_uuid.value,
imgpath: videoInfo.value.imgpath,
author: videoInfo.value.public_name,
name: videoInfo.value.name,
});
pointVisible.value = true;
}
};
@ -399,18 +402,7 @@ const videoDetail = async () => {
if (res.code == 200) {
const userInfo = uni.getStorageSync("userInfo");
videoInfo.value = res.video;
downloadTasks.value.forEach(item => {
if (item.id == video_uuid.value) {
uni.getSavedFileInfo({
filePath: item.localPath, //
success: function (res) {
hasDownload.value = true;
downLoadStatus.value = 'completed';
}
});
}
});
//hasDownload.value = downLoadList.value.includes(video_uuid.value);
let vid = res.video.polyv_uuid;
let uuid = vid.substring(0, 10);
@ -452,6 +444,24 @@ const VideoDownloadRecord = async () => {
const res = await api.isVideoDownloadRecord({ video_uuid: video_uuid.value });
if (res.code == 200) {
isVideoDownloadRecord.value = res.result == 0 ? false : true;
if(isVideoDownloadRecord.value) {
downloadTasks.value.forEach(item => {
if (item.id == video_uuid.value) {
uni.getSavedFileInfo({
filePath: item.localPath, //
success: function (res) {
hasDownload.value = true;
downLoadStatus.value = 'completed';
},
fail: function (err) {
// hasDownload.value = false;
// downLoadStatus.value = 'failed';
}
});
}
});
}
}
};
@ -496,17 +506,48 @@ const resumeDownloadingTasks = () => {
onShow(() => {
hasDownload.value = false;
downLoadStatus.value = 'start';
console.log('onShow');
syncTasksFromStore();
// store
downloadStore.addListener((tasks) => {
downloadTasks.value = tasks;
});
//
resumeDownloadingTasks();
console.log('tasks');
console.log(downloadTasks.value);
if(downloadTasks.value.length > 0) {
for(let i = 0; i < downloadTasks.value.length; i++) {
if(downloadTasks.value[i].id == video_uuid.value) {
console.log('runing');
console.log(downloadTasks.value[i].status);
hasDownload.value = true;
if(downloadTasks.value[i].status == 'completed') {
downLoadStatus.value = 'completed';
}else if(downloadTasks.value[i].status == 'downloading') {
uni.showToast({
title: '视频缓存中',
icon: 'none',
});
hasDownload.value = true;
downLoadStatus.value = 'loading';
}else if(downloadTasks.value[i].status == 'paused') {
hasDownload.value = true;
downLoadStatus.value = 'loading';
}else if(downloadTasks.value[i].status == 'failed') {
hasDownload.value = true;
downLoadStatus.value = 'loading';
}
}
}
};
if (activeTab.value == "comment") {
videoCommentListV2();
}
videoDetail();
if(from.value != 'download') {
videoDetail();
}
uni.hideLoading();
});
@ -694,9 +735,12 @@ onLoad((options) => {
});
video_uuid.value = options.id;
from.value = options.from;
addVideoWatchRecord();
VideoDownloadRecord();
getWelfareNum();
if(from.value != 'download') {
addVideoWatchRecord();
VideoDownloadRecord();
getWelfareNum();
}
// store
syncTasksFromStore();
// store
@ -706,6 +750,18 @@ onLoad((options) => {
});
//
resumeDownloadingTasks();
if(from.value == 'download') {
downloadTasks.value.forEach(item => {
if(item.id == video_uuid.value) {
console.log(222222);
console.log(item.localPath);
videoSrc.value = item.localPath;
showVideo.value = true;
}
});
}
// navTo({
// url: "/pages_app/downLoadVideo/downLoadVideo",
// });
@ -736,6 +792,7 @@ const payVideoDownload = async () => {
author: videoInfo.value.public_name,
name: videoInfo.value.name,
});
} else if (res.code == 106) {
notEnoughVisible.value = true;
notEnoughContent.value = `您的积分不足,是否购买积分?`;
@ -885,6 +942,7 @@ $theme-color: #8b2316;
}
.video-detail-page {
border-top: 2rpx solid #cccccc;
background: $bg-color;
overflow: hidden;
}
@ -914,7 +972,7 @@ $theme-color: #8b2316;
top: calc(var(--status-bar-height) + 44px + 220px);
padding: 24rpx 0 0;
border-bottom: 2rpx solid #cccccc;
width: 100%;
z-index: 99;
@ -926,7 +984,7 @@ $theme-color: #8b2316;
align-items: center;
padding: 16rpx 0 24rpx;
color: $text-secondary;
font-size: 28rpx;
font-size: 28rpx!important;
.tab-line {
position: absolute;
bottom: 0;
@ -939,7 +997,11 @@ $theme-color: #8b2316;
background: $theme-color;
}
&:nth-child(2) {
display: flex;
margin-left: 200rpx;
justify-content: center;
align-items: center;
text-align: center;
}
&.active {
color: $theme-color;
@ -963,7 +1025,7 @@ $theme-color: #8b2316;
width: 100%;
background: #fff;
// padding: 24rpx 28rpx 40rpx;
top: calc(var(--status-bar-height) + 44px + 220px + 88rpx);
top: calc(var(--status-bar-height) + 44px + 220px + 99rpx);
height: calc(100vh - var(--status-bar-height) - 44px - 220px - 90rpx);
overflow-y: scroll;
// background: red;

View File

@ -1,5 +1,5 @@
<template>
<uni-nav-bar
<!-- <uni-nav-bar
left-icon="left"
title="诊疗指南"
@clickLeft="goBack"
@ -8,14 +8,15 @@
height="180rpx"
:border="false"
backgroundColor="#eeeeee"
></uni-nav-bar>
></uni-nav-bar> -->
<navBar title="诊疗指南"/>
<view class="zhinan-page" v-if="tab=='zhinan'">
<!-- 导航栏 -->
<!-- 固定搜索栏 -->
<view class="search-container-fixed filter-bar">
<view class="search-box">
<view class="search-box" @click="goSearch">
<uni-icons type="search" size="16" color="#999"></uni-icons>
<text class="search-text">搜索</text>
</view>
@ -263,7 +264,8 @@
import delImg from "@/static/delete_paper.png"
import api from '@/api/api.js'
import docUrl from "@/utils/docUrl.js"
import navTo from '@/utils/navTo.js';
import navTo from '@/utils/navTo.js';
import navBar from "@/components/navBar/navBar.vue"
const total=ref(0);
const tab=ref('zhinan')
//
@ -285,7 +287,13 @@
const showFilterPopup = () => {
showFilter.value = true;
};
const goSearch=()=>{
uni.sendNativeEvent('goHomeSearch', {
msg: 'goHomeSearch'
},ret => {
console.log(ret);
})
}
const hideFilterPopup = () => {
showFilter.value = false;
};
@ -556,7 +564,7 @@ $accent-color: #4A90E2;
//
.search-container-fixed {
position: fixed;
top: 180rpx; //
top: calc(var(--status-bar-height) + 44px); //
left: 0;
right: 0;
z-index: 90;
@ -613,7 +621,7 @@ $accent-color: #4A90E2;
padding: 30rpx;
gap: 20rpx;
margin:0 30rpx;
margin-top: 100rpx; // (80rpx + )
margin-top: calc(var(--status-bar-height) + 44px + 106rpx); // (80rpx + )
.guideline-item {

View File

@ -1,22 +1,25 @@
<template>
<view class="zhinan-list-page">
<!-- 头部导航栏 -->
<uni-nav-bar
<view class="navbox">
<view class="status_bar"></view>
<uni-nav-bar
left-icon="left"
:title="title"
@clickLeft="goBack"
fixed
color="#8B2316"
height="180rpx"
:border="false"
backgroundColor="#eeeeee"
>
<template v-slot:right>
<view class="nav-right" @click="goGot">
<view class="nav-right" @click="goGot" >
<up-image :src="hotImg" width="40rpx" height="40rpx"></up-image>
</view>
</template>
</uni-nav-bar>
</view>
<!-- 固定搜索栏 -->
<view class="search-container-fixed filter-bar">
<view class="search-box" @click="goToSearch">
@ -48,7 +51,7 @@
class="guideline-item"
v-for="(item, index) in guidelinesList"
:key="item.uuid || index"
@click="viewGuideline(item)"
>
<!-- 指南信息 -->
<view class="item-content">
@ -57,8 +60,9 @@
<view class="item-date">{{ formatDate(item.releaseTime) }}</view>
<!-- 操作按钮 -->
<view class="item-action">
<view class="download-btn" @click.stop="viewGuideline(item)" v-if="!downLoadList.includes(item.uuid)">
<up-icon name="download" color="#8D2316" size="28"></up-icon>
<view class="download-btn" @click.stop="downLoad(item)" v-if="!downLoadtaskList.includes(item.uuid)">
<uni-icons type="arrow-down" size="26" color="#8D2316"></uni-icons>
<!-- <up-icon name="download" color="#8D2316" size="56rpx" ></up-icon> -->
</view>
<view
v-else
@ -139,7 +143,7 @@
</template>
<script setup>
import { ref, onMounted } from "vue";
import { ref, onMounted,computed,nextTick} from "vue";
import api from "@/api/api.js";
import { onShow, onLoad } from "@dcloudio/uni-app";
import docUrl from "@/utils/docUrl.js";
@ -163,6 +167,13 @@ const title = ref("");
const sort = ref(2);
const showInnerSort = ref(false);
const innerSortTitle = ref("上传时间");
import downloadStore from "@/store/downloadStoreFile.js";
const downloadTasks=ref([]);
const downLoadtaskList=computed(()=>{
console.log('downLoadtaskList');
console.log(downloadTasks.value.map((item)=>item.id));
return downloadTasks.value.map((item)=>item.id);
});
const chooseInnerSort = (index) => {
sort.value = index;
if (index == 1) {
@ -197,6 +208,15 @@ const toggleInnerSort = () => {
showInnerSort.value = !showInnerSort.value;
};
onShow(() => {
console.log('onShow');
syncTasksFromStore();
// store
downloadStore.addListener((tasks) => {
downloadTasks.value = tasks;
});
//
resumeDownloadingTasks();
//
if (guidelinesList.value.length === 0) {
loadGuidelinesList(true);
@ -213,6 +233,13 @@ const goToSearch = () => {
uni.navigateTo({
url: `/pages_app/search/search?keywords=${q}&title=${t}${type}`,
});
// const goSearch=()=>{
// uni.sendNativeEvent('goHomeSearch', {
// msg: 'goHomeSearch'
// },ret => {
// console.log(ret);
// })
// }
};
// scroll-view
@ -392,51 +419,185 @@ const downloadGuideline = (item) => {
fail: (err) => {
console.error("下载失败:", err);
uni.showToast({
title: "下载失败",
title: "下载失败1",
icon: "none",
});
},
});
}
};
// pdf/doc/docx/xls/xlsx/ppt/pptx/txt
const viewGuideline = (item) => {
if (!item.path) {
const downLoad = (item) => {
if(!item.path){
uni.showToast({
title: "暂无下载链接",
icon: "none",
});
return;
}
const pdfUrl = docUrl + item.path;
let url = "https://view.xdocin.com/view?src=" + encodeURIComponent(pdfUrl);
uni.downloadFile({
url: pdfUrl,
success: (res) => {
if (res.statusCode === 200) {
let index = downLoadList.value.find((cell) => item.uuid == cell.id);
if (!index) {
downLoadList.value.push(item.uuid);
uni.setStorageSync("downLoadPdf", downLoadList.value);
}
navTo({
url:
"/pages_app/webview/webview?url=" +
encodeURIComponent(url) +
"&title=" +
item.title,
});
}
},
addDownloadTask({
url: docUrl + item.path,
title: item.title,
id: item.uuid,
});
};
// pdf/doc/docx/xls/xlsx/ppt/pptx/txt
const viewGuideline = (cell) => {
console.log(cell);
if (!cell.path) {
uni.showToast({
title: "暂无下载链接",
icon: "none",
});
return;
}
const pdfUrl = docUrl + cell.path;
console.log(downloadTasks.value);
downloadTasks.value.forEach(item => {
if(item.id == cell.uuid) {
uni.openDocument({
filePath: item.localPath,
success: () => console.log('打开成功'),
fail: (err) => console.error('打开失败', err)
});
}
});
// let url = "https://view.xdocin.com/view?src=" + encodeURIComponent(pdfUrl);
// uni.downloadFile({
// url: pdfUrl,
// success: (res) => {
// if (res.statusCode === 200) {
// uni.openDocument({
// filePath: res.tempFilePath, //
// fileType: 'pdf',
// success: () => console.log(''),
// fail: (err) => console.error('', err)
// });
// }
// },
// });
};
//
const goBack = () => {
uni.navigateBack();
};
//
const addDownloadTask = (item) => {
// 使store
const taskIndex = downloadStore.addTask(item);
//
syncTasksFromStore();
//
startDownload(taskIndex);
};
//
const startDownload = (index) => {
const taskItem = downloadStore.getTask(index);
if (!taskItem) return;
if(taskItem.status == "loading"){
uni.showToast({
title: "正在下载",
icon: "none",
});
return false;
};
downloadStore.updateTask(index, {
status: "loading"
});
const task = uni.downloadFile({
url: taskItem.url,
success: (res1) => {
console.log("res1:"+JSON.stringify(res1));
if (res1.statusCode === 200) {
downloadStore.updateTask(index, {
status: "completed",
filePath: res1.tempFilePath,
});
uni.showToast({
title: "下载成功",
icon: "none",
});
uni.saveFile({
tempFilePath: res1.tempFilePath,
success: function (res2) {
console.log("res2:"+JSON.stringify(res2));
uni.getSavedFileInfo({
filePath: res2.savedFilePath,
success: function (res) {
console.log("res:"+JSON.stringify(res));
console.log("size:"+res.size);
downloadStore.updateTask(index, {
status: "completed",
localPath: res2.savedFilePath,
});
},
});
},
});
} else {
downloadStore.updateTask(index, {
status: "failed",
});
removeTask(index);
uni.showToast({
title: "下载失败2",
icon: "none",
});
}
},
fail: (err) => {
downloadStore.updateTask(index, {
status: "failed",
});
removeTask(index);
uni.showToast({
title: "下载失败3: " + (err.errMsg || "未知错误"),
icon: "none",
duration: 2000,
});
},
});
//
task.onProgressUpdate((update) => {
const currentTask = downloadStore.getTask(index);
if (currentTask && currentTask.status === "downloading") {
downloadStore.updateTask(index, {
progress: update.progress
});
}
});
// taskstore/
downloadStore.updateTask(index, {
task: task,
});
};
const syncTasksFromStore = () => {
downloadTasks.value = downloadStore.getTasks();
};
const removeTask = (index) => {
downloadStore.removeTask(index);
syncTasksFromStore();
};
//
const resumeDownloadingTasks = () => {
// 使 nextTick
nextTick(() => {
downloadStore.resumeDownloadingTasks((index) => {
// uni.downloadFile0
console.log("恢复下载任务:", downloadStore.getTask(index)?.url);
startDownload(index);
});
});
};
//
const testLoadMore = () => {
console.log("=== 手动测试加载更多 ===");
@ -490,7 +651,7 @@ $white: #ffffff;
}
.popup-panel {
position: fixed;
top: 256rpx; /* 紧贴筛选栏 */
top:285rpx;
left: 0;
right: 0;
background: #fff;
@ -544,18 +705,18 @@ $white: #ffffff;
.guidelines-scroll-view {
position: fixed;
top: 285rpx;
top: calc(var(--status-bar-height) + 44px + 106rpx);
left: 0;
right: 0;
bottom: 0;
z-index: 99;
height: calc(100vh - 180rpx);
height: calc(100vh - var(--status-bar-height) - 44px - 106rpx);
background-color: $bg-color;
}
//
.search-container-fixed {
position: fixed;
top: 180rpx; //
top: calc(var(--status-bar-height) + 44px); //
left: 0;
right: 0;
z-index: 90;
@ -658,12 +819,12 @@ $white: #ffffff;
justify-content: center;
border-radius: 50%;
background-color: rgba(255, 71, 87, 0.1);
transition: all 0.3s ease;
// transition: all 0.3s ease;
&:active {
transform: scale(0.95);
background-color: rgba(255, 71, 87, 0.2);
}
// &:active {
// transform: scale(0.95);
// background-color: rgba(255, 71, 87, 0.2);
// }
}
.view-btn {

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

BIN
static/search.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
static/videoPlaceholder.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

135
store/downloadStoreFile.js Normal file
View File

@ -0,0 +1,135 @@
// 下载任务全局状态管理
class DownloadStoreFile {
constructor() {
let tasks = uni.getStorageSync('downloadFileTasks');
this.tasks = tasks || [] ; // 下载任务列表
this.listeners = []; // 监听器列表
}
// 添加任务
addTask(data) {
const taskIndex = this.tasks.length;
const taskItem = {
id: Date.now() + Math.random(), // 唯一ID
url: '',
status: 'downloading', // downloading, paused, completed, failed
progress: 0,
task: null,
filePath: '',
createTime: Date.now(),
localPath:''
};
Object.assign(taskItem, data);
this.tasks.push(taskItem);
this.notifyListeners();
this.saveToStorage();
return taskIndex;
}
// 更新任务
updateTask(index, updates) {
if (this.tasks[index]) {
Object.assign(this.tasks[index], updates);
this.notifyListeners();
this.saveToStorage();
}
}
// 删除任务
removeTask(index) {
const taskItem = this.tasks[index];
if (taskItem && taskItem.task && taskItem.status === 'downloading') {
taskItem.task.abort();
}
this.tasks.splice(index, 1);
this.notifyListeners();
this.saveToStorage();
}
// 获取所有任务
getTasks() {
return this.tasks;
}
// 获取任务
getTask(index) {
return this.tasks[index];
}
// 添加监听器
addListener(callback) {
this.listeners.push(callback);
// 返回取消监听的函数
return () => {
const index = this.listeners.indexOf(callback);
if (index > -1) {
this.listeners.splice(index, 1);
}
};
}
// 通知所有监听器
notifyListeners() {
// 创建新数组引用确保Vue能检测到变化
const tasksCopy = [...this.tasks];
this.listeners.forEach(callback => {
try {
callback(tasksCopy);
} catch (e) {
console.error('DownloadStoreFile listener error:', e);
}
});
}
// 保存到本地存储
saveToStorage() {
// 只保存基本信息不保存task对象
const tasksToSave = this.tasks.map(item => ({
id: item.id,
url: item.url,
status: item.status,
progress: item.progress,
filePath: item.filePath,
createTime: item.createTime,
localPath:item.localPath,
}));
uni.setStorageSync('downloadFileTasks', tasksToSave);
}
// 从本地存储加载
loadFromStorage() {
const savedTasks = uni.getStorageSync('downloadFileTasks');
if (savedTasks && Array.isArray(savedTasks)) {
this.tasks = savedTasks.map(item => ({
...item,
task: null // task对象无法序列化需要重新创建
}));
this.notifyListeners();
}
}
// 恢复下载中的任务
resumeDownloadingTasks(startDownloadCallback) {
this.tasks.forEach((taskItem, index) => {
// 如果任务状态是下载中但task对象为null说明需要重新创建下载任务
if (taskItem.status === 'downloading' && !taskItem.task) {
if (typeof startDownloadCallback === 'function') {
startDownloadCallback(index);
}
}
});
}
}
// 创建单例
const downloadStoreFile = new DownloadStoreFile();
// 在应用启动时加载存储的任务
// #ifndef VUE3
if (typeof Vue !== 'undefined') {
Vue.prototype.$downloadStoreFile = downloadStoreFile;
}
// #endif
export default downloadStoreFile;

View File

@ -64,6 +64,10 @@