feat: v-model targe value should support variable

This commit is contained in:
Amour1688
2021-03-13 14:38:00 +08:00
parent 4c858a26e4
commit e9b83a0f96
5 changed files with 46 additions and 48 deletions

View File

@ -22,11 +22,7 @@ interface PersistedState {
window.init = () => {
const { monaco } = window;
const persistedState: PersistedState = JSON.parse(
decodeURIComponent(window.location.hash.slice(1))
|| localStorage.getItem('state')
|| '{}',
);
const persistedState: PersistedState = JSON.parse(localStorage.getItem('state') || '{}');
Object.assign(compilerOptions, persistedState.options);
@ -66,7 +62,10 @@ window.init = () => {
const reCompile = () => {
const src = editor.getValue();
const state = JSON.stringify(compilerOptions);
const state = JSON.stringify({
src,
options: compilerOptions,
});
localStorage.setItem('state', state);
window.location.hash = encodeURIComponent(src);
console.clear();