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.

✨ feat: add business features support with new components and hooks

YuTengjing1dccc04a29b0
diff --git a/src/app/[variants]/(main)/image/features/GenerationFeed/BatchItem.tsx b/src/app/[variants]/(main)/image/features/GenerationFeed/BatchItem.tsx
index f37f9807f89..deca50479d0 100644
--- a/src/app/[variants]/(main)/image/features/GenerationFeed/BatchItem.tsx
+++ b/src/app/[variants]/(main)/image/features/GenerationFeed/BatchItem.tsx
@@ -13,6 +13,7 @@ import { type RuntimeImageGenParams } from 'model-bank';
import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
+import useRenderBusinessBatchItem from '@/business/client/hooks/useRenderBusinessBatchItem';
import APIKeyForm from '@/components/InvalidAPIKey';
import { useImageStore } from '@/store/image';
import { AsyncTaskErrorType } from '@/types/asyncTask';
@@ -71,6 +72,7 @@ export const GenerationBatchItem = memo<GenerationBatchItemProps>(({ batch }) =>
const removeGenerationBatch = useImageStore((s) => s.removeGenerationBatch);
const recreateImage = useImageStore((s) => s.recreateImage);
const reuseSettings = useImageStore((s) => s.reuseSettings);
+ const { shouldRenderBusinessBatchItem, businessBatchItem } = useRenderBusinessBatchItem(batch);
const time = useMemo(() => {
return dayjs(batch.createdAt).format('YYYY-MM-DD HH:mm:ss');
@@ -133,6 +135,10 @@ export const GenerationBatchItem = memo<GenerationBatchItemProps>(({ batch }) =>
);
}
+ if (shouldRenderBusinessBatchItem) {
+ return businessBatchItem;
+ }
+
// Calculate total number of reference images
const referenceImageCount =
(batch.config?.imageUrl ? 1 : 0) + (batch.config?.imageUrls?.length || 0);
diff --git a/src/business/client/features/FileSidePanel/UsageFooter.tsx b/src/business/client/features/FileSidePanel/UsageFooter.tsx
new file mode 100644
index 00000000000..12f30c205f2
--- /dev/null
+++ b/src/business/client/features/FileSidePanel/UsageFooter.tsx
@@ -0,0 +1,3 @@
+export default function UsageFooter() {
+ return null;
+}
diff --git a/src/business/client/features/User/BusinessPanelContent.tsx b/src/business/client/features/User/BusinessPanelContent.tsx
new file mode 100644
index 00000000000..5ee64636b4d
--- /dev/null
+++ b/src/business/client/features/User/BusinessPanelContent.tsx
@@ -0,0 +1,3 @@
+export default function BusinessPanelContent() {
+ return null;
+}
diff --git a/src/business/client/features/User/useBusinessMenuItems.tsx b/src/business/client/features/User/useBusinessMenuItems.tsx
new file mode 100644
index 00000000000..5966b07363b
--- /dev/null
+++ b/src/business/client/features/User/useBusinessMenuItems.tsx
@@ -0,0 +1,4 @@
+// eslint-disable-next-line unused-imports/no-unused-vars, @typescript-eslint/no-unused-vars
+export default function useBusinessMenuItems(isSignin: boolean | undefined) {
+ return [];
+}
diff --git a/src/business/client/hooks/useRenderBusinessBatchItem.tsx b/src/business/client/hooks/useRenderBusinessBatchItem.tsx
new file mode 100644
index 00000000000..ddcb7190476
--- /dev/null
+++ b/src/business/client/hooks/useRenderBusinessBatchItem.tsx
@@ -0,0 +1,9 @@
+import { GenerationBatch } from '@/types/generation';
+
+// eslint-disable-next-line unused-imports/no-unused-vars, @typescript-eslint/no-unused-vars
+export default function useRenderBusinessBatchItem(batch: GenerationBatch) {
+ return {
+ businessBatchItem: null,
+ shouldRenderBusinessBatchItem: false,
+ };
+}
diff --git a/src/features/ChatInput/ActionBar/STT/index.tsx b/src/features/ChatInput/ActionBar/STT/index.tsx
index 9f7597aa28a..efa0526dd75 100644
--- a/src/features/ChatInput/ActionBar/STT/index.tsx
+++ b/src/features/ChatInput/ActionBar/STT/index.tsx
@@ -1,3 +1,4 @@
+import { ENABLE_BUSINESS_FEATURES } from '@lobechat/business-const';
import isEqual from 'fast-deep-equal';
import { memo } from 'react';
@@ -10,10 +11,13 @@ import OpenaiSTT from './openai';
const STT = memo<{ mobile?: boolean }>(({ mobile }) => {
const { sttServer } = useUserStore(settingsSelectors.currentTTS, isEqual);
-
const { enableSTT } = useServerConfigStore(featureFlagsSelectors);
+
if (!enableSTT) return;
+ if (ENABLE_BUSINESS_FEATURES) {
+ return <BrowserSTT mobile={mobile} />;
+ }
switch (sttServer) {
case 'openai': {
return <OpenaiSTT mobile={mobile} />;
diff --git a/src/features/FileSidePanel/index.tsx b/src/features/FileSidePanel/index.tsx
index f88c9500083..3c41819fcab 100644
--- a/src/features/FileSidePanel/index.tsx
+++ b/src/features/FileSidePanel/index.tsx
@@ -1,10 +1,12 @@
'use client';
+import { ENABLE_BUSINESS_FEATURES } from '@lobechat/business-const';
import { DraggablePanel, DraggablePanelContainer, type DraggablePanelProps } from '@lobehub/ui';
import { createStaticStyles, cssVar, useResponsive } from 'antd-style';
import isEqual from 'fast-deep-equal';
import { type PropsWithChildren, memo, useEffect, useState } from 'react';
+import UsageFooter from '@/business/client/features/FileSidePanel/UsageFooter';
import { FOLDER_WIDTH } from '@/const/layoutTokens';
import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';
@@ -69,6 +71,7 @@ const FileSidePanel = memo<PropsWithChildren>(({ children }) => {
}}
>
{children}
+ {ENABLE_BUSINESS_FEATURES && <UsageFooter />}
</DraggablePanelContainer>
</DraggablePanel>
);
diff --git a/src/features/PlanIcon/index.tsx b/src/features/PlanIcon/index.tsx
index a33b3dd4293..ddb32d68df4 100644
--- a/src/features/PlanIcon/index.tsx
+++ b/src/features/PlanIcon/index.tsx
@@ -1,11 +1,10 @@
+import { Plans } from '@lobechat/types';
import { Center, Flexbox, Icon, Tag } from '@lobehub/ui';
import { createStaticStyles, cssVar } from 'antd-style';
import { Atom, Box, CircleSlash, Sparkle, Zap } from 'lucide-react';
import { type CSSProperties, type MouseEvent, memo } from 'react';
import { useTranslation } from 'react-i18next';
-import { Plans } from '@/types/subscription';
-
export const themes = {
[Plans.Free]: {
icon: CircleSlash,
diff --git a/src/features/User/PlanTag.tsx b/src/features/User/PlanTag.tsx
index 5573526bb0c..60fea5952aa 100644
--- a/src/features/User/PlanTag.tsx
+++ b/src/features/User/PlanTag.tsx
@@ -1,3 +1,4 @@
+import { Plans } from '@lobechat/types';
import { Tag } from '@lobehub/ui';
import { cssVar } from 'antd-style';
import { memo } from 'react';
@@ -8,7 +9,6 @@ import urlJoin from 'url-join';
import { OFFICIAL_URL } from '@/const/url';
import { isDesktop } from '@/const/version';
import PlanIcon from '@/features/PlanIcon';
-import { Plans } from '@/types/subscription';
export enum PlanType {
Preview = 'preview',
diff --git a/src/features/User/UserPanel/PanelContent.tsx b/src/features/User/UserPanel/PanelContent.tsx
index e93ba115381..31b8164cc43 100644
--- a/src/features/User/UserPanel/PanelContent.tsx
+++ b/src/features/User/UserPanel/PanelContent.tsx
@@ -1,9 +1,11 @@
+import { ENABLE_BUSINESS_FEATURES } from '@lobechat/business-const';
import { enableBetterAuth, enableNextAuth } from '@lobechat/const';
import { Flexbox } from '@lobehub/ui';
import { useRouter } from 'next/navigation';
import { memo } from 'react';
import { Link, useNavigate } from 'react-router-dom';
+import BusinessPanelContent from '@/business/client/features/User/BusinessPanelContent';
import BrandWatermark from '@/components/BrandWatermark';
import Menu from '@/components/Menu';
import { isDesktop } from '@/const/version';
@@ -60,7 +62,7 @@ const PanelContent = memo<{ closePopover: () => void }>(({ closePopover }) => {
{isDesktop || isLoginWithAuth ? (
<>
<UserInfo avatarProps={{ clickable: false }} />
-
+ {ENABLE_BUSINESS_FEATURES && <BusinessPanelContent />}
<Link style={{ color: 'inherit' }} to={'/settings/stats'}>
<DataStatistics />
</Link>
diff --git a/src/features/User/UserPanel/useMenu.tsx b/src/features/User/UserPanel/useMenu.tsx
index a10f2aaccc6..df42234ad7f 100644
--- a/src/features/User/UserPanel/useMenu.tsx
+++ b/src/features/User/UserPanel/useMenu.tsx
@@ -8,6 +8,7 @@ import { type PropsWithChildren, memo } from 'react';
import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom';
+import useBusinessMenuItems from '@/business/client/features/User/useBusinessMenuItems';
import type { MenuProps } from '@/components/Menu';
import { DEFAULT_DESKTOP_HOTKEY_CONFIG } from '@/const/desktop';
import { OFFICIAL_URL } from '@/const/url';
@@ -50,6 +51,7 @@ export const useMenu = () => {
authSelectors.isLogin(s),
authSelectors.isLoginWithAuth(s),
]);
+ const businessMenuItems = useBusinessMenuItems(isLogin);
const settings: MenuProps['items'] = [
{
@@ -68,10 +70,6 @@ export const useMenu = () => {
},
];
- /* ↓ cloud slot ↓ */
-
- /* ↑ cloud slot ↑ */
-
const pwa: MenuProps['items'] = [
{
icon: <Icon icon={Download} />,
@@ -119,9 +117,7 @@ export const useMenu = () => {
},
...(isLogin ? settings : []),
- /* ↓ cloud slot ↓ */
-
- /* ↑ cloud slot ↑ */
+ ...businessMenuItems,
...(canInstall ? pwa : []),
...data,
...(!hideDocs ? helps : []),
diff --git a/src/store/user/slices/common/initialState.ts b/src/store/user/slices/common/initialState.ts
index f426df38270..90c45f853c0 100644
--- a/src/store/user/slices/common/initialState.ts
+++ b/src/store/user/slices/common/initialState.ts
@@ -1,6 +1,4 @@
-import { type ReferralStatusString } from '@lobechat/types';
-
-import { type Plans } from '@/types/subscription';
+import { type Plans, type ReferralStatusString } from '@lobechat/types';
export interface CommonState {
isFreePlan?: boolean;