fix(web): normalize system version and add header tenant slot (#22207)

This commit is contained in:
chanx authored and GitHub committed 2026-11-10 17:37:42 +08:00
1 parent cc740cf6ee
commit 216e651b1a
3 files changed
+25 -2

No files matched your search

@@ -1,9 +1,16 @@
/**
* Enterprise slots inside the app header. The open-source build renders
* nothing here; the enterprise build replaces this file with the real
* billing entries (upgrade badge, support link, current-plan badge).
* entries (tenant switcher, upgrade badge, support link, current-plan badge).
*/
export function EnterpriseHeaderTenantSwitcher(_props: {
isCompact?: boolean;
}) {
void _props;
return null;
}
export function EnterpriseHeaderUpgradeBadge() {
return null;
}
+15 -1
View File
@@ -216,6 +216,20 @@ export const useSaveSetting = (silent = false) => {
return { data, loading, saveSetting: mutateAsync };
};
// The version endpoint returns either a bare string or `{ version: string }`
// depending on the backend implementation. Normalize both so the sidebar
// never attempts to render an object as a React child.
const normalizeSystemVersion = (payload: unknown): string => {
if (typeof payload === 'string') {
return payload;
}
if (payload && typeof payload === 'object' && 'version' in payload) {
const { version } = payload as { version?: unknown };
return typeof version === 'string' ? version : '';
}
return '';
};
export const useFetchSystemVersion = () => {
const [version, setVersion] = useState('');
const [loading, setLoading] = useState(false);
@@ -225,7 +239,7 @@ export const useFetchSystemVersion = () => {
setLoading(true);
const { data } = await userService.getSystemVersion();
if (data.code === 0) {
setVersion(data.data.version);
setVersion(normalizeSystemVersion(data.data));
setLoading(false);
}
} catch (error) {
+2
View File
@@ -9,6 +9,7 @@ import {
} from '@/components/ui/dropdown-menu';
import {
EnterpriseHeaderPlanBadge,
EnterpriseHeaderTenantSwitcher,
EnterpriseHeaderTicketsLink,
EnterpriseHeaderUpgradeBadge,
} from '@/ee/layouts/components/header-enterprise';
@@ -87,6 +88,7 @@ export function Header({
>
<img src={'/logo.svg'} alt="RAGFlow logo" className="size-10" />
</Link>
<EnterpriseHeaderTenantSwitcher isCompact={isCompact} />
<EnterpriseHeaderUpgradeBadge />
</div>
</div>