refactor: separate market from categories in sub-sidebar
This commit is contained in:
@@ -38,12 +38,6 @@ const PageDashboard = {
|
|||||||
item.dataset.cat = cat;
|
item.dataset.cat = cat;
|
||||||
listEl.appendChild(item);
|
listEl.appendChild(item);
|
||||||
});
|
});
|
||||||
|
|
||||||
const marketItem = document.createElement('div');
|
|
||||||
marketItem.className = 'category-item market-tab';
|
|
||||||
marketItem.textContent = '市场';
|
|
||||||
marketItem.dataset.cat = 'market';
|
|
||||||
listEl.appendChild(marketItem);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Failed to load categories:', e);
|
console.error('Failed to load categories:', e);
|
||||||
}
|
}
|
||||||
@@ -121,8 +115,9 @@ const PageDashboard = {
|
|||||||
categoryList.querySelectorAll('.category-item').forEach(el => el.classList.remove('active'));
|
categoryList.querySelectorAll('.category-item').forEach(el => el.classList.remove('active'));
|
||||||
item.classList.add('active');
|
item.classList.add('active');
|
||||||
this._currentCategory = item.dataset.cat;
|
this._currentCategory = item.dataset.cat;
|
||||||
this._marketMode = (this._currentCategory === 'market');
|
this._marketMode = false;
|
||||||
document.getElementById('dash-search-box').style.display = this._marketMode ? 'none' : 'flex';
|
document.getElementById('btn-market-tab').classList.remove('active');
|
||||||
|
document.getElementById('dash-search-box').style.display = 'flex';
|
||||||
this._loadThemes();
|
this._loadThemes();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -163,6 +158,13 @@ const PageDashboard = {
|
|||||||
|
|
||||||
document.getElementById('btn-market-upload')?.addEventListener('click', () => this._showMarketUpload());
|
document.getElementById('btn-market-upload')?.addEventListener('click', () => this._showMarketUpload());
|
||||||
document.getElementById('btn-market-login')?.addEventListener('click', () => this._showMarketLogin());
|
document.getElementById('btn-market-login')?.addEventListener('click', () => this._showMarketLogin());
|
||||||
|
document.getElementById('btn-market-tab')?.addEventListener('click', () => {
|
||||||
|
document.getElementById('dash-category-list').querySelectorAll('.category-item').forEach(el => el.classList.remove('active'));
|
||||||
|
document.getElementById('btn-market-tab').classList.add('active');
|
||||||
|
this._marketMode = true;
|
||||||
|
document.getElementById('dash-search-box').style.display = 'none';
|
||||||
|
this._loadThemes();
|
||||||
|
});
|
||||||
|
|
||||||
this._updateMarketUI();
|
this._updateMarketUI();
|
||||||
},
|
},
|
||||||
@@ -311,12 +313,20 @@ const PageDashboard = {
|
|||||||
<div class="dashboard-layout">
|
<div class="dashboard-layout">
|
||||||
<div class="dashboard-sub-sidebar">
|
<div class="dashboard-sub-sidebar">
|
||||||
<div id="dash-category-list"></div>
|
<div id="dash-category-list"></div>
|
||||||
<div style="padding:8px 12px;margin-top:auto;display:flex;flex-direction:column;gap:4px">
|
<div style="border-top:1px solid var(--border-subtle);margin:10px 8px 0;padding:12px 0 8px">
|
||||||
<button id="btn-market-login" class="btn btn-sm btn-primary" style="width:100%">登录</button>
|
<button id="btn-market-tab" class="category-item" data-cat="market" style="width:100%;justify-content:flex-start;gap:8px">
|
||||||
<button id="btn-market-upload" class="btn btn-sm btn-secondary" style="width:100%;display:none">发布到市场</button>
|
<span>🏪</span> 市场
|
||||||
|
</button>
|
||||||
|
<div style="padding:4px 12px 0;display:flex;flex-direction:column;gap:4px">
|
||||||
|
<button id="btn-market-login" class="btn btn-sm btn-primary" style="width:100%">登录</button>
|
||||||
|
<button id="btn-market-upload" class="btn btn-sm btn-secondary" style="width:100%;display:none">发布到市场</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style="padding:8px 12px;margin-top:auto">
|
||||||
<button id="btn-import-dashboard" class="btn btn-sm btn-secondary" style="width:100%;">导入 .tsd</button>
|
<button id="btn-import-dashboard" class="btn btn-sm btn-secondary" style="width:100%;">导入 .tsd</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="dashboard-main">
|
<div class="dashboard-main">
|
||||||
<div id="dash-search-box" style="display:flex;gap:8px;margin-bottom:12px;align-items:center">
|
<div id="dash-search-box" style="display:flex;gap:8px;margin-bottom:12px;align-items:center">
|
||||||
<input id="dash-search" type="text" placeholder="搜索仪表盘..." style="flex:1;max-width:300px">
|
<input id="dash-search" type="text" placeholder="搜索仪表盘..." style="flex:1;max-width:300px">
|
||||||
|
|||||||
Reference in New Issue
Block a user