vue2-client 1.8.17 → 1.8.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/package.json +1 -1
- package/src/layouts/SinglePageView.vue +21 -0
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -48,6 +48,7 @@ export default {
|
|
|
48
48
|
},
|
|
49
49
|
created () {
|
|
50
50
|
this.isLoaded = false
|
|
51
|
+
window.addEventListener('message', this.messageFunc)
|
|
51
52
|
if (this.singlePageUrl.indexOf('sso:') !== -1) {
|
|
52
53
|
const serviceKey = this.singlePageUrl.substring(4)
|
|
53
54
|
CASLogin(serviceKey, true).then(res => {
|
|
@@ -82,6 +83,9 @@ export default {
|
|
|
82
83
|
this.iframe = this.$refs.singlepage.contentWindow
|
|
83
84
|
this.path = this.$route.path
|
|
84
85
|
},
|
|
86
|
+
beforeDestroy () {
|
|
87
|
+
window.removeEventListener('message', this.messageFunc)
|
|
88
|
+
},
|
|
85
89
|
methods: {
|
|
86
90
|
...mapMutations('account', ['setLogin']),
|
|
87
91
|
load () {
|
|
@@ -103,6 +107,23 @@ export default {
|
|
|
103
107
|
}
|
|
104
108
|
this.$emit('load', this.fullPath)
|
|
105
109
|
this.isLoaded = true
|
|
110
|
+
},
|
|
111
|
+
mounted () {
|
|
112
|
+
this.$emit('ready')
|
|
113
|
+
},
|
|
114
|
+
sendMessage (methodName, data) {
|
|
115
|
+
const message = {
|
|
116
|
+
method: methodName,
|
|
117
|
+
data: data
|
|
118
|
+
}
|
|
119
|
+
if (this.iframe) {
|
|
120
|
+
console.info('发送消息', message)
|
|
121
|
+
this.iframe.postMessage(message, '*')
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
messageFunc (event) {
|
|
125
|
+
console.info('接收消息' + event.data)
|
|
126
|
+
this.$emit(event.data.method, event.data.data)
|
|
106
127
|
}
|
|
107
128
|
}
|
|
108
129
|
}
|