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

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
+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;