移除"搜索所有资源"开关,搜索变总是搜索所有资源

This commit is contained in:
haiyangcui
2020-11-09 18:25:19 +01:00
parent 9b5aae095e
commit 843a8dd1fc
5 changed files with 37 additions and 39 deletions

View File

@@ -140,9 +140,7 @@
prop="name"
label="片名">
</el-table-column>
<el-table-column v-if="setting.searchAllSites"
sortable
:sort-method="(a , b) => sortByLocaleCompare(a.site.name, b.site.name)"
<el-table-column
prop="site"
label="源站"
width="120">
@@ -299,17 +297,13 @@ export default {
siteClick (siteName) {
this.list = []
this.site = this.sites.find(x => x.name === siteName)
this.show.site = false
if (this.searchTxt.length > 0) {
this.searchSingleSiteEvent(this.site, this.searchTxt)
} else {
this.classList = []
this.type = {}
this.getClass().then(res => {
this.infiniteId += 1
this.classClick(this.classList[0].name)
})
}
this.classList = []
this.type = {}
this.searchTxt = ''
this.getClass().then(res => {
this.infiniteId += 1
this.classClick(this.classList[0].name)
})
},
classClick (className) {
this.show.classList = false
@@ -504,11 +498,7 @@ export default {
})
},
searchEvent (wd) {
if (this.setting.searchAllSites) {
this.searchAllSitesEvent(this.sites, wd)
} else {
this.searchSingleSiteEvent(this.site, wd)
}
this.searchAllSitesEvent(this.sites, wd)
},
searchAllSitesEvent (sites, wd) {
this.searchTxt = wd

View File

@@ -29,7 +29,7 @@
</el-select>
<el-button :loading="loading" @click.stop="updateEvent" icon="el-icon-refresh">更新推荐</el-button>
</div>
<div class="listpage-body" id="recommendataions-body" >
<div class="listpage-body" id="recommendataions-body" infinite-wrapper>
<div class="show-table" id="star-table" v-show="viewMode === 'list'">
<el-table size="mini" fit height="100%" row-key="id"
ref="recommendataionsTable"
@@ -67,9 +67,8 @@
</el-table-column>
<el-table-column
label="操作"
header-align="center"
align="right"
width="200">
header-align="right"
align="right">
<template slot-scope="scope">
<el-button @click.stop="playEvent(scope.row)" type="text">播放</el-button>
<el-button @click.stop="shareEvent(scope.row)" type="text">分享</el-button>
@@ -80,7 +79,7 @@
</el-table>
</div>
<div class="show-picture" id="star-picture" v-show="viewMode === 'picture'">
<Waterfall ref="recommendataionsWaterfall" :list="filteredRecommendations" :gutter="20" :width="240"
<Waterfall ref="recommendataionsWaterfall" :list="loadedRecommendations" :gutter="20" :width="240"
:breakpoints="{
1200: { //当屏幕宽度小于等于1200
rowPerView: 4,
@@ -120,6 +119,7 @@
</div>
</template>
</Waterfall>
<infinite-loading force-use-infinite-wrapper :identifier="infiniteId" @infinite="infiniteHandler"></infinite-loading>
</div>
</div>
</div>
@@ -129,12 +129,14 @@ import { mapMutations } from 'vuex'
import { history, recommendation, setting } from '../lib/dexie'
import zy from '../lib/site/tools'
import Waterfall from 'vue-waterfall-plugin'
import InfiniteLoading from 'vue-infinite-loading'
const { clipboard } = require('electron')
export default {
name: 'recommendations',
data () {
return {
recommendations: [],
loadedRecommendations: [],
sites: [],
viewMode: 'picture',
loading: false,
@@ -143,11 +145,14 @@ export default {
areas: [],
selectedAreas: [],
sortKeyword: '',
sortKeywords: ['上映', '评分', '默认']
sortKeywords: ['上映', '评分', '默认'],
infiniteId: +new Date(),
batchSize: 50
}
},
components: {
Waterfall
Waterfall,
InfiniteLoading
},
computed: {
view: {
@@ -183,7 +188,7 @@ export default {
}
},
filteredRecommendations () {
var filteredData = this.recommendations.filter(x => (this.selectedAreas.length === 0) || this.selectedAreas.includes(x.detail.area))
var filteredData = this.loadedRecommendations.filter(x => (this.selectedAreas.length === 0) || this.selectedAreas.includes(x.detail.area))
filteredData = filteredData.filter(x => (this.selectedTypes.length === 0) || this.selectedTypes.includes(x.detail.type))
return filteredData
}
@@ -219,6 +224,18 @@ export default {
},
methods: {
...mapMutations(['SET_VIEW', 'SET_DETAIL', 'SET_VIDEO', 'SET_SHARE']),
infiniteHandler ($state) {
console.log('infiniteHandler' + this.loadedRecommendations.length)
if (this.loadedRecommendations.length === this.recommendations.length) {
console.log('complete')
$state.complete()
} else {
var nextBatch = this.recommendations.slice(this.loadedRecommendations.length, this.loadedRecommendations.length + this.batchSize)
this.loadedRecommendations.push(...nextBatch)
$state.loaded()
console.log('loaded' + this.loadedRecommendations.length)
}
},
detailEvent (e) {
this.detail = {
show: true,
@@ -323,6 +340,8 @@ export default {
this.recommendations = res.sort(function (a, b) {
return b.id - a.id
})
this.loadedRecommendations = this.recommendations.slice(0, this.batchSize)
this.infiniteId += 1
this.getFilterData()
})
},

View File

@@ -56,12 +56,6 @@
/右方向键:<input style="width:50px" type="number" v-model = "d.forwardTimeInSec" @change="updateSettingEvent">
</div>
</div>
<div class='search'>
<div class="title">搜索</div>
<div class="zy-input" @click="toggleSearchAllSites">
<input type="checkbox" v-model = "d.searchAllSites" @change="updateSettingEvent"> 搜索所有资源
</div>
</div>
<div class='site'>
<div class="title">第三方播放</div>
<div class="site-box">
@@ -249,10 +243,6 @@ export default {
this.setting = this.d
setting.update(this.d)
},
toggleSearchAllSites () {
this.d.searchAllSites = !this.d.searchAllSites
this.updateSettingEvent()
},
toggleExcludeRootClasses () {
this.d.excludeRootClasses = !this.d.excludeRootClasses
this.updateSettingEvent()

View File

@@ -6,7 +6,7 @@ const db = new Dexie('zy')
db.version(4).stores({
search: '++id, keywords',
iptvSearch: '++id, keywords',
setting: 'id, theme, site, shortcut, view, externalPlayer, searchAllSites, excludeRootClasses, excludeR18Films, forwardTimeInSec, starViewMode, recommendationViewMode, historyViewMode, password',
setting: 'id, theme, site, shortcut, view, externalPlayer, excludeRootClasses, excludeR18Films, forwardTimeInSec, starViewMode, recommendationViewMode, historyViewMode, password',
shortcut: 'name, key, desc',
star: '++id, [key+ids], site, name, detail, index, rate, hasUpdate',
recommendation: '++id, [key+ids], site, name, detail, index, rate, hasUpdate',

View File

@@ -5,7 +5,6 @@ const setting = [
shortcut: true,
view: 'picture',
externalPlayer: '',
searchAllSites: true,
excludeRootClasses: true,
excludeR18Films: true,
forwardTimeInSec: 5,