From f94e8f0bece4069520187a9ded0a735565ae3ff1 Mon Sep 17 00:00:00 2001
From: buvta <12312540+buvta@users.noreply.github.com>
Date: Sat, 31 Oct 2020 15:04:27 +0800
Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=86=99Film.vue=E6=90=9C=E7=B4=A2?=
=?UTF-8?q?=E6=A1=86=EF=BC=8C=E9=A2=84=E5=A4=87=E6=94=AF=E6=8C=81=E5=88=86?=
=?UTF-8?q?=E7=BB=84=E6=90=9C=E7=B4=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/Film.vue | 126 ++++++++++++++++++++++++++++-----------
src/lib/element/index.js | 3 +-
2 files changed, 94 insertions(+), 35 deletions(-)
diff --git a/src/components/Film.vue b/src/components/Film.vue
index 93ae7ec..6604267 100644
--- a/src/components/Film.vue
+++ b/src/components/Film.vue
@@ -17,15 +17,25 @@
:value="item.name">
-
@@ -208,7 +218,6 @@ export default {
site: false,
class: false,
classList: false,
- search: false,
find: false
},
sites: [],
@@ -224,6 +233,8 @@ export default {
searchList: [],
searchTxt: '',
searchContents: [],
+ searchGroup: '',
+ searchGroups: [],
// 福利片关键词
r18KeyWords: ['伦理', '论理', '倫理', '福利', '激情', '理论', '写真', '情色', '美女', '街拍', '赤足', '性感', '里番']
}
@@ -265,8 +276,13 @@ export default {
this.SET_SHARE(val)
}
},
- setting () {
- return this.$store.getters.getSetting
+ setting: {
+ get () {
+ return this.$store.getters.getSetting
+ },
+ set (val) {
+ this.SET_SETTING(val)
+ }
},
filterSettings () {
return this.$store.getters.getSetting.excludeR18Films // 需要监听的数据
@@ -283,17 +299,31 @@ export default {
this.changeView()
},
searchTxt () {
- this.searchChangeEvent()
+ if (this.searchTxt === '清除历史记录...') {
+ this.clearSearchHistory()
+ this.searchTxt = ''
+ this.searchChangeEvent()
+ }
},
filterSettings () {
this.siteClick(this.site.name)
}
},
methods: {
- ...mapMutations(['SET_VIEW', 'SET_DETAIL', 'SET_VIDEO', 'SET_SHARE']),
+ ...mapMutations(['SET_VIEW', 'SET_DETAIL', 'SET_VIDEO', 'SET_SHARE', 'SET_SETTING']),
sortByLocaleCompare (a, b) {
return a.localeCompare(b, 'zh')
},
+ dateFormat (row, column) { // 先留着,"最近更新"到底要不要?
+ var date = row[column.property]
+ if (date === undefined) {
+ return ''
+ }
+ return date.split(/\s/)[0]
+ },
+ getFilters (column) {
+ return [...new Set(this.searchContents.map(row => row[column]))].map(e => { return { text: e, value: e } })
+ },
siteClick (siteName) {
this.list = []
this.site = this.sites.find(x => x.name === siteName)
@@ -494,28 +524,59 @@ export default {
}
}
},
- getAllSearch () {
- search.all().then(res => {
- this.searchList = res.reverse()
- })
+ querySearch (queryString, cb) {
+ if (this.searchList.length === 0) return
+ var searchList = this.searchList.slice(0, -1)
+ var results = queryString ? searchList.filter(this.createFilter(queryString)) : this.searchList
+ // 调用 callback 返回建议列表的数据
+ cb(results)
},
- searchEvent (wd) {
- this.searchAllSitesEvent(this.sites, wd)
+ createFilter (queryString) {
+ return (item) => {
+ return (item.keywords.toLowerCase().indexOf(queryString.toLowerCase()) === 0)
+ }
},
- searchAllSitesEvent (sites, wd) {
- this.searchTxt = wd
- this.searchContents = []
- this.pagecount = 0
- this.show.search = false
- this.show.find = true
- this.statusText = ' '
+ addSearchRecord () {
+ const wd = this.searchTxt
if (wd) {
search.find({ keywords: wd }).then(res => {
if (!res) {
search.add({ keywords: wd })
}
- this.getAllSearch()
+ this.getSearchHistory()
})
+ }
+ },
+ clearSearchHistory () {
+ search.clear().then(res => {
+ this.getSearchHistory()
+ })
+ },
+ getSearchHistory () {
+ search.all().then(res => {
+ this.searchList = res.reverse()
+ this.searchList.push({ id: this.searchList.length + 1, keywords: '清除历史记录...' })
+ })
+ },
+ searchEvent () {
+ const wd = this.searchTxt
+ this.setting.searchAllSites = this.searchGroup === '全部'
+ if (this.setting.searchAllSites) {
+ this.searchAllSitesEvent(this.sites, wd)
+ } else {
+ this.searchSingleSiteEvent(this.site, wd)
+ }
+ },
+ searchAndRecord () {
+ this.addSearchRecord()
+ this.searchEvent()
+ },
+ searchAllSitesEvent (sites, wd) {
+ this.searchContents = []
+ this.pagecount = 0
+ this.show.find = true
+ this.statusText = ' '
+ if (wd) {
sites.forEach(site => {
zy.search(site.key, wd).then(res => {
const type = Object.prototype.toString.call(res)
@@ -557,11 +618,6 @@ export default {
sites.push(this.site)
this.searchAllSitesEvent(sites, wd)
},
- clearSearch () {
- search.clear().then(res => {
- this.getAllSearch()
- })
- },
searchChangeEvent () {
if (this.searchTxt.length >= 1) {
this.show.class = false
@@ -588,11 +644,13 @@ export default {
}
}
})
+ this.searchGroups = ['站内', '全部']
+ this.searchGroup = this.setting.searchAllSites ? '全部' : '站内'
}
},
created () {
this.getAllSites()
- this.getAllSearch()
+ this.getSearchHistory()
},
mounted () {
window.addEventListener('resize', () => {
diff --git a/src/lib/element/index.js b/src/lib/element/index.js
index 8bf727b..a4dce1e 100644
--- a/src/lib/element/index.js
+++ b/src/lib/element/index.js
@@ -1,5 +1,5 @@
import Vue from 'vue'
-import { Message, Button, Table, TableColumn, Tag, Input, Dialog, Form, FormItem, Switch, Select, Option, Checkbox } from 'element-ui'
+import { Message, Button, Table, TableColumn, Tag, Input, Dialog, Form, FormItem, Switch, Select, Option, Checkbox, Autocomplete } from 'element-ui'
import Plugin from 'v-fit-columns'
Vue.use(Button)
Vue.use(Table)
@@ -14,4 +14,5 @@ Vue.use(Plugin)
Vue.use(Select)
Vue.use(Option)
Vue.use(Checkbox)
+Vue.use(Autocomplete)
Vue.prototype.$message = Message