From 6a0699ec202af84b2fb101768eb5e6cb3e97dbf1 Mon Sep 17 00:00:00 2001 From: haiyangcui Date: Sun, 11 Oct 2020 14:30:59 +0200 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=BA=90=E7=BD=AE=E9=A1=B6?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/EditSites.vue | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/components/EditSites.vue b/src/components/EditSites.vue index ecf919c..fd4b83a 100644 --- a/src/components/EditSites.vue +++ b/src/components/EditSites.vue @@ -12,7 +12,7 @@
导入
-
重置
+
重置
@@ -49,6 +49,7 @@
  • {{i.name}} + 置顶 编辑 删除 @@ -240,12 +241,24 @@ export default { } }) }, - resetSites () { - sites.clear() - sites.bulkAdd(defaultSites).then(e => { - this.getSites() - this.$message.success('重置源成功') + resetSitesEvent () { + this.resetSites(defaultSites) + this.$message.success('重置源成功') + }, + moveSiteToTop (i) { + this.sites.sort(function (x, y) { return x.key === i.key ? -1 : y.key === i.key ? 1 : 0 }) + this.resetSites(this.sites) + }, + resetId (inArray) { + var id = 1 + inArray.forEach(ele => { + ele.id = id + id += 1 }) + }, + resetSites (newSites) { + this.resetId(newSites) + sites.clear().then(sites.bulkAdd(newSites).then(this.getSites())) } }, created () {