mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-11-23 05:57:21 +00:00
backup and restore prefs
This commit is contained in:
parent
16ff17c3b5
commit
47559730e3
@ -317,6 +317,14 @@
|
|||||||
<p v-text="`${$t('information.preferences_note')}`" />
|
<p v-text="`${$t('information.preferences_note')}`" />
|
||||||
<br />
|
<br />
|
||||||
<button class="btn" v-text="`${$t('actions.reset_preferences')}`" @click="resetPreferences()" />
|
<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>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -593,6 +601,20 @@ export default {
|
|||||||
} else alert(resp.error);
|
} 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>
|
</script>
|
||||||
|
@ -93,7 +93,9 @@
|
|||||||
"clone_playlist": "Clone Playlist",
|
"clone_playlist": "Clone Playlist",
|
||||||
"clone_playlist_success": "Successfully cloned!",
|
"clone_playlist_success": "Successfully cloned!",
|
||||||
"download_as_txt": "Download as .txt",
|
"download_as_txt": "Download as .txt",
|
||||||
"reset_preferences": "Reset preferences"
|
"reset_preferences": "Reset preferences",
|
||||||
|
"backup_preferences": "Backup preferences",
|
||||||
|
"restore_preferences": "Restore preferences"
|
||||||
},
|
},
|
||||||
"comment": {
|
"comment": {
|
||||||
"pinned_by": "Pinned by",
|
"pinned_by": "Pinned by",
|
||||||
|
Loading…
Reference in New Issue
Block a user