From 64709b661026cec2e2db3f30af8bcb87d3aeec50 Mon Sep 17 00:00:00 2001 From: Peng-YM <1048217874pengym@gmail.com> Date: Wed, 9 Dec 2020 09:50:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DUI=E4=B8=8D=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/store/index.js | 6 +++++- web/src/views/Cloud.vue | 4 ++-- web/src/views/User.vue | 24 +++++++++++++++--------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/web/src/store/index.js b/web/src/store/index.js index f79a14a..853c004 100644 --- a/web/src/store/index.js +++ b/web/src/store/index.js @@ -17,7 +17,6 @@ const store = new Vuex.Store({ collections: {}, artifacts: {}, env: {}, - settings: {} }, @@ -70,6 +69,11 @@ const store = new Vuex.Store({ state.env = resp.data; }) }, + async FETCH_SETTINGS({state}) { + return axios.get("/settings").then(resp => { + state.settings = resp.data; + }); + }, // update subscriptions async UPDATE_SUBSCRIPTION({dispatch}, {name, sub}) { return axios.patch(`/sub/${name}`, sub).then(() => { diff --git a/web/src/views/Cloud.vue b/web/src/views/Cloud.vue index f42683b..bf0e68f 100644 --- a/web/src/views/Cloud.vue +++ b/web/src/views/Cloud.vue @@ -2,7 +2,7 @@ - 配置 + 同步配置 @@ -279,7 +279,7 @@ export default { }, setArtifactType(type) { - this.newArtifactType = type; + this.newArtifact.type = type; this.newArtifact.source = ""; }, diff --git a/web/src/views/User.vue b/web/src/views/User.vue index 4cfa1a0..054af35 100644 --- a/web/src/views/User.vue +++ b/web/src/views/User.vue @@ -37,7 +37,7 @@ mdi-cloud - 最近同步于:{{getSyncTime()}} + 最近同步于:{{syncTime}} @@ -66,14 +66,25 @@ export default { axios.get(`/settings`).then(resp => { this.settings.gistToken = resp.data.gistToken; this.settings.githubUser = resp.data.githubUser; + this.settings.syncTime = resp.data.syncTime; }); }, + computed: { + syncTime(){ + if (this.settings.syncTime) { + return format(this.settings.syncTime, "zh_CN"); + } else { + return "从未同步"; + } + } + }, methods: { save() { axios.patch(`/settings`, this.settings); this.$store.commit("SET_SUCCESS_MESSAGE", `保存成功!`); }, + // eslint-disable-next-line no-unused-vars sync(action) { if (!this.settings.gistToken) { this.$store.commit("SET_ERROR_MESSAGE", "未设置GitHub Token!"); @@ -97,14 +108,9 @@ export default { store.dispatch("FETCH_COLLECTIONS").catch(() => { showError(`无法拉取组合订阅列表!`); }); - }, - - getSyncTime() { - if (this.settings.syncTime) { - return format(this.settings.syncTime, "zh_CN"); - } else { - return "从未同步"; - } + store.dispatch("FETCH_ARTIFACTS").catch(() => { + showError(`无法拉取同步配置!`); + }); } } }