mirror of
https://github.com/MadeBaruna/paimon-moe.git
synced 2024-11-23 07:17:43 +01:00
Add ability to swap main account
This commit is contained in:
parent
339b1b023a
commit
0156ff9063
3 changed files with 112 additions and 12 deletions
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
23
src/routes/settings/_setMainAccount.svelte
Normal file
23
src/routes/settings/_setMainAccount.svelte
Normal file
|
@ -0,0 +1,23 @@
|
|||
<script>
|
||||
import { mdiArrowRight } from '@mdi/js';
|
||||
|
||||
import { t } from 'svelte-i18n';
|
||||
|
||||
import Button from '../../components/Button.svelte';
|
||||
import Icon from '../../components/Icon.svelte';
|
||||
|
||||
export let account;
|
||||
export let setMainAccount;
|
||||
export let cancel;
|
||||
</script>
|
||||
|
||||
<div>
|
||||
<p class="text-white font-bold mb-4 text-lg">{$t('settings.modal.setMain')}</p>
|
||||
<p class="text-white mb-4">{$t('settings.modal.setMainNotice')}</p>
|
||||
<p class="text-white mb-4">Account {account.value.substring(7)} <Icon path={mdiArrowRight} size={0.7} /> Main</p>
|
||||
<p class="text-white mb-4">Main <Icon path={mdiArrowRight} size={0.7} /> Account {account.value.substring(7)}</p>
|
||||
<div class="flex justify-end space-x-2">
|
||||
<Button on:click={cancel}>{$t('settings.modal.cancel')}</Button>
|
||||
<Button on:click={setMainAccount} color="green">{$t('settings.modal.continue')}</Button>
|
||||
</div>
|
||||
</div>
|
|
@ -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')}
|
||||
/>
|
||||
<div class="flex flex-1 mt-2 md:mt-0">
|
||||
<Button on:click={openResetAccount} className="mr-2 w-24" color="red">{$t('settings.reset')}</Button>
|
||||
<div class="flex flex-1 mt-2 md:mt-0 flex-wrap gap-2">
|
||||
<Button on:click={openResetAccount} color="red">{$t('settings.reset')}</Button>
|
||||
{#if currentAccount.value !== 'main'}
|
||||
<Button on:click={openDeleteAccount} className="mr-2 w-24" color="red">{$t('settings.delete')}</Button>
|
||||
<Button on:click={openDeleteAccount} color="red">{$t('settings.delete')}</Button>
|
||||
{/if}
|
||||
<Button on:click={addAccount}>{$t('settings.add')}</Button>
|
||||
{#if currentAccount.value !== 'main'}
|
||||
<Button on:click={openChangeMainaccountModal}>{$t('settings.setMainAccount')}</Button>
|
||||
{/if}
|
||||
<Button className="w-24" on:click={addAccount}>{$t('settings.add')}</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -323,11 +390,11 @@
|
|||
</div>
|
||||
<div class="flex mt-2 md:mt-0">
|
||||
<div class="flex flex-col md:flex-row md:items-center w-32 mr-2">
|
||||
<p class="text-white mr-2">AR:</p>
|
||||
<p class="text-white mr-2">{$t('settings.ar')}</p>
|
||||
<Input bind:value={arInput} placeholder="AR" type="number" min="1" />
|
||||
</div>
|
||||
<div class="flex flex-col md:flex-row md:items-center w-32 mr-2">
|
||||
<p class="text-white mr-2">WL:</p>
|
||||
<p class="text-white mr-2">{$t('settings.wl')}</p>
|
||||
<Input bind:value={wlInput} placeholder="WL" type="number" min="1" />
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue