Fixed cronSyncArtifact failed issue

This commit is contained in:
Peng-YM
2022-05-18 11:06:40 +08:00
parent 5954ff0a58
commit 48d533af83
4 changed files with 120 additions and 149 deletions

View File

@@ -108,31 +108,31 @@ export default {
}
},
methods: {
async refresh() {
await axios.post(`/utils/refresh`, {url: this.sub});
await this.fetch();
},
async fetch() {
await axios.get(this.raw ? `${this.url}?raw=true` : this.url).then(resp => {
let {data} = resp;
// eslint-disable-next-line no-debugger
this.proxies = data;
}).catch(err => {
this.$store.commit("SET_ERROR_MESSAGE", err);
});
try {
this.$store.commit("SET_LOADING", true);
await axios.get(this.raw ? `${this.url}?raw=true` : this.url).then(resp => {
let {data} = resp;
// eslint-disable-next-line no-debugger
this.proxies = data;
}).catch(err => {
this.$store.commit("SET_ERROR_MESSAGE", err);
});
await axios.get(this.raw ? `${this.url}?target=URI&raw=true` : `${this.url}?target=URI`).then(resp => {
const {data} = resp;
this.uris = data.split("\n");
});
await axios.get(this.raw ? `${this.url}?target=URI&raw=true` : `${this.url}?target=URI`).then(resp => {
const {data} = resp;
this.uris = data.split("\n");
});
// fix http offset
this.proxies.forEach((p, idx) => {
if (p.type === 'http') {
this.uris.splice(idx, 0, null);
}
})
// fix http offset
this.proxies.forEach((p, idx) => {
if (p.type === 'http') {
this.uris.splice(idx, 0, null);
}
})
} finally {
this.$store.commit("SET_LOADING", false);
}
},
async showInfo(idx) {

View File

@@ -322,16 +322,15 @@ export default {
},
async syncAllArtifacts() {
this.$store.commit("SET_LOADING", true);
try {
const {data} = await axios.get(`/cron/sync-artifacts`);
const {failed} = data;
if (failed.length > 0) {
this.$store.commit("SET_ERROR_MESSAGE", `部分配置(${failed.map(artifact => artifact.name).join(", ")})同步失败,请查看日志!`);
} else {
this.$store.commit("SET_SUCCESS_MESSAGE", `Gist 同步生成节点成功!`);
}
await axios.get(`/cron/sync-artifacts`);
await this.$store.dispatch("FETCH_ARTIFACTS");
this.$store.commit("SET_SUCCESS_MESSAGE", `Gist 同步生成节点成功!`);
} catch (err) {
this.$store.commit("SET_ERROR_MESSAGE", `Gist 同步生成节点失败!${err}`);
} finally {
this.$store.commit("SET_LOADING", false);
}
},