feat(ui): add origin-style admin shell scaffold

This commit is contained in:
2026-04-22 23:03:58 +02:00
parent 8e74dc9284
commit 20122a5f53
4 changed files with 3541 additions and 209 deletions
+46
View File
@@ -0,0 +1,46 @@
import { GlobalStateStore } from '@warkypublic/svelix';
const normalizeApiURL = (url: string): string => url.replace(/\/+$/, '');
const resolveApiURL = (envURL?: string): string => {
const viteEnvURL =
envURL?.trim() ||
import.meta.env.VITE_API_URL?.trim() ||
import.meta.env.VITE_API_BASE_URL?.trim() ||
import.meta.env.VITE_URL?.trim();
if (viteEnvURL) return normalizeApiURL(viteEnvURL);
if (typeof window !== 'undefined') {
return `${window.location.protocol}//${window.location.host}/api`;
}
const stateURL = GlobalStateStore.getState().session.apiURL?.trim();
if (stateURL) return normalizeApiURL(stateURL);
return '';
};
export { GlobalStateStore };
export function ensureApiURL(envURL?: string): string {
const resolved = resolveApiURL(envURL);
if (!resolved) return '';
const state = GlobalStateStore.getState();
if (state.session.apiURL !== resolved) {
state.setApiURL(resolved);
}
return resolved;
}
export function setCurrentPath(pathname: string): void {
const state = GlobalStateStore.getState();
const current = state.navigation.currentPage ?? {};
state.setCurrentPage({
...current,
path: pathname
});
}