mirror of
https://github.com/Li4n0/revsuit.git
synced 2026-09-23 15:11:54 +08:00
99 lines
2.7 KiB
Vue
99 lines
2.7 KiB
Vue
<template>
|
|
<div>
|
|
<SettingForm :form="form" :spinning="spinning"></SettingForm>
|
|
<a-result v-if="status"
|
|
:status="status"
|
|
:title="title"
|
|
:sub-title="subTitle"
|
|
>
|
|
<template #extra>
|
|
<a-row>
|
|
<a-col :span="12" :offset="7">
|
|
<div style="text-align: left">
|
|
<li v-for="err in errors" :key="err">{{ err }}</li>
|
|
</div>
|
|
</a-col>
|
|
</a-row>
|
|
</template>
|
|
</a-result>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import {getPlatformConfig, updatePlatformConfig} from "@/api/settings"
|
|
import SettingForm from "@/components/SettingForm";
|
|
|
|
export default {
|
|
name: "Http",
|
|
data() {
|
|
return {
|
|
form: {},
|
|
spinning: false,
|
|
status: "",
|
|
title: "",
|
|
subTitle: "",
|
|
errors: []
|
|
}
|
|
},
|
|
methods: {
|
|
getConfig() {
|
|
getPlatformConfig().then(res => {
|
|
this.form = res.data
|
|
}).catch(e => {
|
|
this.$notification.error({
|
|
message: 'Error',
|
|
description:
|
|
e.response.data.error,
|
|
style: {
|
|
width: '600px',
|
|
marginLeft: `${335 - 600}px`,
|
|
},
|
|
duration: 4
|
|
});
|
|
})
|
|
},
|
|
updateConfig() {
|
|
this.spinning = true
|
|
let targetConfig = JSON.stringify(this.form)
|
|
updatePlatformConfig(this.form).then(
|
|
() => {
|
|
setTimeout(() => {
|
|
getPlatformConfig().then((res) => {
|
|
this.spinning = false
|
|
let nowConfig = JSON.stringify(res.data)
|
|
if (nowConfig !== targetConfig) {
|
|
this.status = "warning"
|
|
this.title = "Updating the configuration seems to have failed"
|
|
this.subTitle = "Please check your config options."
|
|
}
|
|
this.form = res.data
|
|
this.status = ""
|
|
this.title = ""
|
|
this.subTitle = ""
|
|
}
|
|
).catch(() => {
|
|
this.status = "error"
|
|
this.title = "Updating the configuration seems to have failed, and may cause the platform to exit abnormally, please restart manually."
|
|
this.subTitle = "Please check your config options carefully."
|
|
})
|
|
}, 3000)
|
|
}
|
|
).catch(() => {
|
|
this.status = "error"
|
|
this.title = "Updating the configuration seems to have failed, and may cause the platform to exit abnormally, please restart manually."
|
|
this.subTitle = "Please check your config options carefully."
|
|
})
|
|
}
|
|
},
|
|
mounted() {
|
|
this.getConfig()
|
|
},
|
|
components: {
|
|
SettingForm
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
|
|
</style> |