add messages api
This commit is contained in:
@@ -5,6 +5,8 @@ import { HashRouter as Router } from 'react-router-dom'
|
|||||||
import App from './App'
|
import App from './App'
|
||||||
import {store} from './store/store';
|
import {store} from './store/store';
|
||||||
|
|
||||||
|
import './utils/messagesApi'
|
||||||
|
|
||||||
globalThis.Buffer = Buffer
|
globalThis.Buffer = Buffer
|
||||||
|
|
||||||
window.store = store;
|
window.store = store;
|
||||||
|
|||||||
12
src/utils/messagesApi.js
Normal file
12
src/utils/messagesApi.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
const domains = [
|
||||||
|
"http://dev.kandrusyak.ru",
|
||||||
|
]
|
||||||
|
window.addEventListener("message", messageHandler, false);
|
||||||
|
function messageHandler(event) {
|
||||||
|
if (!domains.includes(event.origin))
|
||||||
|
return;
|
||||||
|
const { action, key, value } = event.data
|
||||||
|
if (action === 'save'){
|
||||||
|
window.localStorage.setItem(key, JSON.stringify(value))
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user