From bbb55c0d82433d40fa344a2b7c14e3a0fdd1b622 Mon Sep 17 00:00:00 2001 From: chuzhongzai Date: Mon, 6 Feb 2023 17:23:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=9C=A8=E7=BA=BF=E7=9C=8B?= =?UTF-8?q?=E6=9C=AC=E5=AD=90=EF=BC=8C=E5=8E=BB=E9=99=A4=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E5=9C=A8=E7=BA=BF=E7=9C=8B=E3=80=82=E4=BC=98=E5=8C=96=E6=9C=AC?= =?UTF-8?q?=E5=AD=90=E5=90=8D=E7=A7=B0=E7=BC=A9=E7=9F=AD=E4=BD=BF=E5=85=B6?= =?UTF-8?q?=E8=87=B3=E5=B0=91=E4=B8=8D=E4=B8=BA=E7=A9=BA=E7=99=BD=E3=80=82?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=83=A8=E5=88=86=E4=BB=A3=E7=A0=81=E3=80=82?= =?UTF-8?q?(=E5=90=8C=E6=AD=A5=E6=9B=B4=E6=96=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Side.vue | 43 +++++++++++++++------ src/store/index.js | 85 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 111 insertions(+), 17 deletions(-) diff --git a/src/components/Side.vue b/src/components/Side.vue index 9eaeff5..bcfe09f 100644 --- a/src/components/Side.vue +++ b/src/components/Side.vue @@ -34,7 +34,7 @@ 下载 删除 - 在线看 + 在线看 @@ -69,7 +69,6 @@ 下载 删除 - 在线看 @@ -83,7 +82,7 @@ - 筛选: + 筛选: @@ -130,6 +129,13 @@ + + + + + + 请输入授权码后再查看 @@ -144,15 +150,15 @@ let inputNode = ref(null) let isEditingPage = ref(false) //是否正在编辑标签 let isEditingTag = ref(false) + //临时变量 let tempTag = ref("") let tempGid = ref("") - -let showNameType = ref("shortName") // shortName name -let showType = ref("gallery") // gallery video collect -let sortType = ref("shortName") // shortName name createTime -let targetPage = ref(1) +let showNameType = ref("shortName") // shortName name +let showType = ref("gallery") // gallery video collect +let sortType = ref("shortName") // shortName name createTime +let targetPage = ref(1) // 当前页数 //防抖计时器 let debounceTimer = 0 @@ -174,6 +180,9 @@ let isShowVideoHistory = computed(() => { let isShowGalleryHistory = computed(() => { return store.state.showType === "gallery" || store.state.showType === "collect" }) +let isOnlineReading = computed(() => { + return store.state.isOnlineReading +}) let min = computed(() => { return store.getters.min @@ -188,6 +197,16 @@ let page = computed(() => { return store.state.page }) +let currentLinks = computed(() => { + return store.state.currentLinks +}) +let imageWidth = computed(() => { + return store.state.imageWidth +}) +let imagePadding = computed(() => { + return store.state.imagePadding +}) + //翻页 function next() { if(targetPage.value < max.value) { @@ -274,11 +293,11 @@ function deleteGallery(gid){ function deleteVideo(id){ store.dispatch("deleteVideo", id) } -function onlineGalleryReader(name){ - window.open("http://zfile.lionwebsite.xyz/1/gallery/" + encodeURI(name)) +function onlineGalleryReader(gid){ + store.dispatch("queryOnlineLinks", gid) } -function onlineVideoViewer(){ - window.open("http://zfile.lionwebsite.xyz/1/video/") +function closeOnlineReader(){ + store.state.isOnlineReading = false } //显示缩略图 diff --git a/src/store/index.js b/src/store/index.js index 5d26259..7c4da21 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -116,6 +116,26 @@ const actions = { ElMessage("查询失败") }) }, + queryOnlineLinks(context, gid){ + // 如果本地有缓存,则直接返回,没有再请求 + if(context.state.onlineLinks[gid] !== undefined){ + context.commit("_setOnlineLinks", gid) + } + else { + axios.get(GalleryManageUrl + "/onlineLinks", { + params: { + AuthCode: state.AuthCode, + gid, + } + }).then((res) => { + if (res.data.result === "success") + context.commit("_addAndSetOnlineLinks", {gid, links: res.data.data}) + + else + ElMessage(res.data.data) + }) + } + }, updateGallery(context, link){ axios.post(GalleryManageUrl + "/update", qs.stringify({AuthCode: state.AuthCode, link})) .then((res) => { @@ -135,10 +155,25 @@ const actions = { if(res.data.result === 'success'){ state.userId = parseInt(res.data.data) context.commit("_authed", AuthCode) + //初始化 context.dispatch("loadMaskDomain").then() context.dispatch("loadWeekUsedAmount").then() context.dispatch("updateGalleryTasks", "all").then() context.dispatch("updateVideoTasks", "all").then() + + //获取图片合适长度 + let screenWidth = window.screen.width * 0.9 - 40 + let width + let i + for(i=3; i>0; i--) + if(screenWidth / i <= 350 || screenWidth / i >= 100){ + width = screenWidth / i + break + } + + width = width - (width % 10) + state.imageWidth = width + 'px' + state.imagePadding = ((screenWidth - i * width) / i) + 'px' } else context.commit("_unAuthed") @@ -558,6 +593,27 @@ const mutations = { _setMaskDomain(state, maskDomain){ state.maskDomain = maskDomain }, + _addAndSetOnlineLinks(state, data){ + let links = JSON.parse(data.links) + state.onlineLinks[data.gid] = [] + state.currentLinks.splice(0) + state.currentGid = data.gid + + links.forEach((link) => { + state.onlineLinks[data.gid].push('http://downloader.lionwebsite.xyz/GalleryManage/onlineImage/' + link + '?gid=' + state.currentGid + '&AuthCode=' + state.AuthCode) + state.currentLinks.push('http://downloader.lionwebsite.xyz/GalleryManage/onlineImage/' + link + '?gid=' + state.currentGid + '&AuthCode=' + state.AuthCode) + }) + + state.isOnlineReading = true + }, + _setOnlineLinks(state, gid){ + state.currentLinks.splice(0) + state.onlineLinks[gid].forEach((link) => { + state.currentLinks.push(link) + }) + state.currentGid = gid + state.isOnlineReading = true + }, _changeThumbnailGallery(state, gallery){ state.thumbnailGallery = gallery state.thumbnailGallery.url = GalleryManageUrl + "/thumbnail/" + encodeURIComponent(gallery.name) + ".webp?AuthCode="+state.AuthCode @@ -565,11 +621,18 @@ const mutations = { } const state = { - totalGalleryTask:[], //存放本子数据的数组 - chosenGallery:false, //准备下载的本子 - thumbnailGallery:{}, + totalGalleryTask:[], //存放本子数据的数组 + chosenGallery:false, //准备下载的本子 + thumbnailGallery:{}, //缩略图链接 collectGallery:[], //收藏的本子 + onlineLinks:{}, //在线本子链接 + isOnlineReading: false, //是否在线看 + currentGid: "", //当前GID + currentLinks: [], //当前本子链接 + imageWidth: "", //图片宽度 + imagePadding: "", //图片padding + totalVideoTask:[], //存放视频数据的数组 chosenVideo:false, //准备下载的视频 @@ -653,13 +716,25 @@ function getShortname(name){ let start = name.indexOf("[") let end = name.indexOf("]") + 1 let temp = name.substring(start, end) - name = name.replace(temp, "") + temp = name.replace(temp, "") + if(temp.trim() === ""){ + name = name.replace("[", "").replace("]", "") + break + } + else + name = 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, "") + temp = name.replace(temp, "") + if(temp.trim() === ""){ + name = name.replace("(", "").replace(")", "") + break + } + else + name = temp } return name.trim() } else {