pull/132/head
Azalea 2025-03-21 18:30:18 -04:00
parent bfdcdc30d6
commit 8578f6e048
4 changed files with 90 additions and 25 deletions

View File

@ -238,9 +238,39 @@ export const EN_REF_MAI_PHOTO = {
'maiphoto.none': 'No photo found. You can upload photo by clicking upload at the end of each game session.',
}
export const EN_REF_AQUATRANS = {
'trans.title': '🏳️‍⚧️ AquaTrans™ Data Transfer',
'trans.confirm.unbackuped.title': 'Confirm transfer',
'trans.confirm.unbackuped.msg': "It seems like you haven't backed up your destination data. Are you sure you want to proceed? (This will overwrite your destination server's data)",
'trans.confirm.untested.title': 'Error',
'trans.confirm.untested.msg': "It seems like you haven't tested both connections yet. Please test the connections first.",
'trans.confirm.done.title': 'Done!',
'trans.confirm.done.msg': 'Transfer completed successfully! Your data on ${dst} is overwritten with your data from ${src}.',
'trans.alert.in-progress': "Transfer already in progress!",
'trans.prompt-html': `
<p>👋 Welcome to the AquaTrans server data transfer tool!</p>
<p>You can use this to export data from any server, and input data into any server using the connection credentials (card number, server address, and keychip id).</p>
<p>This tool will simulate a game client and pull your data from the source server, and push your data to the destination server.</p>
<p>Please fill out the info below to get started!</p>
`,
'trans.error.empty': 'Please fill out all fields.',
'trans.error.untested': 'Please test the connections first.',
'trans.success.import': 'Data imported successfully!',
'trans.source.title': 'Source Server',
'trans.target.title': 'Destination Server',
'trans.field.addr': 'Server Address',
'trans.field.keychip': 'Keychip ID',
'trans.field.game': 'Game',
'trans.field.version': 'Version',
'trans.field.card': 'Card Number',
'trans.btn.test': 'Test Connection',
'trans.btn.export': 'Export Data',
'trans.btn.import': 'Import Data',
}
export const EN_REF = { ...EN_REF_USER, ...EN_REF_Welcome, ...EN_REF_GENERAL,
...EN_REF_LEADERBOARD, ...EN_REF_HOME, ...EN_REF_SETTINGS, ...EN_REF_USERBOX,
...EN_REF_MAI_PHOTO
...EN_REF_MAI_PHOTO, ...EN_REF_AQUATRANS
}
export type LocalizedMessages = typeof EN_REF

View File

@ -1,4 +1,5 @@
import {
EN_REF_AQUATRANS,
EN_REF_GENERAL,
EN_REF_HOME,
EN_REF_LEADERBOARD,
@ -242,5 +243,38 @@ export const zhMaiPhoto: typeof EN_REF_MAI_PHOTO = {
'maiphoto.none': '还没有图片哦~ 可以在每次游戏结束的时候点击上传来上传照片。',
}
export const zhAquaTrans: typeof EN_REF_AQUATRANS = {
'trans.title': '🏳️‍⚧️ AquaTrans™ 数据迁移工具',
'trans.confirm.unbackuped.title': '确认迁移',
'trans.confirm.unbackuped.msg': '似乎还没有备份目标服务器的数据,真的要继续吗?(推荐先备份一下,因为迁移的时候会覆盖数据)',
'trans.confirm.untested.title': '不太聪明喵',
'trans.confirm.untested.msg': '在两个服务器上都测试完连接之后才能进行数据迁移哦!',
'trans.confirm.done.title': '完成!',
'trans.confirm.done.msg': '数据迁移成功!在 ${dst} 上的数据已被来自 ${src} 的数据覆盖。',
'trans.alert.in-progress': '在迁移了在迁移了',
'trans.prompt-html': `
<p>👋 使 AquaTrans </p>
<p>使 Keychip ID</p>
<p></p>
<p></p>
`,
'trans.error.empty': '请填写所有字段。',
'trans.error.untested': '请先进行连接测试。',
'trans.success.import': '数据导入成功!',
'trans.source.title': '源服务器',
'trans.target.title': '目标服务器',
'trans.field.addr': '服务器地址',
'trans.field.keychip': '狗号',
'trans.field.game': '游戏',
'trans.field.version': '版本',
'trans.field.card': '卡号',
'trans.btn.test': '测试连接',
'trans.btn.export': '导出数据',
'trans.btn.import': '导入数据',
}
export const ZH = { ...zhUser, ...zhWelcome, ...zhGeneral,
...zhLeaderboard, ...zhHome, ...zhSettings, ...zhUserbox, ...zhMaiPhoto }
...zhLeaderboard, ...zhHome, ...zhSettings, ...zhUserbox, ...zhMaiPhoto,
...zhAquaTrans
}

View File

@ -40,16 +40,19 @@
srcEl.pull()
.then(() => dstEl.push(srcExportedData))
.then(() => confirm = {
title: "Done!",
message: `Transfer completed successfully! Your data on ${dst.dns} is overwritten with your data from ${src.dns}.`
title: t('trans.confirm.done.title'),
message: t('trans.confirm.done.msg', { src: src.dns, dst: dst.dns })
})
.catch(e => error = e)
.finally(() => loading = false)
}
function startTransfer() {
if (!(srcTested && dstTested)) return alert("Please test both servers first!")
if (loading) return alert("Transfer already in progress!")
if (!(srcTested && dstTested)) return confirm = {
title: t('trans.confirm.untested.title'),
message: t('trans.confirm.untested.msg')
}
if (loading) return alert(t('trans.alert.in-progress'))
console.log("Starting transfer...")
loading = true
@ -57,8 +60,8 @@
// Ask user to make sure to backup their data
confirm = {
title: "Confirm transfer",
message: "It seems like you haven't backed up your destination data. Are you sure you want to proceed? (This will overwrite your destination server's data)",
title: t('trans.confirm.unbackuped.title'),
message: t('trans.confirm.unbackuped.msg'),
dangerous: true,
confirm: actuallyStartTransfer,
cancel: () => { loading = false }
@ -72,7 +75,7 @@
<main class="content">
<div class="outer-title-options">
<h2>🏳️‍⚧️ AquaTrans™ Data Transfer?</h2>
<h2>{t('trans.title')}</h2>
<nav>
{#each tabs as tabName, i}
<div transition:slide={{axis: 'x'}} class:active={tab === i}
@ -85,10 +88,7 @@
</div>
<div class="prompt">
<p>👋 Welcome to the AquaTrans™ server data transfer tool!</p>
<p>You can use this to export data from any server, and input data into any server using the connection credentials (card number, server address, and keychip id).</p>
<p>This tool will simulate a game client and pull your data from the source server, and push your data to the destination server.</p>
<p>Please fill out the info below to get started!</p>
{@html t("trans.prompt-html")}
</div>
<TransferServer bind:src={src} bind:gameInfo={gameInfo} on:change={onChange}

View File

@ -1,5 +1,6 @@
<script lang="ts">
import StatusOverlays from "../../components/StatusOverlays.svelte";
import { t } from "../../libs/i18n";
import { TRANSFER } from "../../libs/sdk";
import { download, selectJsonFile } from "../../libs/ui";
import InputTextShort from "./InputTextShort.svelte";
@ -16,7 +17,7 @@
// Preliminiary checks
if (!src.dns || !src.keychip || !src.card || !gameInfo.game || !gameInfo.version) {
error = "Please fill out all fields"
error = t('trans.error.empty')
return
}
@ -34,7 +35,7 @@
export function pull(): Promise<string> {
return new Promise<string>((resolve, reject) => {
if (loading || !tested) return reject("Please test connection first")
if (loading || !tested) return reject(t('trans.error.untested'))
if (exportedData) return resolve(exportedData)
console.log("Exporting data...")
error = ""
@ -74,7 +75,7 @@
return TRANSFER.push({...src, ...gameInfo}, data).then(() => {
console.log("Data imported successfully")
messages = ["Data imported successfully"]
messages = [t('trans.success.import')]
}).catch(err => error = err.message).finally(() => loading = false)
}
</script>
@ -82,7 +83,7 @@
<StatusOverlays {loading} />
<div class="server source" class:src={isSrc} class:hasError={error} class:tested={tested}>
<h3>{isSrc ? "Source" : "Target"} Server</h3>
<h3>{t(`trans.${isSrc ? "source" : "target"}.title`)}</h3>
{#if error}
<blockquote class="error-msg">{error}</blockquote>
@ -90,21 +91,21 @@
<!-- First input line -->
<div class="inputs">
<InputTextShort desc="Server Address" placeholder="e.g. http://aquadx.hydev.org"
<InputTextShort desc={t('trans.field.addr')} placeholder="e.g. http://aquadx.hydev.org"
bind:value={src.dns} on:change validate={v => /^https?:\/\/[a-z0-9.-]+(:\d+)?$/i.test(v)} disabled={tested} />
<InputTextShort desc="Keychip ID" placeholder="e.g. A0299792458"
<InputTextShort desc={t('trans.field.keychip')} placeholder="e.g. A0299792458"
bind:value={src.keychip} on:change validate={v => /^([A-Z0-9]{11}|[A-Z0-9]{4}-[A-Z0-9]{11})$/.test(v)} disabled={tested} />
</div>
<!-- Second input line -->
<div class="inputs">
<div class="game-version">
<InputTextShort desc="Game" placeholder="e.g. SDHD"
<InputTextShort desc={t('trans.field.game')} placeholder="e.g. SDHD"
bind:value={gameInfo.game} on:change disabled={tested} />
<InputTextShort desc="Version" placeholder="e.g. 2.30"
<InputTextShort desc={t('trans.field.version')} placeholder="e.g. 2.30"
bind:value={gameInfo.version} on:change disabled={tested} />
</div>
<InputTextShort desc="Card Number" placeholder="e.g. 27182818284590452353"
<InputTextShort desc={t('trans.field.card')} placeholder="e.g. 27182818284590452353"
bind:value={src.card} on:change disabled={tested} />
</div>
@ -120,10 +121,10 @@
<!-- Buttons -->
<div class="inputs buttons">
{#if !tested}
<button class="flex-1" on:click={testConnection} disabled={loading}>Test Connection</button>
<button class="flex-1" on:click={testConnection} disabled={loading}>{t('trans.btn.test')}</button>
{:else}
<button class="flex-1" on:click={pull}>Export Data</button>
<button class="flex-1" on:click={pushBtn}>Import Data</button>
<button class="flex-1" on:click={pull}>{t('trans.btn.export')}</button>
<button class="flex-1" on:click={pushBtn}>{t('trans.btn.import')}</button>
{/if}
</div>
</div>