链接全转https协议,去除获取在线预览链接,改为本地生成,修复部分bug,优化预览图(同步更新)

This commit is contained in:
chuzhongzai
2023-07-31 22:23:37 +08:00
parent 7126345398
commit 8e606598dd
5 changed files with 49 additions and 91 deletions
+8 -60
View File
@@ -74,26 +74,6 @@ 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) => {
@@ -117,17 +97,6 @@ const actions = {
context.dispatch("loadWeekUsedAmount").then()
context.dispatch("updateGalleryTasks", "all").then(() => confirmCurrentTask(context.state))
//获取图片合适长度
// 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 = 27 + 'vw'
state.imagePadding = 1 + 'vw'
@@ -315,9 +284,12 @@ const mutations = {
break;
case "下载完成":
task.progress = "下载完成"
let tempLink
tempLink = task.link.replace("element-plus.org", "exhentai.org").replace("element.org", "e-hentai.org")
task.download = GalleryManageUrl + "/file/" + encodeURI(task.name.replace("#", "")) + "?link=" + tempLink + "&AuthCode=" + state.AuthCode
task.download = GalleryManageUrl + "/file/" + encodeURI(task.name) + ".zip?AuthCode=" + state.AuthCode
let links = []
for(let i=1; i<=task.pages; i++)
links.push(GalleryManageUrl + "/onlineImage/" + i + "?gid=" + task.gid);
task.images = links
break;
}
@@ -358,7 +330,7 @@ const mutations = {
preDeleteIndex = -1
if(task.status !== "下载完成")
for(let i=0; i < tasks.length; i++)
if(tasks[i].name === task.name) {
if (tasks[i] !== undefined && tasks[i].name === task.name) {
preDeleteIndex = i
task.status = tasks[i].status
task.proceeding = tasks[i].proceeding
@@ -574,30 +546,9 @@ const mutations = {
else
state.length = state.defaultLength
},
_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('https://downloader.lionwebsite.xyz/GalleryManage/onlineImage/' + link + '?gid=' + state.currentGid + '&AuthCode=' + state.AuthCode)
state.currentLinks.push('https://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
state.thumbnailGallery.url = GalleryManageUrl + "/onlineImage/1?gid="+gallery.gid
}
}
@@ -610,10 +561,7 @@ const state = {
tags: new Map(), //可用tag
isSearch: false, //用于决定是否显示搜索结果
onlineLinks: {}, //在线本子链接
isOnlineReading: false, //是否在线看
currentGid: "", //当前GID
currentLinks: [], //当前本子链接
imageWidth: "", //图片宽度
imagePadding: "", //图片padding
lengthPerPage: 0, //在线预览每页图片数量