From 74256e6c3b11a341c1b30e2fad222b2cafa9b5d4 Mon Sep 17 00:00:00 2001 From: chuzhongzai Date: Fri, 24 Feb 2023 17:24:47 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E5=8A=A0=E5=85=A5=E6=94=B6?= =?UTF-8?q?=E8=97=8F=E4=BB=A5=E5=8F=8A=E6=A0=87=E7=AD=BE=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E3=80=82=E5=8E=BB=E9=99=A4moment.js=EF=BC=8C=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=8E=9F=E7=94=9F=E6=A0=BC=E5=BC=8F=E5=8C=96=E3=80=82=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E4=BB=BB=E5=8A=A1=E7=9A=84=E5=88=86=E7=B1=BB=EF=BC=88?= =?UTF-8?q?=E6=94=B6=E8=97=8F=EF=BC=8C=E4=B8=8B=E8=BD=BD=EF=BC=8C=E5=85=A8?= =?UTF-8?q?=E9=83=A8=EF=BC=89=E3=80=82=EF=BC=88=E5=90=8C=E6=AD=A5=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=EF=BC=89=E4=BF=AE=E6=94=B9=E7=BC=A9=E6=94=BE=E5=8F=82?= =?UTF-8?q?=E6=95=B0=EF=BC=8C=E4=BD=BFsafari=E4=B8=8D=E4=BC=9A=E8=8E=AB?= =?UTF-8?q?=E5=90=8D=E5=85=B6=E5=A6=99=E6=94=BE=E5=A4=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- src/components/Side.vue | 38 +++++++++++--- src/store/index.js | 110 +++++++++++++++++++++++++++++++++++++--- 3 files changed, 134 insertions(+), 16 deletions(-) diff --git a/index.html b/index.html index 795e4fb..daf3a5b 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ - + Vite + Vue diff --git a/src/components/Side.vue b/src/components/Side.vue index b244ad0..dcfa113 100644 --- a/src/components/Side.vue +++ b/src/components/Side.vue @@ -21,10 +21,10 @@ 下载 删除 分享 - {{props.row.isCollect ? '取消收藏' : '收藏'}} + {{props.row.isCollect ? '取消收藏' : '收藏'}} 在线看 预览封面
- 编辑标签 + 编辑标签 更新本子 @@ -54,9 +54,15 @@ 视频长度:{{props.row.duration}}
分辨率:{{props.row.resolution}}
任务创建时间:{{props.row.createTimeDisplay}}
+ 标签:{{props.row.tag === '' ? '无': props.row.tag}}
+ + downloader:{{props.row.downloader}} + 下载 删除 在线播放 + 编辑标签 + {{props.row.isCollect ? '取消收藏' : '收藏'}} @@ -126,7 +132,7 @@ - 提交修改 + 提交修改 @@ -164,6 +170,7 @@ let player = ref() //临时变量 let tempTag = ref("") let tempGid = ref("") +let tempId = ref("") let showNameType = ref("shortName") // shortName fullName @@ -210,7 +217,7 @@ let page = computed(() => { let isLion = computed(() => { return store.state.userId === 3 }) - +//在线预览链接 let currentLinks = computed(() => { return store.state.currentLinks }) @@ -270,23 +277,40 @@ function changeSortType(){ } //收藏,编辑标签,提交编辑 -function changeCollect(gid, isCollect){ +function changeGalleryCollect(gid, isCollect){ if(isCollect) store.dispatch("disCollectGallery", gid) else store.dispatch("collectGallery", gid) } -function editTag(gid, tag){ +function changeVideoCollect(id, isCollect){ + if(isCollect) + store.dispatch("disCollectVideo", id) + else + store.dispatch("collectVideo", id) +} +function editGalleryTag(gid, tag){ tempTag.value = tag tempGid.value = gid isEditingTag.value = true } -function submitTag(){ +function editVideoTag(id, tag){ + tempTag.value = tag + tempId.value = id + isEditingTag.value = true +} +function submitGalleryTag(){ store.dispatch("updateTag", {gid:tempGid.value, tag:tempTag.value}) tempTag.value = '' tempGid.value = '' isEditingTag.value = false } +function submitVideoTag(){ + store.dispatch("updateVideoTag", {id:tempId.value, tag:tempTag.value}) + tempTag.value = '' + tempId.value = '' + isEditingTag.value = false +} //下载,删除,在线看 function downloadTask(link){ diff --git a/src/store/index.js b/src/store/index.js index 80bf306..7cf02de 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -2,7 +2,6 @@ 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 GalleryManageUrl = BaseUrl + "GalleryManage" const VideoManageUrl = BaseUrl + "VideoManage" @@ -153,8 +152,7 @@ const actions = { validate(context, AuthCode){ axios.post(BaseUrl + "validate?AuthCode=" + AuthCode).then((res)=>{ if(res.data.result === 'success'){ - state.userId = parseInt(res.data.data) - context.commit("_authed", {AuthCode, userId: parseInt(res.data.data)}) + context.commit("_authed", {AuthCode, ...JSON.parse(res.data.data)}) //初始化 context.dispatch("loadMaskDomain").then() context.dispatch("loadWeekUsedAmount").then() @@ -196,6 +194,16 @@ const actions = { context.commit("_collectGallery", gid) }) }, + collectVideo(context, id){ + axios.post(VideoManageUrl + "/collect?" + qs.stringify({ + id, + userId: state.userId + })).then((res) => { + ElMessage(res.data.data) + if(res.data.result === 'success') + context.commit("_collectVideo", id) + }) + }, disCollectGallery(context, gid){ axios.post(GalleryManageUrl + "/disCollect?" + qs.stringify( { @@ -207,11 +215,28 @@ const actions = { context.commit("_disCollectGallery", gid) }) }, - updateTag(context, data){ + disCollectVideo(context, id){ + axios.post(VideoManageUrl + "/disCollect?" + qs.stringify({ + id, + userId: state.userId + })).then((res) => { + ElMessage(res.data.data) + if(res.data.result === "success") + context.commit("_disCollectVideo", id) + }) + }, + updateGalleryTag(context, data){ axios.post(GalleryManageUrl + "/tag?" + qs.stringify(data)).then((res) => { ElMessage(res.data.data) if(res.data.result === 'success') - context.commit("_updateTag", data) + context.commit("_updateGalleryTag", data) + }) + }, + updateVideoTag(context, data){ + axios.post(VideoManageUrl + "/tag?" + qs.stringify(data)).then((res) => { + ElMessage(res.data.data) + if(res.data.result === 'success') + context.commit("_updateVideoTag", data) }) }, deleteGallery(context, gid){ @@ -267,6 +292,14 @@ const mutations = { } }) }, + _collectVideo(state, id){ + state.totalVideoTask.forEach((video) => { + if(!video.isCollect && video.id === id){ + video.isCollect = true + state.collectVideo.push(video) + } + }) + }, _disCollectGallery(state, gid){ state.collectGallery.splice(0) state.totalGalleryTask.forEach((gallery) => { @@ -277,17 +310,37 @@ const mutations = { state.collectGallery.push(gallery) }) }, - _updateTag(state, data){ + _disCollectVideo(state, id){ + state.collectVideo.splice(0) + state.totalVideoTask.forEach((video) => { + if(video.isCollect && video.id === id) + video.isCollect = false + + else if(video.isCollect) + state.collectVideo.push(video) + + }) + }, + _updateGalleryTag(state, data){ state.totalGalleryTask.forEach((gallery) => { if(gallery.gid === data.gid){ gallery.tag = data.tag } }) }, + _updateVideoTag(state, data){ + state.totalVideoTask.forEach((video) => { + if(video.id === data.id){ + video.tag = data.tag + } + }) + }, _updateGalleryTasks(state, data){ let {tasks, type} = data if(type === 'all') { state.totalGalleryTask.splice(0) + state.collectGallery.slice(0) + state.downloadGallery.splice(0) tasks.forEach((task) => { //处理名字 task.shortName = getShortname(task.name) @@ -313,7 +366,7 @@ const mutations = { } //处理时间戳 - task.createTimeDisplay = moment(task.createTime * 1000).format("YYYY-MM-DD HH:mm:ss") + task.createTimeDisplay = new Date(task.createTime * 1000).toLocaleString("zh") //处理标签 if (task.tag === undefined) { @@ -335,6 +388,10 @@ const mutations = { task.isCollect = false } + //处理是否下载 + if(task.downloader === state.username) + state.downloadGallery.push(task) + state.totalGalleryTask.push(task) }) } @@ -388,8 +445,12 @@ const mutations = { let {tasks, type} = data if(type === 'all') { state.totalVideoTask.splice(0) + state.collectVideo.splice(0) + state.downloadVideo.splice(0) + tasks.forEach((task) => { task.progress = task.status + //视频下载很快,所以不太注重下载进度 if (task.status === "下载完成") { let tempLink let url = new URL(task.link) @@ -399,8 +460,35 @@ const mutations = { 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") } + + //处理时间戳 + task.createTimeDisplay = new Date(task.createTime * 1000).toLocaleString("zh") + + //处理标签 + if(task.tag === undefined) + task.tag = "" + + //处理是否收藏 + if(task.collector !== undefined){ + let collector = task.collector.split(",") + delete task.collector + for(let i=0; i