migrate from github

This commit is contained in:
2026-07-15 22:51:56 +08:00
commit a1cccc8068
215 changed files with 38318 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
const trimTrailingSlash = (value = '') => String(value).trim().replace(/\/+$/, '');
const trimLeadingSlash = (value = '') => String(value).trim().replace(/^\/+/, '');
const defaultBaseURL = (() => {
if (typeof window !== 'undefined' && window.location?.origin) {
return window.location.origin;
}
return '';
})();
export const API_BASE_URL = trimTrailingSlash(import.meta.env.VITE_API_BASE_URL || defaultBaseURL);
export const resolveWithApiBase = (target = '') => {
const value = String(target || '').trim();
if (!value) {
return API_BASE_URL;
}
try {
return new URL(value).toString();
} catch (_) {
if (!API_BASE_URL) {
return value;
}
const normalizedPath = value.startsWith('/') ? value : `/${trimLeadingSlash(value)}`;
return `${API_BASE_URL}${normalizedPath}`;
}
};
export const GRPC_WEB_ENDPOINT = resolveWithApiBase(import.meta.env.VITE_GRPC_WEB_ENDPOINT || '/grpc');