feat: option to restore settings via url

This commit is contained in:
Bnyro 2023-10-18 20:41:10 +02:00
parent d1ff3d681b
commit 1b678b032c
4 changed files with 101 additions and 5 deletions

View file

@ -24,7 +24,8 @@ const { t, setupLocale } = useI18n(),
next = ref(false),
compact = ref(false),
prm = ref(false),
cc = ref(false);
cc = ref(false),
restoreUrl = ref('');
getJson('https://piped-instances.kavin.rocks')
.then(i => i || getJson('https://instances.tokhmi.xyz'))
@ -40,6 +41,16 @@ getJson('https://raw.codeberg.page/Hyperpipe/pages/api/backend.json').then(
},
);
const getRestoreUrl = () => {
const params = new URLSearchParams();
Object.keys(window.localStorage).forEach(key => {
params.set(key, window.localStorage.getItem(key));
});
restoreUrl.value = window.location.origin + '/restore/?' + params;
};
getRestoreUrl();
function getBool(val) {
return 'bi ' + (val ? 'bi-check2' : 'bi-x-lg');
}
@ -362,6 +373,9 @@ onMounted(() => {
</table>
</div>
<h2>{{ t('title.restore_prefs') }}</h2>
<a :href="restoreUrl">{{ restoreUrl }}</a>
<footer>
{{ date }}
<a