左侧菜单改版:工作台下拉 + 5个图标导航
- 工作台改为下拉菜单(layout-grid + chevron-down 图标) - 顶部 tabs 移到左侧 sidebar,5 个图标导航(首页/财务/台账/方案/产品) - 头像与工作台间、工作台与导航间各加分隔线 - 经营管理 tab 短名改为'财务' - 移除 .tabs 样式,新增 .sidebar-tab 样式
This commit is contained in:
@@ -13,13 +13,57 @@ function applyUserTenants() {
|
||||
e.stopPropagation();
|
||||
toggleUserMenu(user);
|
||||
});
|
||||
const allowedTenants = data.tenants || [];
|
||||
document.querySelectorAll(".workspace-nav-item").forEach(el => {
|
||||
el.style.display = allowedTenants.includes(el.dataset.tenant) ? "" : "none";
|
||||
});
|
||||
// 缓存可用工作台列表,供下拉菜单使用
|
||||
state.allowedTenants = data.tenants || [];
|
||||
updateTenantLabel();
|
||||
});
|
||||
}
|
||||
|
||||
window.toggleTenantMenu = (event) => {
|
||||
event.stopPropagation();
|
||||
let menu = document.getElementById("tenantMenu");
|
||||
if (menu) { menu.remove(); return; }
|
||||
const btn = event.currentTarget;
|
||||
const rect = btn.getBoundingClientRect();
|
||||
const tenants = state.allowedTenants || [];
|
||||
menu = document.createElement("div");
|
||||
menu.id = "tenantMenu";
|
||||
menu.className = "fixed bg-white rounded-lg shadow-xl border border-slate-200 py-1 min-w-[160px] z-[9999]";
|
||||
menu.style.left = Math.min(rect.left - 8, window.innerWidth - 180) + "px";
|
||||
menu.style.top = rect.bottom + 6 + "px";
|
||||
menu.innerHTML = `
|
||||
<div class="px-4 py-2 border-b border-slate-100">
|
||||
<p class="text-xs font-semibold text-slate-500 uppercase tracking-wider">切换工作台</p>
|
||||
</div>
|
||||
${tenants.map(t => `
|
||||
<button class="w-full text-left px-4 py-2 text-sm hover:bg-slate-50 transition-colors flex items-center justify-between gap-2 ${t === state.tenant ? 'text-blue-600 font-medium' : 'text-slate-700'}" onclick="switchTenantFromMenu('${t.replace(/'/g, "\\'")}')">
|
||||
<span>${esc(t)}</span>
|
||||
${t === state.tenant ? '<i data-lucide="check" style="width:14px;height:14px"></i>' : ''}
|
||||
</button>
|
||||
`).join('')}`;
|
||||
document.body.appendChild(menu);
|
||||
if (window.lucide) lucide.createIcons();
|
||||
setTimeout(() => {
|
||||
document.addEventListener("click", function closeMenu() {
|
||||
menu.remove();
|
||||
document.removeEventListener("click", closeMenu);
|
||||
}, { once: true });
|
||||
}, 10);
|
||||
};
|
||||
|
||||
window.switchTenantFromMenu = (tenant) => {
|
||||
document.getElementById("tenantMenu")?.remove();
|
||||
switchTenant(tenant);
|
||||
};
|
||||
|
||||
function updateTenantLabel() {
|
||||
const label = document.querySelector("#currentTenantLabel");
|
||||
if (label) {
|
||||
label.textContent = state.tenant.replace("·无界", "") || "工作台";
|
||||
label.title = state.tenant;
|
||||
}
|
||||
}
|
||||
|
||||
window.toggleUserMenu = (user) => {
|
||||
let menu = document.getElementById("userMenu");
|
||||
if (menu) { menu.remove(); return; }
|
||||
|
||||
@@ -123,7 +123,7 @@ async function load() {
|
||||
function switchTab(tab) {
|
||||
state.active = tab;
|
||||
localStorage.setItem("opc-active-tab", tab);
|
||||
document.querySelectorAll("#tabs button").forEach((btn) => btn.classList.toggle("active", btn.dataset.tab === tab));
|
||||
document.querySelectorAll(".sidebar-tab").forEach((btn) => btn.classList.toggle("active", btn.dataset.tab === tab));
|
||||
document.querySelectorAll(".panel").forEach((panel) => panel.classList.toggle("active", panel.id === tab));
|
||||
render();
|
||||
}
|
||||
@@ -179,7 +179,8 @@ window.switchTenant = (tenant) => {
|
||||
state.selectedProject = null;
|
||||
localStorage.setItem("opc-active-tenant", tenant);
|
||||
document.querySelector("#workspaceTitle").textContent = tenant.replace("·无界", "") + " OPC 工作台";
|
||||
document.querySelectorAll(".workspace-nav-item").forEach((el) => el.classList.toggle("active", el.dataset.tenant === tenant));
|
||||
const label = document.querySelector("#currentTenantLabel");
|
||||
if (label) { label.textContent = tenant.replace("·无界", "") || "工作台"; label.title = tenant; }
|
||||
load();
|
||||
};
|
||||
window.doLogout = async () => {
|
||||
|
||||
Reference in New Issue
Block a user