mirror of https://github.com/hykilpikonna/AquaDX
[+] Export maimai userdata
parent
b32b0e970c
commit
7c4f887ef4
|
@ -21,8 +21,7 @@
|
|||
}
|
||||
</script>
|
||||
|
||||
<main>
|
||||
<div class="fields">
|
||||
<div class="fields">
|
||||
{#each gameFields as field}
|
||||
<div class="field">
|
||||
{#if field.type === "Boolean"}
|
||||
|
@ -37,10 +36,9 @@
|
|||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<StatusOverlays {error} loading={!gameFields.length && !!submitting}/>
|
||||
</main>
|
||||
<StatusOverlays {error} loading={!gameFields.length && !!submitting}/>
|
||||
|
||||
<style lang="sass">
|
||||
.fields
|
||||
|
|
|
@ -34,10 +34,26 @@
|
|||
break
|
||||
}
|
||||
}
|
||||
|
||||
function exportData() {
|
||||
submitting = "export"
|
||||
GAME.export('mai2')
|
||||
.then(data => download(JSON.stringify(data), `AquaDX_maimai2_export_${values[0]}.json`))
|
||||
.catch(e => error = e.message)
|
||||
.finally(() => submitting = "")
|
||||
}
|
||||
|
||||
function download(data: string, filename: string) {
|
||||
const blob = new Blob([data]);
|
||||
const url = URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = filename;
|
||||
link.click();
|
||||
}
|
||||
</script>
|
||||
|
||||
<main>
|
||||
<div class="fields" out:fade={FADE_OUT} in:fade={FADE_IN}>
|
||||
<div class="fields" out:fade={FADE_OUT} in:fade={FADE_IN}>
|
||||
{#each profileFields as [field, name], i (field)}
|
||||
<div class="field">
|
||||
<label for={field}>{name}</label>
|
||||
|
@ -58,10 +74,13 @@
|
|||
</div>
|
||||
{/each}
|
||||
<GameSettingFields game="mai2"/>
|
||||
</div>
|
||||
<button class="exportButton" on:click={exportData}>
|
||||
<Icon icon="bxs:file-export"/>
|
||||
{t('settings.export')}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<StatusOverlays {error} loading={!values[0] || !!submitting}/>
|
||||
</main>
|
||||
<StatusOverlays {error} loading={!values[0] || !!submitting}/>
|
||||
|
||||
<style lang="sass">
|
||||
.fields
|
||||
|
@ -84,4 +103,10 @@
|
|||
|
||||
> input
|
||||
flex: 1
|
||||
|
||||
.exportButton
|
||||
display: flex
|
||||
justify-content: center
|
||||
align-items: center
|
||||
gap: 5px
|
||||
</style>
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
import GameSettingFields from "./GameSettingFields.svelte";
|
||||
</script>
|
||||
|
||||
<main>
|
||||
<div out:fade={FADE_OUT} in:fade={FADE_IN}>
|
||||
<div out:fade={FADE_OUT} in:fade={FADE_IN}>
|
||||
<GameSettingFields game="wacca"/>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
|
|
@ -141,6 +141,7 @@ export const EN_REF_SETTINGS = {
|
|||
'settings.profile.bio': 'Bio',
|
||||
'settings.profile.unset': 'Unset',
|
||||
'settings.profile.unchanged': 'Unchanged',
|
||||
'settings.export': 'Export Player Data',
|
||||
}
|
||||
|
||||
export const EN_REF_USERBOX = {
|
||||
|
|
|
@ -150,6 +150,7 @@ const zhSettings: typeof EN_REF_SETTINGS = {
|
|||
'settings.profile.bio': '简介',
|
||||
'settings.profile.unset': '未设置',
|
||||
'settings.profile.unchanged': '未更改',
|
||||
'settings.export': '导出玩家数据',
|
||||
}
|
||||
|
||||
export const ZH = { ...zhUser, ...zhWelcome, ...zhGeneral,
|
||||
|
|
|
@ -46,7 +46,7 @@ export function fetchWithParams(input: URL | RequestInfo, init?: RequestInitWith
|
|||
|
||||
const cache: { [index: string]: any } = {}
|
||||
|
||||
export async function post(endpoint: string, params: any, init?: RequestInitWithParams): Promise<any> {
|
||||
export async function post(endpoint: string, params: Record<string, any> = {}, init?: RequestInitWithParams): Promise<any> {
|
||||
// Add token if exists
|
||||
const token = localStorage.getItem('token')
|
||||
if (token && !('token' in params)) params = { ...(params ?? {}), token }
|
||||
|
@ -301,6 +301,8 @@ export const GAME = {
|
|||
post(`/api/v2/game/${game}/ranking`, { }),
|
||||
changeName: (game: GameName, newName: string): Promise<{ newName: string }> =>
|
||||
post(`/api/v2/game/${game}/change-name`, { newName }),
|
||||
export: (game: GameName): Promise<Record<string, any>> =>
|
||||
post(`/api/v2/game/${game}/export`),
|
||||
}
|
||||
|
||||
export const DATA = {
|
||||
|
|
|
@ -108,11 +108,11 @@ abstract class ImportController<ExportModel: IExportClass<UserModel>, UserModel:
|
|||
// Check existing data
|
||||
userDataRepo.findByCard(u.ghostCard)?.also { gu ->
|
||||
// Store a backup of the old data
|
||||
val fl = "mai2-backup-${u.auId}-${LocalDateTime.now().urlSafeStr()}.json"
|
||||
val fl = "${game}-backup-${u.auId}-${LocalDateTime.now().urlSafeStr()}.json"
|
||||
(Path(netProps.importBackupPath) / fl).writeText(export(u).toJson())
|
||||
|
||||
// Delete the old data (After migration v1000.7, all user-linked entities have ON DELETE CASCADE)
|
||||
log.info("Mai2 Import: Deleting old data for user ${u.auId}")
|
||||
log.info("$game Import: Deleting old data for user ${u.auId}")
|
||||
userDataRepo.delete(gu)
|
||||
userDataRepo.flush()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue