Merge pull request 'feat: option to restore settings via url' (#144) from Bnyro/Hyperpipe:settings-export into main

Reviewed-on: https://codeberg.org/Hyperpipe/Hyperpipe/pulls/144
This commit is contained in:
Shiny Nematoda 2023-10-19 14:06:29 +00:00
commit 4585baabad
4 changed files with 99 additions and 3 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');
}
@ -366,6 +377,9 @@ onMounted(() => {
</table>
</div>
<h2>{{ t('title.restore_prefs') }}</h2>
<a :href="restoreUrl">{{ restoreUrl }}</a>
<footer>
{{ date }}
<a