是否记住授权码
@@ -145,17 +186,19 @@ import store from "../store";
import {computed, ref, onMounted} from "vue";
import {ElMessage} from "element-plus"
import axios from "axios";
+import qs from "qs";
//授权码相关
let AuthCode = ref("")
let isRemember = ref(false)
let isAlterAuthCode = ref(false)
-let isConfigDarkMode = ref(false)
-let isDark = ref(false)
let newAuthCode = ref("")
let tempAuthCode = ref("")
let isQuerying = ref(false)
+let isViewingTag = ref(false)
+let isConfigDarkMode = ref(false)
+let isDark = ref(false)
let keyword = ref("")
let galleries = ref([])
let queryPage = ref({})
@@ -164,15 +207,19 @@ let darkConfig = ref({})
//查询相关
let type = ref("link")
let param = ref("")
+let paramForTags = ref([]) //tidS
let targetResolution = 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
})
@@ -182,11 +229,40 @@ 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(() => {
return store.state.thumbnailGallery
})
+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)
@@ -204,7 +280,7 @@ function queryWeekUsedAmount(){
}
//提交任务
function postTask(){
- if(!validateLink(param.value)){
+ if(!validateLink(chosenGallery.value.link)){
ElMessage("链接错误")
return
}
@@ -212,11 +288,11 @@ function postTask(){
ElMessage("请选择分辨率再提交")
return
}
- let tempLink = coverLink(param.value)
+ let tempLink = coverLink(chosenGallery.value.link)
store.dispatch("postGalleryTask",
{link: tempLink,
targetResolution: targetResolution.value,
- tag:tag.value})
+ tags:paramForTags.value})
targetResolution.value = ""
}
@@ -238,10 +314,89 @@ function queryLocalTask(){
store.commit("_searchLocalByKeyword", param.value)
break
case "tag":
- store.commit("_searchLocalByTag", param.value.includes(",") ? param.value.split(","): [param.value])
+ 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 && chosenGallery.value.gid !== undefined && !hit){ //未命中结果并且准备与下载任务一并提交
+ result.push({value: '新建 #' + keyWord + ' 标签?', tag:keyWord})
+ }
+ cb(result)
+}
+
+function removeQueryTag(tid){
+ for (let i=0; i
{
+ 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", "")
param.value = ""
diff --git a/src/components/Side.vue b/src/components/Side.vue
index c698249..47786bd 100644
--- a/src/components/Side.vue
+++ b/src/components/Side.vue
@@ -23,7 +23,7 @@
删除
- 编辑标签
+ 编辑标签
更新
分享
@@ -95,20 +95,20 @@
-