@@ -118,7 +118,7 @@ const Share = ({ appId }: { appId: string }) => {
| {item.lastTime ? formatTimeToChatTime(item.lastTime) : '未使用'} |
-
+
{
_hover={{ color: 'myBlue.600' }}
onClick={() => {
const url = `${location.origin}/chat/share?shareId=${item.shareId}`;
- copyData(url, '已复制分享地址');
+ copyData(url, '已复制分享链接');
}}
/>
@@ -205,4 +205,47 @@ const Share = ({ appId }: { appId: string }) => {
);
};
-export default Share;
+enum LinkTypeEnum {
+ share = 'share',
+ iframe = 'iframe'
+}
+
+const OutLink = ({ appId }: { appId: string }) => {
+ const theme = useTheme();
+
+ const [linkType, setLinkType] = useState<`${LinkTypeEnum}`>(LinkTypeEnum.share);
+
+ return (
+
+
+ 外部使用途径
+
+
+ setLinkType(e as `${LinkTypeEnum}`)}
+ />
+
+
+ {linkType === LinkTypeEnum.share && }
+
+ );
+};
+
+export default OutLink;
diff --git a/client/src/pages/app/detail/index.tsx b/client/src/pages/app/detail/index.tsx
index 27eb7c8b0..27efbe464 100644
--- a/client/src/pages/app/detail/index.tsx
+++ b/client/src/pages/app/detail/index.tsx
@@ -20,7 +20,7 @@ const AdEdit = dynamic(() => import('./components/AdEdit'), {
ssr: false,
loading: () =>
});
-const Share = dynamic(() => import('./components/Share'), {
+const OutLink = dynamic(() => import('./components/OutLink'), {
ssr: false
});
const API = dynamic(() => import('./components/API'), {
@@ -30,7 +30,7 @@ const API = dynamic(() => import('./components/API'), {
enum TabEnum {
'basicEdit' = 'basicEdit',
'adEdit' = 'adEdit',
- 'share' = 'share',
+ 'outLink' = 'outLink',
'API' = 'API'
}
@@ -57,7 +57,7 @@ const AppDetail = ({ currentTab }: { currentTab: `${TabEnum}` }) => {
() => [
{ label: '简易配置', id: TabEnum.basicEdit, icon: 'overviewLight' },
{ label: '高级编排', id: TabEnum.adEdit, icon: 'settingLight' },
- { label: '链接分享', id: TabEnum.share, icon: 'shareLight' },
+ { label: '外部使用', id: TabEnum.outLink, icon: 'shareLight' },
{ label: 'API访问', id: TabEnum.API, icon: 'apiLight' },
{ label: '立即对话', id: 'startChat', icon: 'chat' }
],
@@ -178,7 +178,7 @@ const AppDetail = ({ currentTab }: { currentTab: `${TabEnum}` }) => {
/>
)}
{currentTab === TabEnum.API && }
- {currentTab === TabEnum.share && }
+ {currentTab === TabEnum.outLink && }
diff --git a/client/src/pages/chat/share.tsx b/client/src/pages/chat/share.tsx
index 5130fe437..fd681dfda 100644
--- a/client/src/pages/chat/share.tsx
+++ b/client/src/pages/chat/share.tsx
@@ -20,7 +20,7 @@ import ChatHeader from './components/ChatHeader';
import ChatHistorySlider from './components/ChatHistorySlider';
import { serviceSideProps } from '@/utils/i18n';
-const ShareChat = ({ shareId, chatId }: { shareId: string; chatId: string }) => {
+const OutLink = ({ shareId, chatId }: { shareId: string; chatId: string }) => {
const router = useRouter();
const { toast } = useToast();
const { isOpen: isOpenSlider, onClose: onCloseSlider, onOpen: onOpenSlider } = useDisclosure();
@@ -250,4 +250,4 @@ export async function getServerSideProps(context: any) {
};
}
-export default ShareChat;
+export default OutLink;
diff --git a/client/src/service/events/pushBill.ts b/client/src/service/events/pushBill.ts
index dc1d4f622..709298ccb 100644
--- a/client/src/service/events/pushBill.ts
+++ b/client/src/service/events/pushBill.ts
@@ -1,4 +1,4 @@
-import { connectToDatabase, Bill, User, ShareChat } from '../mongo';
+import { connectToDatabase, Bill, User, OutLink } from '../mongo';
import { BillSourceEnum } from '@/constants/user';
import { getModel } from '../utils/data';
import { ChatHistoryItemResType } from '@/types/chat';
@@ -59,7 +59,7 @@ export const updateShareChatBill = async ({
total: number;
}) => {
try {
- await ShareChat.findOneAndUpdate(
+ await OutLink.findOneAndUpdate(
{ shareId },
{
$inc: { total },
diff --git a/client/src/service/models/shareChat.ts b/client/src/service/models/outLink.ts
similarity index 57%
rename from client/src/service/models/shareChat.ts
rename to client/src/service/models/outLink.ts
index a9adc3ef0..ba46ac7d4 100644
--- a/client/src/service/models/shareChat.ts
+++ b/client/src/service/models/outLink.ts
@@ -1,7 +1,8 @@
import { Schema, model, models, Model } from 'mongoose';
-import { ShareChatSchema as ShareChatSchemaType } from '@/types/mongoSchema';
+import { OutLinkSchema as SchmaType } from '@/types/mongoSchema';
+import { OutLinkTypeEnum } from '@/constants/chat';
-const ShareChatSchema = new Schema({
+const OutLinkSchema = new Schema({
shareId: {
type: String,
required: true
@@ -16,6 +17,10 @@ const ShareChatSchema = new Schema({
ref: 'model',
required: true
},
+ type: {
+ type: String,
+ default: OutLinkTypeEnum.share
+ },
name: {
type: String,
required: true
@@ -29,5 +34,4 @@ const ShareChatSchema = new Schema({
}
});
-export const ShareChat: Model =
- models['shareChat'] || model('shareChat', ShareChatSchema);
+export const OutLink: Model = models['outlinks'] || model('outlinks', OutLinkSchema);
diff --git a/client/src/service/mongo.ts b/client/src/service/mongo.ts
index 723dd1e1b..26c18caf8 100644
--- a/client/src/service/mongo.ts
+++ b/client/src/service/mongo.ts
@@ -120,7 +120,7 @@ export * from './models/trainingData';
export * from './models/openapi';
export * from './models/promotionRecord';
export * from './models/collection';
-export * from './models/shareChat';
+export * from './models/outLink';
export * from './models/kb';
export * from './models/inform';
export * from './models/image';
diff --git a/client/src/service/utils/auth.ts b/client/src/service/utils/auth.ts
index fb920bc39..73123d1e0 100644
--- a/client/src/service/utils/auth.ts
+++ b/client/src/service/utils/auth.ts
@@ -1,7 +1,7 @@
import type { NextApiRequest } from 'next';
import jwt from 'jsonwebtoken';
import Cookie from 'cookie';
-import { App, OpenApi, User, ShareChat, KB } from '../mongo';
+import { App, OpenApi, User, OutLink, KB } from '../mongo';
import type { AppSchema } from '@/types/mongoSchema';
import { formatPrice } from '@/utils/user';
import { ERROR_ENUM } from '../errorCode';
@@ -216,7 +216,7 @@ export const authKb = async ({ kbId, userId }: { kbId: string; userId: string })
export const authShareChat = async ({ shareId }: { shareId: string }) => {
// get shareChat
- const shareChat = await ShareChat.findOne({ shareId });
+ const shareChat = await OutLink.findOne({ shareId });
if (!shareChat) {
return Promise.reject('分享链接已失效');
diff --git a/client/src/types/mongoSchema.d.ts b/client/src/types/mongoSchema.d.ts
index f35c987ae..45cda9630 100644
--- a/client/src/types/mongoSchema.d.ts
+++ b/client/src/types/mongoSchema.d.ts
@@ -135,7 +135,7 @@ export interface PromotionRecordSchema {
amount: number;
}
-export interface ShareChatSchema {
+export interface OutLinkSchema {
_id: string;
shareId: string;
userId: string;
|