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(`无法拉取同步配置!`); + }); } } }