share modal behaviur; add route run; codeService

This commit is contained in:
2022-11-24 10:31:27 +01:00
parent 38be5e93c9
commit 52f49c8a95
10 changed files with 133 additions and 58 deletions

View File

@@ -0,0 +1,35 @@
import {
WELCOME_CODE,
STORAGE_KEY_CODE,
} from '../app.config';
import EventEmitter from 'eventemitter3';
const ee = new EventEmitter();
let code;
const init = () => {
const lsCode = localStorage.getItem(STORAGE_KEY_CODE);
console.log('code', lsCode);
code = lsCode ? lsCode : WELCOME_CODE;
};
const codeService = {
get() {
return code;
},
change(_code) {
code = _code;
console.log('save', _code)
localStorage.setItem(STORAGE_KEY_CODE, code);
ee.emit('change', code);
},
setFromUrl(_encoded) {
this.change(atob(_encoded));
},
ee,
};
export default codeService;
init();