feat: TurboSu initial release - racing telemetry dashboard

This commit is contained in:
Yei.J. (AskaEth)
2026-07-25 15:23:40 +08:00
commit d61bb61a83
61 changed files with 5270 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
const Router = {
_routes: {
home: PageHome,
dashboard: PageDashboard,
scene: PageScene,
debug: PageDebug,
settings: PageSettings,
},
_currentPage: 'home',
_currentPageInstance: null,
init() {
window.addEventListener('hashchange', () => this._handleRoute());
this._handleRoute();
document.querySelectorAll('.nav-item[data-route]').forEach(el => {
el.addEventListener('click', (e) => {
e.preventDefault();
const route = el.getAttribute('data-route');
if (route) this.navigate(route);
});
});
},
navigate(page) {
window.location.hash = `#/${page}`;
},
_handleRoute() {
const hash = window.location.hash || '#/home';
const page = hash.replace('#/', '') || 'home';
if (this._currentPageInstance && this._currentPageInstance.cleanup) {
this._currentPageInstance.cleanup();
}
document.querySelectorAll('.page').forEach(p => p.classList.remove('active'));
const pageEl = document.getElementById(`page-${page}`);
if (pageEl) pageEl.classList.add('active');
Sidebar.setActive(page);
const route = this._routes[page];
if (route) {
this._currentPage = page;
this._currentPageInstance = route;
route.render();
}
},
get currentPage() { return this._currentPage; }
};
window.Router = Router;