加入收藏以及标签,优化搜索,优化翻页的位置,加入部分注释,抽取简短名称的处理函数(同步更新)

This commit is contained in:
chuzhongzai 2022-12-30 12:51:12 +08:00
parent 3712db1b04
commit ca9c7700fa
3 changed files with 485 additions and 402 deletions

View File

@ -3,16 +3,21 @@
<span>E站额度本周已用:{{weekUsed.weekUsedAmount}} <br>上次重置时间:{{weekUsed.lastResetAmountTime}}</span><br>
<el-button @click="queryWeekUsedAmount">查询用量</el-button>
<hr>
<el-input v-model="link" placeholder="输入链接"/> <br>
<el-button @click="queryTask">查询远程任务</el-button>
<el-button @click="searchByLink">查找当前页任务</el-button> <br>
<br>
<hr>
<br>
<el-input v-model="keyword" placeholder="输入关键字" @change="searchLocalByKeyword"/>
<br>
<el-button @click="searchRemoteByKeyword">查找所有任务</el-button>
<el-button @click="searchLocalByKeyword">查找当前页任务</el-button>
<el-row>
<el-col>
查询参数类型: <el-select style="width: 125px" v-model="type">
<el-option value="link" label="链接"/>
<el-option value="keyword" label="关键字"/>
<el-option value="tag" label="标签"/>
</el-select>
参数:
<el-input style="width: 250px;" v-model="param"></el-input>
</el-col>
<el-col>
<el-button @click="queryRemoteTask" v-show="type === 'link'">远程查询</el-button>
<el-button @click="queryLocalTask">当前页查询</el-button>
</el-col>
</el-row>
<br>
<el-button @click="openPanel">打开面板</el-button>
<el-button @click="isAlterAuthCode = true">修改授权码</el-button>
@ -98,185 +103,168 @@
</div>
</template>
<script>
<script setup>
import store from "../store";
import {computed, ref, onMounted} from "vue";
import {ElMessage} from "element-plus"
export default {
name: "DashBoard",
setup(){
let AuthCode = ref("")
let isRemember = ref(false)
let isAlterAuthCode = ref(false)
let newAuthCode = ref("")
let tempAuthCode = ref("")
let keyword = ref("")
let link = ref("")
let showTips = ref(false)
let targetResolution = ref("")
let realAuthCode = computed(() => {
return store.state.AuthCode
})
let AuthCode = ref("")
let isRemember = ref(false)
let isAlterAuthCode = ref(false)
let newAuthCode = ref("")
let tempAuthCode = ref("")
let chosenGallery = computed(() => {
return store.state.chosenGallery
})
let type = ref("link")
let param = ref("")
let chosenVideo = computed(() => {
return store.state.chosenVideo
})
let targetResolution = ref("")
let loadComplete = computed(() => {
return store.state.loadComplete
})
let realAuthCode = computed(() => {
return store.state.AuthCode
})
let maskDomain = computed(() => {
return store.state.maskDomain
})
let chosenGallery = computed(() => {
return store.state.chosenGallery
})
let weekUsed = computed(() => {
return store.state.weekUsed
})
let chosenVideo = computed(() => {
return store.state.chosenVideo
})
let thumbnailGallery = computed(() => {
return store.state.thumbnailGallery
})
let loadComplete = computed(() => {
return store.state.loadComplete
})
function alterAuthCode(){
if(newAuthCode.value.trim() === "" || tempAuthCode.value.trim() === "" || newAuthCode.value !== tempAuthCode.value)
ElMessage("请检查授权码输入是否错误")
else {
store.dispatch("alterAuthCode", newAuthCode.value)
isAlterAuthCode.value = false
newAuthCode.value = ""
tempAuthCode.value = ""
}
}
let maskDomain = computed(() => {
return store.state.maskDomain
})
function queryWeekUsedAmount(){
store.dispatch("loadWeekUsedAmount")
}
let weekUsed = computed(() => {
return store.state.weekUsed
})
function postTask(){
if(!validateLink(link.value)){
ElMessage("链接错误")
return
}
if(targetResolution.value === ''){
ElMessage("请选择分辨率再提交")
return
}
let tempLink = coverLink(link.value)
if(link.value.includes("hentai")) {
store.dispatch("postGalleryTask", {link: tempLink, targetResolution: targetResolution.value})
targetResolution.value = ""
}
else {
store.dispatch("postVideoTask", {link: tempLink, targetResolution: targetResolution.value})
targetResolution.value = ""
}
}
let thumbnailGallery = computed(() => {
return store.state.thumbnailGallery
})
function queryTask(){
if(!validateLink(link.value)){
ElMessage("链接错误")
return
}
let tempLink
if(link.value.includes("hentai")) {
tempLink = coverLink(link.value)
store.dispatch("queryGalleryTask", tempLink)
}
else{
tempLink = coverLink(link.value)
store.dispatch("queryVideoTask", tempLink)
}
}
function deleteVideo(){
store.dispatch("deleteVideo", chosenVideo.value.id)
}
function deleteGallery(){
store.dispatch("deleteGallery", chosenGallery.value.gid)
}
function validate(){
if(AuthCode.value.trim() === ""){
ElMessage("请输入授权码后再验证")
}
else{
store.dispatch("validate", AuthCode.value)
if(isRemember.value)
localStorage.setItem("auth", AuthCode.value)
}
}
function validateLink(rawLink){
if(rawLink.trim() === "")
return false
if(rawLink.includes("hentai")){
return rawLink.includes("/g/")
}
else if(rawLink.includes("xvideos.com")){
return true
}
else if(rawLink.includes("pornhub.com")){
return rawLink.includes("view_video.php")
}
}
function coverLink(rawLink){
let url = new URL(rawLink)
maskDomain.value.forEach((mask) => {
if(url.host === mask['raw'])
rawLink = rawLink.replace(mask['raw'], mask['mask'])
})
return rawLink;
}
function searchByLink() {
if(link.value.trim() === ""){
ElMessage("请输入链接后查找")
}
else {
store.dispatch("searchByLink", link.value)
openPanel()
}
}
function searchLocalByKeyword(){
store.dispatch("searchLocalByKeyword", keyword.value)
}
function searchRemoteByKeyword(){
store.dispatch("searchRemoteByKeyword", keyword.value)
}
function openPanel(){
store.commit("_openHistoryPanel")
}
function onlineGalleryReader(name){
window.open("http://zfile.lionwebsite.xyz/1/gallery/" + encodeURI(name))
}
onMounted(() => {
const auth = localStorage.getItem("auth")
if(auth !== null){
store.dispatch("validate", auth)
}
})
return {postTask, queryTask, validate, searchByLink, searchLocalByKeyword, searchRemoteByKeyword, openPanel, onlineGalleryReader,
queryWeekUsedAmount, deleteVideo, deleteGallery, alterAuthCode,
link, loadComplete, AuthCode, realAuthCode, keyword, isRemember, chosenGallery, chosenVideo, targetResolution, weekUsed, showTips, thumbnailGallery,
isAlterAuthCode, newAuthCode, tempAuthCode,
store
}
//
function alterAuthCode(){
if(newAuthCode.value.trim() === "" || tempAuthCode.value.trim() === "" || newAuthCode.value !== tempAuthCode.value)
ElMessage("请检查授权码输入是否错误")
else {
store.dispatch("alterAuthCode", newAuthCode.value)
isAlterAuthCode.value = false
newAuthCode.value = ""
tempAuthCode.value = ""
}
}
//
function queryWeekUsedAmount(){
store.dispatch("loadWeekUsedAmount")
}
function postTask(){
if(!validateLink(param.value)){
ElMessage("链接错误")
return
}
if(targetResolution.value === ''){
ElMessage("请选择分辨率再提交")
return
}
let tempLink = coverLink(param.value)
if(param.value.includes("hentai"))
store.dispatch("postGalleryTask", {link: tempLink, targetResolution: targetResolution.value})
else
store.dispatch("postVideoTask", {link: tempLink, targetResolution: targetResolution.value})
targetResolution.value = ""
}
//
function queryRemoteTask(){
if(!validateLink(param.value)){
ElMessage("链接错误")
return
}
let tempLink = coverLink(param.value)
if(param.value.includes("hentai"))
store.dispatch("queryGalleryTask", tempLink)
else
store.dispatch("queryVideoTask", tempLink)
}
function queryLocalTask(){
switch (type.value){
case "link":
store.commit("_searchLocalByLink", param.value)
break
case "keyword":
store.commit("_searchLocalByKeyword", param.value)
break
case "tag":
store.commit("_searchLocalByTag", param.value.includes(",") ? param.value.split(","): [param.value])
break
}
}
//
function deleteVideo(){
store.dispatch("deleteVideo", chosenVideo.value.id)
}
function deleteGallery(){
store.dispatch("deleteGallery", chosenGallery.value.gid)
}
//
function validate(){
if(AuthCode.value.trim() === ""){
ElMessage("请输入授权码后再验证")
}
else{
store.dispatch("validate", AuthCode.value)
if(isRemember.value)
localStorage.setItem("auth", AuthCode.value)
}
}
//
function validateLink(rawLink){
if(rawLink.trim() === "")
return false
if(rawLink.includes("hentai")){
return rawLink.includes("/g/")
}
else if(rawLink.includes("xvideos.com")){
return true
}
else if(rawLink.includes("pornhub.com")){
return rawLink.includes("view_video.php")
}
}
function coverLink(rawLink){
let url = new URL(rawLink)
maskDomain.value.forEach((mask) => {
if(url.host === mask['raw'])
rawLink = rawLink.replace(mask['raw'], mask['mask'])
})
return rawLink;
}
//线
function openPanel(){
store.commit("_openHistoryPanel")
}
function onlineGalleryReader(name){
window.open("http://zfile.lionwebsite.xyz/1/gallery/" + encodeURI(name))
}
onMounted(() => {
const auth = localStorage.getItem("auth")
if(auth !== null){
store.dispatch("validate", auth)
}
})
</script>
<style scoped>
@ -294,7 +282,6 @@ export default {
padding-left: 100px;
padding-top: 200px;
}
.el-input{
width: 250px;
}

View File

@ -13,10 +13,13 @@
文件大小:{{props.row.fileSize}}<br>
分辨率:{{props.row.resolution}}<br>
任务创建时间:{{props.row.createTimeDisplay}}<br>
标签:{{props.row.tag === '' ? '无': props.row.tag}} <br>
<el-button @click="downloadTask(props.row.download)" :disabled="props.row.download === undefined">下载</el-button>
<el-button @click="deleteGallery(props.row.gid)" :disabled="props.row.download === undefined">删除</el-button>
<el-button @click="onlineGalleryReader(props.row.name)" :disabled="props.row.download === undefined">在线看</el-button>
<el-button @click="showThumbnail(props.row)" :disabled="props.row.download === undefined">预览封面</el-button>
<el-button @click="showThumbnail(props.row)" :disabled="props.row.download === undefined">预览封面</el-button><br>
<el-button @click="changeCollect(props.row.gid, props.row.isCollect)" :disabled="props.row.download === undefined">{{props.row.isCollect ? '取消收藏' : '收藏'}}</el-button>
<el-button @click="editTag(props.row.gid, props.row.tag)" :disabled="props.row.download === undefined">编辑标签</el-button>
</template>
</el-table-column>
@ -67,200 +70,221 @@
<el-row class="pageChanger">
<el-col>
排列顺序:<el-select v-model="sortType" @change="changeSortType">
筛选:<el-select v-model="showType" @change="changeShowType">
<el-option value="gallery" label="本子"/>
<el-option value="video" label="视频"/>
<el-option value="collect" label="收藏"/>
</el-select>
</el-col>
<el-col>
排列顺序:<el-select v-model="sortType" @change="changeSortType" style="width: 125px">
<el-option value="name" label="名字"></el-option>
<el-option value="shortName" label="简洁名字"></el-option>
<el-option value="createTime" label="任务创建时间"></el-option>
</el-select>
</el-col>
<el-col>
显示:<el-select v-model="showNameType" @change="changeShowNameType">
<el-option value="name" label="名字"></el-option>
<el-option value="shortName" label="简洁名字"></el-option>
</el-select>
</el-select>
</el-col>
<el-col>
<el-button @click="toMin">{{min}}</el-button>
<el-button @click="previous">-</el-button>
<el-input v-model="targetPage"
@change="changePage"
v-show="isEditing"
v-show="isEditingPage"
@blur="reverseEditMode"
class="page"
ref="inputNode"></el-input>
<span @click="reverseEditMode" v-show="!isEditing" class="page">{{page}}</span>
<span @click="reverseEditMode" v-show="!isEditingPage" class="page">{{page}}</span>
<el-button @click="next">+</el-button>
<el-button @click="toMax">{{max}}</el-button>
<el-button @click="changeShowType">切换</el-button>
</el-col>
</el-row>
</div>
</div>
</el-drawer>
<el-dialog v-model="isEditingTag" title="编辑标签" width="100%">
<el-form>
<el-form-item>
<template #label>
标签:
</template>
<template #default>
<el-input v-model="tempTag"></el-input>
</template>
</el-form-item>
</el-form>
<el-footer>
<el-button @click="submitTag">提交修改</el-button>
</el-footer>
</el-dialog>
</template>
<script>
<script setup>
import store from "../store";
import {computed, ref} from "vue";
export default {
name: "Side",
setup(){
let inputNode = ref(null)
let isEditing = ref(false)
let showNameType = ref("shortName") // shortName fullName
let showType = ref("gallery") // gallery video
let sortType = ref("shortName") // shortName fullName createTime
let targetPage = ref(1)
let loadComplete = computed(() => {
return store.state.loadComplete
})
//
let inputNode = ref(null)
//
let isEditingPage = ref(false)
//
let isEditingTag = ref(false)
let galleryTasks = computed(() => {
if(store.getters.galleryTasks)
return store.getters.galleryTasks
else
return null
})
let videoTasks = computed(() => {
if(store.getters.videoTasks)
return store.getters.videoTasks
else
return null
})
let isShowVideoHistory = computed(() => {
return store.state.showType === "video"
})
let isShowGalleryHistory = computed(() => {
return store.state.showType === "gallery"
})
let isOpenHistoryPanel = computed(() => {
return store.state.isShowHistory
})
let min = computed(() => {
return store.getters.min
})
let max = computed(() => {
if(targetPage.value > store.getters.max)
store.commit("_changePage", store.getters.max)
return store.getters.max
})
let page = computed(() => {
targetPage.value = store.state.page
return store.state.page
})
function next() {
if(targetPage.value < max.value) {
targetPage.value++
store.commit("_changePage", targetPage.value)
}
}
function previous() {
if(targetPage.value > min.value) {
targetPage.value--
store.commit("_changePage", targetPage.value)
}
}
function toMax() {
store.commit("_changePage", max.value)
targetPage.value = max.value
}
function toMin(){
store.commit("_changePage", min.value)
targetPage.value = min.value
}
function changePage(){
if(targetPage.value >= min.value && targetPage.value <= max.value)
store.commit("_changePage", targetPage.value)
}
function changeShowType(){
if(isShowVideoHistory.value){
store.commit("_setShowType", "gallery")
showType.value = "gallery"
}
else{
store.commit("_setShowType", "video")
showType.value = "video"
}
}
function changeShowNameType(){
store.commit("_setShowNameType", showNameType.value)
if(showNameType.value !== sortType.value){
store.commit("_setSortType", showNameType.value)
sortType.value = showNameType.value
}
}
function changeSortType(){
store.commit("_setSortType", sortType.value)
//
let tempTag = ref("")
let tempGid = ref("")
if(sortType.value !== showNameType.value && sortType.value !== "createTime") {
store.commit("_setShowNameType", sortType.value)
showNameType.value = sortType.value
}
}
let showNameType = ref("shortName") // shortName fullName
let showType = ref("gallery") // gallery video collect
let sortType = ref("shortName") // shortName fullName createTime
let targetPage = ref(1)
function reverseEditMode(){
isEditing.value = !isEditing.value
if(isEditing){
inputNode.value.focus()
}
targetPage.value = page.value
}
let loadComplete = computed(() => {
return store.state.loadComplete
})
function closeHistoryPanel(){
store.commit("_closeHistoryPanel")
}
let galleryTasks = computed(() => {
return store.getters.galleryTasks ? store.getters.galleryTasks: null
})
let videoTasks = computed(() => {
return store.getters.videoTasks ? store.getters.videoTasks: null
})
function downloadTask(link){
window.open(link)
}
let isShowVideoHistory = computed(() => {
return store.state.showType === "video"
})
function deleteGallery(gid){
store.dispatch("deleteGallery", gid)
}
let isShowGalleryHistory = computed(() => {
return store.state.showType === "gallery" || store.state.showType === "collect"
})
function deleteVideo(id){
store.dispatch("deleteVideo", id)
}
let isOpenHistoryPanel = computed(() => {
return store.state.isShowHistory
})
function onlineGalleryReader(name){
window.open("http://zfile.lionwebsite.xyz/1/gallery/" + encodeURI(name))
}
let min = computed(() => {
return store.getters.min
})
function onlineVideoViewer(){
window.open("http://zfile.lionwebsite.xyz/1/video/")
}
let max = computed(() => {
if(targetPage.value > store.getters.max)
store.commit("_changePage", store.getters.max)
return store.getters.max
})
function showThumbnail(gallery){
store.commit("_changeThumbnailGallery", gallery)
setTimeout(() => {document.querySelector(".preview > img").click()}, 1)
}
let page = computed(() => {
targetPage.value = store.state.page
return store.state.page
})
return {galleryTasks, videoTasks, min, max, targetPage, loadComplete, page, isEditing, inputNode, isShowVideoHistory,
isShowGalleryHistory, showType, showNameType, sortType, isOpenHistoryPanel,
reverseEditMode, changePage, changeShowType, changeShowNameType, changeSortType, toMax, toMin, previous, next, downloadTask, deleteGallery,
deleteVideo, onlineGalleryReader, onlineVideoViewer, closeHistoryPanel, showThumbnail,
store
}
//
function next() {
if(targetPage.value < max.value) {
targetPage.value++
store.commit("_changePage", targetPage.value)
}
}
function previous() {
if(targetPage.value > min.value) {
targetPage.value--
store.commit("_changePage", targetPage.value)
}
}
function toMax() {
store.commit("_changePage", max.value)
targetPage.value = max.value
}
function toMin(){
store.commit("_changePage", min.value)
targetPage.value = min.value
}
function changePage(){
if(targetPage.value >= min.value && targetPage.value <= max.value)
store.commit("_changePage", targetPage.value)
}
function reverseEditMode(){
isEditingPage.value = !isEditingPage.value
if(isEditingPage){
inputNode.value.focus()
}
targetPage.value = page.value
}
//
function changeShowType(){
store.commit("_setShowType", showType.value)
}
function changeShowNameType(){
store.commit("_setShowNameType", showNameType.value)
if(showNameType.value !== sortType.value){
store.commit("_setSortType", showNameType.value)
sortType.value = showNameType.value
}
}
function changeSortType(){
store.commit("_setSortType", sortType.value)
if(sortType.value !== showNameType.value && sortType.value !== "createTime") {
store.commit("_setShowNameType", sortType.value)
showNameType.value = sortType.value
}
}
//,,
function changeCollect(gid, isCollect){
if(isCollect)
store.dispatch("disCollectGallery", gid)
else
store.dispatch("collectGallery", gid)
}
function editTag(gid, tag){
tempTag.value = tag
tempGid.value = gid
isEditingTag.value = true
}
function submitTag(){
store.dispatch("updateTag", {gid:tempGid.value, tag:tempTag.value})
tempTag.value = ''
tempGid.value = ''
isEditingTag.value = false
}
//线
function downloadTask(link){
window.open(link)
}
function deleteGallery(gid){
store.dispatch("deleteGallery", gid)
}
function deleteVideo(id){
store.dispatch("deleteVideo", id)
}
function onlineGalleryReader(name){
window.open("http://zfile.lionwebsite.xyz/1/gallery/" + encodeURI(name))
}
function onlineVideoViewer(){
window.open("http://zfile.lionwebsite.xyz/1/video/")
}
//
function showThumbnail(gallery){
store.commit("_changeThumbnailGallery", gallery)
setTimeout(() => {document.querySelector(".preview > img").click()}, 1)
}
//
function closeHistoryPanel(){
store.commit("_closeHistoryPanel")
}
</script>
<style scoped>
@ -271,8 +295,10 @@ export default {
display: block;
}
.pageChanger{
position: absolute;
top:85vh;
margin-top: 5vh;
}
.el-select{
width: 100px;
}
.page{
display: inline-block;

View File

@ -119,6 +119,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)
context.dispatch("loadMaskDomain").then()
context.dispatch("loadWeekUsedAmount").then()
@ -148,43 +149,33 @@ const actions = {
ElMessage("查询用量失败")
})
},
searchByLink(context, link){
context.commit("_searchByLink", link)
collectGallery(context, gid){
axios.post(GalleryManageUrl + "/collect?" +qs.stringify( {
gid,
id:state.userId
})).then((res) => {
ElMessage(res.data.data)
if(res.data.result === 'success')
context.commit("_collectGallery", gid)
})
},
searchLocalByKeyword(context, keyword){
context.commit("_searchLocalByKeyword", keyword)
disCollectGallery(context, gid){
axios.post(GalleryManageUrl + "/disCollect?" + qs.stringify(
{
gid,
id:state.userId
})).then((res) => {
ElMessage(res.data.data)
if(res.data.result === 'success')
context.commit("_disCollectGallery", gid)
})
},
searchRemoteByKeyword(context, keyword){
if(context.state.showType === "gallery"){
axios.get(GalleryManageUrl, {
params:{
type:"name",
param:keyword
}
}).then((res) => {
if(res.data.result === 'success'){
context.commit("_setChosenGallery", {'gallery':JSON.parse(res.data.data)})
}
else{
ElMessage(res.data.data)
}
})
}
else{
axios.get(VideoManageUrl, {
params:{
type:"name",
param:keyword
}
}).then((res) => {
if(res.data.result === 'success'){
context.commit("_setChosenVideo", {'video': JSON.parse(res.data.data)})
}
else{
ElMessage(res.data.data)
}
})
}
updateTag(context, data){
axios.post(GalleryManageUrl + "/tag?" + qs.stringify(data)).then((res) => {
ElMessage(res.data.data)
if(res.data.result === 'success')
context.commit("_updateTag", data)
})
},
deleteGallery(context, gid){
axios.delete(GalleryManageUrl, {
@ -231,32 +222,40 @@ const actions = {
}
const mutations = {
_collectGallery(state, gid){
state.totalGalleryTask.forEach((gallery) => {
if(!gallery.isCollect && gallery.gid === gid){
gallery.isCollect = true
state.collectGallery.push(gallery)
}
})
},
_disCollectGallery(state, gid){
state.collectGallery.splice(0)
state.totalGalleryTask.forEach((gallery) => {
if(gallery.isCollect && gallery.gid === gid)
gallery.isCollect = false
else if(gallery.isCollect)
state.collectGallery.push(gallery)
})
},
_updateTag(state, data){
state.totalGalleryTask.forEach((gallery) => {
if(gallery.gid === data.gid){
gallery.tag = data.tag
}
})
},
_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
}
//处理名字
task.shortName = getShortname(task.name)
//处理进度相关
switch (task.status) {
case "已提交":
task.progress = "已提交"
@ -276,7 +275,29 @@ const mutations = {
break;
}
//处理时间戳
task.createTimeDisplay = moment(task.createTime * 1000).format("YYYY-MM-DD HH:mm:ss")
//处理标签
if (task.tag === undefined) {
task.tag = ""
}
//处理是否收藏
if(task.collector !== undefined){
let collector = task.collector.split(",")
task.collector = undefined
collector.forEach((id) => {
if(parseInt(id) === state.userId) {
task.isCollect = true
state.collectGallery.push(task)
}
})
if(task.isCollect === undefined)
task.isCollect = false
}
state.totalGalleryTask.push(task)
})
}
@ -385,29 +406,27 @@ const mutations = {
ElMessage("授权码错误")
localStorage.removeItem("auth")
},
_searchByLink(state, link){
_searchLocalByLink(state, link){
let tasks
if(state.showType === "gallery") {
tasks = state.totalGalleryTask
}
else
tasks = state.totalVideoTask
let i = 0
let found = false
for (i = 0; i < tasks.length; i++) {
if(state.showType === "gallery")
tasks = state.totalGalleryTask
else
tasks = state.totalVideoTask
for (i = 0; i < tasks.length; i++)
if (tasks[i].link === link) {
state.page = Math.floor(i / state.length) + 1
found = true
break
}
}
if(!found){
if(!found)
ElMessage("未找到此任务")
}
else{
else
ElMessage("已跳转到该任务所在页数")
state.isShowHistory = true
}
},
_searchLocalByKeyword(state, keyword){
state.searchTask.splice(0)
@ -424,11 +443,32 @@ const mutations = {
})
if (state.searchTask.length === 0) {
ElMessage("未找到该关键字的任务")
} else {
state.isShowHistory = true
}
}
},
_searchLocalByTag(state, tags) {
state.searchTask.splice(0)
state.page = 1
let tagAmount = tags.length
let hitAmount
let tasks = state.totalGalleryTask
if (tags[0].trim() !== '') {
tasks.forEach((task) => {
hitAmount = 0
tags.forEach((tag) => {
if (task.tag.includes(tag))
hitAmount++
})
if (hitAmount === tagAmount)
state.searchTask.push(task)
})
if (state.searchTask.length === 0)
ElMessage("未找到符合这些tag的任务")
}
},
_deleteGallery(state, gid){
state.totalGalleryTask.forEach((item, index, arr) => {
if(item.gid === gid){
@ -444,7 +484,7 @@ const mutations = {
},
_setChosenGallery(state,data){
if(data.gallery === false) {
//state.chosenGallery.shortName = getShortName(state.chosenGallery.name)
state.chosenGallery.shortName = getShortname(state.chosenGallery.name)
state.chosenGallery.resolution = data.resolution
state.chosenGallery.fileSize = "等待下载完成后再查看"
state.chosenGallery.createTimeDisplay = "等待下载完成后再查看"
@ -517,6 +557,7 @@ const state = {
totalGalleryTask:[], //存放本子数据的数组
chosenGallery:false, //准备下载的本子
thumbnailGallery:{}, //预览本子
collectGallery:[], //收藏的本子
totalVideoTask:[], //存放视频数据的数组
chosenVideo:false, //准备下载的视频
@ -526,6 +567,7 @@ const state = {
defaultLength:4, //默认个数
shortLength:5, //简洁个数
userId:-1, //用户id
isAuth:false, //是否授权
AuthCode:'', //授权码
loadComplete:false, //是否加载完成
@ -543,6 +585,8 @@ const state = {
const getters = {
galleryTasks(state){
if(state.showType === 'collect')
return state.collectGallery.slice((state.page-1)*state.length, state.page*state.length)
if(state.searchTask.length !== 0)
return state.searchTask.slice((state.page-1)*state.length, state.page*state.length)
if(state.totalGalleryTask.length !== 0)
@ -562,21 +606,26 @@ const getters = {
max(state){
let max = 0
let tasks
if(state.searchTask.length !== 0){
if(state.showType === 'collect')
tasks = state.collectGallery
else if(state.searchTask.length !== 0)
tasks = state.searchTask
}
else if(state.showType === "gallery")
if(state.totalGalleryTask.length !== 0)
tasks = state.totalGalleryTask
else if(state.showType === "video")
if(state.totalVideoTask.length)
tasks = state.totalVideoTask
if(!tasks)
return 1
max = Math.floor(tasks.length/state.length)
if(tasks.length % state.length !== 0){
if(tasks.length % state.length !== 0)
max += 1
}
if(max === 0)
return 1
return max
}
}
@ -588,3 +637,24 @@ export default new vuex.Store({
getters
})
function getShortname(name){
if (name.includes("[")) {
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, "")
}
return name.trim()
} else {
return name
}
}