fix(web): connectStatus not change when connected backend abort connection; fix relative URL parse; fix loadWebCatalog ElMessage bug
This commit is contained in:
@@ -1,9 +1,21 @@
|
||||
import type { AxiosResponse } from 'axios'
|
||||
import type { LeagdoApiResponse } from './api'
|
||||
import API, { setWebsocketOnError, setApiEntryPoint } from './api'
|
||||
import API, {
|
||||
setWebsocketOnError,
|
||||
setApiEntryPoint,
|
||||
legado_http_entry_point,
|
||||
setWebsocketOnMessage,
|
||||
} from './api'
|
||||
import ajax from './axios'
|
||||
import { validatorHttpUrl } from '@/utils/utils'
|
||||
|
||||
import { createApp } from 'vue'
|
||||
import App from '@/App.vue'
|
||||
import store, { useConnectionStore } from '@/store'
|
||||
|
||||
createApp(App).use(store)
|
||||
const connectionStore = useConnectionStore()
|
||||
|
||||
const LeagdoApiResponseKeys: string[] = Array.of('isSuccess', 'errorMsg')
|
||||
|
||||
const notification = ElMessage
|
||||
@@ -31,6 +43,8 @@ const responseCheckInterceptor = (resp: AxiosResponse) => {
|
||||
notification.warning({ message: '后端返回内容格式错误', grouping: true })
|
||||
throw new Error()
|
||||
}
|
||||
connectionStore.setConnectType('primary')
|
||||
connectionStore.setConnectStatus('已连接 ' + legado_http_entry_point)
|
||||
return resp
|
||||
}
|
||||
|
||||
@@ -39,13 +53,18 @@ const axiosErrorInterceptor = (err: unknown) => {
|
||||
message: '后端连接失败,请检查阅读WEB服务或者设置其它可用链接',
|
||||
grouping: true,
|
||||
})
|
||||
connectionStore.setConnectType('danger')
|
||||
connectionStore.setConnectStatus('连接异常')
|
||||
throw err
|
||||
}
|
||||
// http全局
|
||||
ajax.interceptors.response.use(responseCheckInterceptor, axiosErrorInterceptor)
|
||||
// websocket
|
||||
setWebsocketOnError(axiosErrorInterceptor)
|
||||
|
||||
setWebsocketOnMessage(() => {
|
||||
connectionStore.setConnectType('primary')
|
||||
connectionStore.setConnectStatus('已连接 ' + legado_http_entry_point)
|
||||
})
|
||||
/**
|
||||
* 按照阅读的默认规则 解析阅读HTTP WebSocket API入口地址
|
||||
* @returns [http_url, webSocekt_url]
|
||||
|
||||
Reference in New Issue
Block a user