加入标签搜索,优化搜索逻辑以及代码,加入部分注释,抽取简短名称的处理函数(同步更新)

This commit is contained in:
chuzhongzai
2022-12-30 12:51:14 +08:00
parent 9aca694f68
commit 69d45dd6ef
3 changed files with 373 additions and 419 deletions
+164 -179
View File
@@ -3,24 +3,29 @@
<span>E站额度本周已用:{{weekUsed.weekUsedAmount}} 上次重置时间:{{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>
<hr>
<br>
<el-input v-model="keyword" placeholder="输入关键字"/>
<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>
<hr>
<el-button @click="isAlterAuthCode = true">修改授权码</el-button>
<hr>
<div v-show="thumbnailGallery !== {}">
<span>
{{thumbnailGallery.shortName}}
{{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.url,]" :initial-index="0" class="preview"></el-image>
@@ -98,186 +103,167 @@
</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 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 chosenVideo = computed(() => {
return store.state.chosenVideo
})
let type = ref("link")
let param = ref("")
let loadComplete = computed(() => {
return store.state.loadComplete
})
let targetResolution = ref("")
let maskDomain = computed(() => {
return store.state.maskDomain
})
let realAuthCode = computed(() => {
return store.state.AuthCode
})
let weekUsed = computed(() => {
return store.state.weekUsed
})
let chosenGallery = computed(() => {
return store.state.chosenGallery
})
let chosenVideo = computed(() => {
return store.state.chosenVideo
})
let thumbnailGallery = computed(() => {
return store.state.thumbnailGallery
})
let loadComplete = computed(() => {
return store.state.loadComplete
})
let maskDomain = computed(() => {
return store.state.maskDomain
})
let weekUsed = computed(() => {
return store.state.weekUsed
})
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 thumbnailGallery = computed(() => {
return store.state.thumbnailGallery
})
function queryWeekUsedAmount(){
store.dispatch("loadWeekUsedAmount")
}
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 = ""
}
}
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(!validateLink(link.value)){
ElMessage("请检查输入的链接")
}
else {
store.dispatch("searchByLink", link.value)
}
}
function searchLocalByKeyword(){
console.log(keyword.value)
store.dispatch("searchLocalByKeyword",keyword.value)
}
function searchRemoteByKeyword(){
store.dispatch("searchRemoteByKeyword", keyword.value)
}
function onlineGalleryReader(name){
window.open("http://zfile.lionwebsite.xyz/1/gallery/" + encodeURI(name))
}
function showThumbnailGallery(gallery){
store.commit("_changeThumbnailGallery", gallery)
document.querySelector(".preview > img").click()
}
onMounted(() => {
const auth = localStorage.getItem("auth")
if(auth !== null){
store.dispatch("validate", auth)
AuthCode.value = localStorage.getItem("auth")
}
})
return {postTask, queryTask, validate, searchByLink, searchLocalByKeyword, searchRemoteByKeyword,
queryWeekUsedAmount, deleteVideo, deleteGallery, onlineGalleryReader, showThumbnailGallery, alterAuthCode,
link, loadComplete, AuthCode, realAuthCode, keyword, isRemember, chosenGallery, chosenVideo, targetResolution, weekUsed,
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 onlineGalleryReader(name){
window.open("http://zfile.lionwebsite.xyz/1/gallery/" + encodeURI(name))
}
function showThumbnailGallery(gallery){
store.commit("_changeThumbnailGallery", gallery)
document.querySelector(".preview > img").click()
}
onMounted(() => {
const auth = localStorage.getItem("auth")
if(auth !== null){
store.dispatch("validate", auth)
AuthCode.value = localStorage.getItem("auth")
}
})
</script>
<style scoped>
@@ -287,7 +273,6 @@ export default {
background-color: ghostwhite;
text-align: center;
}
.el-input{
width: 300px;
}
+143 -157
View File
@@ -133,173 +133,158 @@
</div>
</template>
<script>
<script setup>
import store from "../store";
import {computed, ref} from "vue";
export default {
name: "Side",
setup(){
let inputNode = ref(null)
let isEditingPage = ref(false)
let isEditingTag = ref(false)
let tempTag = ref("")
let tempGid = ref("")
let showNameType = ref("shortName") // shortName name
let showType = ref("gallery") // gallery video collect
let sortType = ref("shortName") // shortName name createTime
let targetPage = ref(1)
let debounceTimer = 0
let loadComplete = computed(() => {
return store.state.loadComplete
})
//输入
let inputNode = ref(null)
//是否正在编辑页数
let isEditingPage = ref(false)
//是否正在编辑标签
let isEditingTag = ref(false)
//临时变量
let tempTag = ref("")
let tempGid = ref("")
let galleryTasks = computed(() => {
return store.getters.galleryTasks ? store.getters.galleryTasks: null
})
let videoTasks = computed(() => {
return store.getters.videoTasks ? store.getters.videoTasks: null
})
let showNameType = ref("shortName") // shortName name
let showType = ref("gallery") // gallery video collect
let sortType = ref("shortName") // shortName name createTime
let targetPage = ref(1)
let isShowVideoHistory = computed(() => {
return store.state.showType === "video"
})
//防抖计时器
let debounceTimer = 0
//是否加载完成
let loadComplete = computed(() => {
return store.state.loadComplete
})
let isShowGalleryHistory = computed(() => {
return store.state.showType === "gallery" || store.state.showType === "collect"
})
let galleryTasks = computed(() => {
return store.getters.galleryTasks ? store.getters.galleryTasks: null
})
let videoTasks = computed(() => {
return store.getters.videoTasks ? store.getters.videoTasks: null
})
let min = computed(() => {
return store.getters.min
})
let isShowVideoHistory = computed(() => {
return store.state.showType === "video"
})
let isShowGalleryHistory = computed(() => {
return store.state.showType === "gallery" || store.state.showType === "collect"
})
let max = computed(() => {
if(targetPage.value > store.getters.max)
store.commit("_changePage", store.getters.max)
return store.getters.max
})
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
})
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(){
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 reverseEditMode(){
isEditingPage.value = !isEditingPage.value
if(isEditingPage.value){
inputNode.value.focus()
}
targetPage.value = page.value
}
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){
if(gallery.download !== undefined)
clearTimeout(debounceTimer)
debounceTimer = setTimeout(() => {
store.commit("_changeThumbnailGallery", gallery)
}, 500)
}
return {galleryTasks, videoTasks, min, max, targetPage, loadComplete, page, isEditingPage, isEditingTag, inputNode, isShowVideoHistory,
isShowGalleryHistory, showType, showNameType, sortType, tempTag, tempGid,
reverseEditMode, changePage, changeShowType, changeShowNameType, changeSortType, changeCollect, toMax, toMin, previous, next, downloadTask, deleteGallery,
deleteVideo, onlineGalleryReader, onlineVideoViewer, showThumbnail, editTag, submitTag,
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.value){
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){
if(gallery.download !== undefined)
clearTimeout(debounceTimer)
debounceTimer = setTimeout(() => {
store.commit("_changeThumbnailGallery", gallery)
}, 500)
}
</script>
<style scoped>
@@ -311,8 +296,9 @@ export default {
display: block;
}
.pageChanger{
position: absolute;
top: 85vh;
/*position: absolute;*/
/*top: 85vh;*/
margin-top: 5vh;
}
.el-select{
width: 125px;