Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

💄 style: brand the loading screen and LobeHub provider card via the business slot (#18638)

LiJianc5caffe6849b
diff --git a/packages/business/const/package.json b/packages/business/const/package.json
index 1f03bfc3523..cf5d6050fe7 100644
--- a/packages/business/const/package.json
+++ b/packages/business/const/package.json
@@ -3,7 +3,8 @@
"version": "1.0.0",
"private": true,
"exports": {
- ".": "./src/index.ts"
+ ".": "./src/index.ts",
+ "./branding": "./src/branding.ts"
},
"main": "./src/index.ts"
}
diff --git a/packages/model-bank/src/modelProviders/lobehub.ts b/packages/model-bank/src/modelProviders/lobehub.ts
index 4168f0d0b17..4cd71757260 100644
--- a/packages/model-bank/src/modelProviders/lobehub.ts
+++ b/packages/model-bank/src/modelProviders/lobehub.ts
@@ -1,20 +1,34 @@
+import { BRANDING_NAME } from '@lobechat/business-const';
+
import type { ModelProviderCard } from '../types';
+/**
+ * The branded first-party provider. Display metadata follows the business
+ * branding slot: OSS/cloud keep the LobeHub identity, while custom-branding
+ * distributions (BRANDING_NAME override) get their own name and drop the
+ * LobeHub marketing copy/links automatically.
+ */
+const isCustomBranding = BRANDING_NAME !== 'LobeHub';
+
const LobeHub: ModelProviderCard = {
chatModels: [],
- description:
- 'LobeHub Cloud uses official APIs to access AI models and measures usage with Credits tied to model tokens.',
+ ...(isCustomBranding
+ ? {}
+ : {
+ description:
+ 'LobeHub Cloud uses official APIs to access AI models and measures usage with Credits tied to model tokens.',
+ modelsUrl: 'https://lobehub.com/zh/docs/usage/subscription/model-pricing',
+ }),
enabled: true,
id: 'lobehub',
- modelsUrl: 'https://lobehub.com/zh/docs/usage/subscription/model-pricing',
- name: 'LobeHub',
+ name: BRANDING_NAME,
settings: {
modelEditable: false,
showAddNewModel: false,
showModelFetcher: false,
},
showConfig: false,
- url: 'https://lobehub.com',
+ url: isCustomBranding ? '' : 'https://lobehub.com',
};
export default LobeHub;
diff --git a/plugins/vite/customBrandingLoadingScreen.test.ts b/plugins/vite/customBrandingLoadingScreen.test.ts
new file mode 100644
index 00000000000..e6aa8b1f550
--- /dev/null
+++ b/plugins/vite/customBrandingLoadingScreen.test.ts
@@ -0,0 +1,54 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+const SAMPLE_HTML = `<body>
+ <div id="loading-screen">
+ <div id="loading-brand" aria-label="Loading" role="status">
+ <svg fill="currentColor" height="40" viewBox="0 0 940 320" xmlns="http://www.w3.org/2000/svg">
+ <title>LobeHub</title>
+ <path d="M15 240.035V87.172h39.24V205.75h66.192v34.285H15z" />
+ </svg>
+ </div>
+ </div>
+ <div id="root" style="height: 100%"></div>
+ </body>`;
+
+const loadHandler = async () => {
+ const { customBrandingLoadingScreen } = await import('./customBrandingLoadingScreen');
+ const plugin = customBrandingLoadingScreen();
+ return (plugin.transformIndexHtml as { handler: (html: string) => string }).handler;
+};
+
+describe('customBrandingLoadingScreen', () => {
+ beforeEach(() => {
+ vi.resetModules();
+ });
+
+ it('keeps the default LobeHub wordmark untouched', async () => {
+ vi.doMock('@lobechat/business-const/branding', () => ({ BRANDING_NAME: 'LobeHub' }));
+ const handler = await loadHandler();
+
+ expect(handler(SAMPLE_HTML)).toBe(SAMPLE_HTML);
+ });
+
+ it('replaces the wordmark with the custom brand name', async () => {
+ vi.doMock('@lobechat/business-const/branding', () => ({ BRANDING_NAME: 'AI Workstation' }));
+ const handler = await loadHandler();
+
+ const result = handler(SAMPLE_HTML);
+ expect(result).not.toContain('<svg');
+ expect(result).not.toContain('LobeHub');
+ expect(result).toContain('AI Workstation');
+ expect(result).toContain('id="loading-brand"');
+ // the rest of the document is preserved
+ expect(result).toContain('<div id="root" style="height: 100%"></div>');
+ });
+
+ it('escapes HTML-sensitive characters in the brand name', async () => {
+ vi.doMock('@lobechat/business-const/branding', () => ({ BRANDING_NAME: 'A<B>&"C' }));
+ const handler = await loadHandler();
+
+ const result = handler(SAMPLE_HTML);
+ expect(result).toContain('A&lt;B&gt;&amp;&quot;C');
+ expect(result).not.toContain('A<B>');
+ });
+});
diff --git a/plugins/vite/customBrandingLoadingScreen.ts b/plugins/vite/customBrandingLoadingScreen.ts
new file mode 100644
index 00000000000..93eabd86f40
--- /dev/null
+++ b/plugins/vite/customBrandingLoadingScreen.ts
@@ -0,0 +1,38 @@
+// Deep import on purpose: the package root barrel uses extensionless relative
+// imports that Node's type-stripping loader (which evaluates externalized
+// config-time imports) cannot resolve. branding.ts is a dependency-free leaf
+// exposed via the './branding' subpath — keep it import-free.
+import { BRANDING_NAME } from '@lobechat/business-const/branding';
+import type { Plugin } from 'vite';
+
+const LOADING_BRAND_BLOCK = /<div id="loading-brand"[^>]*>[\S\s]*?<\/div>/;
+
+const escapeHtml = (value: string) =>
+ value
+ .replaceAll('&', '&amp;')
+ .replaceAll('<', '&lt;')
+ .replaceAll('>', '&gt;')
+ .replaceAll('"', '&quot;');
+
+/**
+ * Replace the hardcoded LobeHub wordmark in the static loading screen with the
+ * custom brand name, so white-label deployments (BRANDING_NAME !== 'LobeHub')
+ * never flash the LobeHub logo before the SPA boots. No-op for the default
+ * branding.
+ */
+export const customBrandingLoadingScreen = (): Plugin => ({
+ name: 'custom-branding-loading-screen',
+ transformIndexHtml: {
+ handler(html) {
+ if (BRANDING_NAME === 'LobeHub') return html;
+
+ return html.replace(
+ LOADING_BRAND_BLOCK,
+ `<div id="loading-brand" aria-label="Loading" role="status" style="font-size: 26px; font-weight: 700; letter-spacing: 0.02em;">${escapeHtml(
+ BRANDING_NAME,
+ )}</div>`,
+ );
+ },
+ order: 'pre',
+ },
+});
diff --git a/src/features/Settings/provider/(list)/ProviderGrid/Card.tsx b/src/features/Settings/provider/(list)/ProviderGrid/Card.tsx
index 7472a1bc256..a6d53189827 100644
--- a/src/features/Settings/provider/(list)/ProviderGrid/Card.tsx
+++ b/src/features/Settings/provider/(list)/ProviderGrid/Card.tsx
@@ -104,7 +104,7 @@ const ProviderCard = memo<ProviderCardProps>(
>
{source === 'custom'
? description
- : t(`${id}.description`, { defaultValue: description })}
+ : description && t(`${id}.description`, { defaultValue: description })}
</Text>
</Flexbox>
</div>
diff --git a/src/routes/(main)/community/(detail)/model/features/Sidebar/RelatedProviders/Item.tsx b/src/routes/(main)/community/(detail)/model/features/Sidebar/RelatedProviders/Item.tsx
index 0127ae0fd72..7ece771a4db 100644
--- a/src/routes/(main)/community/(detail)/model/features/Sidebar/RelatedProviders/Item.tsx
+++ b/src/routes/(main)/community/(detail)/model/features/Sidebar/RelatedProviders/Item.tsx
@@ -48,7 +48,7 @@ const RelatedItem = memo<DiscoverModelDetailProviderItem>(({ description, id, na
rows: 2,
}}
>
- {t(`${id}.description`, { defaultValue: description })}
+ {description && t(`${id}.description`, { defaultValue: description })}
</Text>
</Flexbox>
</Block>
diff --git a/src/routes/(main)/community/(detail)/provider/features/Header.tsx b/src/routes/(main)/community/(detail)/provider/features/Header.tsx
index 3132b5da3c2..751966e9709 100644
--- a/src/routes/(main)/community/(detail)/provider/features/Header.tsx
+++ b/src/routes/(main)/community/(detail)/provider/features/Header.tsx
@@ -73,7 +73,7 @@ const Header = memo<{ mobile?: boolean }>(({ mobile: isMobile }) => {
color: cssVar.colorTextSecondary,
}}
>
- {t(`${identifier}.description`, { defaultValue: description })}
+ {description && t(`${identifier}.description`, { defaultValue: description })}
</Flexbox>
</Flexbox>
);
diff --git a/src/routes/(main)/community/(detail)/provider/features/Sidebar/ActionButton/ProviderConfig.tsx b/src/routes/(main)/community/(detail)/provider/features/Sidebar/ActionButton/ProviderConfig.tsx
index c2d6c4f7bf2..66f33b757b5 100644
--- a/src/routes/(main)/community/(detail)/provider/features/Sidebar/ActionButton/ProviderConfig.tsx
+++ b/src/routes/(main)/community/(detail)/provider/features/Sidebar/ActionButton/ProviderConfig.tsx
@@ -52,7 +52,7 @@ const ProviderConfig = memo(() => {
if (!items || items?.length === 0)
return (
- <Button block size={'large'} style={{ flex: 1 }} type={'primary'}>
+ <Button block size={'large'} style={{ flex: 1 }} type={'primary'} onClick={openSettings}>
{t('providers.config')}
</Button>
);
diff --git a/src/routes/(main)/community/(detail)/provider/features/Sidebar/ActionButton/index.tsx b/src/routes/(main)/community/(detail)/provider/features/Sidebar/ActionButton/index.tsx
index 861a9afd380..1e28acfa321 100644
--- a/src/routes/(main)/community/(detail)/provider/features/Sidebar/ActionButton/index.tsx
+++ b/src/routes/(main)/community/(detail)/provider/features/Sidebar/ActionButton/index.tsx
@@ -21,7 +21,9 @@ const ActionButton = memo(() => {
<ShareButton
meta={{
avatar: <ProviderIcon provider={identifier} size={64} type={'avatar'} />,
- desc: t(`${identifier}.description`, { defaultValue: description }),
+ desc: description
+ ? t(`${identifier}.description`, { defaultValue: description })
+ : undefined,
tags: (
<Flexbox horizontal align={'center'} gap={4} justify={'center'} wrap={'wrap'}>
{models
diff --git a/src/routes/(main)/community/(detail)/provider/features/Sidebar/Related/Item.tsx b/src/routes/(main)/community/(detail)/provider/features/Sidebar/Related/Item.tsx
index f2730503222..97d7f7395fc 100644
--- a/src/routes/(main)/community/(detail)/provider/features/Sidebar/Related/Item.tsx
+++ b/src/routes/(main)/community/(detail)/provider/features/Sidebar/Related/Item.tsx
@@ -48,7 +48,7 @@ const RelatedItem = memo<DiscoverProviderItem>(({ description, identifier, name
rows: 2,
}}
>
- {t(`${identifier}.description`, { defaultValue: description })}
+ {description && t(`${identifier}.description`, { defaultValue: description })}
</Text>
</Flexbox>
</Block>
diff --git a/src/routes/(main)/community/(detail)/provider/features/Sidebar/RelatedModels/Item.tsx b/src/routes/(main)/community/(detail)/provider/features/Sidebar/RelatedModels/Item.tsx
index 77f8e9d0665..ebad4b2b86e 100644
--- a/src/routes/(main)/community/(detail)/provider/features/Sidebar/RelatedModels/Item.tsx
+++ b/src/routes/(main)/community/(detail)/provider/features/Sidebar/RelatedModels/Item.tsx
@@ -48,7 +48,7 @@ const RelatedItem = memo<DiscoverProviderDetailModelItem>(({ description, id, di
rows: 2,
}}
>
- {t(`${id}.description`, { defaultValue: description })}
+ {description && t(`${id}.description`, { defaultValue: description })}
</Text>
</Flexbox>
</Block>
diff --git a/vite.config.ts b/vite.config.ts
index 868965aaec2..3abed0ad33b 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -7,6 +7,7 @@ import type { PluginOption, ViteDevServer } from 'vite';
import { defineConfig, loadEnv } from 'vite';
import { VitePWA } from 'vite-plugin-pwa';
+import { customBrandingLoadingScreen } from './plugins/vite/customBrandingLoadingScreen';
import { viteEnvRestartKeys } from './plugins/vite/envRestartKeys';
import {
createSharedRolldownOutput,
@@ -151,6 +152,7 @@ export default defineConfig({
},
},
vercelSkewProtection(),
+ customBrandingLoadingScreen(),
viteEnvRestartKeys(['APP_URL']),
enableViteDevTools &&
DevTools({