@@ -68,14 +68,14 @@
排列顺序:
-
+
显示:
-
+
diff --git a/src/store/index.js b/src/store/index.js
index 8fd91e7..63ece02 100644
--- a/src/store/index.js
+++ b/src/store/index.js
@@ -8,100 +8,110 @@ const GalleryManageUrl = BaseUrl + "GalleryManage/"
const VideoManageUrl = BaseUrl + "VideoManage/"
const actions = {
- updateGalleryTasks(context){
- const AuthCode = context.state.AuthCode
+ updateGalleryTasks(context, type){
axios.get(GalleryManageUrl, {
params:{
- param:"",
- type:"all",
- AuthCode
+ type,
+ AuthCode: state.AuthCode
}
}).then((res) => {
- context.commit("_emptyGalleryTasks")
- context.commit("_updateGalleryTasks", JSON.parse(res.data.data))
+ if(res.data.result === "success")
+ context.commit("_updateGalleryTasks", {tasks:JSON.parse(res.data.data), type})
+
+ else if(type === 'undone') {
+ context.dispatch("updateGalleryTasks", "all").then()
+ clearInterval(state.refreshTimer)
+ state.refreshTimer = 0
+ }
})
},
- updateVideoTasks(context){
- const AuthCode = context.state.AuthCode
+ updateVideoTasks(context, type){
axios.get(VideoManageUrl, {
params:{
- param:"123",
- type:"all",
- AuthCode
+ type,
+ AuthCode: state.AuthCode
}
}).then(res => {
- context.commit("_emptyVideoTasks")
- context.commit("_updateVideoTasks", JSON.parse(res.data.data))
+ if(res.data.result === "success")
+ context.commit("_updateVideoTasks", {tasks:JSON.parse(res.data.data), type})
+
+ else if(type === 'undone') {
+ clearInterval(state.refreshTimer)
+ state.refreshTimer = 0
+ context.dispatch("updateVideoTasks", "all").then()
+ }
})
},
postGalleryTask(context, data){
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("_setChosenGallery", {gallery:false, resolution:data.targetResolution})
- }
- else{
- if(res.data.data)
- ElMessage(res.data.data)
- else{
- ElMessage("提交失败")
- }
- }
- })
- },
- postVideoTask(context, data){
- axios.post(VideoManageUrl, qs.stringify({
- AuthCode:context.state.AuthCode,
+ AuthCode: state.AuthCode,
link: data.link,
targetResolution: data.targetResolution
})).then((res) => {
if(res.data.result === "success") {
ElMessage("提交成功")
- context.commit("_setChosenVideo", {video:false, resolution:data.targetResolution})
+ context.commit("_setChosenGallery", {gallery: false, resolution: data.targetResolution})
+ if(state.refreshTimer === 0)
+ state.refreshTimer = setInterval(() => {
+ context.dispatch("updateGalleryTasks", "undone").then()
+ }, 20000)
}
else{
if(res.data.data)
ElMessage(res.data.data)
- else{
+ else
+ ElMessage("提交失败")
+ }
+ })
+ },
+ postVideoTask(context, data){
+ axios.post(VideoManageUrl, qs.stringify({
+ AuthCode: state.AuthCode,
+ link: data.link,
+ targetResolution: data.targetResolution
+ })).then((res) => {
+ if(res.data.result === "success") {
+ ElMessage("提交成功")
+ context.commit("_setChosenVideo", {video: false, resolution: data.targetResolution})
+ if(state.refreshTimer === 0)
+ state.refreshTimer = setInterval(() => {
+ context.dispatch("updateVideoTasks", "undone").then()
+ }, 20000)
+ }
+ else{
+ if(res.data.data)
+ ElMessage(res.data.data)
+ else
ElMessage("提交失败")
- }
}
})
},
queryGalleryTask(context, link){
- const AuthCode = context.state.AuthCode
axios.get(GalleryManageUrl, {
params:{
- param:link,
+ param: link,
type:'link',
- AuthCode
+ AuthCode: state.AuthCode
}
}).then((res) => {
- if(res.data.result === 'success'){
- const gallery = JSON.parse(res.data.data)
- context.commit("_setChosenGallery", {gallery})
- }
+ if(res.data.result === 'success')
+ context.commit("_setChosenGallery", {gallery: JSON.parse(res.data.data)})
+
else
ElMessage("查询失败")
})
},
queryVideoTask(context, link){
- const AuthCode = context.state.AuthCode
axios.get(VideoManageUrl, {
params:{
param: link,
- type:"link",
- AuthCode
+ type: "link",
+ AuthCode: state.AuthCode
}
}).then((res) => {
- if(res.data.result === 'success'){
- const video = JSON.parse(res.data.data)
- context.commit("_setChosenVideo", {video})
- }
+ if(res.data.result === 'success')
+ context.commit("_setChosenVideo", {video: JSON.parse(res.data.data)})
+
else
ElMessage("查询失败")
})
@@ -109,45 +119,33 @@ const actions = {
validate(context, AuthCode){
axios.post(BaseUrl + "validate?AuthCode=" + AuthCode).then((res)=>{
if(res.data.result === 'success'){
- context.commit("_authed", AuthCode, context)
- context.dispatch("updateGalleryTasks").then()
- context.dispatch("updateVideoTasks").then()
+ context.commit("_authed", AuthCode)
context.dispatch("loadMaskDomain").then()
context.dispatch("loadWeekUsedAmount").then()
- setInterval(() => {
- context.dispatch("update").then()
- }, 30000)
+ context.dispatch("updateGalleryTasks", "all").then()
+ context.dispatch("updateVideoTasks", "all").then()
}
- else{
+ else
context.commit("_unAuthed")
- }
})
},
- update(context){
- if(context.state.showType === "video")
- context.dispatch("updateVideoTasks").then()
- else
- context.dispatch("updateGalleryTasks").then()
- },
loadMaskDomain(context){
axios.get(BaseUrl + "maskDomain").then((res) => {
- if(res.data.result === "success"){
+ if(res.data.result === "success")
context.commit("_setMaskDomain", JSON.parse(res.data.data))
- }
})
},
loadWeekUsedAmount(context){
axios.get(GalleryManageUrl + "weekUsedAmount", {
params: {
- AuthCode: context.state.AuthCode
+ AuthCode: state.AuthCode
}
}).then((res) => {
if(res.data.result === "success"){
context.state.weekUsed = JSON.parse(res.data.data)
ElMessage("查询用量成功")
- }else{
+ }else
ElMessage("查询用量失败")
- }
})
},
searchByLink(context, link){
@@ -198,9 +196,8 @@ const actions = {
ElMessage("删除成功")
context.commit("_deleteGallery", gid)
}
- else{
+ else
ElMessage(res.data.data)
- }
})
},
deleteVideo(context, id){
@@ -214,91 +211,159 @@ const actions = {
ElMessage("删除成功")
context.commit("_deleteVideo", id)
}
- else{
+ else
ElMessage(res.data.data)
- }
})
+ },
+ alterAuthCode(context, AuthCode){
+ axios.put(BaseUrl + "AuthCode?" + qs.stringify({'AuthCode': state.AuthCode, 'newAuthCode': AuthCode}))
+ .then((res) => {
+ if(res.data.result === 'success') {
+ ElMessage("修改成功")
+ if(localStorage.getItem("auth") === state.AuthCode)
+ localStorage.setItem("auth", AuthCode)
+ state.AuthCode = AuthCode
+ }
+ else
+ ElMessage(res.data.data)
+ })
}
}
const mutations = {
- _emptyGalleryTasks(state){
- state.totalGalleryTask.splice(0)
- },
- _emptyVideoTasks(state){
- state.totalVideoTask.splice(0)
- },
- _updateGalleryTasks(state, tasks){
- tasks.forEach((task) => {
- if(task.name.includes("[")) {
- let name = task.name
- let lastIndex = name.lastIndexOf("[")
- name = name.substring(0, lastIndex)
- while (name.includes("[") && name.includes("]")) {
- let start = name.indexOf("[")
- let end = name.indexOf("]") + 1
- let temp = name.substring(start, end)
- name = name.replace(temp, "")
+ _updateGalleryTasks(state, data){
+ let {tasks, type} = data
+ if(type === 'all') {
+ state.totalGalleryTask.splice(0)
+ tasks.forEach((task) => {
+ if (task.name.includes("[")) {
+ let name = task.name
+ let lastIndex = name.lastIndexOf("[")
+ name = name.substring(0, lastIndex)
+ while (name.includes("[") && name.includes("]")) {
+ let start = name.indexOf("[")
+ let end = name.indexOf("]") + 1
+ let temp = name.substring(start, end)
+ name = name.replace(temp, "")
+ }
+ while (name.includes("(") && name.includes(")")) {
+ let start = name.indexOf("(")
+ let end = name.indexOf(")") + 1
+ let temp = name.substring(start, end)
+ name = name.replace(temp, "")
+ }
+ task.shortName = name.trim()
+ } else {
+ task.shortName = task.name
}
- while (name.includes("(") && name.includes(")")) {
- let start = name.indexOf("(")
- let end = name.indexOf(")") + 1
- let temp = name.substring(start, end)
- name = name.replace(temp, "")
+
+ switch (task.status) {
+ case "已提交":
+ task.progress = "已提交"
+ break;
+ case "下载中":
+ task.progress = (Math.round((task.proceeding / task.pages) * 100)).toString() + "%"
+ break;
+ case "下载完成":
+ task.progress = "下载完成"
+ let tempLink
+ let url = new URL(task.link)
+ state.maskDomain.forEach((mask) => {
+ if (url.host === mask['raw'])
+ tempLink = task.link.replace(mask['raw'], mask['mask'])
+ })
+ task.download = GalleryManageUrl + "file/" + encodeURI(task.name) + "?link=" + tempLink + "&AuthCode=" + state.AuthCode
+ break;
}
- task.shortName = name.trim()
- }
- else{
- task.shortName = task.name
- }
- if(task.status === "已提交"){
- task.progress = "已提交"
- }
- else if(task.status === "下载中"){
- task.progress = (Math.round((task.proceeding / task.pages)*100)).toString() + "%"
- }
- else if(task.status === "下载完成"){
- task.progress = "下载完成"
- let tempLink
- let url = new URL(task.link)
+ task.createTimeDisplay = moment(task.createTime * 1000).format("YYYY-MM-DD HH:mm:ss")
+ state.totalGalleryTask.push(task)
+ })
+ }
+ else {
+ let tempArray = Array.from(state.totalGalleryTask)
+ state.totalGalleryTask.splice(0)
+ let preDeleteIndex
+ tempArray.forEach((task) => {
+ preDeleteIndex = -1
+ if(task.status !== "下载完成")
+ tasks.forEach((newTask, index) => {
+ if(newTask.name === task.name){
+ preDeleteIndex = index
+ task.status = newTask.status
+ task.proceeding = newTask.proceeding
+ if(task.proceeding === 0)
+ task.progress = task.status
+ else
+ task.progress = (Math.round((task.proceeding / task.pages) * 100)).toString() + "%"
+ }
+ })
- state.maskDomain.forEach((mask) => {
- if(url.host === mask['raw'])
- tempLink = task.link.replace(mask['raw'], mask['mask'])
+ if(preDeleteIndex !== -1)
+ delete tasks[preDeleteIndex]
+ state.totalGalleryTask.push(task)
+ })
+ }
+
+ switch (state.sortType) {
+ case "name":
+ state.totalGalleryTask = state.totalGalleryTask.sort((before, after) => {
+ return before.name > after.name ? 1: -1
})
- 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
- })
+ break
+ case "shortName":
+ state.totalGalleryTask = state.totalGalleryTask.sort((before, after) => {
+ return before.shortName > after.shortName ? 1: -1
+ })
+ break
+ case "createTime":
+ state.totalGalleryTask = state.totalGalleryTask.sort((before, after) => {
+ return before.createTime - after.createTime
+ })
+ }
if(state.isAuth && !state.loadComplete){
state.loadComplete = true
ElMessage("加载完成")
}
},
- _updateVideoTasks(state, tasks){
- tasks.forEach((task) => {
- task.progress = task.status
- if(task.status === "下载完成"){
- let tempLink
- let url = new URL(task.link)
+ _updateVideoTasks(state, data){
+ let {tasks, type} = data
+ if(type === 'all') {
+ state.totalVideoTask.splice(0)
+ tasks.forEach((task) => {
+ task.progress = task.status
+ if (task.status === "下载完成") {
+ let tempLink
+ let url = new URL(task.link)
- state.maskDomain.forEach((mask) => {
- if(url.host === mask['raw'])
- tempLink = task.link.replace(mask['raw'], mask['mask'])
- })
- 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.maskDomain.forEach((mask) => {
+ if (url.host === mask['raw'])
+ tempLink = task.link.replace(mask['raw'], mask['mask'])
+ })
+ 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)
+ })
+ }
+ else{
+ let tempArray = Array.from(state.totalVideoTask)
+ state.totalVideoTask.splice(0)
+ let preDeleteIndex
+ tempArray.forEach((task) => {
+ preDeleteIndex = -1
+ if(task.status !== "下载完成")
+ tasks.forEach((newTask, index) => {
+ if(newTask.name === task.name){
+ task.progress = task.status
+ preDeleteIndex = index
+ }
+ })
+ if(preDeleteIndex !== -1)
+ delete tasks[preDeleteIndex]
+ state.totalVideoTask.push(task)
+ })
+ }
state.totalVideoTask = state.totalVideoTask.sort((before, after) => {
if(state.sortType === 'name')
return before.name > after.name ? 1: -1
@@ -379,6 +444,7 @@ const mutations = {
},
_setChosenGallery(state,data){
if(data.gallery === false) {
+ //state.chosenGallery.shortName = getShortName(state.chosenGallery.name)
state.chosenGallery.resolution = data.resolution
state.chosenGallery.fileSize = "等待下载完成后再查看"
state.chosenGallery.createTimeDisplay = "等待下载完成后再查看"
@@ -404,7 +470,7 @@ const mutations = {
_setSortType(state, sortType){
state.sortType = sortType
switch (sortType) {
- case "fullName":
+ case "name":
state.totalGalleryTask = state.totalGalleryTask.sort((before, after) => {
return before.name > after.name ? 1: -1
})
@@ -456,13 +522,14 @@ const state = {
chosenVideo:false, //准备下载的视频
page:1, //当前页数
- length:4, //每页能有多少个链接
+ length:5, //每页能有多少个链接
defaultLength:4, //默认个数
- shortLength:6, //简洁个数
+ shortLength:5, //简洁个数
isAuth:false, //是否授权
AuthCode:'', //授权码
loadComplete:false, //是否加载完成
+ refreshTimer:0, //更新计时器id
isInclude:false, //是否搜索到任务
searchTask:[], //搜索到的任务