pref: trim the input of outlink (#2860)

This commit is contained in:
Finley Ge
2024-10-09 14:05:23 +08:00
committed by GitHub
parent f6c5695df4
commit 7afa8f00b8
2 changed files with 50 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { Flex, Box, Button, ModalFooter, ModalBody, Input, Link, Grid } from '@chakra-ui/react'; import { Flex, Box, Button, ModalBody, Input, Link } from '@chakra-ui/react';
import MyModal from '@fastgpt/web/components/common/MyModal'; import MyModal from '@fastgpt/web/components/common/MyModal';
import { PublishChannelEnum } from '@fastgpt/global/support/outLink/constant'; import { PublishChannelEnum } from '@fastgpt/global/support/outLink/constant';
import type { FeishuAppType, OutLinkEditType } from '@fastgpt/global/support/outLink/type'; import type { FeishuAppType, OutLinkEditType } from '@fastgpt/global/support/outLink/type';
@@ -11,7 +11,6 @@ import BasicInfo from '../components/BasicInfo';
import { getDocPath } from '@/web/common/system/doc'; import { getDocPath } from '@/web/common/system/doc';
import { useSystemStore } from '@/web/common/system/useSystemStore'; import { useSystemStore } from '@/web/common/system/useSystemStore';
import MyIcon from '@fastgpt/web/components/common/Icon'; import MyIcon from '@fastgpt/web/components/common/Icon';
import { useSystem } from '@fastgpt/web/hooks/useSystem';
import FormLabel from '@fastgpt/web/components/common/MyBox/FormLabel'; import FormLabel from '@fastgpt/web/components/common/MyBox/FormLabel';
const FeiShuEditModal = ({ const FeiShuEditModal = ({
@@ -39,11 +38,16 @@ const FeiShuEditModal = ({
}); });
const { runAsync: onclickCreate, loading: creating } = useRequest2( const { runAsync: onclickCreate, loading: creating } = useRequest2(
(e) => (e: Omit<OutLinkEditType<FeishuAppType>, 'appId' | 'type'>) =>
createShareChat({ createShareChat({
...e, ...e,
appId, appId,
type: PublishChannelEnum.feishu type: PublishChannelEnum.feishu,
app: {
appId: e?.app?.appId?.trim(),
appSecret: e.app?.appSecret?.trim(),
encryptKey: e.app?.encryptKey?.trim()
}
}), }),
{ {
errorToast: t('common:common.Create Failed'), errorToast: t('common:common.Create Failed'),
@@ -52,14 +56,24 @@ const FeiShuEditModal = ({
} }
); );
const { runAsync: onclickUpdate, loading: updating } = useRequest2((e) => updateShareChat(e), { const { runAsync: onclickUpdate, loading: updating } = useRequest2(
errorToast: t('common:common.Update Failed'), (e) =>
successToast: t('common:common.Update Success'), updateShareChat({
onSuccess: onEdit ...e,
}); app: {
appId: e?.app?.appId?.trim(),
appSecret: e.app?.appSecret?.trim(),
encryptKey: e.app?.encryptKey?.trim()
}
}),
{
errorToast: t('common:common.Update Failed'),
successToast: t('common:common.Update Success'),
onSuccess: onEdit
}
);
const { feConfigs } = useSystemStore(); const { feConfigs } = useSystemStore();
const { isPc } = useSystem();
return ( return (
<MyModal <MyModal

View File

@@ -38,12 +38,19 @@ const OffiAccountEditModal = ({
}); });
const { runAsync: onclickCreate, loading: creating } = useRequest2( const { runAsync: onclickCreate, loading: creating } = useRequest2(
(e) => (e: OutLinkEditType<OffiAccountAppType>) => {
createShareChat({ if (e?.app) {
e.app.appId = e.app.appId?.trim();
e.app.secret = e.app.secret?.trim();
e.app.CallbackToken = e.app.CallbackToken?.trim();
e.app.CallbackEncodingAesKey = e.app.CallbackEncodingAesKey?.trim();
}
return createShareChat({
...e, ...e,
appId, appId,
type: PublishChannelEnum.officialAccount type: PublishChannelEnum.officialAccount
}), });
},
{ {
errorToast: t('common:common.Create Failed'), errorToast: t('common:common.Create Failed'),
successToast: t('common:common.Create Success'), successToast: t('common:common.Create Success'),
@@ -51,11 +58,22 @@ const OffiAccountEditModal = ({
} }
); );
const { runAsync: onclickUpdate, loading: updating } = useRequest2((e) => updateShareChat(e), { const { runAsync: onclickUpdate, loading: updating } = useRequest2(
errorToast: t('common:common.Update Failed'), (e) => {
successToast: t('common:common.Update Success'), if (e?.app) {
onSuccess: onEdit e.app.appId = e.app.appId?.trim();
}); e.app.secret = e.app.secret?.trim();
e.app.CallbackToken = e.app.CallbackToken?.trim();
e.app.CallbackEncodingAesKey = e.app.CallbackEncodingAesKey?.trim();
}
return updateShareChat(e);
},
{
errorToast: t('common:common.Update Failed'),
successToast: t('common:common.Update Success'),
onSuccess: onEdit
}
);
const { feConfigs } = useSystemStore(); const { feConfigs } = useSystemStore();