mirror of
https://github.com/mue/mue.git
synced 2026-06-11 19:18:57 +02:00
fix: close #245, port various fixes from 7.0
This commit is contained in:
@@ -110,23 +110,11 @@ export function loadSettings(hotreload) {
|
||||
`);
|
||||
}
|
||||
|
||||
// everything below this either doesn't support hot reload (custom js) or shouldn't run on a hot reload event
|
||||
// everything below this shouldn't run on a hot reload event
|
||||
if (hotreload === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (window.location.href.startsWith('http://') || window.location.href.startsWith('https://')){
|
||||
const js = localStorage.getItem('customjs');
|
||||
if (js) {
|
||||
try {
|
||||
// eslint-disable-next-line no-eval
|
||||
eval(js);
|
||||
} catch (e) {
|
||||
console.error('Failed to run custom JS: ', e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (localStorage.getItem('experimental') === 'true') {
|
||||
experimentalInit();
|
||||
}
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
import variables from 'modules/variables';
|
||||
import { toast } from 'react-toastify';
|
||||
|
||||
export function saveFile(data, filename = 'file') {
|
||||
const getMessage = (text) => variables.language.getMessage(variables.languagecode, text);
|
||||
|
||||
export function saveFile(data, filename = 'file', type = 'text/json') {
|
||||
if (typeof data === 'object') {
|
||||
data = JSON.stringify(data, undefined, 4);
|
||||
}
|
||||
|
||||
const blob = new Blob([data], { type: 'text/json' });
|
||||
const blob = new Blob([data], { type });
|
||||
|
||||
const event = document.createEvent('MouseEvents');
|
||||
const a = document.createElement('a');
|
||||
|
||||
a.href = window.URL.createObjectURL(blob);
|
||||
a.download = filename;
|
||||
a.dataset.downloadurl = ['text/json', a.download, a.href].join(':');
|
||||
a.dataset.downloadurl = [type, a.download, a.href].join(':');
|
||||
|
||||
event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
||||
a.dispatchEvent(event);
|
||||
@@ -29,7 +31,6 @@ export function exportSettings() {
|
||||
}
|
||||
|
||||
export function importSettings(e) {
|
||||
const getMessage = (text) => variables.language.getMessage(variables.languagecode, text);
|
||||
const content = JSON.parse(e.target.result);
|
||||
|
||||
Object.keys(content).forEach((key) => {
|
||||
|
||||
Reference in New Issue
Block a user