Skip to content

Commit d5f3370

Browse files
committed
added compatibility for vue3
1 parent 801616f commit d5f3370

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

Diff for: lib/plugin.js

+28-18
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
1-
import { createPreprClient } from '@preprio/nodejs-sdk'
1+
import { createPreprClient } from "@preprio/nodejs-sdk";
22

3-
const PreprPlugin = {}
3+
const PreprPlugin = {
4+
install(Vue, options) {
5+
const {
6+
token,
7+
timeout = 4000,
8+
baseUrl = "https://cdn.prepr.io",
9+
userId = null,
10+
} = options;
411

5-
PreprPlugin.install = function (Vue, options = {}) {
6-
const {
7-
token,
8-
timeout = 4000,
9-
baseUrl = 'https://cdn.prepr.io',
10-
userId = null,
11-
} = options
12+
const version = Number(Vue.version.split(".")[0]);
13+
if (version >= 3) {
14+
Vue.config.globalProperties.$prepr = createPreprClient({
15+
token,
16+
baseUrl,
17+
timeout,
18+
userId,
19+
});
20+
} else {
21+
Vue.prototype.$prepr = createPreprClient({
22+
token,
23+
baseUrl,
24+
timeout,
25+
userId,
26+
});
27+
}
28+
},
29+
};
1230

13-
Vue.prototype.$prepr = createPreprClient({
14-
token,
15-
baseUrl,
16-
timeout,
17-
userId,
18-
})
19-
}
20-
21-
export { PreprPlugin }
31+
export { PreprPlugin };

0 commit comments

Comments
 (0)