去除标签;修改在线看,允许未下载的本子在线看(同步更新)
This commit is contained in:
parent
83c093c4ee
commit
e50c6e6805
@ -8,24 +8,16 @@
|
||||
查询参数类型: <el-select style="width: 125px" v-model="type" @change="resetLocalQuery()">
|
||||
<el-option value="link" label="链接"/>
|
||||
<el-option value="keyword" label="关键字"/>
|
||||
<el-option value="tag" label="标签"/>
|
||||
</el-select>
|
||||
<el-input style="width: 200px;" v-model="param" v-if="type !== 'tag'">
|
||||
<el-input style="width: 200px;" v-model="param">
|
||||
<template #prepend>
|
||||
参数:
|
||||
</template>
|
||||
</el-input>
|
||||
<div v-if="type === 'tag'">
|
||||
<el-tag v-for="tid in paramForTags" closable @close="removeQueryTag(tid)">
|
||||
{{store.state.tags.get(tid).tag}}
|
||||
</el-tag>
|
||||
<el-autocomplete v-model="param" :fetch-suggestions="completeQueryTag" @select="handleTagSelect" ref="tagInput" placeholder="检索标签"/>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col>
|
||||
<el-button @click="queryRemoteTask" v-show="type === 'link'">远程查询</el-button>
|
||||
<el-button @click="queryLocalTask">当前页查询</el-button>
|
||||
<el-button @click="removeAllQueryTag" v-show="type === 'tag'">清空查询标签</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<br>
|
||||
@ -37,24 +29,22 @@
|
||||
<el-switch @click="toggleStyle" v-model="isDark">夜间模式</el-switch>
|
||||
<hr>
|
||||
<el-button @click="isQuerying = true">里站搜索</el-button>
|
||||
<el-button @click="isViewingTag = true">查看标签</el-button>
|
||||
<hr>
|
||||
<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}}<br>
|
||||
<el-space v-show="thumbnailGallery.tag !== ''">标签:{{thumbnailGallery.tag}}</el-space>
|
||||
</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="width: 300px; height: 250px" fit="contain"/>
|
||||
</picture>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-dialog title="查询本子" v-model="chosenGallery">
|
||||
<el-dialog title="查询本子" v-model="chosenGallery" style="height: 350px">
|
||||
<el-image v-show='chosenGallery.thumb_link !== undefined'
|
||||
style="float: right; width: 250px; height: 250px" fit="contain"
|
||||
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>
|
||||
@ -69,27 +59,14 @@
|
||||
</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>
|
||||
标签:<el-tag v-for="tid in paramForTags" closable @close="removeQueryTag(tid)">
|
||||
{{store.state.tags.get(tid).tag}}
|
||||
</el-tag>
|
||||
<el-autocomplete v-model="param" :fetch-suggestions="completeQueryTag" @select="handleTagSelect" ref="tagInputForSubmit"/>
|
||||
</tr>
|
||||
</table>
|
||||
<template #footer>
|
||||
<el-button @click="postTask" v-if="chosenGallery.availableResolution">下载</el-button>
|
||||
<el-button @click="removeAllQueryTag" v-if="chosenGallery.availableResolution">清空标签</el-button>
|
||||
<el-button @click="readOnlineGallery(chosenGallery)">在线预览</el-button>
|
||||
<tr v-if="chosenGallery.status === '下载完成'">
|
||||
<el-button @click="onlineGalleryReader(chosenGallery.gid)">在线预览</el-button>
|
||||
<el-button @click="showThumbnailGallery(chosenGallery)">查看封面图</el-button>
|
||||
<el-button @click="deleteGallery">删除</el-button>
|
||||
</tr>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog title="修改授权码" v-model="isAlterAuthCode">
|
||||
@ -141,33 +118,6 @@
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog title="查看标签" v-model="isViewingTag" style="margin-top: 0; width: 550px">
|
||||
<div style="text-align: center">
|
||||
输入关键字:<el-input style="width: 150px" v-model="tagKeyWord"></el-input>
|
||||
<el-button @click="tagKeyWord = ''">清空</el-button>
|
||||
<el-button @click="pullNewTag">刷新</el-button>
|
||||
</div>
|
||||
|
||||
<el-table :data="tags" height="450px" stripe>
|
||||
<el-table-column prop="id" label="id" width="50px" sortable/>
|
||||
<el-table-column prop="tag" label="标签" width="300px" sortable/>
|
||||
<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"></el-input>
|
||||
<el-button @click="postTag">创建标签</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<div class="DashBoard" v-show="!loadComplete">
|
||||
<el-input v-model="AuthCode" placeholder="请输入授权码" style="padding-top: 200px"/> <br>
|
||||
<el-checkbox v-model="isRemember">是否记住授权码</el-checkbox>
|
||||
@ -191,7 +141,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("")
|
||||
@ -201,19 +150,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
|
||||
})
|
||||
@ -224,27 +169,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
|
||||
})
|
||||
|
||||
@ -252,18 +178,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)
|
||||
@ -295,9 +209,7 @@ function postTask(){
|
||||
}
|
||||
store.dispatch("postGalleryTask",
|
||||
{link: chosenGallery.value.link,
|
||||
targetResolution: targetResolution.value,
|
||||
mode: targetDownloadMode.value,
|
||||
tags:paramForTags.value})
|
||||
targetResolution: targetResolution.value})
|
||||
targetResolution.value = ""
|
||||
}
|
||||
|
||||
@ -319,89 +231,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++){
|
||||
if(paramForTags.value[i] === tid){
|
||||
paramForTags.value.splice(i, 1)
|
||||
break
|
||||
}
|
||||
}
|
||||
if(chosenGallery.value.gid === undefined) //查询本地标签
|
||||
queryLocalTask()
|
||||
}
|
||||
|
||||
function removeAllQueryTag(){
|
||||
paramForTags.value.splice(0)
|
||||
if(chosenGallery.value.gid === undefined) //查询本地标签
|
||||
queryLocalTask()
|
||||
}
|
||||
|
||||
function handleTagSelect(data){
|
||||
if('tag' in data){ //需要新建,不知道怎么处理回调,直接把axios搬到vue里面
|
||||
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", "")
|
||||
@ -424,7 +255,7 @@ function validate(){
|
||||
}
|
||||
}
|
||||
|
||||
//验证链接以及伪装链接
|
||||
//验证链接
|
||||
function validateLink(rawLink){
|
||||
if(rawLink.trim() === "")
|
||||
return false
|
||||
@ -435,12 +266,8 @@ function validateLink(rawLink){
|
||||
}
|
||||
|
||||
//在线阅读以及展示缩略图
|
||||
function onlineGalleryReader(gid){
|
||||
store.dispatch("queryOnlineLinks", gid)
|
||||
}
|
||||
function showThumbnailGallery(gallery){
|
||||
store.commit("_changeThumbnailGallery", gallery)
|
||||
document.querySelector(".preview > img").click()
|
||||
function readOnlineGallery(gallery){
|
||||
store.dispatch("readOnlineGallery", gallery)
|
||||
}
|
||||
|
||||
//重新给节点发送未完成任务
|
||||
|
||||
@ -92,7 +92,10 @@ function close(){
|
||||
<span>页数:{{gallery.page}}</span><br>
|
||||
<span class="ct6">类型:{{gallery.type}}</span><br>
|
||||
<a :href="gallery.link">链接</a><br>
|
||||
<el-button style=" margin-left: 80%; margin-top: -5vh" @click="param=gallery.link; queryRemoteTask()">查看</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>
|
||||
</el-scrollbar>
|
||||
|
||||
@ -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)
|
||||
@ -64,7 +61,6 @@ function switch_page(target_page){
|
||||
}, 100)
|
||||
//下一页
|
||||
}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()
|
||||
@ -82,15 +78,15 @@ function set_current_page(page){
|
||||
<template>
|
||||
<el-dialog v-model="isShowUp" width="90%" style="margin-top: 0; margin-bottom: 0; padding: 0" @close="closeDialog">
|
||||
<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': store.state.imageWidth, 'padding-right': store.state.imagePadding, 'background-color': 'gary'}"
|
||||
: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-image>
|
||||
</el-scrollbar>
|
||||
|
||||
|
||||
@ -18,14 +18,11 @@
|
||||
文件大小:{{props.row.fileSize}}<br>
|
||||
分辨率:{{props.row.resolution}}<br>
|
||||
任务创建时间:{{props.row.createTimeDisplay}}<br>
|
||||
标签:{{props.row.tag === '' ? '无': props.row.tag}} <br>
|
||||
<span v-show="isLion">
|
||||
downloader:{{props.row.downloader}}
|
||||
</span>
|
||||
|
||||
<el-button @click="deleteGallery(props.row.gid)" :disabled="props.row.status !== '下载完成'">删除</el-button>
|
||||
<el-button @click="editGalleryTag(props.row)">编辑标签</el-button>
|
||||
<el-button @click="shareGallery({gid:props.row.gid, shortName:props.row.shortName + '.zip'})" v-show="isLion" :disabled="props.row.status !== '下载完成'">分享</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
@ -40,7 +37,7 @@
|
||||
<span>
|
||||
<el-button @click="downloadTask(scoped.row.download)" :disabled="scoped.row.status !== '下载完成' || scoped.row.mode === 2">下载</el-button>
|
||||
<el-button @click="changeGalleryCollect(scoped.row.gid, scoped.row.isCollect)">{{scoped.row.isCollect ? '取消收藏' : '收藏'}}</el-button>
|
||||
<el-button @click="onlineGalleryReader(scoped.row)" :disabled="scoped.row.status !== '下载完成' || scoped.row.mode === 1">在线看</el-button>
|
||||
<el-button @click="readOnlineGallery(scoped.row)" :disabled="scoped.row.status !== '下载完成' || scoped.row.mode === 1">在线看</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@ -92,24 +89,7 @@
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
|
||||
<el-dialog v-model="isEditingTag" title="编辑本子标签">
|
||||
<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>
|
||||
|
||||
<OnlineReader :current-gallery="currentGallery" :isOnlineReading="isOnlineReading" @close="isOnlineReading = false"/>
|
||||
<OnlineReader/>
|
||||
|
||||
<span v-show="!loadComplete" class="side">请输入授权码后再查看</span>
|
||||
</div>
|
||||
@ -122,27 +102,18 @@ 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 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 onlineReadingScrollbar = ref(null)
|
||||
|
||||
//防抖计时器
|
||||
let debounceTimer = 0
|
||||
//是否加载完成
|
||||
@ -175,21 +146,6 @@ let emptyText = computed(() => {
|
||||
return '您未' + action + "本子"
|
||||
})
|
||||
|
||||
//在线预览相关
|
||||
let currentGallery = ref({name:"name"})
|
||||
let imageWidth = computed(() => {
|
||||
return store.state.imageWidth
|
||||
})
|
||||
let imagePadding = computed(() => {
|
||||
return store.state.imagePadding
|
||||
})
|
||||
|
||||
//标签
|
||||
let tags = computed(() => {
|
||||
return store.state.tags
|
||||
})
|
||||
let newTag = ref("")
|
||||
|
||||
//翻页
|
||||
function next() {
|
||||
if(targetPage.value < max.value) {
|
||||
@ -234,67 +190,13 @@ 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
|
||||
}else{
|
||||
console.log("id:", id, key)
|
||||
}
|
||||
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 mark(gid, tid){
|
||||
store.dispatch("mark", {gid, tid})
|
||||
}
|
||||
|
||||
function disMark(gid, tid){
|
||||
store.dispatch("disMark", {gid, tid})
|
||||
}
|
||||
|
||||
//下载,删除,在线看
|
||||
function downloadTask(link){
|
||||
@ -303,27 +205,8 @@ function downloadTask(link){
|
||||
function deleteGallery(gid){
|
||||
store.dispatch("deleteGallery", gid)
|
||||
}
|
||||
function onlineGalleryReader(gallery){
|
||||
currentGallery.value = gallery
|
||||
isOnlineReading.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 readOnlineGallery(gallery){
|
||||
store.dispatch("readOnlineGallery", gallery)
|
||||
}
|
||||
|
||||
//显示缩略图
|
||||
|
||||
@ -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()
|
||||
@ -67,7 +66,6 @@ const actions = {
|
||||
}).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
|
||||
}
|
||||
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
|
||||
@ -706,13 +540,3 @@ function deleteTask(tasks, key, value){
|
||||
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()
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user