Skip to content

Commit

Permalink
move
Browse files Browse the repository at this point in the history
  • Loading branch information
trueai-org committed Aug 11, 2024
1 parent d5db10f commit 5d581b0
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 13 deletions.
22 changes: 14 additions & 8 deletions src/locales/en-US/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export default {
'pages.login.register': 'Register',
'pages.login.returnLogin': 'Return to login',
'pages.login.registerSuccess': 'Register successful!',


'pages.welcome.todayDraw': 'Today Draw',
'pages.welcome.yesterdayDraw': 'Yesterday Draw',
Expand Down Expand Up @@ -103,7 +102,8 @@ export default {
'pages.submit': 'OK',

'pages.user.isWhite': 'Is White',
'pages.user.isWhite.help': 'Whitelisted users are not restricted by stream and ip drawing restrictions',
'pages.user.isWhite.help':
'Whitelisted users are not restricted by stream and ip drawing restrictions',
'pages.account.permanentInvitationLink': 'Permanent Invitation Link',
'pages.account.notRunning': 'Service Not Running',
'pages.account.lock': 'Account locked',
Expand All @@ -122,7 +122,8 @@ export default {
'pages.account.sponsor': 'Sponsor',
'pages.account.workTime': 'Working Time',
'pages.account.fishingTime': 'Fishing Time',
'pages.account.fishingTimeTips': 'When touching fish, only change tasks are accepted, and new drawing tasks are not accepted',
'pages.account.fishingTimeTips':
'When touching fish, only change tasks are accepted, and new drawing tasks are not accepted',
'pages.account.sort': 'Sort',
'pages.account.cfmodal': 'CF Real person verification',
'pages.account.renewDate': 'Expiration Time',
Expand All @@ -147,7 +148,7 @@ export default {

'pages.account.info': 'Account Info',
'pages.account.interval': 'Interval before execution (seconds)',
'pages.account.intervalAfter':'Wait after execution (seconds)',
'pages.account.intervalAfter': 'Wait after execution (seconds)',
'pages.account.cfRefresh': 'Regenerates the CF validation link',
'pages.account.cfok': 'Mark verification passed',
'pages.account.mjVersionSuccess': 'MJ version switch successful',
Expand Down Expand Up @@ -184,14 +185,15 @@ export default {
'pages.account.isVerticalDomain': 'Enable Vertical Domain',
'pages.account.verticalDomainIds': 'Vertical Domain configuration',
'pages.account.subChannels': 'Sub Channels',
'pages.account.subChannelsHelp': 'Please input channels, each row of a, format: [invite link], [channel address], example: https://discord.gg/xxx, https://discord.com/channels/xxx/xxx',
'pages.account.subChannelsHelp':
'Please input channels, each row of a, format: [invite link], [channel address], example: https://discord.gg/xxx, https://discord.com/channels/xxx/xxx',
'pages.account.allowModesTooltip':
'If the user specifies the mode or adds a user-defined parameter, such as --fast, but the account does not allow FAST, this parameter is automatically removed',

'pages.task.info': 'Task Info',
'pages.task.type': 'Type',
'pages.task.submitTime': 'Submit Time',
'pages.task.preview':'Preview',
'pages.task.preview': 'Preview',
'pages.task.status': 'Status',
'pages.task.progress': 'Progress',
'pages.task.description': 'Description',
Expand Down Expand Up @@ -320,7 +322,8 @@ export default {
'pages.setting.captchaNotifyHook': 'Captcha Notify Hook',
'pages.setting.enableRegister': 'Enable Register',
'pages.setting.isVerticalDomain': 'Enable Vertical Domain',
'pages.setting.isVerticalDomainTips': 'When vertical domain painting is enabled, the promat entry will be calculated and then assigned to the corresponding account according to the entry. If no account is matched, the account painting that is not opened in vertical domain will be assigned',
'pages.setting.isVerticalDomainTips':
'When vertical domain painting is enabled, the promat entry will be calculated and then assigned to the corresponding account according to the entry. If no account is matched, the account painting that is not opened in vertical domain will be assigned',
'pages.setting.registerUserDefaultDayLimit': 'Register User Default Day Limit',
'pages.setting.enableGuest': 'Enable Guest',
'pages.setting.guestDefaultDayLimit': 'Guest Default Day Limit',
Expand All @@ -332,5 +335,8 @@ export default {
'pages.setting.otherSetting': 'Other Setting',
'pages.setting.accountSetting': 'Account Setting',
'pages.setting.tips':
'Tip: You need to restart the Discord and Proxy configurations to modify them. You do not need to restart other configurations.',
'Note: Modifying the account configuration requires restarting the service. Other configuration modifications take effect in real time without restarting the service.',
'pages.setting.migrate': 'Migrate',
'pages.setting.migrateSuccess':'The migration job is running in the background, please check later',
'pages.setting.migrateTips':'Enter Host',
};
5 changes: 4 additions & 1 deletion src/locales/zh-CN/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,9 @@ export default {
'pages.setting.ipBlackRateLimiting':'黑名单限流配置',
'pages.setting.otherSetting':'其他设置',
'pages.setting.accountSetting':'账号设置',
'pages.setting.tips':'提示:修改 Discord 配置和 Proxy 代理配置需重启服务,其他配置修改实时生效,无需重启服务。',
'pages.setting.tips':'提示:修改账号配置需重启服务,其他配置修改实时生效,无需重启服务。',
'pages.setting.migrate':'一键迁移',
'pages.setting.migrateSuccess':'迁移作业正在后台执行,请稍后查看',
'pages.setting.migrateTips':'请填写 Host',

};
74 changes: 70 additions & 4 deletions src/pages/Setting/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import JsonEditor from '@/components/JsonEditor';
import { getConfig, updateConfig } from '@/services/mj/api';
import { getConfig, migrateAccountAndTasks, updateConfig } from '@/services/mj/api';
import { SaveOutlined } from '@ant-design/icons';
import { PageContainer } from '@ant-design/pro-components';
import { useIntl } from '@umijs/max';
Expand All @@ -17,6 +17,7 @@ import {
Space,
Spin,
Switch,
Tooltip,
} from 'antd';
import React, { useEffect, useState } from 'react';

Expand Down Expand Up @@ -63,6 +64,38 @@ const Setting: React.FC = () => {
});
};

const [host, setHost] = useState('');
const [token, setToken] = useState('');

const onMigrate = async (host: string, token: string) => {
try {
setLoading(true);
const migrationData = {
Host: host,
ApiSecret: token,
};

const res = await migrateAccountAndTasks(migrationData);
if (res.success) {
message.success(intl.formatMessage({ id: 'pages.setting.migrateSuccess' }));
} else {
message.error(res.message);
}
} catch (error) {
message.error(error as string);
} finally {
setLoading(false);
}
};

const onMigrateClick = () => {
if (host) {
onMigrate(host, token);
} else {
message.warning(intl.formatMessage({ id: 'pages.setting.migrateTips' }));
}
};

return (
<PageContainer>
<Form
Expand All @@ -79,9 +112,42 @@ const Setting: React.FC = () => {
style={{ paddingTop: '4px', paddingBottom: '4px' }}
description={intl.formatMessage({ id: 'pages.setting.tips' })}
/>
<Button loading={loading} icon={<SaveOutlined />} type={'primary'} onClick={onFinish}>
{intl.formatMessage({ id: 'pages.setting.save' })}
</Button>
<Space>
<Tooltip
placement="bottom"
title={
<div
style={{
display: 'flex',
flexDirection: 'column',
gap: 8,

padding: 8,
}}
>
<Input
style={{ marginBottom: 8 }}
placeholder="Host"
value={host}
onChange={(e) => setHost(e.target.value)}
/>
<Input
placeholder="Token"
value={token}
onChange={(e) => setToken(e.target.value)}
/>
</div>
}
>
<Button loading={loading} type="primary" ghost onClick={onMigrateClick}>
{intl.formatMessage({ id: 'pages.setting.migrate' })}
</Button>
</Tooltip>

<Button loading={loading} icon={<SaveOutlined />} type={'primary'} onClick={onFinish}>
{intl.formatMessage({ id: 'pages.setting.save' })}
</Button>
</Space>
</Space>

<Row gutter={16}>
Expand Down
9 changes: 9 additions & 0 deletions src/services/mj/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,3 +366,12 @@ export async function updateConfig(data: object, options?: { [key: string]: any
...(options || {}),
});
}

// 一键迁移
export async function migrateAccountAndTasks(data: object, options?: { [key: string]: any }) {
return request<API.Result>('/mj/admin/mjplus-migration', {
method: 'POST',
data: data,
...(options || {}),
});
}

0 comments on commit 5d581b0

Please sign in to comment.