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 + } } }