mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-14 23:57:27 +00:00
backup and restore prefs
This commit is contained in:
parent
16ff17c3b5
commit
47559730e3
2 changed files with 25 additions and 1 deletions
|
@ -317,6 +317,14 @@
|
|||
<p v-text="`${$t('information.preferences_note')}`" />
|
||||
<br />
|
||||
<button class="btn" v-text="`${$t('actions.reset_preferences')}`" @click="resetPreferences()" />
|
||||
<button class="btn mx-4" v-text="`${$t('actions.backup_preferences')}`" @click="backupPreferences()" />
|
||||
<label
|
||||
for="fileSelector"
|
||||
class="btn"
|
||||
v-text="`${$t('actions.restore_preferences')}`"
|
||||
@click="restorePreferences()"
|
||||
/>
|
||||
<input class="hidden" id="fileSelector" ref="fileSelector" type="file" @change="restorePreferences()" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
@ -593,6 +601,20 @@ export default {
|
|||
} else alert(resp.error);
|
||||
});
|
||||
},
|
||||
backupPreferences() {
|
||||
const data = JSON.stringify(localStorage);
|
||||
this.download(data, "preferences.json", "application/json");
|
||||
},
|
||||
restorePreferences() {
|
||||
var file = this.$refs.fileSelector.files[0];
|
||||
file.text().then(text => {
|
||||
const data = JSON.parse(text);
|
||||
Object.keys(data).forEach(function (key) {
|
||||
localStorage.setItem(key, data[key]);
|
||||
});
|
||||
window.location.reload();
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -93,7 +93,9 @@
|
|||
"clone_playlist": "Clone Playlist",
|
||||
"clone_playlist_success": "Successfully cloned!",
|
||||
"download_as_txt": "Download as .txt",
|
||||
"reset_preferences": "Reset preferences"
|
||||
"reset_preferences": "Reset preferences",
|
||||
"backup_preferences": "Backup preferences",
|
||||
"restore_preferences": "Restore preferences"
|
||||
},
|
||||
"comment": {
|
||||
"pinned_by": "Pinned by",
|
||||
|
|
Loading…
Reference in a new issue