From ffdef41bf2ba02ef99f27f2d1e397130363fcbd0 Mon Sep 17 00:00:00 2001
From: archer <545436317@qq.com>
Date: Wed, 26 Jul 2023 11:59:12 +0800
Subject: [PATCH] feat: phone slider
---
client/public/locales/en/common.json | 7 +-
client/public/locales/zh/common.json | 7 +-
client/src/components/Icon/index.tsx | 2 +-
client/src/components/Layout/navbar.tsx | 2 +-
client/src/components/Layout/navbarPhone.tsx | 2 +-
client/src/components/Tabs/index.tsx | 17 +-
client/src/hooks/useConfirm.tsx | 7 +-
client/src/pages/account/index.tsx | 4 +-
.../app/detail/components/AdEdit/index.tsx | 2 +-
.../app/detail/components/BasicEdit/index.tsx | 19 +-
client/src/pages/app/detail/index.tsx | 2 +-
client/src/pages/app/list/index.tsx | 14 +-
.../chat/components/ChatHistorySlider.tsx | 298 +++++++++++-------
.../src/pages/chat/components/SliderApps.tsx | 2 +-
client/src/pages/chat/components/ToolMenu.tsx | 2 +-
client/src/pages/chat/index.tsx | 9 +-
client/src/pages/chat/share.tsx | 9 +-
.../kb/detail/components/Import/Chunk.tsx | 4 +-
.../pages/kb/detail/components/Import/Csv.tsx | 4 +-
.../pages/kb/detail/components/Import/QA.tsx | 4 +-
.../src/pages/kb/detail/components/Info.tsx | 4 +-
client/src/pages/kb/list/index.tsx | 4 +-
client/src/store/user.ts | 5 +-
client/src/types/i18n.d.ts | 11 +-
24 files changed, 275 insertions(+), 166 deletions(-)
diff --git a/client/public/locales/en/common.json b/client/public/locales/en/common.json
index 80a7aeacf..e0885b329 100644
--- a/client/public/locales/en/common.json
+++ b/client/public/locales/en/common.json
@@ -1,13 +1,18 @@
{
+ "App": "App",
"Cancel": "No",
"Confirm": "Yes",
"Warning": "Warning",
"app": {
"App Detail": "App Detail",
- "My Apps": "My Apps"
+ "My Apps": "My Apps",
+ "Confirm Save App Tip": "After saving, the advanced orchestration configuration will be overwritten. Make sure that the application does not use advanced orchestration.",
+ "Confirm Del App Tip": "Confirm to delete the app and all its chats"
},
"chat": {
"Confirm to clear history": "Confirm to clear history?",
+ "Exit Chat": "Exit",
+ "History": "History",
"New Chat": "New Chat",
"You need to a chat app": "You need to a chat app"
},
diff --git a/client/public/locales/zh/common.json b/client/public/locales/zh/common.json
index 89c4e9d6e..7181d49d1 100644
--- a/client/public/locales/zh/common.json
+++ b/client/public/locales/zh/common.json
@@ -1,13 +1,18 @@
{
+ "App": "应用",
"Cancel": "取消",
"Confirm": "确认",
"Warning": "提示",
"app": {
"App Detail": "应用详情",
- "My Apps": "我的应用"
+ "My Apps": "我的应用",
+ "Confirm Save App Tip": "保存后将会覆盖高级编排配置,请确保该应用未使用高级编排功能。",
+ "Confirm Del App Tip": "确认删除该应用及其所有聊天记录?"
},
"chat": {
"Confirm to clear history": "确认清空该应用的聊天记录?",
+ "Exit Chat": "退出聊天",
+ "History": "记录",
"New Chat": "新对话",
"You need to a chat app": "你需要创建一个应用"
},
diff --git a/client/src/components/Icon/index.tsx b/client/src/components/Icon/index.tsx
index b387ba4e4..8efdd5edc 100644
--- a/client/src/components/Icon/index.tsx
+++ b/client/src/components/Icon/index.tsx
@@ -35,7 +35,7 @@ const map = {
apikey: require('./icons/apikey.svg').default,
save: require('./icons/save.svg').default,
minus: require('./icons/minus.svg').default,
- chatLight: require('./icons/light/chat.svg').default,
+ chat: require('./icons/light/chat.svg').default,
chatFill: require('./icons/fill/chat.svg').default,
clear: require('./icons/light/clear.svg').default,
apiLight: require('./icons/light/appApi.svg').default,
diff --git a/client/src/components/Layout/navbar.tsx b/client/src/components/Layout/navbar.tsx
index bcd9ef403..085986fa3 100644
--- a/client/src/components/Layout/navbar.tsx
+++ b/client/src/components/Layout/navbar.tsx
@@ -26,7 +26,7 @@ const Navbar = ({ unread }: { unread: number }) => {
() => [
{
label: t('navbar.Chat'),
- icon: 'chatLight',
+ icon: 'chat',
activeIcon: 'chatFill',
link: `/chat?appId=${lastChatAppId}&chatId=${lastChatId}`,
activeLink: ['/chat']
diff --git a/client/src/components/Layout/navbarPhone.tsx b/client/src/components/Layout/navbarPhone.tsx
index aff1fc04f..5bba9684b 100644
--- a/client/src/components/Layout/navbarPhone.tsx
+++ b/client/src/components/Layout/navbarPhone.tsx
@@ -14,7 +14,7 @@ const NavbarPhone = ({ unread }: { unread: number }) => {
() => [
{
label: t('navbar.Chat'),
- icon: 'chatLight',
+ icon: 'chat',
link: `/chat?appId=${lastChatAppId}&chatId=${lastChatId}`,
activeLink: ['/chat'],
unread: 0
diff --git a/client/src/components/Tabs/index.tsx b/client/src/components/Tabs/index.tsx
index 24e4495ec..d84e1c04e 100644
--- a/client/src/components/Tabs/index.tsx
+++ b/client/src/components/Tabs/index.tsx
@@ -1,6 +1,7 @@
import React, { useMemo } from 'react';
-import { Box, Grid, useTheme } from '@chakra-ui/react';
+import { Box, Grid } from '@chakra-ui/react';
import type { GridProps } from '@chakra-ui/react';
+import { useTranslation } from 'react-i18next';
// @ts-ignore
interface Props extends GridProps {
@@ -11,7 +12,7 @@ interface Props extends GridProps {
}
const Tabs = ({ list, size = 'md', activeId, onChange, ...props }: Props) => {
- const theme = useTheme();
+ const { t } = useTranslation();
const sizeMap = useMemo(() => {
switch (size) {
case 'sm':
@@ -47,14 +48,14 @@ const Tabs = ({ list, size = 'md', activeId, onChange, ...props }: Props) => {
{
onChange(item.id);
}}
>
- {item.label}
+ {t(item.label) || item.label}
))}
diff --git a/client/src/hooks/useConfirm.tsx b/client/src/hooks/useConfirm.tsx
index bf0f56e64..c11eca95e 100644
--- a/client/src/hooks/useConfirm.tsx
+++ b/client/src/hooks/useConfirm.tsx
@@ -11,8 +11,9 @@ import {
} from '@chakra-ui/react';
import { useTranslation } from 'next-i18next';
-export const useConfirm = ({ title = 'Warning', content }: { title?: string; content: string }) => {
+export const useConfirm = (props: { title?: string; content: string }) => {
const { t } = useTranslation();
+ const { title = t('Warning'), content } = props;
const { isOpen, onOpen, onClose } = useDisclosure();
const cancelRef = useRef(null);
@@ -29,13 +30,13 @@ export const useConfirm = ({ title = 'Warning', content }: { title?: string; con
},
[onOpen]
),
- ConfirmChild: useCallback(
+ ConfirmModal: useCallback(
() => (
- {t(title)}
+ {title}
{content}
diff --git a/client/src/pages/account/index.tsx b/client/src/pages/account/index.tsx
index a4c79cc4a..2968086d0 100644
--- a/client/src/pages/account/index.tsx
+++ b/client/src/pages/account/index.tsx
@@ -39,7 +39,7 @@ const Account = ({ currentTab }: { currentTab: `${TabEnum}` }) => {
{ icon: 'loginoutLight', label: '登出', id: TabEnum.loginout, Component: () => <>> }
]);
- const { openConfirm, ConfirmChild } = useConfirm({
+ const { openConfirm, ConfirmModal } = useConfirm({
content: '确认退出登录?'
});
@@ -111,7 +111,7 @@ const Account = ({ currentTab }: { currentTab: `${TabEnum}` }) => {
{currentTab === TabEnum.inform && }
-
+
);
};
diff --git a/client/src/pages/app/detail/components/AdEdit/index.tsx b/client/src/pages/app/detail/components/AdEdit/index.tsx
index 52ba0076f..2a741e112 100644
--- a/client/src/pages/app/detail/components/AdEdit/index.tsx
+++ b/client/src/pages/app/detail/components/AdEdit/index.tsx
@@ -347,7 +347,7 @@ const AppEdit = ({ app, fullScreen, onFullScreen }: Props) => {
}
+ icon={}
borderRadius={'lg'}
aria-label={'save'}
variant={'base'}
diff --git a/client/src/pages/app/detail/components/BasicEdit/index.tsx b/client/src/pages/app/detail/components/BasicEdit/index.tsx
index a955ab420..93cd7fb23 100644
--- a/client/src/pages/app/detail/components/BasicEdit/index.tsx
+++ b/client/src/pages/app/detail/components/BasicEdit/index.tsx
@@ -52,6 +52,7 @@ import MyTooltip from '@/components/MyTooltip';
import Avatar from '@/components/Avatar';
import MyIcon from '@/components/Icon';
import ChatBox, { type ComponentRef, type StartChatFnProps } from '@/components/ChatBox';
+import { useTranslation } from 'react-i18next';
import { getSpecialModule } from '@/components/ChatBox/utils';
import { addVariable } from '../VariableEditModal';
@@ -63,6 +64,7 @@ const InfoModal = dynamic(() => import('../InfoModal'));
const Settings = ({ appId }: { appId: string }) => {
const theme = useTheme();
const router = useRouter();
+ const { t } = useTranslation();
const { toast } = useToast();
const { appDetail, updateAppDetail, loadKbList, myKbList } = useUserStore();
const { isPc } = useGlobalStore();
@@ -72,9 +74,11 @@ const Settings = ({ appId }: { appId: string }) => {
const [refresh, setRefresh] = useState(false);
- const { openConfirm, ConfirmChild } = useConfirm({
- title: '警告',
- content: '保存后将会覆盖高级编排配置,请确保该应用未使用高级编排功能。'
+ const { openConfirm: openConfirmSave, ConfirmModal: ConfirmSaveModal } = useConfirm({
+ content: t('app.Confirm Save App Tip')
+ });
+ const { openConfirm: openConfirmDel, ConfirmModal: ConfirmDelModal } = useConfirm({
+ content: t('app.Confirm Del App Tip')
});
const { register, setValue, getValues, reset, handleSubmit, control } = useForm({
defaultValues: getDefaultAppForm()
@@ -227,7 +231,7 @@ const Settings = ({ appId }: { appId: string }) => {
color: 'red.600'
}}
isLoading={isLoading}
- onClick={openConfirm(handleDelModel)}
+ onClick={openConfirmDel(handleDelModel)}
/>
{
}
+ leftIcon={}
onClick={() => router.push(`/chat?appId=${appId}`)}
>
对话
@@ -286,7 +290,7 @@ const Settings = ({ appId }: { appId: string }) => {
isLoading={isSaving}
fontSize={'sm'}
size={['sm', 'md']}
- onClick={openConfirm(handleSubmit((data) => onSubmitSave(data)))}
+ onClick={openConfirmSave(handleSubmit((data) => onSubmitSave(data)))}
>
{isPc ? '保存并预览' : '保存'}
@@ -494,7 +498,8 @@ const Settings = ({ appId }: { appId: string }) => {
/>
-
+
+
{settingAppInfo && (
setSettingAppInfo(undefined)} />
)}
diff --git a/client/src/pages/app/detail/index.tsx b/client/src/pages/app/detail/index.tsx
index 6eaa03905..27eb7c8b0 100644
--- a/client/src/pages/app/detail/index.tsx
+++ b/client/src/pages/app/detail/index.tsx
@@ -59,7 +59,7 @@ const AppDetail = ({ currentTab }: { currentTab: `${TabEnum}` }) => {
{ label: '高级编排', id: TabEnum.adEdit, icon: 'settingLight' },
{ label: '链接分享', id: TabEnum.share, icon: 'shareLight' },
{ label: 'API访问', id: TabEnum.API, icon: 'apiLight' },
- { label: '立即对话', id: 'startChat', icon: 'chatLight' }
+ { label: '立即对话', id: 'startChat', icon: 'chat' }
],
[]
);
diff --git a/client/src/pages/app/list/index.tsx b/client/src/pages/app/list/index.tsx
index d85c099a6..f1ab1d849 100644
--- a/client/src/pages/app/list/index.tsx
+++ b/client/src/pages/app/list/index.tsx
@@ -34,7 +34,7 @@ const MyApps = () => {
const theme = useTheme();
const router = useRouter();
const { myApps, loadMyApps } = useUserStore();
- const { openConfirm, ConfirmChild } = useConfirm({
+ const { openConfirm, ConfirmModal } = useConfirm({
title: '删除提示',
content: '确认删除该应用所有信息?'
});
@@ -53,7 +53,7 @@ const MyApps = () => {
title: '删除成功',
status: 'success'
});
- loadMyApps();
+ loadMyApps(true);
} catch (err: any) {
toast({
title: err?.message || '删除失败',
@@ -65,7 +65,7 @@ const MyApps = () => {
);
/* 加载模型 */
- useQuery(['loadModels'], loadMyApps, {
+ useQuery(['loadModels'], () => loadMyApps(true), {
refetchOnMount: true
});
@@ -147,7 +147,7 @@ const MyApps = () => {
size={'sm'}
icon={
-
+
}
variant={'base'}
@@ -165,8 +165,10 @@ const MyApps = () => {
))}
-
- {isOpenCreateModal && }
+
+ {isOpenCreateModal && (
+ loadMyApps(true)} />
+ )}
);
};
diff --git a/client/src/pages/chat/components/ChatHistorySlider.tsx b/client/src/pages/chat/components/ChatHistorySlider.tsx
index 420684348..dc71f33d2 100644
--- a/client/src/pages/chat/components/ChatHistorySlider.tsx
+++ b/client/src/pages/chat/components/ChatHistorySlider.tsx
@@ -1,4 +1,4 @@
-import React, { useMemo } from 'react';
+import React, { useMemo, useState } from 'react';
import {
Box,
Button,
@@ -18,6 +18,9 @@ import MyTooltip from '@/components/MyTooltip';
import MyIcon from '@/components/Icon';
import { useTranslation } from 'react-i18next';
import { useConfirm } from '@/hooks/useConfirm';
+import Tabs from '@/components/Tabs';
+import { useUserStore } from '@/store/user';
+import { useQuery } from '@tanstack/react-query';
type HistoryItemType = {
id: string;
@@ -26,6 +29,11 @@ type HistoryItemType = {
top?: boolean;
};
+enum TabEnum {
+ 'app' = 'app',
+ 'history' = 'history'
+}
+
const ChatHistorySlider = ({
appId,
appName,
@@ -36,7 +44,8 @@ const ChatHistorySlider = ({
onDelHistory,
onClearHistory,
onSetHistoryTop,
- onSetCustomTitle
+ onSetCustomTitle,
+ onClose
}: {
appId?: string;
appName: string;
@@ -48,25 +57,41 @@ const ChatHistorySlider = ({
onClearHistory: () => void;
onSetHistoryTop?: (e: { chatId: string; top: boolean }) => void;
onSetCustomTitle?: (e: { chatId: string; title: string }) => void;
+ onClose: () => void;
}) => {
const theme = useTheme();
const router = useRouter();
const { t } = useTranslation();
const { isPc } = useGlobalStore();
+ const { myApps, loadMyApps, userInfo } = useUserStore();
+
+ const [currentTab, setCurrentTab] = useState<`${TabEnum}`>(TabEnum.history);
+
// custom title edit
const { onOpenModal, EditModal: EditTitleModal } = useEditInfo({
title: '自定义历史记录标题',
placeholder: '如果设置为空,会自动跟随聊天记录。'
});
- const { openConfirm, ConfirmChild } = useConfirm({
+ const { openConfirm, ConfirmModal } = useConfirm({
content: t('chat.Confirm to clear history')
});
const concatHistory = useMemo(
- () => (!activeChatId ? [{ id: activeChatId, title: '新对话' }].concat(history) : history),
+ () =>
+ !activeChatId ? [{ id: activeChatId, title: t('chat.New Chat') }].concat(history) : history,
[activeChatId, history]
);
+ const isShare = useMemo(() => !appId || !userInfo, [appId, userInfo]);
+
+ useQuery(['init'], () => {
+ if (isShare) {
+ setCurrentTab(TabEnum.history);
+ return null;
+ }
+ return loadMyApps(false);
+ });
+
return (
)}
- {/* btn */}
-
+
+ {/* menu */}
+
+ {!isPc && !isShare && (
+ setCurrentTab(e as `${TabEnum}`)}
+ />
+ )}
}
+ leftIcon={}
overflow={'hidden'}
onClick={() => onChangeChat()}
>
{t('chat.New Chat')}
-
-
-
+ {(isPc || isShare) && (
+
+
+
+ )}
- {/* chat history */}
- {concatHistory.map((item, i) => (
- {
- onChangeChat(item.id);
+ {/* chat history */}
+ {(currentTab === TabEnum.history || isPc) && (
+ <>
+ {concatHistory.map((item, i) => (
+
-
-
- {item.customTitle || item.title}
-
- {!!item.id && (
-
-
-
- )}
-
- ))}
+
+
+
+ {onSetHistoryTop && (
+
+ )}
+ {onSetCustomTitle && (
+
+ )}
+
+
+
+
+ )}
+
+ ))}
+ >
+ )}
+ {currentTab === TabEnum.app && !isPc && (
+ <>
+ {myApps.map((item) => (
+ {
+ router.replace({
+ query: {
+ appId: item._id
+ }
+ });
+ onClose();
+ }
+ })}
+ >
+
+
+ {item.name}
+
+
+ ))}
+ >
+ )}
{!isPc && appId && (
@@ -245,11 +323,11 @@ const ChatHistorySlider = ({
borderRadius={'50%'}
aria-label={''}
/>
- 切换应用
+ {t('chat.Exit Chat')}
)}
-
+
);
};
diff --git a/client/src/pages/chat/components/SliderApps.tsx b/client/src/pages/chat/components/SliderApps.tsx
index 45322e051..dc5324c27 100644
--- a/client/src/pages/chat/components/SliderApps.tsx
+++ b/client/src/pages/chat/components/SliderApps.tsx
@@ -10,7 +10,7 @@ const SliderApps = ({ appId }: { appId: string }) => {
const router = useRouter();
const { myApps, loadMyApps } = useUserStore();
- useQuery(['loadModels'], loadMyApps);
+ useQuery(['loadModels'], () => loadMyApps(false));
return (
<>
diff --git a/client/src/pages/chat/components/ToolMenu.tsx b/client/src/pages/chat/components/ToolMenu.tsx
index 921878bff..f241cd5cb 100644
--- a/client/src/pages/chat/components/ToolMenu.tsx
+++ b/client/src/pages/chat/components/ToolMenu.tsx
@@ -10,7 +10,7 @@ const ToolMenu = ({ history }: { history: ChatItemType[] }) => {
const router = useRouter();
const menuList = useRef([
{
- icon: 'chatLight',
+ icon: 'chat',
label: '新对话',
onClick: () => {
router.push({
diff --git a/client/src/pages/chat/index.tsx b/client/src/pages/chat/index.tsx
index 2270fad73..7d06e54d1 100644
--- a/client/src/pages/chat/index.tsx
+++ b/client/src/pages/chat/index.tsx
@@ -258,7 +258,13 @@ const Chat = ({ appId, chatId }: { appId: string; chatId: string }) => {
return isPc || !appId ? (
{children}
) : (
-
+
{children}
@@ -269,6 +275,7 @@ const Chat = ({ appId, chatId }: { appId: string; chatId: string }) => {
appName={chatData.app.name}
appAvatar={chatData.app.avatar}
activeChatId={chatId}
+ onClose={onCloseSlider}
history={history.map((item, i) => ({
id: item.chatId,
title: item.title,
diff --git a/client/src/pages/chat/share.tsx b/client/src/pages/chat/share.tsx
index 66877c321..5130fe437 100644
--- a/client/src/pages/chat/share.tsx
+++ b/client/src/pages/chat/share.tsx
@@ -151,7 +151,13 @@ const ShareChat = ({ shareId, chatId }: { shareId: string; chatId: string }) =>
return isPc ? (
{children}
) : (
-
+
{children}
@@ -167,6 +173,7 @@ const ShareChat = ({ shareId, chatId }: { shareId: string; chatId: string }) =>
id: item.chatId,
title: item.title
}))}
+ onClose={onCloseSlider}
onChangeChat={(chatId) => {
console.log(chatId);
diff --git a/client/src/pages/kb/detail/components/Import/Chunk.tsx b/client/src/pages/kb/detail/components/Import/Chunk.tsx
index 456cd82c5..6b70473de 100644
--- a/client/src/pages/kb/detail/components/Import/Chunk.tsx
+++ b/client/src/pages/kb/detail/components/Import/Chunk.tsx
@@ -69,7 +69,7 @@ const ChunkImport = ({ kbId }: { kbId: string }) => {
return formatPrice(files.reduce((sum, file) => sum + file.tokens, 0) * unitPrice);
}, [files, unitPrice]);
- const { openConfirm, ConfirmChild } = useConfirm({
+ const { openConfirm, ConfirmModal } = useConfirm({
content: `该任务无法终止,需要一定时间生成索引,请确认导入。如果余额不足,未完成的任务会被暂停,充值后可继续进行。`
});
@@ -455,7 +455,7 @@ const ChunkImport = ({ kbId }: { kbId: string }) => {
)}
)}
-
+
);
};
diff --git a/client/src/pages/kb/detail/components/Import/Csv.tsx b/client/src/pages/kb/detail/components/Import/Csv.tsx
index 57675c946..aa0d46f27 100644
--- a/client/src/pages/kb/detail/components/Import/Csv.tsx
+++ b/client/src/pages/kb/detail/components/Import/Csv.tsx
@@ -39,7 +39,7 @@ const CsvImport = ({ kbId }: { kbId: string }) => {
);
const emptyFiles = useMemo(() => files.length === 0, [files]);
- const { openConfirm, ConfirmChild } = useConfirm({
+ const { openConfirm, ConfirmModal } = useConfirm({
content: `该任务无法终止,需要一定时间生成索引,请确认导入。如果余额不足,未完成的任务会被暂停,充值后可继续进行。`
});
@@ -234,7 +234,7 @@ const CsvImport = ({ kbId }: { kbId: string }) => {
)}
-
+
);
};
diff --git a/client/src/pages/kb/detail/components/Import/QA.tsx b/client/src/pages/kb/detail/components/Import/QA.tsx
index 54dc8f4f0..59b6991ab 100644
--- a/client/src/pages/kb/detail/components/Import/QA.tsx
+++ b/client/src/pages/kb/detail/components/Import/QA.tsx
@@ -71,7 +71,7 @@ const QAImport = ({ kbId }: { kbId: string }) => {
return formatPrice(files.reduce((sum, file) => sum + file.tokens, 0) * unitPrice * 1.3);
}, [files, unitPrice]);
- const { openConfirm, ConfirmChild } = useConfirm({
+ const { openConfirm, ConfirmModal } = useConfirm({
content: `该任务无法终止!导入后会自动调用大模型生成问答对,会有一些细节丢失,请确认!如果余额不足,未完成的任务会被暂停。`
});
@@ -446,7 +446,7 @@ const QAImport = ({ kbId }: { kbId: string }) => {
)}
)}
-
+
);
};
diff --git a/client/src/pages/kb/detail/components/Info.tsx b/client/src/pages/kb/detail/components/Info.tsx
index b68442ed0..998c744c2 100644
--- a/client/src/pages/kb/detail/components/Info.tsx
+++ b/client/src/pages/kb/detail/components/Info.tsx
@@ -40,7 +40,7 @@ const Info = (
const [btnLoading, setBtnLoading] = useState(false);
const [refresh, setRefresh] = useState(false);
- const { openConfirm, ConfirmChild } = useConfirm({
+ const { openConfirm, ConfirmModal } = useConfirm({
content: '确认删除该知识库?数据将无法恢复,请确认!'
});
@@ -251,7 +251,7 @@ const Info = (
/>
-
+
);
};
diff --git a/client/src/pages/kb/list/index.tsx b/client/src/pages/kb/list/index.tsx
index 0e0ca7791..506d1b9a9 100644
--- a/client/src/pages/kb/list/index.tsx
+++ b/client/src/pages/kb/list/index.tsx
@@ -18,7 +18,7 @@ const Kb = () => {
const theme = useTheme();
const router = useRouter();
const { toast } = useToast();
- const { openConfirm, ConfirmChild } = useConfirm({
+ const { openConfirm, ConfirmModal } = useConfirm({
title: '删除提示',
content: '确认删除该知识库?'
});
@@ -152,7 +152,7 @@ const Kb = () => {
)}
-
+
);
};
diff --git a/client/src/store/user.ts b/client/src/store/user.ts
index 4793c4792..7d8e849f7 100644
--- a/client/src/store/user.ts
+++ b/client/src/store/user.ts
@@ -19,7 +19,7 @@ type State = {
updateUserInfo: (user: UserUpdateParams) => void;
myApps: AppListItemType[];
myCollectionApps: AppListItemType[];
- loadMyApps: () => Promise;
+ loadMyApps: (init?: boolean) => Promise;
appDetail: AppSchema;
loadAppDetail: (id: string, init?: boolean) => Promise;
updateAppDetail(appId: string, data: AppUpdateParams): Promise;
@@ -63,7 +63,8 @@ export const useUserStore = create()(
},
myApps: [],
myCollectionApps: [],
- async loadMyApps() {
+ async loadMyApps(init = true) {
+ if (get().myApps.length > 0 && !init) return [];
const res = await getMyModels();
set((state) => {
state.myApps = res;
diff --git a/client/src/types/i18n.d.ts b/client/src/types/i18n.d.ts
index 9a942c22f..07c25d502 100644
--- a/client/src/types/i18n.d.ts
+++ b/client/src/types/i18n.d.ts
@@ -1,13 +1,10 @@
import 'i18next';
import common from '../../public/locales/en/common.json';
-interface I18nNamespaces {
- common: typeof common;
-}
-
declare module 'i18next' {
- interface CustomTypeOptions {
- defaultNS: 'common';
- resources: I18nNamespaces;
+ interface Resources {
+ [key: string]: {
+ [key: string]: string;
+ };
}
}