fix: expose all page objects to window for inline onclick handlers

This commit is contained in:
2026-07-12 21:16:05 +08:00
parent 6fa1a65843
commit 531d2a6e26

View File

@@ -82,10 +82,11 @@ const App = {
showPublic(page, param) { showPublic(page, param) {
document.getElementById('top-bar').classList.remove('hidden'); document.getElementById('top-bar').classList.remove('hidden');
document.getElementById('top-auth').classList.remove('hidden');
document.getElementById('main-layout').classList.add('hidden'); document.getElementById('main-layout').classList.add('hidden');
const pub = document.getElementById('public-page'); const pub = document.getElementById('public-page');
pub.classList.remove('hidden'); pub.classList.remove('hidden');
const topAuth = document.getElementById('top-auth');
if (Auth.logged()) { topAuth.classList.add('hidden'); } else { topAuth.classList.remove('hidden'); }
const comp = page === 'login' ? LoginPage : page === 'register' ? RegisterPage : page === 'install' ? InstallPage : HomePage; const comp = page === 'login' ? LoginPage : page === 'register' ? RegisterPage : page === 'install' ? InstallPage : HomePage;
comp.render(param).then(html => { pub.innerHTML = html; if (comp.mount) comp.mount(param); }).catch(() => { comp.render(param).then(html => { pub.innerHTML = html; if (comp.mount) comp.mount(param); }).catch(() => {
pub.innerHTML = '<div class="pub-card"><div class="logo"><i class="fas fa-exclamation-triangle" style="color:var(--d)"></i><h2>加载失败</h2><p>请刷新页面重试</p></div></div>'; pub.innerHTML = '<div class="pub-card"><div class="logo"><i class="fas fa-exclamation-triangle" style="color:var(--d)"></i><h2>加载失败</h2><p>请刷新页面重试</p></div></div>';
@@ -118,3 +119,22 @@ const App = {
}; };
document.addEventListener('DOMContentLoaded', () => App.init()); document.addEventListener('DOMContentLoaded', () => App.init());
window.App = App;
window.Dashboard = Dashboard;
window.TicketsPage = TicketsPage;
window.TicketDetail = TicketDetail;
window.TicketCreate = TicketCreate;
window.TrackingPage = TrackingPage;
window.UnclaimedPage = UnclaimedPage;
window.UsersPage = UsersPage;
window.TemplatesPage = TemplatesPage;
window.NotificationsPage = NotificationsPage;
window.SettingsPage = SettingsPage;
window.ExportPage = ExportPage;
window.LoginPage = LoginPage;
window.RegisterPage = RegisterPage;
window.HomePage = HomePage;
window.InstallPage = InstallPage;
window.U = U;
window.Auth = Auth;
window.API = API;