fix: move install check to init once, route() sync for instant nav, hide top-bar in admin
This commit is contained in:
@@ -306,7 +306,7 @@ tbody tr:last-child td{border-bottom:none}
|
||||
.footer-inner{max-width:1280px;margin:0 auto;display:flex;justify-content:center;gap:28px;flex-wrap:wrap}
|
||||
.footer-inner a{color:var(--g4);text-decoration:none;transition:color .2s}
|
||||
.footer-inner a:hover{color:white}
|
||||
#app{min-height:calc(100vh - 52px);display:flex;flex-direction:column}
|
||||
#app{min-height:100vh;display:flex;flex-direction:column}
|
||||
#public-page,#main-layout{flex:1}
|
||||
|
||||
/* ===== Install Page ===== */
|
||||
|
||||
@@ -11,7 +11,8 @@ const App = {
|
||||
{ id: 'export', label: '数据导出', icon: 'fa-download', roles: ['owner'] },
|
||||
],
|
||||
|
||||
init() {
|
||||
async init() {
|
||||
try { const s = await API.get('/install/status'); if (!s.installed) { location.hash = '#/install'; return; } } catch { location.hash = '#/install'; return; }
|
||||
this.loadFooter();
|
||||
window.addEventListener('hashchange', () => this.route());
|
||||
this.route();
|
||||
@@ -32,19 +33,12 @@ const App = {
|
||||
closeModal() { document.getElementById('modal-overlay').classList.add('hidden'); },
|
||||
navigate(page, param) { location.hash = `#/${page}` + (param ? `/${param}` : ''); },
|
||||
|
||||
async route() {
|
||||
route() {
|
||||
const hash = location.hash || '#/home';
|
||||
const parts = hash.replace('#/', '').split('/');
|
||||
const page = parts[0];
|
||||
const param = parts.slice(1).join('/');
|
||||
|
||||
if (page !== 'install') {
|
||||
try {
|
||||
const s = await API.get('/install/status');
|
||||
if (!s.installed) { location.hash = '#/install'; return; }
|
||||
} catch { location.hash = '#/install'; return; }
|
||||
}
|
||||
|
||||
if (page === 'verify') {
|
||||
const params = new URLSearchParams((location.hash.split('?')[1] || ''));
|
||||
const token = params.get('token');
|
||||
@@ -85,6 +79,7 @@ const App = {
|
||||
},
|
||||
|
||||
showPublic(page, param) {
|
||||
document.getElementById('top-bar').classList.remove('hidden');
|
||||
document.getElementById('top-auth').classList.remove('hidden');
|
||||
document.getElementById('main-layout').classList.add('hidden');
|
||||
const pub = document.getElementById('public-page');
|
||||
@@ -94,10 +89,9 @@ const App = {
|
||||
},
|
||||
|
||||
showLayout() {
|
||||
document.getElementById('top-auth').classList.add('hidden');
|
||||
document.getElementById('top-bar').classList.add('hidden');
|
||||
document.getElementById('public-page').classList.add('hidden');
|
||||
document.getElementById('main-layout').classList.remove('hidden');
|
||||
document.getElementById('main-layout').classList.remove('hidden');
|
||||
const u = Auth.user();
|
||||
document.getElementById('user-info').innerHTML = `<div class="av">${(u.game_name||u.username).charAt(0).toUpperCase()}</div><div class="dt"><div class="nm">${u.game_name||u.username}</div><div class="rl">${U.ROLE[u.role]}</div></div>`;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user