Skip to content

Commit

Permalink
4.8.10 test (#2470)
Browse files Browse the repository at this point in the history
* i18n

* perf: invoice type

* fix: helper line change error

* perf: base64 image

* perf: app list ui

* perf: upload max size check

* perf: init system plugin

* perf: dataset list ui

* perf: http node ui

* perf: ui

* perf: invoice tip

* fix: ts

* perf: invoice table

* perf: null check
  • Loading branch information
c121914yu authored Aug 22, 2024
1 parent 19904e6 commit b3acd57
Show file tree
Hide file tree
Showing 33 changed files with 574 additions and 550 deletions.
12 changes: 7 additions & 5 deletions docSite/content/zh-cn/docs/development/upgrading/4810.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ STORE_LOG_LEVEL=warn
7. 商业版新增 - SSO 定制
8. 优化 - 知识库集合禁用,目录禁用会递归修改其下所有 children 的禁用状态。
9. 优化 - 节点选择,避免切换 tab 时候,path 加载报错。
10. 修复 - Prompt 模式调用工具,stream=false 模式下,会携带 0: 开头标记。
11. 修复 - 对话日志鉴权问题:仅为 APP 管理员的用户,无法查看对话日志详情。
12. 修复 - 选择 Milvus 部署时,无法导出知识库。
13. 修复 - 创建 APP 副本,无法复制系统配置。
14. 修复 - 图片识别模式下,自动解析图片链接正则不够严谨问题。
10. 优化 - 最新 React Markdown 组件,支持 Base64 图片。
11. 优化 - 知识库列表 UI。
12. 修复 - Prompt 模式调用工具,stream=false 模式下,会携带 0: 开头标记。
13. 修复 - 对话日志鉴权问题:仅为 APP 管理员的用户,无法查看对话日志详情。
14. 修复 - 选择 Milvus 部署时,无法导出知识库。
15. 修复 - 创建 APP 副本,无法复制系统配置。
16. 修复 - 图片识别模式下,自动解析图片链接正则不够严谨问题。
4 changes: 2 additions & 2 deletions packages/global/core/workflow/template/system/http468.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export const HttpNode468: FlowNodeTemplateType = {
renderTypeList: [FlowNodeInputTypeEnum.custom],
valueType: WorkflowIOValueTypeEnum.number,
label: '',
value: 120,
min: 30,
value: 30,
min: 5,
max: 600,
required: true
},
Expand Down
10 changes: 5 additions & 5 deletions packages/global/support/user/team/type.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ export type LafAccountType = {
export type TeamInvoiceHeaderType = {
teamName: string;
unifiedCreditCode: string;
companyAddress: string;
companyPhone: string;
bankName: string;
bankAccount: string;
needSpecialInvoice?: boolean;
companyAddress?: string;
companyPhone?: string;
bankName?: string;
bankAccount?: string;
needSpecialInvoice: boolean;
emailAddress: string;
};

Expand Down
3 changes: 2 additions & 1 deletion packages/global/support/wallet/bill/type.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ export type InvoiceType = {
} & TeamInvoiceHeaderType;

export type InvoiceSchemaType = {
teamId: string;
_id: string;
teamId: string;
status: 1 | 2;
createTime: Date;
finishTime?: Date;
file?: Buffer;
} & InvoiceType;
4 changes: 4 additions & 0 deletions packages/service/common/file/multer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ type FileType = {
size: number;
};

/*
maxSize: File max size (MB)
*/
export const getUploadModel = ({ maxSize = 500 }: { maxSize?: number }) => {
maxSize *= 1024 * 1024;

class UploadModel {
uploader = multer({
limits: {
Expand Down
3 changes: 2 additions & 1 deletion packages/service/core/workflow/dispatch/tools/http468.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type HttpRequestProps = ModuleDispatchProps<{
[NodeInputKeyEnum.httpParams]: PropsArrType[];
[NodeInputKeyEnum.httpJsonBody]: string;
[NodeInputKeyEnum.addInputParam]: Record<string, any>;
[NodeInputKeyEnum.httpTimeout]?: number;
[key: string]: any;
}>;
type HttpResponse = DispatchNodeResultType<{
Expand All @@ -57,7 +58,7 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
system_httpHeader: httpHeader,
system_httpParams: httpParams = [],
system_httpJsonBody: httpJsonBody,
system_httpTimeout: httpTimeout,
system_httpTimeout: httpTimeout = 60,
[NodeInputKeyEnum.addInputParam]: dynamicInput,
...body
}
Expand Down
1 change: 1 addition & 0 deletions packages/web/i18n/en/dataset.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"external_read_url": "External read url",
"external_read_url_tip": "You can configure the reading address of your file library. This allows users to read and authenticate. You can currently use the {{fileId}} variable to refer to the external file ID.",
"external_url": "File read url",
"file_model_function_tip": "For enhanced indexing and QA generation",
"filename": "filename",
"folder_dataset": "Folder",
"rebuild_embedding_start_tip": "The task of switching index models has begun",
Expand Down
3 changes: 3 additions & 0 deletions packages/web/i18n/en/user.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"bill": {
"not_need_invoice": "Balance payment, unable to issue invoice"
},
"bind_inform_account_error": "Abnormal binding notification account",
"bind_inform_account_success": "Binding notification account successful",
"code_error": {
Expand Down
3 changes: 1 addition & 2 deletions packages/web/i18n/zh/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -617,8 +617,7 @@
"success": "开始同步"
}
},
"training": {
}
"training": {}
},
"data": {
"Auxiliary Data": "辅助数据",
Expand Down
1 change: 1 addition & 0 deletions packages/web/i18n/zh/dataset.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"external_read_url": "外部预览地址",
"external_read_url_tip": "可以配置你文件库的阅读地址。便于对用户进行阅读鉴权操作。目前可以使用 {{fileId}} 变量来指代外部文件 ID。",
"external_url": "文件访问 URL",
"file_model_function_tip": "用于增强索引和 QA 生成",
"filename": "文件名",
"folder_dataset": "文件夹",
"rebuild_embedding_start_tip": "切换索引模型任务已开始",
Expand Down
3 changes: 3 additions & 0 deletions packages/web/i18n/zh/user.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"bill": {
"not_need_invoice": "余额支付,无法开票"
},
"bind_inform_account_error": "绑定通知账号异常",
"bind_inform_account_success": "绑定通知账号成功",
"delete": {
Expand Down
2 changes: 1 addition & 1 deletion projects/app/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ SANDBOX_URL=http://localhost:3001
PRO_URL=
# 首页路径
HOME_URL=/

# 日志等级: debug, info, warn, error
LOG_LEVEL=debug
STORE_LOG_LEVEL=warn
# Loki Log Path
6 changes: 5 additions & 1 deletion projects/app/src/components/Markdown/img/Image.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
import { ImageProps, Skeleton } from '@chakra-ui/react';
import { Box, ImageProps, Skeleton } from '@chakra-ui/react';
import MyPhotoView from '@fastgpt/web/components/common/Image/PhotoView';
import { useBoolean } from 'ahooks';

Expand All @@ -8,6 +8,10 @@ const MdImage = ({ src, ...props }: { src?: string } & ImageProps) => {

const [renderSrc, setRenderSrc] = useState(src);

if (src?.includes('base64') && !src.startsWith('data:image')) {
return <Box>Invalid base64 image</Box>;
}

return (
<Skeleton isLoaded={isLoaded}>
<MyPhotoView
Expand Down
7 changes: 6 additions & 1 deletion projects/app/src/components/Markdown/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo } from 'react';
import React, { useCallback, useMemo } from 'react';
import ReactMarkdown from 'react-markdown';
import 'katex/dist/katex.min.css';
import RemarkMath from 'remark-math'; // Math syntax
Expand Down Expand Up @@ -52,6 +52,10 @@ const Markdown = ({
return formatSource;
}, [source]);

const urlTransform = useCallback((val: string) => {
return val;
}, []);

return (
<ReactMarkdown
className={`markdown ${styles.markdown}
Expand All @@ -60,6 +64,7 @@ const Markdown = ({
remarkPlugins={[RemarkMath, [RemarkGfm, { singleTilde: false }], RemarkBreaks]}
rehypePlugins={[RehypeKatex, [RehypeExternalLinks, { target: '_blank' }]]}
components={components}
urlTransform={urlTransform}
>
{formatSource}
</ReactMarkdown>
Expand Down
1 change: 1 addition & 0 deletions projects/app/src/components/common/NextHead/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const NextHead = ({ title, icon, desc }: { title?: string; icon?: string; desc?:
name="viewport"
content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no, viewport-fit=cover"
/>
<meta httpEquiv="Content-Security-Policy" content="img-src * data:;" />
{desc && <meta name="description" content={desc} />}
{icon && <link rel="icon" href={icon} />}
</Head>
Expand Down
10 changes: 6 additions & 4 deletions projects/app/src/pages/account/components/Info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ const PlanUsage = () => {

return standardPlan ? (
<Box mt={[6, 0]}>
<Flex fontSize={'lg'} h={'30px'}>
<Flex fontSize={['md', 'lg']} h={'30px'}>
<Flex alignItems={'center'}>
<MyIcon mr={2} name={'support/account/plans'} w={'20px'} />
{t('common:support.wallet.subscription.Team plan and usage')}
Expand All @@ -428,7 +428,7 @@ const PlanUsage = () => {
borderColor={'borderColor.low'}
borderRadius={'md'}
>
<Flex px={[5, 7]} py={[3, 6]}>
<Flex px={[5, 7]} py={[3, 6]} whiteSpace={'nowrap'}>
<Box flex={'1 0 0'}>
<Box color={'myGray.600'} fontSize="sm">
{t('common:support.wallet.subscription.Current plan')}
Expand Down Expand Up @@ -475,8 +475,10 @@ const PlanUsage = () => {
>
<Flex>
<Flex flex={'1 0 0'} alignItems={'flex-end'}>
<Box fontSize={'md'}>{t('common:info.resource')}</Box>
<Box fontSize={'xs'} color={'myGray.500'}>
<Box fontSize={'md'} fontWeight={'bold'} color={'myGray.900'}>
{t('common:info.resource')}
</Box>
<Box ml={1} display={['none', 'block']} fontSize={'xs'} color={'myGray.500'}>
{t('common:info.include')}
</Box>
</Flex>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,52 +32,25 @@ import MyBox from '@fastgpt/web/components/common/MyBox';
import { getTeamInvoiceHeader } from '@/web/support/user/team/api';
import { useToast } from '@fastgpt/web/hooks/useToast';
import { useRouter } from 'next/router';
import { useForm } from 'react-hook-form';

type chosenBillDataType = {
_id: string;
price: number;
};

const ApplyInvoiceModal = ({ onClose }: { onClose: () => void }) => {
const { t } = useTranslation();
const { toast } = useToast();
const router = useRouter();

const [chosenBillDataList, setChosenBillDataList] = useState<chosenBillDataType[]>([]);
const [totalPrice, setTotalPrice] = useState(0);
const [formData, setFormData] = useState<TeamInvoiceHeaderType>({
teamName: '',
unifiedCreditCode: '',
companyAddress: '',
companyPhone: '',
bankName: '',
bankAccount: '',
needSpecialInvoice: undefined,
emailAddress: ''
});

const router = useRouter();
const {
isOpen: isOpenSettleModal,
onOpen: onOpenSettleModal,
onClose: onCloseSettleModal
} = useDisclosure();

const handleChange = useCallback((e: any) => {
const { name, value } = e.target;
setFormData((prev) => ({ ...prev, [name]: value }));
}, []);

const handleRatiosChange = useCallback((v: string) => {
setFormData((prev) => ({ ...prev, needSpecialInvoice: v === 'true' }));
}, []);

const isHeaderValid = useCallback((v: TeamInvoiceHeaderType) => {
const emailRegex = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
for (const [key, value] of Object.entries(v)) {
if (typeof value === 'string' && value.trim() === '') {
return false;
}
}
return emailRegex.test(v.emailAddress);
}, []);

const {
loading: isLoading,
data: billsList,
Expand All @@ -86,12 +59,23 @@ const ApplyInvoiceModal = ({ onClose }: { onClose: () => void }) => {
manual: false
});

const { run: handleSubmitInvoice, loading: isSubmitting } = useRequest2(
() =>
const handleSingleCheck = useCallback(
(item: invoiceBillDataType) => {
if (chosenBillDataList.find((bill) => bill._id === item._id)) {
setChosenBillDataList(chosenBillDataList.filter((bill) => bill._id !== item._id));
} else {
setChosenBillDataList([...chosenBillDataList, { _id: item._id, price: item.price }]);
}
},
[chosenBillDataList]
);

const { runAsync: onSubmitApply, loading: isSubmitting } = useRequest2(
(data) =>
submitInvoice({
amount: totalPrice,
billIdList: chosenBillDataList.map((item) => item._id),
...formData
...data
}),
{
manual: true,
Expand All @@ -104,39 +88,29 @@ const ApplyInvoiceModal = ({ onClose }: { onClose: () => void }) => {
}
);

const inputForm = useForm<TeamInvoiceHeaderType>({
defaultValues: {
teamName: '',
unifiedCreditCode: '',
companyAddress: '',
companyPhone: '',
bankName: '',
bankAccount: '',
needSpecialInvoice: false,
emailAddress: ''
}
});
const { loading: isLoadingHeader } = useRequest2(() => getTeamInvoiceHeader(), {
manual: false,
onSuccess: (res) => setFormData(res)
onSuccess: (res) => inputForm.reset(res)
});

const handleSubmit = useCallback(async () => {
if (!isHeaderValid(formData)) {
toast({
title: t('common:support.wallet.invoice_data.in_valid'),
status: 'info'
});
return;
}
handleSubmitInvoice();
}, [formData, handleSubmitInvoice, isHeaderValid, t, toast]);

const handleBack = useCallback(() => {
setChosenBillDataList([]);
getInvoiceBills();
onCloseSettleModal();
}, [getInvoiceBills, onCloseSettleModal]);

const handleSingleCheck = useCallback(
(item: invoiceBillDataType) => {
if (chosenBillDataList.find((bill) => bill._id === item._id)) {
setChosenBillDataList(chosenBillDataList.filter((bill) => bill._id !== item._id));
} else {
setChosenBillDataList([...chosenBillDataList, { _id: item._id, price: item.price }]);
}
},
[chosenBillDataList]
);

return (
<MyModal
isOpen={true}
Expand Down Expand Up @@ -258,11 +232,7 @@ const ApplyInvoiceModal = ({ onClose }: { onClose: () => void }) => {
</Box>
<MyBox isLoading={isLoadingHeader}>
<Flex justify={'center'}>
<InvoiceHeaderSingleForm
formData={formData}
handleChange={handleChange}
handleRatiosChange={handleRatiosChange}
/>
<InvoiceHeaderSingleForm inputForm={inputForm} />
</Flex>
</MyBox>
<Flex
Expand All @@ -289,7 +259,7 @@ const ApplyInvoiceModal = ({ onClose }: { onClose: () => void }) => {
</Box>
</Flex>
</Button>
<Button isLoading={isSubmitting} px="0" onClick={handleSubmit}>
<Button isLoading={isSubmitting} px="0" onClick={inputForm.handleSubmit(onSubmitApply)}>
<Flex alignItems={'center'}>
<Box px={'1.25rem'} py={'0.5rem'}>
{t('common:common.Confirm')}
Expand Down
Loading

0 comments on commit b3acd57

Please sign in to comment.