新增按照任务创建时间/名称排序, 默认只加载40个任务,剩下的需要手动查询,移除本地搜索的定时器,新增新特性提示(同步更新)

This commit is contained in:
chuzhongzai
2022-10-20 10:07:39 +08:00
parent 3d57901ea5
commit 67278c0faf
3 changed files with 194 additions and 132 deletions
+102 -36
View File
@@ -2,14 +2,15 @@ import vuex from "vuex"
import axios from "axios"
import {ElMessage} from "element-plus"
import qs from "qs"
import moment from 'moment'
const BaseUrl = "http://downloader.lionwebsite.xyz/"
const GalleryTaskHandlerUrl = BaseUrl + "GalleryManage/"
const VideoTaskHandlerUrl = BaseUrl + "VideoManage/"
const GalleryManageUrl = BaseUrl + "GalleryManage/"
const VideoManageUrl = BaseUrl + "VideoManage/"
const actions = {
updateGalleryTasks(context){
const AuthCode = context.state.AuthCode
axios.get(GalleryTaskHandlerUrl, {
axios.get(GalleryManageUrl, {
params:{
param:"",
type:"all",
@@ -27,7 +28,7 @@ const actions = {
},
updateVideoTasks(context){
const AuthCode = context.state.AuthCode
axios.get(VideoTaskHandlerUrl, {
axios.get(VideoManageUrl, {
params:{
param:"123",
type:"all",
@@ -43,14 +44,14 @@ const actions = {
})
},
postGalleryTask(context, data){
axios.post(GalleryTaskHandlerUrl, qs.stringify({
axios.post(GalleryManageUrl, qs.stringify({
AuthCode:context.state.AuthCode,
link:data.link,
targetResolution:data.targetResolution
})).then((res) => {
if(res.data.result === "success") {
ElMessage("提交成功")
context.commit("_setPreDownloadGallery", {gallery:false, resolution:data.targetResolution})
context.commit("_setChosenGallery", {gallery:false, resolution:data.targetResolution})
}
else{
if(res.data.data)
@@ -62,14 +63,14 @@ const actions = {
})
},
postVideoTask(context, data){
axios.post(VideoTaskHandlerUrl, qs.stringify({
axios.post(VideoManageUrl, qs.stringify({
AuthCode:context.state.AuthCode,
link: data.link,
targetResolution: data.targetResolution
})).then((res) => {
if(res.data.result === "success") {
ElMessage("提交成功")
context.commit("_setPreDownloadVideo", {video:false, resolution:data.targetResolution})
context.commit("_setChosenVideo", {video:false, resolution:data.targetResolution})
}
else{
if(res.data.data)
@@ -82,7 +83,7 @@ const actions = {
},
queryGalleryTask(context, link){
const AuthCode = context.state.AuthCode
axios.get(GalleryTaskHandlerUrl, {
axios.get(GalleryManageUrl, {
params:{
param:link,
type:'link',
@@ -91,7 +92,7 @@ const actions = {
}).then((res) => {
if(res.data.result === 'success'){
const gallery = JSON.parse(res.data.data)
context.commit("_setPreDownloadGallery", {gallery})
context.commit("_setChosenGallery", {gallery})
}
else
ElMessage("查询失败")
@@ -99,7 +100,7 @@ const actions = {
},
queryVideoTask(context, link){
const AuthCode = context.state.AuthCode
axios.get(VideoTaskHandlerUrl, {
axios.get(VideoManageUrl, {
params:{
param: link,
type:"link",
@@ -108,7 +109,7 @@ const actions = {
}).then((res) => {
if(res.data.result === 'success'){
const video = JSON.parse(res.data.data)
context.commit("_setPreDownloadVideo", {video})
context.commit("_setChosenVideo", {video})
}
else
ElMessage("查询失败")
@@ -145,13 +146,14 @@ const actions = {
})
},
loadWeekUsedAmount(context){
axios.get(GalleryTaskHandlerUrl + "weekUsedAmount", {
axios.get(GalleryManageUrl + "weekUsedAmount", {
params: {
AuthCode: context.state.AuthCode
}
}).then((res) => {
if(res.data.result === "success"){
context.state.weekUsed = JSON.parse(res.data.data)
ElMessage("查询用量成功")
}else{
ElMessage("查询用量失败")
}
@@ -160,11 +162,43 @@ const actions = {
searchByLink(context, link){
context.commit("_searchByLink", link)
},
searchByKeyword(context, keyword){
context.commit("_searchByKeyword", keyword)
searchLocalByKeyword(context, keyword){
context.commit("_searchLocalByKeyword", keyword)
},
searchRemoteByKeyword(context, keyword){
if(context.state.showType === "gallery"){
axios.get(GalleryManageUrl, {
params:{
type:"name",
param:keyword
}
}).then((res) => {
if(res.data.result === 'success'){
context.commit("_setChosenGallery", {'gallery':JSON.parse(res.data.data)})
}
else{
ElMessage(res.data.data)
}
})
}
else{
axios.get(VideoManageUrl, {
params:{
type:"name",
param:keyword
}
}).then((res) => {
if(res.data.result === 'success'){
context.commit("_setChosenVideo", {'video': JSON.parse(res.data.data)})
}
else{
ElMessage(res.data.data)
}
})
}
},
deleteGallery(context, gid){
axios.delete(GalleryTaskHandlerUrl, {
axios.delete(GalleryManageUrl, {
params:{
AuthCode:state.AuthCode,
gid
@@ -179,7 +213,7 @@ const actions = {
})
},
deleteVideo(context, id){
axios.delete(VideoTaskHandlerUrl, {
axios.delete(VideoManageUrl, {
params:{
AuthCode:state.AuthCode,
id
@@ -220,10 +254,17 @@ const mutations = {
if(url.host === mask['raw'])
tempLink = task.link.replace(mask['raw'], mask['mask'])
})
task.download = GalleryTaskHandlerUrl + "file/" + encodeURI(task.name) + "?link=" + tempLink + "&AuthCode=" + state.AuthCode
task.download = GalleryManageUrl + "file/" + encodeURI(task.name) + "?link=" + tempLink + "&AuthCode=" + state.AuthCode
}
task.createTimeDisplay = moment(task.createTime * 1000).format("YYYY-MM-DD HH:mm:ss")
state.totalGalleryTask.push(task)
})
state.totalGalleryTask = state.totalGalleryTask.sort((before, after) => {
if(state.sortType === 'name')
return before.name > after.name ? 1: -1
else
return before.createTime - after.createTime
})
if(state.isAuth && !state.loadComplete){
state.loadComplete = true
ElMessage("加载完成")
@@ -240,10 +281,17 @@ const mutations = {
if(url.host === mask['raw'])
tempLink = task.link.replace(mask['raw'], mask['mask'])
})
task.download = VideoTaskHandlerUrl + "file/" + encodeURI(task.name) + "?link=" + tempLink + "&AuthCode=" + state.AuthCode
task.download = VideoManageUrl + "file/" + encodeURI(task.name) + "?link=" + tempLink + "&AuthCode=" + state.AuthCode
}
task.createTimeDisplay = moment(task.createTime * 1000).format("YYYY-MM-DD HH:mm:ss")
state.totalVideoTask.push(task)
})
state.totalVideoTask = state.totalVideoTask.sort((before, after) => {
if(state.sortType === 'name')
return before.name > after.name ? 1: -1
else
return before.createTime - after.createTime
})
},
_changePage(state, targetPage){
state.page = targetPage
@@ -282,7 +330,7 @@ const mutations = {
ElMessage("已跳转到该任务所在页数")
}
},
_searchByKeyword(state, keyword){
_searchLocalByKeyword(state, keyword){
state.searchTask.splice(0)
state.page = 1
let tasks
@@ -311,28 +359,45 @@ const mutations = {
arr.splice(index, 1)
})
},
_setPreDownloadGallery(state,data){
_setChosenGallery(state,data){
if(data.gallery === false) {
state.preDownloadGallery.resolution = data.resolution
state.preDownloadGallery.fileSize = "等待下载完成后再查看"
state.preDownloadGallery.progress = "已提交"
state.totalGalleryTask.push(state.preDownloadGallery)
state.chosenGallery.resolution = data.resolution
state.chosenGallery.fileSize = "等待下载完成后再查看"
state.chosenGallery.createTimeDisplay = "等待下载完成后再查看"
state.chosenGallery.progress = "已提交"
state.totalGalleryTask.push(state.chosenGallery)
}
state.preDownloadGallery = data.gallery
state.chosenGallery = data.gallery
},
_setPreDownloadVideo(state,data){
_setChosenVideo(state,data){
if(data.video === false) {
state.preDownloadVideo.resolution = data.resolution
state.preDownloadVideo.fileSize = "下载完成后再查看"
state.preDownloadVideo.duration = "下载完成后再查看"
state.preDownloadVideo.progress = "已提交"
state.totalVideoTask.push(state.preDownloadVideo)
state.chosenVideo.resolution = data.resolution
state.chosenVideo.fileSize = "下载完成后再查看"
state.chosenVideo.duration = "下载完成后再查看"
state.chosenVideo.createTimeDisplay = "下载完成后再查看"
state.chosenVideo.progress = "已提交"
state.totalVideoTask.push(state.chosenVideo)
}
state.preDownloadVideo = data.video
state.chosenVideo = data.video
},
_setShowType(state, showType){
state.showType = showType
},
_setSortType(state, sortType){
state.sortType = sortType
state.totalGalleryTask = state.totalGalleryTask.sort((before, after) => {
if(sortType === 'name')
return before.name > after.name ? 1: -1
else
return before.createTime - after.createTime
})
state.totalVideoTask = state.totalVideoTask.sort((before, after) => {
if(sortType === 'name')
return before.name > after.name ? 1: -1
else
return before.createTime - after.createTime
})
},
_setMaskDomain(state, maskDomain){
state.maskDomain = maskDomain
},
@@ -346,13 +411,13 @@ const mutations = {
const state = {
totalGalleryTask:[], //存放本子数据的数组
preDownloadGallery:false, //准备下载的本子
chosenGallery:false, //准备下载的本子
totalVideoTask:[], //存放视频数据的数组
preDownloadVideo:false, //准备下载的视频
chosenVideo:false, //准备下载的视频
page:1, //当前页数
length:8, //每页能有多少个链接
length:5, //每页能有多少个链接
isAuth:false, //是否授权
AuthCode:'', //授权码
@@ -362,6 +427,7 @@ const state = {
searchTask:[], //搜索到的任务
isShowHistory:false, //是否打开面板
showType:"gallery", //展示类型
sortType:"name", //排序类型
weekUsed:{},
maskDomain:[]