diff --git a/src/components/EditSites.vue b/src/components/EditSites.vue index f31e70d..51f0d14 100644 --- a/src/components/EditSites.vue +++ b/src/components/EditSites.vue @@ -13,7 +13,7 @@
- + 保存
@@ -33,13 +33,13 @@ + label="启用"> @@ -49,9 +49,6 @@ :filters="getFilters" :filter-method="filterHandle" filter-placement="bottom-end"> - 置顶 编辑 - 检测 + + 检测 删除 @@ -142,18 +140,14 @@ export default { ], api: [ { required: true, message: 'API地址不能为空', trigger: 'blur' } - ], - download: [ - { required: false, trigger: 'blur' } ] }, enableBatchEdit: false, batchGroupName: '', batchIsActive: 1, multipleSelection: [], - tableKey: 1, checkAllSiteLoading: false, - editeOldkey: '' + editOldkey: '' } }, computed: { @@ -219,9 +213,6 @@ export default { sites: res } }) - for (const i of this.sites) { - delete i.status - } }, getSitesGroup () { const arr = [] @@ -254,7 +245,7 @@ export default { this.dialogType = 'edit' this.dialogVisible = true this.siteInfo = siteInfo - this.editeOldkey = siteInfo.key + this.editOldkey = siteInfo.key }, closeDialog () { this.dialogVisible = false @@ -271,19 +262,8 @@ export default { this.$message.warning('删除源失败, 错误信息: ' + err) }) }, - listUpdatedEvent () { - sites.clear().then(res1 => { - // 重新排序 - var id = 1 - this.sites.forEach(element => { - element.id = id - sites.add(element) - id += 1 - }) - }) - }, checkSiteKey (e) { - if (this.dialogType === 'edit' && this.editeOldkey === this.siteInfo.key) { + if (this.dialogType === 'edit' && this.editOldkey === this.siteInfo.key) { return true } else { for (const i of this.sites) { @@ -326,7 +306,7 @@ export default { this.dialogVisible = false this.getSites() }) - this.editeOldkey = '' + this.editOldkey = '' }, exportSites () { this.getSites() @@ -400,7 +380,8 @@ export default { } }, isActiveChangeEvent (row) { - this.updateDatabase() + sites.remove(row.id) + sites.add(row) }, resetId (inArray) { var id = 1 @@ -437,23 +418,13 @@ export default { }, async checkAllSite () { this.checkAllSiteLoading = true - for (const i of this.sites) { - i.status = '' - this.tableKey = Math.random() - const flag = await zy.check(i.key) - if (flag) { - i.status = '可用' - } else { - i.status = '失效' - i.isActive = 0 - } - this.tableKey = Math.random() - } - this.checkAllSiteLoading = false - this.updateDatabase() + Promise.all(this.sites.map(site => this.checkSingleSite(site))).then(res => { + this.checkAllSiteLoading = false + this.getSites() + }) }, - async checkSimpleSite (row) { - this.checkAllSiteLoading = true + async checkSingleSite (row) { + row.status = ' ' const flag = await zy.check(row.key) if (flag) { row.status = '可用' @@ -461,14 +432,13 @@ export default { row.status = '失效' row.isActive = 0 } - this.updateDatabase() - this.tableKey = Math.random() - this.checkAllSiteLoading = false + sites.remove(row.id) + sites.add(row) + return row.status } }, mounted () { this.rowDrop() - this.checkAllSiteLoading = false }, created () { this.getSites() diff --git a/src/components/Film.vue b/src/components/Film.vue index 0a14ced..54a68cf 100644 --- a/src/components/Film.vue +++ b/src/components/Film.vue @@ -71,6 +71,7 @@
- - - - - - - - - - - - - - - - - - + :data="searchContents.filter(res => !setting.excludeR18Films || (res.type !== undefined && !containsR18Keywords(res.type)))" + height="100%" + row-key="id" + :empty-text="statusText" + @row-click="(row) => detailEvent(row.site, row)" + style="width: 100%"> + + + + + + + + + + + + + + + + + +
@@ -213,6 +215,7 @@ export default { type: {}, pagecount: 0, list: [], + statusText: ' ', infiniteId: +new Date(), searchList: [], searchTxt: '', @@ -261,9 +264,6 @@ export default { setting () { return this.$store.getters.getSetting }, - sitesList () { - return this.$store.getters.getEditSites.sites // 需要监听的数据 - }, filterSettings () { return this.$store.getters.getSetting.excludeR18Films // 需要监听的数据 } @@ -281,9 +281,6 @@ export default { searchTxt () { this.searchChangeEvent() }, - sitesList () { - this.getAllsites() - }, filterSettings () { this.siteClick(this.site) } @@ -370,8 +367,10 @@ export default { const key = this.site.key const type = this.type.tid const page = this.pagecount - if (page < 1) { + this.statusText = ' ' + if (key && page < 1) { // OK资源前几类硬是去不掉 $state.complete() + this.statusText = '暂无数据' return false } zy.list(key, page, type).then(res => { @@ -391,6 +390,7 @@ export default { $state.loaded() } else { $state.complete() + this.statusText = '暂无数据' } }) }, @@ -478,6 +478,7 @@ export default { }, changeView () { if (this.view === 'Film') { + this.getAllsites() if (this.setting.view === 'picture') { this.$refs.filmWaterfall.refresh() this.getPage().then(() => { @@ -504,6 +505,7 @@ export default { this.pagecount = 0 this.show.search = false this.show.find = true + this.statusText = ' ' if (wd) { search.find({ keywords: wd }).then(res => { if (!res) { @@ -519,6 +521,7 @@ export default { zy.detail(site.key, element.id).then(detailRes => { detailRes.site = site this.searchContents.push(detailRes) + this.statusText = '暂无数据' }) }) } @@ -526,6 +529,7 @@ export default { zy.detail(site.key, res.id).then(detailRes => { detailRes.site = site this.searchContents.push(detailRes) + this.statusText = '暂无数据' }) } }) @@ -580,6 +584,7 @@ export default { } }, created () { + this.getAllsites() this.getAllSearch() } } diff --git a/src/lib/site/tools.js b/src/lib/site/tools.js index 36c6ab3..effdceb 100644 --- a/src/lib/site/tools.js +++ b/src/lib/site/tools.js @@ -3,6 +3,62 @@ import axios from 'axios' import parser from 'fast-xml-parser' import cheerio from 'cheerio' +// 请求超时时限 +axios.defaults.timeout = 5000 + +// 重试次数,共请求3次 +axios.defaults.retry = 2 + +// 请求的间隙 +axios.defaults.retryDelay = 1000 + +// 添加请求拦截器(配置发送请求的信息) +axios.interceptors.request.use(function (config) { + // 处理请求之前的配置 + // 引入代理,播放器代理怎么搞? + return config +}, function (error) { + // 请求失败的处理 + return Promise.reject(error) +}) + +// 添加响应拦截器 +axios.interceptors.response.use(function (response) { + // 对响应数据做些事 + if (response.status && response.status === 200 && response.request.responseURL.includes('api.php') && !response.data.startsWith('= config.retry) { + err.message = '多次请求均超时' + return Promise.reject(err) + } + + config.__retryCount += 1 + + var backoff = new Promise(function (resolve) { + setTimeout(function () { + resolve() + }, config.retryDelay || 1) + }) + + return backoff.then(function () { + return axios(config) + }) + } else { + if (err && !err.response) { + err.message = '连接服务器失败!' + } + return Promise.reject(err) + } +}) + const zy = { xmlConfig: { // XML 转 JSON 配置 trimValues: true,