去除标签;修改在线看,允许未下载的本子在线看(同步更新)
This commit is contained in:
+38
-214
@@ -42,8 +42,7 @@ const actions = {
|
||||
if(res.data.result === "success") {
|
||||
ElMessage("提交成功")
|
||||
context.commit("_setChosenGallery", {gallery: false,
|
||||
resolution:data.targetResolution,
|
||||
tags: data.tags})
|
||||
resolution:data.targetResolution})
|
||||
if(state.galleryRefreshTimer === 0)
|
||||
state.galleryRefreshTimer = setInterval(() => {
|
||||
context.dispatch("updateGalleryTasks", "undone").then()
|
||||
@@ -61,13 +60,12 @@ const actions = {
|
||||
axios.get(GalleryManageUrl, {
|
||||
params:{
|
||||
param: link,
|
||||
type:'link',
|
||||
type: 'link',
|
||||
AuthCode: state.AuthCode
|
||||
}
|
||||
}).then((res) => {
|
||||
if(res.data.result === 'success')
|
||||
context.commit("_setChosenGallery", {gallery: JSON.parse(res.data.data)})
|
||||
|
||||
else
|
||||
ElMessage("查询失败")
|
||||
})
|
||||
@@ -76,12 +74,10 @@ const actions = {
|
||||
axios.post(BaseUrl + "validate?AuthCode=" + AuthCode).then((res)=>{
|
||||
if(res.data.result === 'success'){
|
||||
let data = JSON.parse(res.data.data);
|
||||
if(!data.isAvailable){
|
||||
if(!data.isAvailable)
|
||||
ElMessage({duration:0, message:"节点挂了,不能下也不能看,找狮子处理", type: "error"})
|
||||
}
|
||||
context.commit("_authed", {AuthCode, ...data})
|
||||
//初始化
|
||||
context.dispatch("loadTags", true).then()
|
||||
context.dispatch("loadWeekUsedAmount").then()
|
||||
context.dispatch("updateGalleryTasks", "all").then(() => confirmCurrentTask(context.state))
|
||||
|
||||
@@ -106,85 +102,9 @@ const actions = {
|
||||
ElMessage("查询用量失败")
|
||||
})
|
||||
},
|
||||
loadTags(context, isShowTip){
|
||||
axios.get(GalleryManageUrl + "/allTag", {
|
||||
params: {
|
||||
AuthCode: state.AuthCode
|
||||
}
|
||||
}).then((res) => {
|
||||
if(res.data.result === "success"){
|
||||
context.commit("_loadTags", JSON.parse(res.data.data))
|
||||
if(isShowTip)
|
||||
ElMessage("加载标签成功")
|
||||
}else
|
||||
ElMessage(res.data.data)
|
||||
})
|
||||
},
|
||||
postTag(context, tag){
|
||||
axios.post(GalleryManageUrl + "/tag?" + qs.stringify({
|
||||
tag,
|
||||
AuthCode: state.AuthCode
|
||||
})
|
||||
).then((res) => {
|
||||
if (res.data.result === 'success') {
|
||||
ElMessage('创建标签成功')
|
||||
context.commit("_postTag", {tag:tag, id:parseInt(res.data.tid), usage: 0})
|
||||
}
|
||||
else
|
||||
ElMessage(res.data.data)
|
||||
})
|
||||
},
|
||||
deleteTag(context, tid){
|
||||
axios.delete(GalleryManageUrl + "/tag?" + qs.stringify({
|
||||
tid,
|
||||
AuthCode: state.AuthCode
|
||||
})).then((res) => {
|
||||
if (res.data.result === 'success') {
|
||||
ElMessage('删除标签成功')
|
||||
context.commit("_deleteTag", tid)
|
||||
}
|
||||
else
|
||||
ElMessage(res.data.data)
|
||||
})
|
||||
},
|
||||
mark(context, data){
|
||||
data.AuthCode = context.state.AuthCode
|
||||
axios.post(GalleryManageUrl + "/mark?" + qs.stringify(data)).then((res) => {
|
||||
if(res.data.result === 'success'){
|
||||
ElMessage("标记成功")
|
||||
context.commit("_mark", data)
|
||||
}else{
|
||||
ElMessage(res.data.data)
|
||||
}
|
||||
})
|
||||
},
|
||||
disMark(context, data){
|
||||
data.AuthCode = context.state.AuthCode
|
||||
axios.post(GalleryManageUrl + "/disMark?" + qs.stringify(data)).then((res) => {
|
||||
if(res.data.result === 'success'){
|
||||
ElMessage("取消标记成功")
|
||||
context.commit("_disMark", data)
|
||||
}else {
|
||||
ElMessage(res.data.data)
|
||||
}
|
||||
})
|
||||
},
|
||||
createTagAndMark(context, data){
|
||||
data.AuthCode = context.state.AuthCode
|
||||
axios.post(GalleryManageUrl + '/tagAndMark?' + qs.stringify(data)).then((res) => {
|
||||
if(res.data.result === 'success') {
|
||||
ElMessage("创建标签并标记成功")
|
||||
context.commit("_mark", {tid:parseInt(res.data.tid), gid: data.gid, usage: 1, tag:data.tag})
|
||||
|
||||
}else {
|
||||
ElMessage(res.data.data)
|
||||
}
|
||||
})
|
||||
},
|
||||
collectGallery(context, gid){
|
||||
axios.post(GalleryManageUrl + "/collect?" +qs.stringify( {
|
||||
gid,
|
||||
AuthCode:state.AuthCode
|
||||
gid, AuthCode:state.AuthCode
|
||||
})).then((res) => {
|
||||
ElMessage(res.data.data)
|
||||
if(res.data.result === 'success')
|
||||
@@ -193,8 +113,7 @@ const actions = {
|
||||
},
|
||||
disCollectGallery(context, gid){
|
||||
axios.post(GalleryManageUrl + "/disCollect?" + qs.stringify({
|
||||
gid,
|
||||
AuthCode:state.AuthCode
|
||||
gid, AuthCode:state.AuthCode
|
||||
})).then((res) => {
|
||||
ElMessage(res.data.data)
|
||||
if(res.data.result === 'success')
|
||||
@@ -204,8 +123,7 @@ const actions = {
|
||||
deleteGallery(context, gid){
|
||||
axios.delete(GalleryManageUrl, {
|
||||
params:{
|
||||
AuthCode:state.AuthCode,
|
||||
gid
|
||||
AuthCode:state.AuthCode, gid
|
||||
}}).then((res) => {
|
||||
if(res.data.result === "success"){
|
||||
ElMessage("删除成功")
|
||||
@@ -215,6 +133,17 @@ const actions = {
|
||||
ElMessage(res.data.data)
|
||||
})
|
||||
},
|
||||
readOnlineGallery(context, gallery){
|
||||
if(gallery.images !== undefined && gallery.images.length !== 0)
|
||||
context.commit("_setReadingGallery", gallery)
|
||||
else
|
||||
axios.post(GalleryManageUrl + "/cache?url=" + gallery.link).then((res) => {
|
||||
gallery.pages = res.data.data.pages
|
||||
setTimeout(() => {
|
||||
context.commit("_setReadingGallery", gallery)
|
||||
}, 100)
|
||||
})
|
||||
},
|
||||
alterAuthCode(context, AuthCode){
|
||||
axios.put(BaseUrl + "AuthCode?" + qs.stringify({'AuthCode': state.AuthCode, 'newAuthCode': AuthCode}))
|
||||
.then((res) => {
|
||||
@@ -247,12 +176,11 @@ const mutations = {
|
||||
},
|
||||
_disCollectGallery(state, gid){
|
||||
let index
|
||||
for(let i=0; i < state.collectGallery.length; i++){
|
||||
for(let i=0; i < state.collectGallery.length; i++)
|
||||
if(state.collectGallery[i].gid === gid){
|
||||
index = i
|
||||
break
|
||||
}
|
||||
}
|
||||
state.collectGallery[index].isCollect = false
|
||||
state.collectGallery.splice(index, 1)
|
||||
},
|
||||
@@ -266,6 +194,7 @@ const mutations = {
|
||||
tasks.forEach((task) => {
|
||||
//处理名字
|
||||
task.shortName = getShortname(task.name)
|
||||
task.thumb_link = GalleryManageUrl + "/ehThumbnail?path=" + task.thumb_link
|
||||
|
||||
//处理进度相关
|
||||
switch (task.status) {
|
||||
@@ -277,15 +206,7 @@ const mutations = {
|
||||
break;
|
||||
case "下载完成":
|
||||
task.progress = "下载完成"
|
||||
if(task.mode === 1 || task.mode === 3)
|
||||
task.download = GalleryManageUrl + "/file/" + encodeURI(task.name) + ".zip?AuthCode=" + state.AuthCode + "&gid=" + task.gid
|
||||
|
||||
if(task.mode === 2 || task.mode === 3) {
|
||||
let links = []
|
||||
for (let i = 1; i <= task.pages; i++)
|
||||
links.push(GalleryManageUrl + "/onlineImage/" + i + "?gid=" + task.gid);
|
||||
task.images = links
|
||||
}
|
||||
task.download = GalleryManageUrl + "/file/" + encodeURI(task.name) + ".zip?AuthCode=" + state.AuthCode + "&gid=" + task.gid
|
||||
break;
|
||||
case "压缩中":
|
||||
task.progress = "压缩中"
|
||||
@@ -295,19 +216,6 @@ const mutations = {
|
||||
//处理时间戳
|
||||
task.createTimeDisplay = new Date(task.createTime * 1000).toLocaleString("zh")
|
||||
|
||||
//处理标签
|
||||
if ('tags' in task) {
|
||||
task.tag = ''
|
||||
task.tags.forEach((tid) => {
|
||||
task.tag += ' ' + state.tags.get(tid).tag
|
||||
})
|
||||
task.tag = task.tag.trim()
|
||||
|
||||
}else{
|
||||
task.tag = ""
|
||||
task.tags = []
|
||||
}
|
||||
|
||||
//处理是否收藏
|
||||
if('isCollect' in task)
|
||||
state.collectGallery.push(task)
|
||||
@@ -320,8 +228,7 @@ const mutations = {
|
||||
|
||||
state.totalGalleryTask.push(task)
|
||||
})
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
let tempArray = Array.from(state.totalGalleryTask)
|
||||
state.totalGalleryTask.splice(0)
|
||||
let preDeleteIndex
|
||||
@@ -384,44 +291,6 @@ const mutations = {
|
||||
ElMessage("授权码错误")
|
||||
localStorage.removeItem("auth")
|
||||
},
|
||||
_loadTags(state, tags){
|
||||
state.tags.clear()
|
||||
for(let i in tags)
|
||||
state.tags.set(parseInt(i), tags[i])
|
||||
},
|
||||
_postTag(state, tag){
|
||||
state.tags.set(tag.id, tag)
|
||||
},
|
||||
_deleteTag(state, tid){
|
||||
state.tags.delete(tid)
|
||||
},
|
||||
_mark(state, data){
|
||||
state.totalGalleryTask.forEach((gallery) => {
|
||||
if(gallery.gid === data.gid){
|
||||
gallery.tags.push(data.tid)
|
||||
if('tag' in data) //新建的tag
|
||||
state.tags.set(data.tid, {id:data.tid, tag: data.tag, usage:data.usage})
|
||||
else
|
||||
state.tags.get(data.tid).usage++
|
||||
generateNewTag(state, gallery)
|
||||
}
|
||||
})
|
||||
},
|
||||
_disMark(state, data){
|
||||
state.totalGalleryTask.forEach((gallery) => {
|
||||
if(gallery.gid === data.gid){
|
||||
let index
|
||||
for(index=0; index<gallery.tags.length; index++){
|
||||
if(gallery.tags[index] === data.tid){
|
||||
gallery.tags.splice(index, 1) //删除tid
|
||||
state.tags.get(data.tid).usage--
|
||||
break;
|
||||
}
|
||||
}
|
||||
generateNewTag(state, gallery)
|
||||
}
|
||||
})
|
||||
},
|
||||
_searchLocalByLink(state, link){
|
||||
let tasks = state.currentTasks
|
||||
let i = 0
|
||||
@@ -471,41 +340,6 @@ const mutations = {
|
||||
confirmCurrentTask(state)
|
||||
}
|
||||
},
|
||||
_searchLocalByTag(state, tidS) {
|
||||
state.searchTask.splice(0)
|
||||
state.page = 1
|
||||
|
||||
let hitAmount
|
||||
let tasks = state.currentTasks
|
||||
|
||||
if (tidS.length > 0) {
|
||||
tasks.forEach((task) => {
|
||||
if(tidS.length <= task.tags.length) {
|
||||
|
||||
hitAmount = 0
|
||||
for(let i=0; i<task.tag.length; i++){
|
||||
for(let j=0; j<tidS.length; j++){
|
||||
if(task.tags[i] === tidS[j])
|
||||
hitAmount ++
|
||||
}
|
||||
}
|
||||
if (hitAmount === tidS.length)
|
||||
state.searchTask.push(task)
|
||||
}
|
||||
})
|
||||
|
||||
if (state.searchTask.length === 0) {
|
||||
ElMessage("未找到符合这些tag的任务")
|
||||
state.isSearch = false
|
||||
}
|
||||
else {
|
||||
state.isSearch = true
|
||||
}
|
||||
}else {
|
||||
state.isSearch = false
|
||||
confirmCurrentTask(state)
|
||||
}
|
||||
},
|
||||
_deleteGallery(state, gid){
|
||||
let tasks = [state.totalGalleryTask, state.downloadGallery, state.collectGallery]
|
||||
deleteTask(tasks, 'gid', gid)
|
||||
@@ -517,14 +351,7 @@ const mutations = {
|
||||
state.chosenGallery.fileSize = "等待下载完成后再查看"
|
||||
state.chosenGallery.createTimeDisplay = "等待下载完成后再查看"
|
||||
state.chosenGallery.progress = "已提交"
|
||||
state.chosenGallery.tags = []
|
||||
state.chosenGallery.downloader = state.userId
|
||||
if(data.tags.length > 0){
|
||||
for (let tag of data.tags) {
|
||||
state.chosenGallery.tags.push(parseInt(tag))
|
||||
}
|
||||
}
|
||||
generateNewTag(state, state.chosenGallery)
|
||||
state.totalGalleryTask.push(state.chosenGallery)
|
||||
state.downloadGallery.push(state.chosenGallery)
|
||||
}
|
||||
@@ -545,27 +372,34 @@ const mutations = {
|
||||
else
|
||||
state.length = state.defaultLength
|
||||
},
|
||||
_changeThumbnailGallery(state, gallery){
|
||||
if(gallery.mode === 2 || gallery.mode === 3) {
|
||||
state.thumbnailGallery = gallery
|
||||
state.thumbnailGallery.url = GalleryManageUrl + "/onlineImage/1?gid=" + gallery.gid
|
||||
} else if(gallery.thumb_link !== undefined){
|
||||
state.thumbnailGallery = gallery
|
||||
state.thumbnailGallery.url = GalleryManageUrl + "/ehThumbnail?path=" + gallery.thumb_link
|
||||
state.thumbnailGallery.images = [GalleryManageUrl + "/ehThumbnail?path=" + gallery.thumb_link,]
|
||||
_setReadingGallery(state, gallery){
|
||||
if(gallery.images === undefined) {
|
||||
gallery.images = []
|
||||
for(let i=1; i<=gallery.pages; i++)
|
||||
gallery.images.push(GalleryManageUrl + "/onlineImage/" + i + "?gid=" + gallery.gid);
|
||||
}
|
||||
state.readingGallery = gallery
|
||||
state.isReading = true;
|
||||
},
|
||||
_closeReader(state){
|
||||
state.isReading = false;
|
||||
},
|
||||
_changeThumbnailGallery(state, gallery){
|
||||
state.thumbnailGallery = gallery
|
||||
}
|
||||
}
|
||||
|
||||
const state = {
|
||||
totalGalleryTask: [], //存放本子数据的数组
|
||||
chosenGallery: false, //准备下载的本子
|
||||
thumbnailGallery: {}, //缩略图链接
|
||||
thumbnailGallery: {}, //缩略图本子
|
||||
collectGallery: [], //收藏的本子
|
||||
downloadGallery: [], //下载的本子
|
||||
tags: new Map(), //可用tag
|
||||
isSearch: false, //用于决定是否显示搜索结果
|
||||
|
||||
readingGallery: {'name': '', 'images': []}, //在线看本子
|
||||
isReading: false, //是否正在看
|
||||
|
||||
currentGid: "", //当前GID
|
||||
imageWidth: "", //图片宽度
|
||||
imagePadding: "", //图片padding
|
||||
@@ -705,14 +539,4 @@ function deleteTask(tasks, key, value){
|
||||
tasks[j].splice(i, 1)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
function generateNewTag(state, gallery){
|
||||
let tag = ''
|
||||
console.log(state.tags)
|
||||
console.log(gallery.tags)
|
||||
gallery.tags.forEach((tid) => {
|
||||
tag += state.tags.get(tid).tag + ' '
|
||||
})
|
||||
gallery.tag = tag.trim()
|
||||
}
|
||||
Reference in New Issue
Block a user