From 5d581b0a117c724031e920bdf953a15aac8a7616 Mon Sep 17 00:00:00 2001 From: trueai-org Date: Sun, 11 Aug 2024 17:48:44 +0800 Subject: [PATCH] move --- src/locales/en-US/pages.ts | 22 +++++++---- src/locales/zh-CN/pages.ts | 5 ++- src/pages/Setting/index.tsx | 74 +++++++++++++++++++++++++++++++++++-- src/services/mj/api.ts | 9 +++++ 4 files changed, 97 insertions(+), 13 deletions(-) diff --git a/src/locales/en-US/pages.ts b/src/locales/en-US/pages.ts index e4b2db7..e090ef8 100644 --- a/src/locales/en-US/pages.ts +++ b/src/locales/en-US/pages.ts @@ -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', @@ -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', @@ -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', @@ -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', @@ -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', @@ -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', @@ -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', }; diff --git a/src/locales/zh-CN/pages.ts b/src/locales/zh-CN/pages.ts index dee4651..da4d75f 100644 --- a/src/locales/zh-CN/pages.ts +++ b/src/locales/zh-CN/pages.ts @@ -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', }; diff --git a/src/pages/Setting/index.tsx b/src/pages/Setting/index.tsx index 668d4c6..4b84244 100644 --- a/src/pages/Setting/index.tsx +++ b/src/pages/Setting/index.tsx @@ -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'; @@ -17,6 +17,7 @@ import { Space, Spin, Switch, + Tooltip, } from 'antd'; import React, { useEffect, useState } from 'react'; @@ -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 (
{ style={{ paddingTop: '4px', paddingBottom: '4px' }} description={intl.formatMessage({ id: 'pages.setting.tips' })} /> - + + + setHost(e.target.value)} + /> + setToken(e.target.value)} + /> + + } + > + + + + + diff --git a/src/services/mj/api.ts b/src/services/mj/api.ts index fa44299..0b8b686 100644 --- a/src/services/mj/api.ts +++ b/src/services/mj/api.ts @@ -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('/mj/admin/mjplus-migration', { + method: 'POST', + data: data, + ...(options || {}), + }); +}