add messages api
This commit is contained in:
@@ -5,10 +5,12 @@ 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'
|
import { allowMessages } from './utils/messagesApi'
|
||||||
|
|
||||||
globalThis.Buffer = Buffer
|
globalThis.Buffer = Buffer
|
||||||
|
|
||||||
|
allowMessages();
|
||||||
|
|
||||||
window.store = store;
|
window.store = store;
|
||||||
|
|
||||||
BigInt.prototype.toJSON = function() {
|
BigInt.prototype.toJSON = function() {
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
const domains = [
|
export const allowMessages = () => {
|
||||||
"http://dev.kandrusyak.ru",
|
const domains = [
|
||||||
]
|
"http://dev.kandrusyak.ru",
|
||||||
window.addEventListener("message", messageHandler, false);
|
]
|
||||||
function messageHandler(event) {
|
window.addEventListener("message", messageHandler, false);
|
||||||
if (!domains.includes(event.origin))
|
|
||||||
return;
|
function messageHandler(event) {
|
||||||
const { action, key, value } = event.data
|
if (!domains.includes(event.origin))
|
||||||
if (action === 'save'){
|
return;
|
||||||
window.localStorage.setItem(key, JSON.stringify(value))
|
const {action, key, value} = event.data
|
||||||
|
if (action === 'save') {
|
||||||
|
window.localStorage.setItem(key, JSON.stringify(value))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user