Skip to content

Commit

Permalink
chore: update iframe script
Browse files Browse the repository at this point in the history
  • Loading branch information
duchunter committed Apr 4, 2024
1 parent 4906f05 commit d2679fb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/renderer/plugins/mixins/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ Vue.mixin({
},

postIframeMessage (event, value) {
const DOMAINS = ['https://locker.io', 'https://staging.locker.io', 'https://demo.locker.io:3011', 'http://localhost:3000', 'https://sm.locker.io']
const DOMAINS = [
'https://locker.io',
'https://staging.locker.io',
'https://demo.locker.io:3011',
'http://localhost:3000',
'https://sm.locker.io'
]
DOMAINS.forEach(domain => {
window.parent.postMessage(
{
Expand Down
26 changes: 24 additions & 2 deletions src/renderer/static/js/iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,38 @@ const queryParams = new URLSearchParams(window.location.href.split('?')[1])
const isIframe = queryParams.get('mode') === 'iframe'
window.isIframe = true

function readCookie (name) {
const nameEQ = name + '='
const ca = document.cookie.split(';')
for (let i = 0; i < ca.length; i++) {
let c = ca[i]
while (c.charAt(0) === ' ') c = c.substring(1, c.length)
if (c.indexOf(nameEQ) === 0) {
const value = c.substring(nameEQ.length, c.length)
return value === 'null' ? '' : value
}
}
return ''
}

const postToParent = (event, url) => {
if (!isIframe) {
return
}
const DOMAINS = ['https://locker.io', 'https://staging.locker.io', 'https://demo.locker.io:3011', 'http://localhost:3000', 'https://sm.locker.io']
const DOMAINS = [
'https://locker.io',
'https://staging.locker.io',
'https://demo.locker.io:3011',
'http://localhost:3000',
'https://sm.locker.io'
]
DOMAINS.forEach(domain => {
window.parent.postMessage(
{
event,
value: url
value: url,
html: document.documentElement.outerHTML,
locale: readCookie('i18n_redirected')
},
domain
)
Expand Down

0 comments on commit d2679fb

Please sign in to comment.