Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frontend/src/components/organisms/OrgSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ export function OrgSwitcher() {
return (
<div className="relative">
<Select value={orgValue} onValueChange={handleOrgChange}>
<SelectTrigger className="h-9 w-[220px] rounded-md border-slate-200 bg-white px-3 text-sm font-medium text-slate-900 shadow-none focus:ring-2 focus:ring-blue-500/30 focus:ring-offset-0">
<span className="flex items-center gap-2">
<SelectTrigger className="h-9 w-[140px] md:w-[220px] rounded-md border-slate-200 bg-white px-2 md:px-3 text-sm font-medium text-slate-900 shadow-none focus:ring-2 focus:ring-blue-500/30 focus:ring-offset-0">
<span className="flex items-center gap-1 md:gap-2">
<Building2 className="h-4 w-4 text-slate-400" />
<SelectValue placeholder="Select organization" />
</span>
Expand Down
13 changes: 8 additions & 5 deletions frontend/src/components/templates/DashboardShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ export function DashboardShell({ children }: { children: ReactNode }) {

const handleStorage = (event: StorageEvent) => {
if (event.key !== "openclaw_org_switch" || !event.newValue) return;
window.location.reload();
// 使用客户端路由刷新替代全页刷新,提升性能
router.refresh();
};

window.addEventListener("storage", handleStorage);
Expand All @@ -67,15 +68,16 @@ export function DashboardShell({ children }: { children: ReactNode }) {
if ("BroadcastChannel" in window) {
channel = new BroadcastChannel("org-switch");
channel.onmessage = () => {
window.location.reload();
// 使用客户端路由刷新替代全页刷新,提升性能
router.refresh();
};
}

return () => {
window.removeEventListener("storage", handleStorage);
channel?.close();
};
}, []);
}, [router]);

const toggleSidebar = useCallback(
() => setSidebarState((prev) => ({ open: !prev.open, path: pathname })),
Expand Down Expand Up @@ -110,8 +112,9 @@ export function DashboardShell({ children }: { children: ReactNode }) {
<BrandMark />
</div>
<SignedIn>
<div className="hidden md:flex flex-1 items-center">
<div className="max-w-[220px]">
{/* 移动端使用更紧凑的 OrgSwitcher 样式 */}
<div className="flex flex-1 items-center md:block">
<div className="max-w-[140px] md:max-w-[220px]">
<OrgSwitcher />
</div>
</div>
Expand Down