From 72790f5f3ec618c6030b57335ec0a10b9d7173ca Mon Sep 17 00:00:00 2001 From: Hunlongyu Date: Wed, 28 Oct 2020 11:59:55 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=91=20=E6=B7=BB=E5=8A=A0=E4=BA=86?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=BA=90=E6=A3=80=E6=B5=8B=E5=8A=9F=E8=83=BD?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/scss/style.scss | 3 +++ src/components/EditSites.vue | 31 ++++++++++++++++++++++++++++++- src/lib/site/tools.js | 12 ++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/assets/scss/style.scss b/src/assets/scss/style.scss index 188b857..b50d81d 100644 --- a/src/assets/scss/style.scss +++ b/src/assets/scss/style.scss @@ -228,6 +228,9 @@ cursor: pointer; } } + .is-loading:before { + background-color: none; + } .el-input{ width: 200px; } diff --git a/src/components/EditSites.vue b/src/components/EditSites.vue index 876c2e3..a319270 100644 --- a/src/components/EditSites.vue +++ b/src/components/EditSites.vue @@ -6,6 +6,7 @@ 新增 导出 导入 + 检测 清空 重置 @@ -20,6 +21,7 @@ ref="editSitesTable" size="mini" fit height="100%" row-key="id" :data="sites" + :key="tableKey" @selection-change="handleSelectionChange" @sort-change="handleSortChange"> {{scope.row.group}} + + + import { mapMutations } from 'vuex' import { sites } from '../lib/dexie' +import zy from '../lib/site/tools' import { remote } from 'electron' import { sites as defaultSites } from '../lib/dexie/initData' import fs from 'fs' @@ -132,7 +144,9 @@ export default { enableBatchEdit: false, batchGroupName: '', batchIsActive: 1, - multipleSelection: [] + multipleSelection: [], + tableKey: 1, + checkSiteLoading: false } }, computed: { @@ -365,6 +379,21 @@ export default { _this.updateDatabase() } }) + }, + async checkSite () { + this.checkSiteLoading = true + for (const i of this.sites) { + i.status = 'loading' + this.tableKey = Math.random() + const flag = await zy.check(i.key) + if (flag) { + i.status = '可用' + } else { + i.status = '失效' + } + this.tableKey = Math.random() + } + this.checkSiteLoading = false } }, mounted () { diff --git a/src/lib/site/tools.js b/src/lib/site/tools.js index 3bfc384..1152a14 100644 --- a/src/lib/site/tools.js +++ b/src/lib/site/tools.js @@ -193,6 +193,18 @@ const zy = { } }) }) + }, + async check (key, id) { + try { + const cls = await this.class(key) + if (cls) { + return true + } else { + return false + } + } catch (e) { + return false + } } }