mirror of
https://github.com/labring/FastGPT.git
synced 2026-02-27 01:02:22 +08:00
fix icon border radius (#6255)
* fix icon border radius * http header auth * fix initial fitview * add comment --------- Co-authored-by: archer <545436317@qq.com>
This commit is contained in:
@@ -2,8 +2,7 @@ import type { ButtonProps } from '@chakra-ui/react';
|
||||
import { Box, Button, Flex, ModalBody, ModalFooter, useDisclosure } from '@chakra-ui/react';
|
||||
import { HeaderSecretTypeEnum } from '@fastgpt/global/common/secret/constants';
|
||||
import type { SecretValueType, StoreSecretValueType } from '@fastgpt/global/common/secret/type';
|
||||
import React, { useMemo } from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||
import MyModal from '@fastgpt/web/components/common/MyModal';
|
||||
@@ -90,19 +89,17 @@ const HeaderAuthConfig = ({
|
||||
return storeHeader2HeaderValue(storeHeaderSecretConfig);
|
||||
}, [storeHeaderSecretConfig]);
|
||||
|
||||
const { handleSubmit, reset, getValues } = useForm<HeaderSecretConfigType>({
|
||||
defaultValues: {
|
||||
Basic: headerSecretValue?.Basic || { secret: '', value: '' },
|
||||
Bearer: headerSecretValue?.Bearer || { secret: '', value: '' },
|
||||
customs: headerSecretValue?.customs || []
|
||||
const [formValues, setFormValues] = useState<HeaderSecretConfigType>({});
|
||||
|
||||
// 当模态框打开时,重置表单为最新的值
|
||||
useEffect(() => {
|
||||
if (isOpen) {
|
||||
setFormValues(headerSecretValue);
|
||||
}
|
||||
});
|
||||
const currentValue = getValues();
|
||||
}, [isOpen, headerSecretValue]);
|
||||
|
||||
const onSubmit = async (data: HeaderSecretConfigType) => {
|
||||
if (!headerSecretValue) return;
|
||||
|
||||
const storeData = headerValue2StoreHeader(data);
|
||||
const onSubmit = () => {
|
||||
const storeData = headerValue2StoreHeader(formValues);
|
||||
onUpdate(storeData);
|
||||
onClose();
|
||||
};
|
||||
@@ -129,11 +126,11 @@ const HeaderAuthConfig = ({
|
||||
w={480}
|
||||
>
|
||||
<ModalBody px={9}>
|
||||
<HeaderAuthForm headerSecretValue={currentValue} onChange={(data) => reset(data)} />
|
||||
<HeaderAuthForm headerSecretValue={formValues} onChange={setFormValues} />
|
||||
</ModalBody>
|
||||
<ModalFooter px={9} display={'flex'} flexDirection={'column'}>
|
||||
<Flex justifyContent={'end'} w={'full'}>
|
||||
<Button onClick={handleSubmit(onSubmit)}>{t('common:Save')}</Button>
|
||||
<Button onClick={onSubmit}>{t('common:Save')}</Button>
|
||||
</Flex>
|
||||
</ModalFooter>
|
||||
<Box
|
||||
|
||||
@@ -35,7 +35,7 @@ const AppTypeCard = ({
|
||||
boxShadow: '0 4px 10px 0 rgba(19, 51, 107, 0.08), 0 0 1px 0 rgba(19, 51, 107, 0.08)'
|
||||
}}
|
||||
>
|
||||
<MyIcon name={option.icon as any} w={'6'} />
|
||||
<MyIcon name={option.icon as any} w={'6'} borderRadius={4} />
|
||||
<Box fontWeight={'medium'} color={'myGray.900'} mt={2}>
|
||||
{t(option.title)}
|
||||
</Box>
|
||||
|
||||
@@ -16,9 +16,9 @@ import HelperLines from './components/HelperLines';
|
||||
import { useWorkflow } from './hooks/useWorkflow';
|
||||
import { EDGE_TYPE, FlowNodeTypeEnum } from '@fastgpt/global/core/workflow/node/constant';
|
||||
import type { NodeProps } from 'reactflow';
|
||||
import ReactFlow, { SelectionMode } from 'reactflow';
|
||||
import ReactFlow, { SelectionMode, useReactFlow } from 'reactflow';
|
||||
import { Box, IconButton, useDisclosure } from '@chakra-ui/react';
|
||||
import React, { useState } from 'react';
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import { WorkflowUIContext } from '../context/workflowUIContext';
|
||||
|
||||
const NodeSimple = dynamic(() => import('./nodes/NodeSimple'));
|
||||
@@ -100,6 +100,18 @@ const Workflow = () => {
|
||||
|
||||
const [movingCanvas, setMovingCanvas] = useState(false);
|
||||
|
||||
// 异步 fitView:等待所有节点加载完成后再执行
|
||||
const { fitView } = useReactFlow();
|
||||
const fitViewDone = useRef(false);
|
||||
useEffect(() => {
|
||||
// 确保仅自动布局一次。且所有节点都渲染完成。
|
||||
if (fitViewDone.current || !nodes.length || !nodes.every((node) => node.width && node.height))
|
||||
return;
|
||||
|
||||
fitViewDone.current = true;
|
||||
setTimeout(() => fitView({ padding: 0.3, nodes }), 0);
|
||||
}, [nodes, fitView]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box
|
||||
@@ -136,11 +148,6 @@ const Workflow = () => {
|
||||
|
||||
<ReactFlow
|
||||
ref={reactFlowWrapperCallback}
|
||||
fitView
|
||||
fitViewOptions={{
|
||||
padding: 0.3,
|
||||
nodes: nodes.filter((node) => node.width && node.height)
|
||||
}}
|
||||
nodes={nodes}
|
||||
edges={edges}
|
||||
minZoom={minZoom}
|
||||
|
||||
@@ -76,6 +76,16 @@ class ErrorLogger {
|
||||
private setupGlobalErrorHandlers() {
|
||||
// Capture JavaScript runtime errors
|
||||
window.addEventListener('error', (event) => {
|
||||
const msg = event.message;
|
||||
// Ignore html2pdf core-js errors
|
||||
if (
|
||||
(msg?.includes('Cannot redefine property') || msg?.includes('toString')) &&
|
||||
event.filename?.includes('html2pdf')
|
||||
) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
this.addLog({
|
||||
timestamp: Date.now(),
|
||||
type: 'runtime.error',
|
||||
|
||||
Reference in New Issue
Block a user