Skip to content

Commit

Permalink
limit
Browse files Browse the repository at this point in the history
  • Loading branch information
trueai-org committed Aug 23, 2024
1 parent 4697631 commit fc0030f
Show file tree
Hide file tree
Showing 9 changed files with 216 additions and 15 deletions.
10 changes: 8 additions & 2 deletions src/locales/en-US/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ export default {
'pages.account.enableFastToRelax': 'Automatically switches to slow speed',
'pages.account.enableFastToRelaxTips':
'When the fast mode is used up, it automatically switches to the slow mode',
'pages.account.enableRelaxToFast': 'Automatically switches to fast speed',
'pages.account.enableRelaxToFastTips':
'When enabled, automatically switches to fast mode when renewing a subscription or having a fast duration',
'pages.account.mjChannelId': 'MJBot Private ChannelID',
'pages.account.nijiChannelId': 'NijiBot Private ChannelID',
'pages.account.basicInfo': 'Basic Info',
Expand Down Expand Up @@ -290,12 +293,14 @@ export default {
'pages.draw.actionSuccess': 'Action executed successfully',
'pages.draw.subSuccess': 'Submit successful, please wait...',
'pages.draw.swapDesc': 'Face replacement (first image as face source, or input image link)',
'pages.draw.swapVideoDesc': 'Video Face replacement (first image as face source, or input image link)',
'pages.draw.swapVideoDesc':
'Video Face replacement (first image as face source, or input image link)',
'pages.draw.swap1Desc':
'The first image is used as the face source, and if it is not uploaded, enter the image link',
'pages.draw.swap2Desc':
'The second image is the target image, and if it is not uploaded, enter the image link',
'pages.draw.swap2VidelDesc': 'Second, please upload the target video, if not uploaded, enter the video link',
'pages.draw.swap2VidelDesc':
'Second, please upload the target video, if not uploaded, enter the video link',
'pages.draw.inputIdShow': 'Enter the task ID to bring up tasks that are not displayed',
'pages.draw.inputJobIdShow':
'Enter the job id or url to convert the midjourney task to the local system task',
Expand Down Expand Up @@ -366,6 +371,7 @@ export default {
'pages.setting.enableGuest': 'Enable Guest',
'pages.setting.guestDefaultDayLimit': 'Guest Default Day Limit',
'pages.setting.ipRateLimiting': 'IP Rate Limiting',
'pages.setting.bannedLimiting': 'Banned Limiting',
'pages.setting.ipBlackRateLimiting': 'IP Black Rate Limiting',
'pages.setting.save': 'Save',
'pages.setting.saveSuccess': 'Save Success',
Expand Down
3 changes: 3 additions & 0 deletions src/locales/zh-CN/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ export default {
'pages.account.remixAutoSubmit':'Remix 自动提交',
'pages.account.enableFastToRelax':'自动切换慢速',
'pages.account.enableFastToRelaxTips':'启用后,当快速模式用完后,自动切换到慢速模式',
'pages.account.enableRelaxToFast':'自动切换快速',
'pages.account.enableRelaxToFastTips':'启用后,当续订或拥有快速时长时,自动切换到快速模式',
'pages.account.mjChannelId':'MJ私信ID',
'pages.account.nijiChannelId':'Niji私信ID',
'pages.account.basicInfo':'基本信息',
Expand Down Expand Up @@ -345,6 +347,7 @@ export default {
'pages.setting.enableGuest':'开启访客',
'pages.setting.guestDefaultDayLimit':'访客日绘图限制',
'pages.setting.ipRateLimiting':'限流配置',
'pages.setting.bannedLimiting':'Banned 限流配置',
'pages.setting.ipBlackRateLimiting':'黑名单限流配置',
'pages.setting.otherSetting':'其他设置',
'pages.setting.accountSetting':'账号设置',
Expand Down
8 changes: 8 additions & 0 deletions src/pages/AccountList/components/contents/AddContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ const AddContent = ({
>
<Switch />
</Form.Item>
<Form.Item
label={intl.formatMessage({ id: 'pages.account.enableRelaxToFast' })}
name="enableRelaxToFast"
valuePropName="checked"
tooltip={intl.formatMessage({ id: 'pages.account.enableRelaxToFastTips' })}
>
<Switch />
</Form.Item>
<Form.Item
label={intl.formatMessage({ id: 'pages.account.remixAutoSubmit' })}
name="remixAutoSubmit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ const ReconnectContent = ({
>
<Switch />
</Form.Item>
<Form.Item
label={intl.formatMessage({ id: 'pages.account.enableRelaxToFast' })}
name="enableRelaxToFast"
valuePropName="checked"
tooltip={intl.formatMessage({ id: 'pages.account.enableRelaxToFastTips' })}
>
<Switch />
</Form.Item>
<Form.Item
label={intl.formatMessage({ id: 'pages.account.remixAutoSubmit' })}
name="remixAutoSubmit"
Expand Down
167 changes: 160 additions & 7 deletions src/pages/AccountList/components/contents/UpdateContent.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,73 @@
import { Card, Col, Form, FormInstance, Input, InputNumber, Row, Switch } from 'antd';
import { useEffect } from 'react';
import {
Alert,
Button,
Card,
Col,
Form,
FormInstance,
Input,
InputNumber,
Modal,
Row,
Select,
Switch,
} from 'antd';
import { useEffect, useState } from 'react';

import { allDomain } from '@/services/mj/api';
import { FullscreenOutlined } from '@ant-design/icons';
import { useIntl } from '@umijs/max';

const UpdateContent = ({
form,
onSubmit,
record,
r,
}: {
form: FormInstance;
onSubmit: (values: any) => void;
record: Record<string, any>;
r: any;
}) => {
const intl = useIntl();

// 当组件挂载或者record更新时,设置表单的初始值
// // 当组件挂载或者record更新时,设置表单的初始值
// useEffect(() => {
// form.setFieldsValue(record);
// });

useEffect(() => {
form.setFieldsValue(record);
}, []);

useEffect(() => {
form.setFieldsValue(record);
});
}, [r]);

const [opts, setOpts] = useState([]);
useEffect(() => {
allDomain().then((res) => {
if (res.success) {
setOpts(res.data);
}
});
}, []);
const [isModalVisible, setIsModalVisible] = useState(false);
const [subChannels, setSubChannels] = useState('');

const showModal = () => {
setIsModalVisible(true);
};

const handleOk = () => {
record.subChannels = subChannels.split('\n');
form.setFieldsValue({ subChannels: subChannels.split('\n') });
setIsModalVisible(false);
};

const handleCancel = () => {
setIsModalVisible(false);
};

return (
<Form
Expand All @@ -40,7 +90,10 @@ const UpdateContent = ({
>
<Input />
</Form.Item>
<Form.Item label={intl.formatMessage({ id: 'pages.account.nijiChannelId' })} name="nijiBotChannelId">
<Form.Item
label={intl.formatMessage({ id: 'pages.account.nijiChannelId' })}
name="nijiBotChannelId"
>
<Input />
</Form.Item>
<Form.Item
Expand All @@ -50,10 +103,66 @@ const UpdateContent = ({
>
<Switch />
</Form.Item>

<Form.Item label={intl.formatMessage({ id: 'pages.account.enableMj' })} name="enableMj">
<Switch />
</Form.Item>
<Form.Item
label={intl.formatMessage({ id: 'pages.account.enableNiji' })}
name="enableNiji"
>
<Switch />
</Form.Item>
<Form.Item label={intl.formatMessage({ id: 'pages.account.isBlend' })} name="isBlend">
<Switch />
</Form.Item>
<Form.Item
label={intl.formatMessage({ id: 'pages.account.isDescribe' })}
name="isDescribe"
>
<Switch />
</Form.Item>
<Form.Item
label={intl.formatMessage({ id: 'pages.account.isShorten' })}
name="isShorten"
>
<Switch />
</Form.Item>
<Form.Item
label={intl.formatMessage({ id: 'pages.account.dayDrawLimit' })}
name="dayDrawLimit"
extra={
record.dayDrawCount > 0 && (
<span>
{intl.formatMessage({ id: 'pages.account.dayDrawCount' })} {record.dayDrawCount}
</span>
)
}
>
<InputNumber min={-1} />
</Form.Item>
</Card>
</Col>
<Col span={12}>
<Card type="inner" title={intl.formatMessage({ id: 'pages.account.otherInfo' })}>
<Form.Item
label={intl.formatMessage({ id: 'pages.account.permanentInvitationLink' })}
name="permanentInvitationLink"
>
<Input />
</Form.Item>
<Form.Item
label={intl.formatMessage({ id: 'pages.account.isVerticalDomain' })}
name="isVerticalDomain"
>
<Switch />
</Form.Item>
<Form.Item
label={intl.formatMessage({ id: 'pages.account.verticalDomainIds' })}
name="verticalDomainIds"
>
<Select options={opts} allowClear mode="multiple"></Select>
</Form.Item>
<Form.Item
label={intl.formatMessage({ id: 'pages.account.timeoutMinutes' })}
name="timeoutMinutes"
Expand All @@ -63,18 +172,62 @@ const UpdateContent = ({
<Form.Item label={intl.formatMessage({ id: 'pages.account.weight' })} name="weight">
<InputNumber min={1} />
</Form.Item>
<Form.Item label={intl.formatMessage({ id: 'pages.account.remark' })} name="remark">

<Form.Item label={intl.formatMessage({ id: 'pages.account.sponsor' })} name="sponsor">
<Input />
</Form.Item>
<Form.Item label={intl.formatMessage({ id: 'pages.account.sponsor' })} name="sponsor">
<Form.Item label={intl.formatMessage({ id: 'pages.account.remark' })} name="remark">
<Input />
</Form.Item>
<Form.Item label={intl.formatMessage({ id: 'pages.account.sort' })} name="sort">
<InputNumber />
</Form.Item>
<Form.Item
label={intl.formatMessage({ id: 'pages.account.subChannels' })}
name="subChannels"
extra={
<Button
type="primary"
style={{ marginTop: '10px' }}
onClick={() => {
setSubChannels(form.getFieldValue('subChannels').join('\n'));
showModal();
}}
icon={<FullscreenOutlined />}
></Button>
}
>
<Input.TextArea disabled autoSize={{ minRows: 1, maxRows: 5 }} />
</Form.Item>
</Card>
</Col>
</Row>

<Modal
title={intl.formatMessage({ id: 'pages.account.subChannels' })}
visible={isModalVisible}
onOk={handleOk}
onCancel={handleCancel}
width={960}
>
<div>
<Alert
message={intl.formatMessage({ id: 'pages.account.subChannelsHelp' })}
type="info"
style={{ marginBottom: '10px' }}
/>
</div>
<Input.TextArea
placeholder="https://discord.com/channels/xxx/xxx"
autoSize={{ minRows: 10, maxRows: 24 }}
style={{ width: '100%' }}
value={subChannels}
onChange={(e) => {
// 设置 form 的值
setSubChannels(e.target.value);
}}
/>
</Modal>
</Form>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/pages/AccountList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ const AccountList: React.FC = () => {
onClick={() =>
openModal(
intl.formatMessage({ id: 'pages.account.update' }),
<UpdateContent form={form} record={record} onSubmit={handleUpdate} />,
<UpdateContent r={Math.random()} form={form} record={record} onSubmit={handleUpdate} />,
1000,
)
}
Expand Down
14 changes: 11 additions & 3 deletions src/pages/Draw/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -806,9 +806,17 @@ const Draw: React.FC = () => {
{getTaskStatus(task)}

{/* 图片 */}
{task.action === 'SWAP_VIDEO_FACE'
? getTaskVideo(task.imageUrl, 250)
: getTaskImage(task.imageUrl, 250)}
{task.action === 'SWAP_VIDEO_FACE' ? (
<>
{/* <Flex style={{ maxHeight: 60 }}>
<div>{getTaskImage(task.replicateSource, 125)}</div>
<div>{getTaskVideo(task.replicateTarget, 125)}</div>
</Flex> */}
{getTaskVideo(task.imageUrl, 250)}
</>
) : (
getTaskImage(task.imageUrl, 250)
)}
</>
);
}
Expand Down
9 changes: 9 additions & 0 deletions src/pages/Setting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,15 @@ const Setting: React.FC = () => {
<InputNumber min={-1} />
</Form.Item>


<Form.Item
label={intl.formatMessage({ id: 'pages.setting.bannedLimiting' })}
name="bannedLimiting"
>
<JsonEditor />
</Form.Item>


<Form.Item
label={intl.formatMessage({ id: 'pages.setting.ipRateLimiting' })}
name="ipRateLimiting"
Expand Down
10 changes: 8 additions & 2 deletions src/pages/Task/components/TaskContent.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useIntl } from '@umijs/max';
import { Card, Descriptions, Image, Progress, Spin, Tag, Tooltip } from 'antd';
import { Card, Descriptions, Flex, Image, Progress, Spin, Tag, Tooltip } from 'antd';

const TaskContent = ({ record }: { record: Record<string, any> }) => {
const intl = useIntl();
Expand Down Expand Up @@ -138,7 +138,13 @@ const TaskContent = ({ record }: { record: Record<string, any> }) => {

{record.action === 'SWAP_VIDEO_FACE' ? (
<Descriptions.Item label={intl.formatMessage({ id: 'pages.task.video' })}>
{getVideo(record.imageUrl)}
<Flex vertical>
{/* <Flex>
<div>{getImage(record.replicateSource)}</div>
<div>{getVideo(record.replicateTarget)}</div>
</Flex> */}
{getVideo(record.imageUrl)}
</Flex>
</Descriptions.Item>
) : (
<Descriptions.Item label={intl.formatMessage({ id: 'pages.task.image' })}>
Expand Down

0 comments on commit fc0030f

Please sign in to comment.