diff --git a/src/locales/en.json b/src/locales/en.json index 388a9c21..c3155416 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -645,6 +645,8 @@ "delete": "Delete", "add": "Add", "server": "Select your server:", + "ar": "AR:", + "wl": "WL:", "drive": [ "Paimon.moe uses the Application Data Directory on your Google Drive to save and sync your Wish counter and Todo list.", "Paimon.moe can only read and write files that this site created." @@ -661,12 +663,16 @@ "feedback": "If you found any bugs, wrong data, or any other feedback, please leave a message on", "or": "or", "thanks": "Thanks😁!", + "setMainAccount": "Set As Main Account", "modal": { "notice": "All Todo and Wish history data will be deleted", "backup": "You can backup your wish history first by exporting it to an excel file!", + "setMain": "Change main account?", + "setMainNotice": "This will change the account:", "cancel": "Cancel", "delete": "Delete", - "reset": "Reset" + "reset": "Reset", + "continue": "Continue" }, "changelog": "Changelog", "exportDescription": "You can export & import your Paimon.moe data here", @@ -680,7 +686,11 @@ "importContinue": "Continue", "importSuccess": "Import Success! Reloading in 5 seconds...", "importFailed": "Import Failed!", - "email": "Email:" + "email": "Email:", + "mainAccountChanged": "Main account changed, reloading in 5 seconds...", + "dataDeleted": "Data has been deleted", + "dataReset": "Data has been reset", + "accountAdded": "Account {accountNumber} added, select it on the account list!" }, "privacypolicy": { "title": "Privacy Policy", @@ -865,4 +875,4 @@ "save": "Save", "cancel": "Cancel" } -} +} \ No newline at end of file diff --git a/src/routes/settings/_setMainAccount.svelte b/src/routes/settings/_setMainAccount.svelte new file mode 100644 index 00000000..60c449c5 --- /dev/null +++ b/src/routes/settings/_setMainAccount.svelte @@ -0,0 +1,23 @@ + + +
+

{$t('settings.modal.setMain')}

+

{$t('settings.modal.setMainNotice')}

+

Account {account.value.substring(7)} Main

+

Main Account {account.value.substring(7)}

+
+ + +
+
diff --git a/src/routes/settings/index.svelte b/src/routes/settings/index.svelte index e6f4ab42..3179a514 100644 --- a/src/routes/settings/index.svelte +++ b/src/routes/settings/index.svelte @@ -13,6 +13,7 @@ import ResetAccountModal from './_resetAccount.svelte'; import DonateModal from '../../components/DonateModal.svelte'; import ExportImportModal from './_importExportModal.svelte'; + import SetMainaccountModal from './_setMainAccount.svelte'; import { driveSignedIn, @@ -108,7 +109,7 @@ .join(','), ); - pushToast(`Account ${accountNumber} added, select it on the account list!`); + pushToast($t('settings.accountAdded', { values: { accountNumber } })); } async function selectAccount() { @@ -166,6 +167,10 @@ 'achievement', 'collectables-updated', 'furnishing', + 'furnishing-inventory', + 'furnishing-set-placed', + 'furnishing-set-character', + 'fishing', ]; for (let k of keyWillBeDeleted) { @@ -184,7 +189,7 @@ await updateSave('accounts', undefined); } - pushToast('Data deleted'); + pushToast($t('settings.dataDeleted')); closeModal(); } @@ -202,6 +207,10 @@ 'achievement', 'collectables-updated', 'furnishing', + 'furnishing-inventory', + 'furnishing-set-placed', + 'furnishing-set-character', + 'fishing', ]; for (let k of keyWillBeDeleted) { @@ -211,7 +220,7 @@ await updateSave(`${prefix}todos`, undefined, true); await updateSave(`${prefix}todos`, []); - pushToast('Data deleted'); + pushToast($t('settings.dataReset')); closeModal(); } @@ -225,6 +234,46 @@ } } + async function setMainAccount() { + const prefix = getAccountPrefix(); + const keyWillBeMoved = [ + 'server', + 'ar', + 'wl', + 'todos', + 'wish-counter-character-event', + 'wish-counter-weapon-event', + 'wish-counter-standard', + 'wish-counter-beginners', + 'wish-uid', + 'characters', + 'achievement', + 'collectables-updated', + 'furnishing', + 'furnishing-inventory', + 'furnishing-set-placed', + 'furnishing-set-character', + 'fishing', + ]; + + const temp = {}; + for (let k of keyWillBeMoved) { + temp[k] = await localforage.getItem(k); + } + + for (let k of keyWillBeMoved) { + const data = await localforage.getItem(`${prefix}${k}`); + await localforage.setItem(k, data); + await localforage.setItem(`${prefix}${k}`, temp[k]); + } + + pushToast($t('settings.mainAccountChanged')); + setTimeout(() => { + window.location.reload(); + }, 5000); + closeModal(); + } + function openDeleteAccount() { openModal( DeleteAccountModal, @@ -277,6 +326,21 @@ ); } + function openChangeMainaccountModal() { + openModal( + SetMainaccountModal, + { + account: currentAccount, + setMainAccount, + cancel: closeModal, + }, + { + closeButton: false, + styleWindow: { background: '#25294A', width: '500px' }, + }, + ); + } + $: currentAccount, selectAccount(); $: selectedServer, updateServer(); $: arInput, updateAR(); @@ -307,12 +371,15 @@ options={accountList} placeholder={$t('settings.selectAccount')} /> -
- +
+ {#if currentAccount.value !== 'main'} - + + {/if} + + {#if currentAccount.value !== 'main'} + {/if} -
@@ -323,11 +390,11 @@
-

AR:

+

{$t('settings.ar')}

-

WL:

+

{$t('settings.wl')}