fix: update form value trigger tips
This commit is contained in:
@@ -13,7 +13,7 @@ import Wrapper from './wrapper';
|
|||||||
import InputWrapper from './wrapper/input';
|
import InputWrapper from './wrapper/input';
|
||||||
|
|
||||||
const LabelWrapper = styled.div`
|
const LabelWrapper = styled.div`
|
||||||
background-color: var(--color-white-1);
|
background-color: var(--ant-color-bg-container);
|
||||||
`;
|
`;
|
||||||
|
|
||||||
interface InputTextareaProps extends TextAreaProps {
|
interface InputTextareaProps extends TextAreaProps {
|
||||||
|
|||||||
@@ -193,7 +193,6 @@ const Wrapper: FC<WrapperProps> = ({
|
|||||||
onClick
|
onClick
|
||||||
}) => {
|
}) => {
|
||||||
const { token } = theme.useToken();
|
const { token } = theme.useToken();
|
||||||
console.log('token=====', token);
|
|
||||||
const wrapperClass = classNames(
|
const wrapperClass = classNames(
|
||||||
status ? `validate-status-${status}` : '',
|
status ? `validate-status-${status}` : '',
|
||||||
className,
|
className,
|
||||||
|
|||||||
@@ -79,11 +79,6 @@ export default {
|
|||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
motion: true,
|
motion: true,
|
||||||
colorFill: '#000',
|
colorFill: '#000',
|
||||||
// colorFillTertiary: '#1D1E20',
|
|
||||||
// colorBgContainer: '#141414',
|
|
||||||
colorBgBase: '#000'
|
colorBgBase: '#000'
|
||||||
// colorBorder: '#353535'
|
|
||||||
// colorSplit: '#262626',
|
|
||||||
// colorBorderSecondary: '#262626'
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -239,5 +239,8 @@ export default {
|
|||||||
'common.appearance.dark': 'Dark',
|
'common.appearance.dark': 'Dark',
|
||||||
'common.appearance.light': 'Light',
|
'common.appearance.light': 'Light',
|
||||||
'common.appearance.system': 'System Default',
|
'common.appearance.system': 'System Default',
|
||||||
'common.exception.404': 'Sorry, the page you visited does not exist.'
|
'common.exception.404': 'Sorry, the page you visited does not exist.',
|
||||||
|
'common.appearance.darkmode': 'Dark Mode',
|
||||||
|
'common.appearance.lightmode': 'Light Mode',
|
||||||
|
'common.appearance.tips': 'Default follows system preference.'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,5 +17,6 @@ export default {
|
|||||||
'menu.users': 'Users',
|
'menu.users': 'Users',
|
||||||
'menu.profile': 'Profile',
|
'menu.profile': 'Profile',
|
||||||
'menu.login': 'Login',
|
'menu.login': 'Login',
|
||||||
'menu.usage': 'Usage'
|
'menu.usage': 'Usage',
|
||||||
|
'menu.404': '404'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -239,7 +239,10 @@ export default {
|
|||||||
'common.appearance.dark': 'Dark',
|
'common.appearance.dark': 'Dark',
|
||||||
'common.appearance.light': 'Light',
|
'common.appearance.light': 'Light',
|
||||||
'common.appearance.system': 'System Default',
|
'common.appearance.system': 'System Default',
|
||||||
'common.exception.404': 'Sorry, the page you visited does not exist.'
|
'common.exception.404': 'Sorry, the page you visited does not exist.',
|
||||||
|
'common.appearance.darkmode': 'Dark Mode',
|
||||||
|
'common.appearance.lightmode': 'Light Mode',
|
||||||
|
'common.appearance.tips': 'Default follows system preference.'
|
||||||
};
|
};
|
||||||
|
|
||||||
// ========== To-Do: Translate Keys (Remove After Translation) ==========
|
// ========== To-Do: Translate Keys (Remove After Translation) ==========
|
||||||
@@ -247,5 +250,8 @@ export default {
|
|||||||
// 2. 'common.appearance.light': 'Light',
|
// 2. 'common.appearance.light': 'Light',
|
||||||
// 3. 'common.appearance.system': 'System Default',
|
// 3. 'common.appearance.system': 'System Default',
|
||||||
// 4. 'common.appearance': 'Appearance',
|
// 4. 'common.appearance': 'Appearance',
|
||||||
// 5. 'common.exception.404': 'Sorry, the page you visited does not exist.'
|
// 5. 'common.exception.404': 'Sorry, the page you visited does not exist.',
|
||||||
|
// 6. 'common.appearance.darkmode': 'Dark Mode',
|
||||||
|
// 7. 'common.appearance.lightmode': 'Light Mode',
|
||||||
|
// 8. 'common.appearance.tips': 'Default follows system preference.'
|
||||||
// ========== End of To-Do List ==========
|
// ========== End of To-Do List ==========
|
||||||
|
|||||||
@@ -17,5 +17,6 @@ export default {
|
|||||||
'menu.users': 'ユーザー',
|
'menu.users': 'ユーザー',
|
||||||
'menu.profile': 'プロフィール',
|
'menu.profile': 'プロフィール',
|
||||||
'menu.login': 'ログイン',
|
'menu.login': 'ログイン',
|
||||||
'menu.usage': '使用状況'
|
'menu.usage': '使用状況',
|
||||||
|
'menu.404': '404'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -237,9 +237,15 @@ export default {
|
|||||||
'common.appearance.dark': 'Темная',
|
'common.appearance.dark': 'Темная',
|
||||||
'common.appearance.light': 'Светлая',
|
'common.appearance.light': 'Светлая',
|
||||||
'common.appearance.system': 'Как в системе',
|
'common.appearance.system': 'Как в системе',
|
||||||
'common.exception.404': 'Sorry, the page you visited does not exist.'
|
'common.exception.404': 'Sorry, the page you visited does not exist.',
|
||||||
|
'common.appearance.darkmode': 'Dark Mode',
|
||||||
|
'common.appearance.lightmode': 'Light Mode',
|
||||||
|
'common.appearance.tips': 'Default follows system preference.'
|
||||||
};
|
};
|
||||||
|
|
||||||
// ========== To-Do: Translate Keys (Remove After Translation) ==========
|
// ========== To-Do: Translate Keys (Remove After Translation) ==========
|
||||||
// 1. 'common.exception.404': 'Sorry, the page you visited does not exist.'
|
// 1. 'common.exception.404': 'Sorry, the page you visited does not exist.',
|
||||||
|
// 2. 'common.appearance.darkmode': 'Dark Mode',
|
||||||
|
// 3. 'common.appearance.lightmode': 'Light Mode',
|
||||||
|
// 4. 'common.appearance.tips': 'Default follows system preference.'
|
||||||
// ========== End of To-Do List ==========
|
// ========== End of To-Do List ==========
|
||||||
|
|||||||
@@ -17,5 +17,6 @@ export default {
|
|||||||
'menu.users': 'Пользователи',
|
'menu.users': 'Пользователи',
|
||||||
'menu.profile': 'Профиль',
|
'menu.profile': 'Профиль',
|
||||||
'menu.login': 'Авторизация',
|
'menu.login': 'Авторизация',
|
||||||
'menu.usage': 'Использование'
|
'menu.usage': 'Использование',
|
||||||
|
'menu.404': '404'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -234,5 +234,8 @@ export default {
|
|||||||
'common.appearance.dark': '深色',
|
'common.appearance.dark': '深色',
|
||||||
'common.appearance.light': '浅色',
|
'common.appearance.light': '浅色',
|
||||||
'common.appearance.system': '跟随系统',
|
'common.appearance.system': '跟随系统',
|
||||||
'common.exception.404': '抱歉,你访问的页面不存在'
|
'common.exception.404': '抱歉,你访问的页面不存在',
|
||||||
|
'common.appearance.darkmode': '深色模式',
|
||||||
|
'common.appearance.lightmode': '浅色模式',
|
||||||
|
'common.appearance.tips': '默认跟随系统设置'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,5 +17,6 @@ export default {
|
|||||||
'menu.users': '用户',
|
'menu.users': '用户',
|
||||||
'menu.profile': '个人信息',
|
'menu.profile': '个人信息',
|
||||||
'menu.login': '登录',
|
'menu.login': '登录',
|
||||||
'menu.usage': '使用量'
|
'menu.usage': '使用量',
|
||||||
|
'menu.404': '404'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -43,6 +43,34 @@ interface AdvanceConfigProps {
|
|||||||
source: string;
|
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<{
|
const CheckboxField: React.FC<{
|
||||||
title: string;
|
title: string;
|
||||||
label: string;
|
label: string;
|
||||||
@@ -78,40 +106,6 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
|
|||||||
const worker_selector = Form.useWatch('worker_selector', form);
|
const worker_selector = Form.useWatch('worker_selector', form);
|
||||||
const { onValuesChange } = useFormContext();
|
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(() => {
|
const paramsConfig = useMemo(() => {
|
||||||
if (backend === backendOptionsMap.llamaBox) {
|
if (backend === backendOptionsMap.llamaBox) {
|
||||||
return llamaConfig;
|
return llamaConfig;
|
||||||
|
|||||||
@@ -154,7 +154,6 @@ const AddModal: FC<AddModalProps> = (props) => {
|
|||||||
|
|
||||||
const handleOnSelectModel = (item: any, evaluate?: boolean) => {
|
const handleOnSelectModel = (item: any, evaluate?: boolean) => {
|
||||||
setSelectedModel(item);
|
setSelectedModel(item);
|
||||||
console.log('item.isGGUF=========>', item.isGGUF);
|
|
||||||
if (!item.isGGUF) {
|
if (!item.isGGUF) {
|
||||||
setIsGGUF(false);
|
setIsGGUF(false);
|
||||||
form.current?.form?.resetFields(resetFields);
|
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 handleOnValuesChange = (data: any) => {
|
||||||
const formdata = form.getFieldsValue?.();
|
const formdata = form.getFieldsValue?.();
|
||||||
let alldata = {};
|
let alldata = {};
|
||||||
@@ -100,7 +107,7 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
|
|||||||
worker_selector: originFormData.current?.worker_selector || null
|
worker_selector: originFormData.current?.worker_selector || null
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const isEqual = _.isEqual(alldata, originFormData.current);
|
const isEqual = _.isEqualWith(alldata, originFormData.current, customizer);
|
||||||
if (isEqual) {
|
if (isEqual) {
|
||||||
setWarningStatus({
|
setWarningStatus({
|
||||||
show: false,
|
show: false,
|
||||||
|
|||||||
@@ -1,8 +1,29 @@
|
|||||||
import useUserSettings from '@/hooks/use-user-settings';
|
import useUserSettings from '@/hooks/use-user-settings';
|
||||||
import { MoonOutlined, SunOutlined } from '@ant-design/icons';
|
import { MoonOutlined, SunOutlined } from '@ant-design/icons';
|
||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
import { Radio } from 'antd';
|
import { Switch } from 'antd';
|
||||||
import React from 'react';
|
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 = [
|
const ThemeOptions = [
|
||||||
{
|
{
|
||||||
@@ -18,23 +39,34 @@ const ThemeOptions = [
|
|||||||
];
|
];
|
||||||
const Appearance: React.FC = () => {
|
const Appearance: React.FC = () => {
|
||||||
const { setTheme, userSettings } = useUserSettings();
|
const { setTheme, userSettings } = useUserSettings();
|
||||||
|
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
const handleOnChange = (e: any) => {
|
const handleOnChange = (checked: boolean) => {
|
||||||
setTheme(e.target.value);
|
if (checked) {
|
||||||
|
setTheme('realDark');
|
||||||
|
} else {
|
||||||
|
setTheme('light');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isDarkMode = useMemo(() => {
|
||||||
|
const darkMode = userSettings?.theme === 'realDark';
|
||||||
|
return darkMode;
|
||||||
|
}, [userSettings?.theme]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Radio.Group
|
<Wrapper>
|
||||||
onChange={handleOnChange}
|
<div className="theme">
|
||||||
style={{ marginTop: 16 }}
|
<span className="theme-label">
|
||||||
value={userSettings.theme}
|
{intl.formatMessage({ id: 'common.appearance.darkmode' })}
|
||||||
>
|
</span>
|
||||||
{ThemeOptions.map((item) => (
|
<Switch checked={isDarkMode} onChange={handleOnChange} />
|
||||||
<Radio key={item.key} value={item.key}>
|
</div>
|
||||||
{intl.formatMessage({ id: item.label })}
|
<div className="tips">
|
||||||
</Radio>
|
{intl.formatMessage({ id: 'common.appearance.tips' })}
|
||||||
))}
|
</div>
|
||||||
</Radio.Group>
|
</Wrapper>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user