fix: ignore the fields when compare data

This commit is contained in:
jialin
2025-05-06 17:42:14 +08:00
parent efd2088745
commit 6a2d2dfdaf
3 changed files with 14 additions and 3 deletions
@@ -20,7 +20,8 @@ import {
localPathTipsList, localPathTipsList,
modelSourceMap, modelSourceMap,
ollamaModelOptions, ollamaModelOptions,
sourceOptions sourceOptions,
updateIgnoreFields
} from '../config'; } from '../config';
import { FormContext } from '../config/form-context'; import { FormContext } from '../config/form-context';
import { FormData, ListItem } from '../config/types'; import { FormData, ListItem } from '../config/types';
@@ -115,8 +116,13 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
} }
const originalData = _.pick(originFormData.current, Object.keys(alldata)); const originalData = _.pick(originFormData.current, Object.keys(alldata));
console.log('alldata:', alldata, originalData);
const isEqual = _.isEqualWith(alldata, originalData, customizer); const isEqual = _.isEqualWith(
_.omit(alldata, updateIgnoreFields),
_.omit(originalData, updateIgnoreFields),
customizer
);
if (isEqual) { if (isEqual) {
setWarningStatus({ setWarningStatus({
show: false, show: false,
+3
View File
@@ -477,6 +477,9 @@ export const excludeFields = [
'gpu_selector' 'gpu_selector'
]; ];
// ingore fields when compare old and new data
export const updateIgnoreFields = ['categories', 'replicas', 'description'];
// if some fields need to trigger manual check, add them here // if some fields need to trigger manual check, add them here
export const updateExcludeFields = [ export const updateExcludeFields = [
'repo_id', 'repo_id',
@@ -6,6 +6,8 @@ import { RcFile } from 'antd/es/upload';
import { debounce, round } from 'lodash'; import { debounce, round } from 'lodash';
import React, { useCallback, useRef } from 'react'; import React, { useCallback, useRef } from 'react';
const acceptImageType = ['image/png', 'image/jpg', 'image/jpeg'];
interface UploadImgProps { interface UploadImgProps {
size?: 'small' | 'middle' | 'large'; size?: 'small' | 'middle' | 'large';
height?: number; height?: number;
@@ -34,7 +36,7 @@ const UploadImg: React.FC<UploadImgProps> = ({
children, children,
icon, icon,
title, title,
accept = 'image/*', accept = acceptImageType.join(','),
size = 'small' size = 'small'
}) => { }) => {
const intl = useIntl(); const intl = useIntl();