Skip to content

Commit b513878

Browse files
committed
feat: global hook version check
1 parent 228b217 commit b513878

File tree

1 file changed

+9
-1
lines changed
  • packages/app-backend-core/src

1 file changed

+9
-1
lines changed

packages/app-backend-core/src/hook.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @param {Window|global} target
1010
*/
1111
export function installHook (target, isIframe = false) {
12+
const devtoolsVersion = '6.0'
1213
let listeners = {}
1314

1415
function injectIframeHook (iframe) {
@@ -49,7 +50,12 @@ export function installHook (target, isIframe = false) {
4950
}
5051
}, 1000)
5152

52-
if (Object.prototype.hasOwnProperty.call(target, '__VUE_DEVTOOLS_GLOBAL_HOOK__')) return
53+
if (Object.prototype.hasOwnProperty.call(target, '__VUE_DEVTOOLS_GLOBAL_HOOK__')) {
54+
if (target.__VUE_DEVTOOLS_GLOBAL_HOOK__.devtoolsVersion !== devtoolsVersion) {
55+
console.error(`Another version of Vue Devtools seems to be installed. Please enable only one version at a time.`)
56+
}
57+
return
58+
}
5359

5460
let hook
5561

@@ -68,6 +74,7 @@ export function installHook (target, isIframe = false) {
6874
}
6975

7076
hook = {
77+
devtoolsVersion,
7178
// eslint-disable-next-line accessor-pairs
7279
set Vue (value) {
7380
sendToParent(hook => { hook.Vue = value })
@@ -96,6 +103,7 @@ export function installHook (target, isIframe = false) {
96103
}
97104
} else {
98105
hook = {
106+
devtoolsVersion,
99107
Vue: null,
100108
enabled: undefined,
101109
_buffer: [],

0 commit comments

Comments
 (0)