mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-15 17:30:13 +08:00
fix: resolve dashboard build type errors
This commit is contained in:
@@ -139,14 +139,12 @@
|
||||
navigateToFolder((item as any).folderId)
|
||||
"
|
||||
>
|
||||
<template #prepend>
|
||||
<v-icon
|
||||
v-if="(item as any).isRoot"
|
||||
size="small"
|
||||
class="mr-1"
|
||||
>mdi-home</v-icon
|
||||
>
|
||||
</template>
|
||||
<v-icon
|
||||
v-if="(item as any).isRoot"
|
||||
size="small"
|
||||
class="mr-1"
|
||||
>mdi-home</v-icon
|
||||
>
|
||||
{{ item.title }}
|
||||
</v-breadcrumbs-item>
|
||||
</template>
|
||||
|
||||
@@ -65,6 +65,33 @@ function normalizeBaseUrl(baseUrl: string | null | undefined): string {
|
||||
return stripTrailingSlashes(baseUrl?.trim() || "");
|
||||
}
|
||||
|
||||
export function normalizeConfiguredApiBaseUrl(
|
||||
baseUrl: string | null | undefined,
|
||||
): string {
|
||||
return normalizeBaseUrl(baseUrl);
|
||||
}
|
||||
|
||||
export function getApiBaseUrlValidationError(
|
||||
baseUrl: string | null | undefined,
|
||||
): string {
|
||||
const normalizedBaseUrl = normalizeConfiguredApiBaseUrl(baseUrl);
|
||||
|
||||
if (!normalizedBaseUrl) {
|
||||
return "";
|
||||
}
|
||||
|
||||
try {
|
||||
const parsedUrl = new URL(normalizedBaseUrl);
|
||||
if (!["http:", "https:"].includes(parsedUrl.protocol)) {
|
||||
return "API Base URL must use http:// or https://";
|
||||
}
|
||||
} catch {
|
||||
return "API Base URL must be a valid absolute URL";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
export function getApiBaseUrl(): string {
|
||||
return normalizeBaseUrl(service.defaults.baseURL);
|
||||
}
|
||||
|
||||
@@ -472,7 +472,7 @@ import SidebarCustomizer from "@/components/shared/SidebarCustomizer.vue";
|
||||
import WaitingForRestart from "@/components/shared/WaitingForRestart.vue";
|
||||
import MigrationDialog from "@/components/shared/MigrationDialog.vue";
|
||||
import BackupDialog from "@/components/shared/BackupDialog.vue";
|
||||
import axios from "@/utils/request";
|
||||
import axios, { getApiBaseUrlValidationError } from "@/utils/request";
|
||||
import { useI18n, useModuleI18n } from "@/i18n/composables";
|
||||
import { useToast } from "@/utils/toast";
|
||||
|
||||
|
||||
@@ -275,7 +275,11 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch, onMounted } from "vue";
|
||||
import axios from "@/utils/request";
|
||||
import axios, {
|
||||
getApiBaseUrlValidationError,
|
||||
normalizeConfiguredApiBaseUrl,
|
||||
setApiBaseUrl,
|
||||
} from "@/utils/request";
|
||||
import AddNewPlatform from "@/components/platform/AddNewPlatform.vue";
|
||||
import ProviderConfigDialog from "@/components/chat/ProviderConfigDialog.vue";
|
||||
import { useI18n, useModuleI18n } from "@/i18n/composables";
|
||||
|
||||
Reference in New Issue
Block a user