Add pending apps and frontend components
- apps/captain-mobile: Mobile API service - apps/flow-ui: Flow UI application - apps/mindlink: Mindlink application - apps/storage: Storage API and workers - apps/tzzr-cli: TZZR CLI tool - deck-frontend/backups: Historical TypeScript versions - hst-frontend: Standalone HST frontend Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1 @@
|
||||
export { Router } from './router.ts';
|
||||
68
deck-frontend/backups/20260113_211524/src/router/router.ts
Normal file
68
deck-frontend/backups/20260113_211524/src/router/router.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import type { Store } from '@/state/store.ts';
|
||||
import type { AppState, BaseType, ViewType } from '@/types/index.ts';
|
||||
|
||||
const VALID_BASES: BaseType[] = [
|
||||
'hst', 'flg', 'itm', 'loc', 'ply', // Taxonomía
|
||||
'mst', 'bck', // Maestros
|
||||
'mth', 'atc', // Registro
|
||||
'mail', 'chat', // Comunicación
|
||||
'key', 'mindlink' // Servicios
|
||||
];
|
||||
const VALID_VIEWS: ViewType[] = ['grid', 'tree', 'graph'];
|
||||
|
||||
export class Router {
|
||||
private store: Store<AppState>;
|
||||
private onNavigate: () => void;
|
||||
|
||||
constructor(store: Store<AppState>, onNavigate: () => void) {
|
||||
this.store = store;
|
||||
this.onNavigate = onNavigate;
|
||||
|
||||
window.addEventListener('hashchange', () => this.handleHashChange());
|
||||
}
|
||||
|
||||
parseHash(): void {
|
||||
const hash = window.location.hash
|
||||
.replace(/^#\/?/, '')
|
||||
.replace(/\/?$/, '')
|
||||
.split('/')
|
||||
.filter(Boolean);
|
||||
|
||||
const state = this.store.getState();
|
||||
let base = state.base;
|
||||
let view = state.view;
|
||||
|
||||
if (hash[0] && VALID_BASES.includes(hash[0].toLowerCase() as BaseType)) {
|
||||
base = hash[0].toLowerCase() as BaseType;
|
||||
}
|
||||
|
||||
if (hash[1] && VALID_VIEWS.includes(hash[1].toLowerCase() as ViewType)) {
|
||||
view = hash[1].toLowerCase() as ViewType;
|
||||
}
|
||||
|
||||
this.store.setState({ base, view });
|
||||
}
|
||||
|
||||
updateHash(): void {
|
||||
const state = this.store.getState();
|
||||
const parts: string[] = [state.base];
|
||||
if (state.view !== 'grid') {
|
||||
parts.push(state.view);
|
||||
}
|
||||
window.location.hash = '/' + parts.join('/') + '/';
|
||||
}
|
||||
|
||||
private handleHashChange(): void {
|
||||
this.parseHash();
|
||||
this.onNavigate();
|
||||
}
|
||||
|
||||
navigate(base?: BaseType, view?: ViewType): void {
|
||||
const state = this.store.getState();
|
||||
this.store.setState({
|
||||
base: base ?? state.base,
|
||||
view: view ?? state.view
|
||||
});
|
||||
this.updateHash();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user