mirror of
https://github.com/wukko/cobalt.git
synced 2025-01-22 18:56:21 +01:00
web/ManageSettings: use downloadFile
for exporting settings
and also use 4 spaces for formatting the json file cuz 2 spaces is foul
This commit is contained in:
parent
b036437871
commit
277a6caefa
1 changed files with 9 additions and 15 deletions
|
@ -1,12 +1,9 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { t } from "$lib/i18n/translations";
|
import { t } from "$lib/i18n/translations";
|
||||||
|
import { downloadFile } from "$lib/download";
|
||||||
import { createDialog } from "$lib/state/dialogs";
|
import { createDialog } from "$lib/state/dialogs";
|
||||||
import {
|
|
||||||
storedSettings,
|
|
||||||
updateSetting,
|
|
||||||
loadFromString,
|
|
||||||
} from "$lib/state/settings";
|
|
||||||
import { validateSettings } from "$lib/settings/validate";
|
import { validateSettings } from "$lib/settings/validate";
|
||||||
|
import { storedSettings, updateSetting, loadFromString } from "$lib/state/settings";
|
||||||
|
|
||||||
import ActionButton from "$components/buttons/ActionButton.svelte";
|
import ActionButton from "$components/buttons/ActionButton.svelte";
|
||||||
import ResetSettingsButton from "$components/settings/ResetSettingsButton.svelte";
|
import ResetSettingsButton from "$components/settings/ResetSettingsButton.svelte";
|
||||||
|
@ -87,16 +84,13 @@
|
||||||
pseudoinput.click();
|
pseudoinput.click();
|
||||||
};
|
};
|
||||||
|
|
||||||
const exportSettings = () => {
|
const exportSettings = async () => {
|
||||||
const blob = new Blob(
|
return await downloadFile({
|
||||||
[JSON.stringify($storedSettings, null, 2)],
|
file: new File(
|
||||||
{ type: "application/json" }
|
[JSON.stringify($storedSettings, null, 4)],
|
||||||
);
|
"settings.json", { type: "application/json" }
|
||||||
|
),
|
||||||
const pseudolink = document.createElement("a");
|
});
|
||||||
pseudolink.href = URL.createObjectURL(blob);
|
|
||||||
pseudolink.download = "settings.json";
|
|
||||||
pseudolink.click();
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue