fix: update form value trigger tips
This commit is contained in:
@@ -43,6 +43,34 @@ interface AdvanceConfigProps {
|
||||
source: string;
|
||||
}
|
||||
|
||||
const placementStrategyTips = [
|
||||
{
|
||||
title: 'Spread',
|
||||
tips: 'resources.form.spread.tips'
|
||||
},
|
||||
{
|
||||
title: 'Binpack',
|
||||
tips: 'resources.form.binpack.tips'
|
||||
}
|
||||
];
|
||||
|
||||
const scheduleTypeTips = [
|
||||
{
|
||||
title: {
|
||||
text: 'models.form.scheduletype.auto',
|
||||
locale: true
|
||||
},
|
||||
tips: 'models.form.scheduletype.auto.tips'
|
||||
},
|
||||
{
|
||||
title: {
|
||||
text: 'models.form.scheduletype.manual',
|
||||
locale: true
|
||||
},
|
||||
tips: 'models.form.scheduletype.manual.tips'
|
||||
}
|
||||
];
|
||||
|
||||
const CheckboxField: React.FC<{
|
||||
title: string;
|
||||
label: string;
|
||||
@@ -78,40 +106,6 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
|
||||
const worker_selector = Form.useWatch('worker_selector', form);
|
||||
const { onValuesChange } = useFormContext();
|
||||
|
||||
const placementStrategyTips = [
|
||||
{
|
||||
title: 'Spread',
|
||||
tips: intl.formatMessage({
|
||||
id: 'resources.form.spread.tips'
|
||||
})
|
||||
},
|
||||
{
|
||||
title: 'Binpack',
|
||||
tips: intl.formatMessage({
|
||||
id: 'resources.form.binpack.tips'
|
||||
})
|
||||
}
|
||||
];
|
||||
|
||||
const scheduleTypeTips = [
|
||||
{
|
||||
title: intl.formatMessage({
|
||||
id: 'models.form.scheduletype.auto'
|
||||
}),
|
||||
tips: intl.formatMessage({
|
||||
id: 'models.form.scheduletype.auto.tips'
|
||||
})
|
||||
},
|
||||
{
|
||||
title: intl.formatMessage({
|
||||
id: 'models.form.scheduletype.manual'
|
||||
}),
|
||||
tips: intl.formatMessage({
|
||||
id: 'models.form.scheduletype.manual.tips'
|
||||
})
|
||||
}
|
||||
];
|
||||
|
||||
const paramsConfig = useMemo(() => {
|
||||
if (backend === backendOptionsMap.llamaBox) {
|
||||
return llamaConfig;
|
||||
|
||||
@@ -154,7 +154,6 @@ const AddModal: FC<AddModalProps> = (props) => {
|
||||
|
||||
const handleOnSelectModel = (item: any, evaluate?: boolean) => {
|
||||
setSelectedModel(item);
|
||||
console.log('item.isGGUF=========>', item.isGGUF);
|
||||
if (!item.isGGUF) {
|
||||
setIsGGUF(false);
|
||||
form.current?.form?.resetFields(resetFields);
|
||||
|
||||
@@ -81,6 +81,13 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
|
||||
}
|
||||
};
|
||||
|
||||
const customizer = (val1: any, val2: any) => {
|
||||
if ((val1 === null && val2 === '') || (val1 === '' && val2 === null)) {
|
||||
return true;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
const handleOnValuesChange = (data: any) => {
|
||||
const formdata = form.getFieldsValue?.();
|
||||
let alldata = {};
|
||||
@@ -100,7 +107,7 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
|
||||
worker_selector: originFormData.current?.worker_selector || null
|
||||
};
|
||||
}
|
||||
const isEqual = _.isEqual(alldata, originFormData.current);
|
||||
const isEqual = _.isEqualWith(alldata, originFormData.current, customizer);
|
||||
if (isEqual) {
|
||||
setWarningStatus({
|
||||
show: false,
|
||||
|
||||
@@ -1,8 +1,29 @@
|
||||
import useUserSettings from '@/hooks/use-user-settings';
|
||||
import { MoonOutlined, SunOutlined } from '@ant-design/icons';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { Radio } from 'antd';
|
||||
import React from 'react';
|
||||
import { Switch } from 'antd';
|
||||
import React, { useMemo } from 'react';
|
||||
import styled from 'styled-components';
|
||||
|
||||
const Wrapper = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
padding: 16px 0;
|
||||
.theme {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
max-width: 220px;
|
||||
}
|
||||
.theme-label {
|
||||
font-size: 16px;
|
||||
font-weight: var(--font-weight-500);
|
||||
}
|
||||
.tips {
|
||||
color: var(--ant-color-text-secondary);
|
||||
}
|
||||
`;
|
||||
|
||||
const ThemeOptions = [
|
||||
{
|
||||
@@ -18,23 +39,34 @@ const ThemeOptions = [
|
||||
];
|
||||
const Appearance: React.FC = () => {
|
||||
const { setTheme, userSettings } = useUserSettings();
|
||||
|
||||
const intl = useIntl();
|
||||
|
||||
const handleOnChange = (e: any) => {
|
||||
setTheme(e.target.value);
|
||||
const handleOnChange = (checked: boolean) => {
|
||||
if (checked) {
|
||||
setTheme('realDark');
|
||||
} else {
|
||||
setTheme('light');
|
||||
}
|
||||
};
|
||||
|
||||
const isDarkMode = useMemo(() => {
|
||||
const darkMode = userSettings?.theme === 'realDark';
|
||||
return darkMode;
|
||||
}, [userSettings?.theme]);
|
||||
|
||||
return (
|
||||
<Radio.Group
|
||||
onChange={handleOnChange}
|
||||
style={{ marginTop: 16 }}
|
||||
value={userSettings.theme}
|
||||
>
|
||||
{ThemeOptions.map((item) => (
|
||||
<Radio key={item.key} value={item.key}>
|
||||
{intl.formatMessage({ id: item.label })}
|
||||
</Radio>
|
||||
))}
|
||||
</Radio.Group>
|
||||
<Wrapper>
|
||||
<div className="theme">
|
||||
<span className="theme-label">
|
||||
{intl.formatMessage({ id: 'common.appearance.darkmode' })}
|
||||
</span>
|
||||
<Switch checked={isDarkMode} onChange={handleOnChange} />
|
||||
</div>
|
||||
<div className="tips">
|
||||
{intl.formatMessage({ id: 'common.appearance.tips' })}
|
||||
</div>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user