Skip to content

Commit

Permalink
fix: //version
Browse files Browse the repository at this point in the history
  • Loading branch information
Zephyruso committed Dec 23, 2024
1 parent 573f11f commit 50a269d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
16 changes: 3 additions & 13 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,7 @@ import ReconnectingWebSocket from 'reconnectingwebsocket'
import { computed, nextTick, ref, watch } from 'vue'

axios.interceptors.request.use((config) => {
config.baseURL =
activeBackend.value?.protocol +
'://' +
activeBackend.value?.host +
':' +
activeBackend.value?.port

if (activeBackend.value?.secondaryPath) {
config.baseURL += activeBackend.value?.secondaryPath
}

config.baseURL = getUrlFromBackend(activeBackend.value!)
config.headers['Authorization'] = 'Bearer ' + activeBackend.value?.password
return config
})
Expand Down Expand Up @@ -162,7 +152,7 @@ export const queryDNSAPI = (params: { name: string; type: string }) => {

const createWebSocket = <T>(url: string, searchParams?: Record<string, string>) => {
const backend = activeBackend.value!
const resurl = new URL(`${getUrlFromBackend(backend)}${url}`)
const resurl = new URL(`${getUrlFromBackend(backend)}/${url}`)

resurl.searchParams.append('token', backend?.password || '')

Expand Down Expand Up @@ -210,7 +200,7 @@ export const isBackendAvailable = async (backend: Backend, timeout: number = 500
const timeoutId = setTimeout(() => controller.abort(), timeout)

try {
const res = await fetch(`${getUrlFromBackend(backend)}version`, {
const res = await fetch(`${getUrlFromBackend(backend)}/version`, {
method: 'GET',
headers: {
Authorization: `Bearer ${backend.password}`,
Expand Down
2 changes: 1 addition & 1 deletion src/helper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,5 @@ export const importSettings = () => {
}

export const getUrlFromBackend = (end: Omit<Backend, 'uuid'>) => {
return `${end.protocol}://${end.host}:${end.port}${end.secondaryPath || '/'}`
return `${end.protocol}://${end.host}:${end.port}${end.secondaryPath || ''}`
}
6 changes: 5 additions & 1 deletion src/views/HomePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,11 @@ const documentVisible = useDocumentVisibility()
watch(
documentVisible,
async () => {
if (!activeBackend.value || backendList.value.length === 0 || !documentVisible.value) {
if (
!activeBackend.value ||
backendList.value.length === 0 ||
documentVisible.value !== 'visible'
) {
return
}
try {
Expand Down

0 comments on commit 50a269d

Please sign in to comment.