Skip to content

Commit

Permalink
pref: trim the input of outlink (#2860)
Browse files Browse the repository at this point in the history
  • Loading branch information
FinleyGe authored Oct 9, 2024
1 parent f6c5695 commit 7afa8f0
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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 { PublishChannelEnum } from '@fastgpt/global/support/outLink/constant';
import type { FeishuAppType, OutLinkEditType } from '@fastgpt/global/support/outLink/type';
Expand All @@ -11,7 +11,6 @@ import BasicInfo from '../components/BasicInfo';
import { getDocPath } from '@/web/common/system/doc';
import { useSystemStore } from '@/web/common/system/useSystemStore';
import MyIcon from '@fastgpt/web/components/common/Icon';
import { useSystem } from '@fastgpt/web/hooks/useSystem';
import FormLabel from '@fastgpt/web/components/common/MyBox/FormLabel';

const FeiShuEditModal = ({
Expand Down Expand Up @@ -39,11 +38,16 @@ const FeiShuEditModal = ({
});

const { runAsync: onclickCreate, loading: creating } = useRequest2(
(e) =>
(e: Omit<OutLinkEditType<FeishuAppType>, 'appId' | 'type'>) =>
createShareChat({
...e,
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'),
Expand All @@ -52,14 +56,24 @@ const FeiShuEditModal = ({
}
);

const { runAsync: onclickUpdate, loading: updating } = useRequest2((e) => updateShareChat(e), {
errorToast: t('common:common.Update Failed'),
successToast: t('common:common.Update Success'),
onSuccess: onEdit
});
const { runAsync: onclickUpdate, loading: updating } = useRequest2(
(e) =>
updateShareChat({
...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 { isPc } = useSystem();

return (
<MyModal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,42 @@ const OffiAccountEditModal = ({
});

const { runAsync: onclickCreate, loading: creating } = useRequest2(
(e) =>
createShareChat({
(e: OutLinkEditType<OffiAccountAppType>) => {
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,
appId,
type: PublishChannelEnum.officialAccount
}),
});
},
{
errorToast: t('common:common.Create Failed'),
successToast: t('common:common.Create Success'),
onSuccess: onCreate
}
);

const { runAsync: onclickUpdate, loading: updating } = useRequest2((e) => updateShareChat(e), {
errorToast: t('common:common.Update Failed'),
successToast: t('common:common.Update Success'),
onSuccess: onEdit
});
const { runAsync: onclickUpdate, loading: updating } = useRequest2(
(e) => {
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 updateShareChat(e);
},
{
errorToast: t('common:common.Update Failed'),
successToast: t('common:common.Update Success'),
onSuccess: onEdit
}
);

const { feConfigs } = useSystemStore();

Expand Down

0 comments on commit 7afa8f0

Please sign in to comment.