完善其他iframe跳转页面token传输

This commit is contained in:
syruan 2025-12-17 11:12:03 +08:00
parent fd37640245
commit c3269ee876
3 changed files with 57 additions and 3 deletions

View File

@ -1,8 +1,10 @@
<template>
<iframe :src="iframeSrc" style="width: 100%; height: 100vh; border: none"></iframe>
<iframe ref="rentFrame" :src="iframeSrc" style="width: 100%; height: 100vh; border: none"></iframe>
</template>
<script>
import { getToken } from '@/utils/auth'
export default {
name: 'RentManage',
data() {
@ -17,6 +19,22 @@ export default {
? 'http://36.33.26.201:21999/iws/mall-view/home?redirect=rent-manage'
: 'http://localhost:8102/iws/mall-view/home?redirect=rent-manage'
console.log('🚀 ~ this.iframeSrc:', this.iframeSrc)
// iframe token
this.$refs.rentFrame.onload = () => {
const token = getToken() // Cookie token
console.log('A项目token:' + token)
if (token) {
// 使 postMessage B
this.$refs.rentFrame.contentWindow.postMessage(
{
type: 'SET_TOKEN',
token: token,
},
window.location.origin
)
}
}
},
}
</script>

View File

@ -1,8 +1,10 @@
<template>
<iframe :src="iframeSrc" style="width: 100%; height: 100vh; border: none"></iframe>
<iframe ref="requirementFrame" :src="iframeSrc" style="width: 100%; height: 100vh; border: none"></iframe>
</template>
<script>
import { getToken } from '@/utils/auth'
export default {
name: 'RequirementIframe',
data() {
@ -17,6 +19,22 @@ export default {
? 'http://36.33.26.201:21999/iws/mall-view/home?redirect=parity'
: 'http://localhost:8102/iws/mall-view/home?redirect=parity'
console.log('🚀 ~ this.iframeSrc:', this.iframeSrc)
// iframe token
this.$refs.requirementFrame.onload = () => {
const token = getToken() // Cookie token
console.log('A项目token:' + token)
if (token) {
// 使 postMessage B
this.$refs.requirementFrame.contentWindow.postMessage(
{
type: 'SET_TOKEN',
token: token,
},
window.location.origin
)
}
}
},
}
</script>

View File

@ -1,8 +1,10 @@
<template>
<iframe :src="iframeSrc" style="width: 100%; height: 100vh; border: none"></iframe>
<iframe ref="requirementListFrame" :src="iframeSrc" style="width: 100%; height: 100vh; border: none"></iframe>
</template>
<script>
import { getToken } from '@/utils/auth'
export default {
name: 'requirementListIframe',
data() {
@ -17,6 +19,22 @@ export default {
? 'http://36.33.26.201:21999/iws/mall-view/home?redirect=sourcingNeed'
: 'http://localhost:8102/iws/mall-view/home?redirect=sourcingNeed'
console.log('🚀 ~ this.iframeSrc:', this.iframeSrc)
// iframe token
this.$refs.requirementListFrame.onload = () => {
const token = getToken() // Cookie token
console.log('A项目token:' + token)
if (token) {
// 使 postMessage B
this.$refs.requirementListFrame.contentWindow.postMessage(
{
type: 'SET_TOKEN',
token: token,
},
window.location.origin
)
}
}
},
}
</script>