去除标签;修改在线看,允许未下载的本子在线看(同步更新);修复里站搜索时切换页面不会回到顶部;修复里站搜索时不会显示加载图标

This commit is contained in:
chuzhongzai 2023-12-25 20:38:24 +08:00
parent f1270e3ebb
commit 61c4dbc8e8
5 changed files with 97 additions and 614 deletions

View File

@ -20,24 +20,21 @@
<el-button @click="isConfig = true">配置</el-button><br>
<span style="display: inline">夜间模式</span>
<el-switch @click="toggleStyle" v-model="isDark">夜间模式</el-switch>
<hr>
<el-button @click="isQuerying = true">里站搜索</el-button>
<el-button @click="isViewingTag = true">查看标签</el-button>
<br>
<el-button v-if="isLion" @click="resetUndone">重置任务</el-button>
<div v-show="thumbnailGallery.url !== undefined">
<div v-show="thumbnailGallery.thumb_link !== undefined">
<span>
{{thumbnailGallery.shortName}}
</span><br>
<picture>
<el-image :src="thumbnailGallery.url" :preview-src-list="[thumbnailGallery.images[0],]" :initial-index="0" class="preview"
<el-image :src="thumbnailGallery.thumb_link" :preview-src-list="[thumbnailGallery.thumb_link,]" class="preview"
style="height: 30vh" fit="contain"/>
</picture>
</div>
</el-drawer>
<el-dialog title="查询本子" v-model="chosenGallery" width="100%">
<el-image v-if='chosenGallery.thumb_link !== undefined' style="float: right; width: 250px; height: 250px" fit="contain"
<el-image v-show='chosenGallery.thumb_link !== undefined' style="float: right; width: 250px; height: 250px" fit="contain"
:src="'https://downloader.lionwebsite.xyz/GalleryManage/ehThumbnail?path=' + chosenGallery.thumb_link"/>
<table>
<tr>本子名字:{{chosenGallery.name}}</tr>
@ -52,13 +49,6 @@
</el-option>
</el-select>
</tr>
<tr v-if="chosenGallery.availableResolution">
下载模式:<el-select v-model="targetDownloadMode" style="width: 200px" default-first-option>
<el-option :value="1" label="仅下载"/>
<el-option :value="2" label="仅在线看"/>
<el-option :value="3" label="在线看并下载"/>
</el-select>
</tr>
<tr v-if="chosenGallery.availableResolution">
标签:<el-tag v-for="tid in paramForTags" closable @close="removeQueryTag(tid)">
{{store.state.tags.get(tid).tag}}
@ -66,13 +56,13 @@
<el-autocomplete v-model="param" :fetch-suggestions="completeQueryTag" @select="handleTagSelect" ref="tagInputForSubmit"/>
</tr>
</table>
<el-button @click="postTask" v-if="chosenGallery.availableResolution">下载</el-button>
<el-button @click="removeAllQueryTag" v-if="chosenGallery.availableResolution">清空标签</el-button>
<tr v-if="chosenGallery.status === '下载完成'">
<el-button @click="onlineGalleryReader(chosenGallery.gid)">在线预览</el-button>
<el-button @click="showThumbnail(chosenGallery)">查看封面图</el-button>
<el-button @click="deleteGallery">删除</el-button>
</tr>
<template #footer>
<el-button @click="onlineGalleryReader(chosenGallery)">在线预览</el-button>
<el-button @click="postTask" v-if="chosenGallery.availableResolution">下载</el-button>
<tr v-if="chosenGallery.status === '下载完成'">
<el-button @click="deleteGallery">删除</el-button>
</tr>
</template>
</el-dialog>
<HentaiSearch :is-querying="isQuerying" @close="isQuerying = false"></HentaiSearch>
@ -123,33 +113,6 @@
</template>
</el-dialog>
<el-dialog title="查看标签" v-model="isViewingTag" style="margin-top: 0; width: 100%">
<div style="text-align: center">
输入关键字:<el-input style="width: 150px" v-model="tagKeyWord"></el-input><br>
<el-button @click="tagKeyWord = ''">重置关键字</el-button>
<el-button @click="pullNewTag">刷新</el-button>
</div>
<el-table :data="tags" height="350px" stripe>
<el-table-column prop="id" label="id" width="50px" sortable/>
<el-table-column prop="tag" label="标签" width="150px"/>
<el-table-column prop="usage" label="用量" width="75px" sortable/>
<el-table-column width="75px">
<template #default="scoped">
<el-button v-if="scoped.row.usage === 0" @click="deleteTag(scoped.row.id)">删除</el-button>
</template>
</el-table-column>
</el-table>
<span style="color: red; font: bold 15px sans-serif">
创建标签前先看看有没有符合的尽量用统一一点的标签比如已经有个图包就不要创建图集之类的了毕竟标签多起来数据挺多的
</span>
<template #footer>
输入新标签:<el-input v-model="tag" style="width: 100px"></el-input>
<el-button @click="postTag">创建标签</el-button>
</template>
</el-dialog>
<div class="DashBoard" v-show="!loadComplete">
<div class="validate">
<el-input v-model="AuthCode" placeholder="请输入授权码" />
@ -163,7 +126,6 @@
import store from "../store";
import {computed, ref, onMounted} from "vue";
import {ElMessage} from "element-plus"
import axios from "axios";
import HentaiSearch from "./HentaiSearch.vue";
//
@ -174,7 +136,6 @@ let newAuthCode = ref("")
let tempAuthCode = ref("")
let isQuerying = ref(false)
let isViewingTag = ref(false)
let isConfig = ref(false)
let isDark = ref(false)
let keyword = ref("furry yaoi")
@ -184,19 +145,15 @@ let lengthPerPage = ref(0)
//
let type = ref("link")
let param = ref("")
let paramForTags = ref([]) //tidS
let targetResolution = ref("")
let targetDownloadMode = ref("")
let tag = ref("")
let tagKeyWord = ref("") //tag
let realAuthCode = computed(() => {
return store.state.AuthCode
})
let chosenGallery = computed(() => {
paramForTags.value.splice(0)
param.value = ''
return store.state.chosenGallery
})
@ -208,27 +165,8 @@ let loadComplete = computed(() => {
let weekUsed = computed(() => {
return store.state.weekUsed
})
let tags = computed(() => {
let tags = store.state.tags
let result = []
tags.forEach((tag) => {
result.push(tag)
})
if(isViewingTag.value) { //
if (tagKeyWord.value.trim() === '')
return result
else
return result.filter((tag) => {
return tag.tag.includes(tagKeyWord.value)
})
}
return result
})
let thumbnailGallery = computed(() => {
if(store.state.thumbnailGallery.images === undefined)
store.state.thumbnailGallery.images = []
return store.state.thumbnailGallery
})
@ -236,18 +174,6 @@ let isLion = computed(() => {
return store.state.userId === 3
})
function pullNewTag(){
store.dispatch("loadTags")
}
function postTag(){
store.dispatch("postTag", tag.value)
}
function deleteTag(tid){
store.dispatch("deleteTag", tid)
}
//
function alterAuthCode(){
if(newAuthCode.value.trim() === "" || tempAuthCode.value.trim() === "" || newAuthCode.value !== tempAuthCode.value)
@ -281,8 +207,7 @@ function postTask(){
store.dispatch("postGalleryTask",
{link: chosenGallery.value.link,
targetResolution: targetResolution.value,
mode: targetDownloadMode.value,
tags:tag.value})
mode: targetDownloadMode.value})
targetResolution.value = ""
}
@ -304,44 +229,8 @@ function queryLocalTask(){
case "keyword":
store.commit("_searchLocalByKeyword", param.value)
break
case "tag":
store.commit("_searchLocalByTag", paramForTags.value)
break
}
}
let tagInput = ref({}) //
let tagInputForSubmit = ref({}) //
function completeQueryTag(keyWord, cb) {
if(keyWord.includes(' ')) { //
let temp = keyWord.split(' ')
keyWord = temp[temp.length - 1]
}else{ //
keyWord = param.value
}
let result = []
let skip
let hit = false //
tags.value.forEach((tag) => {
if(tag.tag.includes(keyWord)) {
skip = false
for (let id of paramForTags.value) { //
if(tag.id === id){
if(!hit && tag.tag === keyWord){ //
hit = true
}
skip = true
break
}
}
if(!skip)
result.push({value: tag.tag, tid: tag.id})
}
})
if(result.length === 0 && !keyWord.includes("#") && chosenGallery.value.gid !== undefined && !hit){ //
result.push({value: '新建 #' + keyWord + ' 标签?', tag:keyWord})
}
cb(result)
}
function removeQueryTag(tid){
for (let i=0; i<paramForTags.value.length; i++){
@ -354,46 +243,6 @@ function removeQueryTag(tid){
queryLocalTask()
}
function removeAllQueryTag(){
paramForTags.value.splice(0)
if(chosenGallery.value.gid === undefined) //
queryLocalTask()
}
function handleTagSelect(data){
if('tag' in data){ //,axiosvue
axios.post("https://downloader.lionwebsite.xyz/GalleryManage/tag?" + qs.stringify({
tag:data.tag,
AuthCode: store.state.AuthCode
})
).then((res) => {
if (res.data.result === 'success') {
ElMessage('创建标签成功')
paramForTags.value.push(parseInt(res.data.tid))
tagInputForSubmit.value.blur()
store.dispatch("loadTags", false).then()
}
else
ElMessage(res.data.data)
})}else{
paramForTags.value.push(data.tid)
console.log(chosenGallery)
if(chosenGallery.value.gid === undefined){
queryLocalTask()
tagInput.value.blur()
}else{
tagInputForSubmit.value.blur()
}
}
param.value = ''
}
function resetLocalQuery(){
store.commit("_searchLocalByKeyword", "")
store.commit("_searchLocalByTag", [''])
param.value = ""
}
//
function deleteGallery(){
store.dispatch("deleteGallery", chosenGallery.value.gid)
@ -411,7 +260,7 @@ function validate(){
}
}
//
//
function validateLink(rawLink){
if(rawLink.trim() === "")
return false
@ -422,11 +271,8 @@ function validateLink(rawLink){
}
//线
function openPanel(){
store.commit("_openHistoryPanel")
}
function onlineGalleryReader(gid){
store.dispatch("queryOnlineLinks", gid)
function onlineGalleryReader(gallery){
store.dispatch("readOnlineGallery", gallery)
}
//
@ -445,12 +291,6 @@ function toggleStyle(){
light()
}
//
function showThumbnail(gallery){
store.commit("_changeThumbnailGallery", gallery)
setTimeout(() => {document.querySelector(".preview > img").click()}, 1)
}
onMounted(() => {
const auth = localStorage.getItem("auth")
adjustForStyle()

View File

@ -14,7 +14,6 @@ let queryPage = ref({})
let galleries = ref([])
let param = ref()
let isShowUp = ref()
let isLoading = ref()
watch(props, () => {
isShowUp.value = props.isQuerying
})
@ -28,11 +27,11 @@ function queryGalleries(link){
tempParam = keyword.value
}
tempParam = tempParam.replace(" ", "+")
isLoading = true
document.getElementById("loading").style.display = "inline-block";
axios.get("https://downloader.lionwebsite.xyz/query?keyword=" + tempParam)
.then((res) => {
isLoading = false
document.getElementById("loading").style.display = "none";
if (res.data.result === "success") {
let tempGalleries = JSON.parse(res.data.data)
queryPage.value.first = 'first' in res.data ? res.data.first : undefined
@ -44,6 +43,8 @@ function queryGalleries(link){
tempGalleries.forEach((gallery) => {
galleries.value.push(gallery)
})
scrollBar.value.setScrollTop(0)
}else {
ElMessage({message: res.data.data, type: "error"})
}
@ -94,7 +95,7 @@ function adjustGalleryName(name, length) {
<template>
<el-dialog title="里站搜索" v-model="isShowUp" top="0" style="margin-bottom: 0" fullscreen class="el-dialogClass" @close="close">
<div style="text-align: center">
<el-input v-model="keyword" style="width: 50vw"></el-input> <el-button @click="queryGalleries(null)">查询</el-button> <div id="loading" v-if="isLoading"/>
<el-input v-model="keyword" style="width: 50vw"></el-input> <el-button @click="queryGalleries(null)">查询</el-button> <div id="loading"/>
</div>
<el-scrollbar height="75vh" ref="scrollBar">
<div style="height: 20vh; width: 100%; border-radius: 5px; padding-bottom: 2vh" v-for="gallery in galleries">
@ -110,7 +111,10 @@ function adjustGalleryName(name, length) {
<span>页数{{gallery.page}}</span><br>
<span class="ct6">类型{{gallery.type}}</span><br>
<a :href="gallery.link">链接</a><br>
<el-button style="position: relative; margin-left: 65%;" @click="param=gallery.link; queryRemoteTask()" type="primary">下载</el-button>
<el-button-group style=" margin-left: 50%; margin-top: -5vh">
<el-button @click="store.dispatch('readOnlineGallery', gallery)">在线看</el-button>
<el-button @click="param=gallery.link; queryRemoteTask()">查看详情</el-button>
</el-button-group>
</div>
</div><br>
</el-scrollbar>
@ -135,7 +139,7 @@ function adjustGalleryName(name, length) {
border-top-color: #3498db;
border-radius: 50%;
animation: spin 1s linear infinite;
display: inline-block;
display: none;
}
@keyframes spin {

View File

@ -1,9 +1,6 @@
<script setup>
import {computed, ref, watch} from "vue";
import {computed, ref} from "vue";
import store from "../store/index.js";
let props = defineProps(['currentGallery', 'isOnlineReading'])
let emit = defineEmits(['close'])
let isShowUp = ref()
let onlineReadingScrollbar = ref()
let links = ref()
let index = ref(0)
@ -13,19 +10,21 @@ let current_page = 0
let lengthPerPage = computed(() => {
return store.state.lengthPerPage
})
watch(props, (props)=>{
isShowUp.value = props.isOnlineReading
let readingGallery = computed(() => {
return store.state.readingGallery
})
let isShowUp = computed(() => {
alterPage()
return store.state.isReading
})
//
function alterPage(){
if(props.currentGallery.images.length > lengthPerPage.value){
links.value = props.currentGallery.images.slice(0, lengthPerPage.value)
max.value = Math.ceil(props.currentGallery.images.length / lengthPerPage.value)
if(readingGallery.value.images.length > lengthPerPage.value){
links.value = readingGallery.value.images.slice(0, lengthPerPage.value)
max.value = Math.ceil(readingGallery.value.images.length / lengthPerPage.value)
}else{
links.value = props.currentGallery.images
links.value = readingGallery.value.images
max.value = 0
}
index.value = 0
@ -34,7 +33,7 @@ function alterPage(){
//
function jump(targetIndex){
links.value = props.currentGallery.images.slice(targetIndex * lengthPerPage.value, (targetIndex + 1) * lengthPerPage.value)
links.value = readingGallery.value.images.slice(targetIndex * lengthPerPage.value, (targetIndex + 1) * lengthPerPage.value)
index.value = targetIndex
temp_index.value = targetIndex + 1
onlineReadingScrollbar.value.setScrollTop(0)
@ -42,14 +41,12 @@ function jump(targetIndex){
function closeDialog(){
onlineReadingScrollbar.value.setScrollTop(0)
emit('close')
store.commit("_closeReader")
}
function switch_page(target_page){
console.log(current_page, target_page)
//
if(target_page > (current_page + 1) && current_page === 0 && index.value > 0) {
console.log("上一页")
document.querySelector("span.el-image-viewer__btn.el-image-viewer__close").click()
jump(index.value - 1)
onlineReadingScrollbar.value.setScrollTop(onlineReadingScrollbar.value.wrapRef.scrollHeight)
@ -66,7 +63,6 @@ function switch_page(target_page){
//
}else if(target_page === 0 && current_page === lengthPerPage.value - 1 && index.value < max.value){
console.log("下一页")
jump(index.value + 1)
current_page = 0
document.querySelector("div.el-scrollbar__wrap.el-scrollbar__wrap--hidden-default > div > div:nth-child(1) > img").click()
@ -84,15 +80,15 @@ function set_current_page(page){
<template>
<el-dialog v-model="isShowUp" @close="closeDialog" width="100%" top="0" fullscreen >
<template #header style="padding-bottom: 0">
在线预览: {{currentGallery.name}} 页数{{currentGallery.pages}}<br>
在线预览: {{readingGallery.name}} 页数{{readingGallery.pages}}<br>
<div style="font-size: 3vh; display: inline" v-if="max > 0">
{{ index + 1 }} - {{ (index) * lengthPerPage + 1 }} ~
{{ (index + 1) * lengthPerPage + 1 > currentGallery.images.length ? currentGallery.images.length : (index + 1) * lengthPerPage }}
{{ (index + 1) * lengthPerPage + 1 > readingGallery.images.length ? readingGallery.images.length : (index + 1) * lengthPerPage }}
</div>
</template>
<el-scrollbar height="75vh" ref="onlineReadingScrollbar">
<el-image v-for="(link, i) in links" :src="link" :style="{'width': 'auto', 'text-align': 'center', 'background-color': 'ghostwhite'}"
:preview-src-list="links" :initial-index="i" @switch="switch_page" @show="set_current_page(i)"/>
:preview-src-list="links" :initial-index="i" @switch="switch_page" @show="set_current_page(i)" loading="lazy"/>
</el-scrollbar>
<!--五页以下-->

View File

@ -1,12 +1,14 @@
<template>
<div class="side">
<div v-show="loadComplete" class="load_complete">
<el-scrollbar max-height="80vh">
<div v-if="currentTasks.length === 0">
{{emptyText}}
</div>
<div v-for="gallery in currentTasks" :style="{'height': '20vh', 'background': isDark() ? '': 'FloralWhite', 'border-radius': '1%',
'margin-bottom': '10px'}"
@click="viewInfo(gallery)" id="gallery">
<el-image :src="getGalleryThumb(gallery)"
<el-image :src="gallery.thumb_link"
style="height: 20vh; width: 35vw; float:left"
fit="contain"
loading="lazy"
@ -25,26 +27,16 @@
<el-row>
<el-button @click="store.state.isShowHistory = true"></el-button>
<el-select style="width: 22vw" v-model="type">
<el-option value="link" label="链接"/>
<el-option value="keyword" label="关键字"/>
<el-option value="tag" label="标签"/>
</el-select>
<el-input style="width: 60vw" v-model="param" v-show="type === 'keyword'" placeholder="关键字搜索">
<el-input style="width: 60vw" v-model="param" placeholder="搜索">
<template #append>
<el-button @click="queryLocalTask">搜索</el-button>
</template>
</el-input>
<el-autocomplete v-model="param" :fetch-suggestions="generateQueryTag"
@select="handleQueryTagSelect" placeholder="检索标签"
style="width: 60vw" v-if="type === 'tag'">
<template #append>
<el-button :disabled="paramForTags.length === 0" @click="removeAllQueryTag">清空tag</el-button>
</template>
</el-autocomplete>
</el-row>
</el-col>
<el-tag v-for="tid in paramForTags" closable @close="removeQueryTag(tid)" size="large" style="display: inline-block" v-if="paramForTags.length !== 0">
{{store.state.tags.get(tid).tag}}
</el-tag>
<el-row class="pageChanger">
<el-col>
@ -89,25 +81,9 @@
</div>
</div>
<el-dialog v-model="isEditingTag" title="编辑本子标签" width="100%">
<el-form>
<el-form-item>
<template #label>
标签:
</template>
<template #default>
<el-tag v-for="tid in galleryForTag.tags" closable @close="disMark(galleryForTag.gid, tid)">
{{tags.get(tid).tag}}
</el-tag>
<el-autocomplete v-model="newTag" :fetch-suggestions="querySimilarTag" @select="handleTagSelect" ref="tagInput"/>
</template>
</el-form-item>
</el-form>
</el-dialog>
<el-dialog v-model="isViewing" width="100%" top="0" style="padding: 0">
<div style="height: 20vh; font: bold 16px semi-expanded">
<el-image :src="getGalleryThumb(currentGallery)"
<el-image :src="currentGallery.thumb_link"
style="float: left; width: 40vw; height: 20vh" fit="contain"/>
{{adjustGalleryName(currentGallery.name, 150)}}
</div>
@ -119,7 +95,6 @@
分辨率:{{currentGallery.resolution}} <br>
链接:<a :href="currentGallery.link">link</a> <br>
下载链接:<a :href="currentGallery.download">link</a><br>
标签:{{currentGallery.tag === '' ? '无': currentGallery.tag}} <br>
<span v-show="isLion">
downloader:{{currentGallery.downloader}}
</span>
@ -132,18 +107,14 @@
size="large">下载</el-button>
<el-button @click="deleteGallery(currentGallery.gid)" :disabled="currentGallery.status !== '下载完成'"
size="large">删除</el-button>
<el-button @click="shareGallery({gid:currentGallery.gid, shortName:currentGallery.shortName + '.zip'})" v-if="isLion"
size="large">分享</el-button>
<el-button @click="changeGalleryCollect(currentGallery.gid, currentGallery.isCollect)" :disabled="currentGallery.status !== '下载完成'"
size="large">{{currentGallery.isCollect ? '取消收藏' : '收藏'}}</el-button>
<el-button @click="onlineGalleryReader" :disabled="currentGallery.status !== '下载完成' || currentGallery.mode === 1"
<el-button @click="readOnlineGallery(currentGallery)" :disabled="currentGallery.status !== '下载完成' || currentGallery.mode === 1"
size="large">在线看</el-button>
<el-button @click="editGalleryTag(currentGallery)" :disabled="currentGallery.status !== '下载完成'"
size="large">编辑标签</el-button>
</template>
</el-dialog>
<OnlineReader :current-gallery="currentGallery" :isOnlineReading="isOnlineReading" @close="isOnlineReading = false"/>
<OnlineReader/>
</template>
<script setup>
@ -153,35 +124,23 @@ import axios from "axios";
import {ElMessage} from "element-plus";
import OnlineReader from "./OnlineReader.vue";
let link = "https://downloader.lionwebsite.xyz/GalleryManage/"
let GalleryManagePrefix = "https://downloader.lionwebsite.xyz/GalleryManage/"
//
let inputNode = ref(null)
//
let isEditingPage = ref(false)
//
let isEditingTag = ref(false)
//
let isOnlineReading = ref(false)
//
let isViewing = ref(false)
//
let galleryForTag = ref({})
let category = ref("myDownload") //myDownload myCollect total
let galleryNameType = ref("shortName") // shortName name
let sortType = ref("shortName") // shortName name createTime
let targetPage = ref(1) //
//
let type = ref("keyword")
let param = ref("")
let paramForTags = ref([]) //tidS
let onlineReadingScrollbar = ref(null)
let loadComplete = computed(() => {
return store.state.loadComplete
@ -191,13 +150,6 @@ let currentTasks = computed(() => {
return store.getters.currentTasks ? store.getters.currentTasks: null
})
//
let tags = computed(() => {
return store.state.tags
})
let newTag = ref("")
let min = computed(() => {
return store.getters.min
})
@ -219,7 +171,7 @@ let emptyText = computed(() => {
return '您未' + action + '本子'
})
//线
//
let currentGallery = ref({name:"name"})
//
@ -249,9 +201,8 @@ function changePage(){
}
function reverseEditMode(){
isEditingPage.value = !isEditingPage.value
if(isEditingPage){
if(isEditingPage)
inputNode.value.focus()
}
targetPage.value = page.value
}
@ -266,118 +217,24 @@ function changeSortType(){
store.commit("_setSortType", sortType.value)
}
//,,
//
function changeGalleryCollect(gid, isCollect){
if(isCollect)
store.dispatch("disCollectGallery", gid)
else
store.dispatch("collectGallery", gid)
}
function editGalleryTag(gallery){
galleryForTag.value = gallery
isEditingTag.value = true
}
let tagInput = ref()
function querySimilarTag(keyWord, cb){
let result = []
let hit = false //
let skip //
for(const [key, tag] of store.state.tags){
skip = false
for(let id of galleryForTag.value.tags)
if(id === key) {
if (!hit && tag.tag === keyWord) //
hit = true
skip = true
break
}
if(skip)
continue
if(tag.tag.includes(keyWord))
result.push({value: tag.tag, tag:tag})
}
if(keyWord.trim() !== '' && !keyWord.includes("#") && !hit && !keyWord.includes("?") && result.length === 0)
result.push({value: '新建 #' + keyWord + ' 标签?', tag:{tag:keyWord}})
cb(result)
}
function handleTagSelect(data){
if(data.value.includes('#')) {
if(data.tag.tag.includes("?")) {
ElMessage("非法字符?")
return
}
else
store.dispatch("createTagAndMark", {tag: data.tag.tag.replace('#', ''), gid: galleryForTag.value.gid})
}
else
store.dispatch("mark", {gid:galleryForTag.value.gid, tid:data.tag.id})
newTag.value = ""
tagInput.value.blur()
}
function generateQueryTag(keyWord, cb){
let result = []
let hit = false //
let skip //
for(const [key, tag] of store.state.tags){
skip = false
if(paramForTags.value.length !== 0) {
for (let id of paramForTags.value)
if (id === key) {
if (!hit && tag.tag === keyWord) //
hit = true
skip = true
break
}
if(skip)
continue
}
if(tag.tag.includes(keyWord))
result.push({value: tag.tag, tag:tag})
}
cb(result)
}
function removeQueryTag(tid){
for (let i=0; i<paramForTags.value.length; i++){
if(paramForTags.value[i] === tid){
paramForTags.value.splice(i, 1)
break
}
}
queryLocalTask()
}
function removeAllQueryTag(){
paramForTags.value.splice(0)
queryLocalTask()
}
function handleQueryTagSelect(data) {
console.log(data)
paramForTags.value.push(data.tag.id)
param.value = ''
queryLocalTask()
}
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", paramForTags.value)
break
}
}
function mark(gid, tid){
store.dispatch("mark", {gid, tid})
}
function disMark(gid, tid){
store.dispatch("disMark", {gid, tid})
}
//线
function downloadTask(link){
window.open(link)
@ -387,31 +244,13 @@ function deleteGallery(gid){
isViewing.value = false
})
}
function onlineGalleryReader(){
isOnlineReading.value = true;
function readOnlineGallery(gallery){
store.dispatch("readOnlineGallery", gallery)
}
function viewInfo(gallery){
currentGallery.value = gallery
isViewing.value = true;
}
function shareGallery(data){
const {gid, shortName} = data
let link
axios.post("https://downloader.lionwebsite.xyz/GalleryManage/share?userId=3&expireHour=3&gid=" + gid).then((res) => {
if(res.data.result === "success"){
let data = JSON.parse(res.data.data)
link = 'https://lionwebsite.xyz/GetFile/{0}?ShareCode={1}'.replace('{0}', encodeURIComponent(shortName)).replace('{1}', data.shareCode)
ElMessage({dangerouslyUseHTMLString: true,
message: "<span>分享成功, 过期时间:" + data.expireTime + "</span><br><a href=" + link + ">链接</a>",
duration: 0,
'show-close': true
})
navigator.clipboard.writeText(link)
}
else
ElMessage(res.data.data)
})
}
function adjustGalleryName(name, length) {
let truncated = '';
@ -432,19 +271,6 @@ function adjustGalleryName(name, length) {
return truncated;
}
function getGalleryThumb(gallery){
if(gallery.status !== '下载完成')
return ''
if(gallery.mode === 2 || gallery.mode === 3)
return 'https://downloader.lionwebsite.xyz/GalleryManage/onlineImage/0?gid=' + gallery.gid
if(gallery.thumb_link !== undefined)
return 'https://downloader.lionwebsite.xyz/GalleryManage/ehThumbnail?path=' + gallery.thumb_link
return ''
}
function isDark(){
return document.querySelector('html').classList.contains('dark')
}

View File

@ -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))
@ -104,85 +100,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')
@ -192,26 +112,17 @@ 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')
context.commit("_disCollectGallery", gid)
})
},
updateGalleryTag(context, data){
axios.post(GalleryManageUrl + "/tag?" + qs.stringify(data)).then((res) => {
ElMessage(res.data.data)
if(res.data.result === 'success')
context.commit("_updateGalleryTag", data)
})
},
deleteGallery(context, gid){
axios.delete(GalleryManageUrl, {
params:{
AuthCode:state.AuthCode,
gid
AuthCode:state.AuthCode, gid
}}).then((res) => {
if(res.data.result === "success"){
ElMessage("删除成功")
@ -221,6 +132,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) => {
@ -253,12 +175,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)
},
@ -272,6 +193,7 @@ const mutations = {
tasks.forEach((task) => {
//处理名字
task.shortName = getShortname(task.name)
task.thumb_link = GalleryManageUrl + "/ehThumbnail?path=" + task.thumb_link
//处理进度相关
switch (task.status) {
@ -283,15 +205,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 = "压缩中"
@ -301,19 +215,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)
@ -326,8 +227,7 @@ const mutations = {
state.totalGalleryTask.push(task)
})
}
else {
} else {
let tempArray = Array.from(state.totalGalleryTask)
state.totalGalleryTask.splice(0)
let preDeleteIndex
@ -390,44 +290,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
@ -478,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)
@ -524,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.chosenGallery.downloader = state.userId
state.totalGalleryTask.push(state.chosenGallery)
state.downloadGallery.push(state.chosenGallery)
@ -553,33 +373,40 @@ const mutations = {
else
state.length = state.defaultLength
},
_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
},
_openHistoryPanel(state){
state.isShowHistory = true
},
_closeHistoryPanel(state){
state.isShowHistory = false
},
_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,]
}
}
}
const state = {
totalGalleryTask: [], //存放本子数据的数组
chosenGallery: false, //准备下载的本子
thumbnailGallery: {}, //预览本子
thumbnailGallery: {}, //缩略图本子
collectGallery: [], //收藏的本子
downloadGallery: [], //下载的本子
tags: new Map(), //可用tag
isSearch: false, //用于决定是否显示搜索结果
readingGallery: {'name': '', 'images': []}, //在线看本子
isReading: false, //是否正在看
currentGid: "", //当前GID
lengthPerPage: 0, //在线预览每页图片数量
@ -714,14 +541,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()
}