Restructure into pnpm monorepo with game shell, docs, and SpacetimeDB backend
- Restructure flat static prototype into pnpm workspace monorepo - apps/game: playable shell with R3F 3D scene, HUD, SpacetimeDB connection - apps/docs: design docs and prototypes - apps/site: landing page - packages/ui: shared Button and Panel primitives - services/spacetimedb: backend module (9 tables, 11 reducers) - Archive legacy static files to archive/legacy-static/ - Game loop: connect, undock, target, approach, dock, mine, sell - Add pnpm-workspace.yaml, tsconfig.base.json, spacetime.json
This commit is contained in:
25
archive/legacy-static/js/router.js
Normal file
25
archive/legacy-static/js/router.js
Normal file
@@ -0,0 +1,25 @@
|
||||
window.GDD = window.GDD || {};
|
||||
|
||||
const { useState, useEffect, useCallback } = React;
|
||||
|
||||
/* Hash-based router */
|
||||
window.GDD.useRouter = function() {
|
||||
const [page, setPage] = useState(getPage());
|
||||
|
||||
function getPage() {
|
||||
const hash = window.location.hash.slice(1) || 'overview';
|
||||
return hash;
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const handler = () => setPage(getPage());
|
||||
window.addEventListener('hashchange', handler);
|
||||
return () => window.removeEventListener('hashchange', handler);
|
||||
}, []);
|
||||
|
||||
const navigate = useCallback((path) => {
|
||||
window.location.hash = path;
|
||||
}, []);
|
||||
|
||||
return { page, navigate };
|
||||
};
|
||||
Reference in New Issue
Block a user