Skip to content

Commit

Permalink
未配置端点错误处理
Browse files Browse the repository at this point in the history
  • Loading branch information
HoshinoSuzumi committed Jun 7, 2023
1 parent 2c1f256 commit d0129ad
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion nuxt.config.js
Expand Up @@ -7,7 +7,7 @@ export default {
},
publicRuntimeConfig: {
version: process.env.CEVER_VERSION || 'unstable',
CEVER_BACKEND_BASE: process.env.CEVER_BACKEND_BASE
CEVER_BACKEND_BASE: process.env.CEVER_BACKEND_BASE | null
},
// Global page headers: https://go.nuxtjs.dev/config-head
head: {
Expand Down
26 changes: 16 additions & 10 deletions pages/settings.vue
Expand Up @@ -58,17 +58,23 @@ export default defineComponent({
}
},
mounted() {
const server_status_endpoint = new URL('status', this.$config.CEVER_BACKEND_BASE);
this.$axios.get(server_status_endpoint.href).then(res => {
if (res.data.status === 'ok')
this.server_online = 'online'
else
if (!this.$config.CEVER_BACKEND_BASE) {
const server_status_endpoint = new URL('status', this.$config.CEVER_BACKEND_BASE);
this.$axios.get(server_status_endpoint.href).then(res => {
if (res.data.status === 'ok')
this.server_online = 'online'
else
this.server_online = 'offline'
this.server_version = res.data.version;
}).catch(err => {
this.server_online = 'offline'
this.server_version = res.data.version;
}).catch(err => {
this.server_online = 'offline'
this.server_version = `Failed to fetch (${err.response.status} ${err.response.data.detail})`
})
this.server_version = `Failed to fetch (${err.response.status} ${err.response.data.detail})`
})
} else {
this.server_endpoint = 'unavailable'
this.server_online = 'unavailable'
this.server_version = 'unavailable'
}
this.languageOptions = this.$i18n.locales.map(locale => ({
value: locale.code,
Expand Down

1 comment on commit d0129ad

@vercel
Copy link

@vercel vercel bot commented on d0129ad Jun 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.