@jctrans-materials/nuxt 1.0.37-beta.6 → 1.0.37-beta.8
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/dist/module.cjs +8 -0
- package/dist/module.d.cts +1 -0
- package/dist/module.d.mts +1 -0
- package/dist/module.d.ts +1 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +8 -0
- package/dist/runtime/gio.client.d.ts +3 -0
- package/dist/runtime/gio.client.js +15 -0
- package/dist/runtime/gio.server.d.ts +28 -0
- package/dist/runtime/gio.server.js +42 -0
- package/dist/runtime/plugin.client.js +16 -7
- package/package.json +6 -5
package/dist/module.cjs
CHANGED
|
@@ -68,6 +68,14 @@ const module$1 = kit.defineNuxtModule({
|
|
|
68
68
|
src: resolve("./runtime/plugin"),
|
|
69
69
|
mode: "all"
|
|
70
70
|
});
|
|
71
|
+
kit.addPlugin({
|
|
72
|
+
src: resolve("./runtime/gio.client"),
|
|
73
|
+
mode: "client"
|
|
74
|
+
});
|
|
75
|
+
kit.addPlugin({
|
|
76
|
+
src: resolve("./runtime/gio.server"),
|
|
77
|
+
mode: "server"
|
|
78
|
+
});
|
|
71
79
|
kit.addPlugin({
|
|
72
80
|
src: resolve("./runtime/plugin.client"),
|
|
73
81
|
mode: "client"
|
package/dist/module.d.cts
CHANGED
package/dist/module.d.mts
CHANGED
package/dist/module.d.ts
CHANGED
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -65,6 +65,14 @@ const module$1 = defineNuxtModule({
|
|
|
65
65
|
src: resolve("./runtime/plugin"),
|
|
66
66
|
mode: "all"
|
|
67
67
|
});
|
|
68
|
+
addPlugin({
|
|
69
|
+
src: resolve("./runtime/gio.client"),
|
|
70
|
+
mode: "client"
|
|
71
|
+
});
|
|
72
|
+
addPlugin({
|
|
73
|
+
src: resolve("./runtime/gio.server"),
|
|
74
|
+
mode: "server"
|
|
75
|
+
});
|
|
68
76
|
addPlugin({
|
|
69
77
|
src: resolve("./runtime/plugin.client"),
|
|
70
78
|
mode: "client"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineNuxtPlugin } from "#app";
|
|
2
|
+
import "gio-webjs-sdk";
|
|
3
|
+
export default defineNuxtPlugin({
|
|
4
|
+
name: "jctrans-gio-sdk-loader",
|
|
5
|
+
enforce: "pre",
|
|
6
|
+
setup() {
|
|
7
|
+
if (process.dev && typeof window !== "undefined") {
|
|
8
|
+
if (typeof window.gdp !== "function") {
|
|
9
|
+
console.warn(
|
|
10
|
+
"[GIO] SDK \u5DF2\u5F15\u5165\uFF0C\u4F46 window.gdp \u4ECD\u4E0D\u53EF\u7528\uFF0C\u8BF7\u68C0\u67E5\u6253\u5305/\u8FD0\u884C\u73AF\u5883"
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
declare const _default: import("#app").Plugin<{
|
|
2
|
+
gio: {
|
|
3
|
+
init: () => void;
|
|
4
|
+
track: () => void;
|
|
5
|
+
isInitialized: () => boolean;
|
|
6
|
+
isBrowser: () => boolean;
|
|
7
|
+
setUserId: () => void;
|
|
8
|
+
clearUserId: () => void;
|
|
9
|
+
setGeneralProps: () => void;
|
|
10
|
+
setPageAttributes: () => void;
|
|
11
|
+
sendPage: () => void;
|
|
12
|
+
};
|
|
13
|
+
trackEvent: () => void;
|
|
14
|
+
}> & import("#app").ObjectPlugin<{
|
|
15
|
+
gio: {
|
|
16
|
+
init: () => void;
|
|
17
|
+
track: () => void;
|
|
18
|
+
isInitialized: () => boolean;
|
|
19
|
+
isBrowser: () => boolean;
|
|
20
|
+
setUserId: () => void;
|
|
21
|
+
clearUserId: () => void;
|
|
22
|
+
setGeneralProps: () => void;
|
|
23
|
+
setPageAttributes: () => void;
|
|
24
|
+
sendPage: () => void;
|
|
25
|
+
};
|
|
26
|
+
trackEvent: () => void;
|
|
27
|
+
}>;
|
|
28
|
+
export default _default;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { defineNuxtPlugin, useRuntimeConfig } from "#app";
|
|
2
|
+
const normalizeDirectiveName = (value) => {
|
|
3
|
+
if (typeof value !== "string") return "gio-track";
|
|
4
|
+
const trimmed = value.trim();
|
|
5
|
+
if (!trimmed) return "gio-track";
|
|
6
|
+
return trimmed.replace(/^v-/, "");
|
|
7
|
+
};
|
|
8
|
+
export default defineNuxtPlugin((nuxtApp) => {
|
|
9
|
+
const runtimeConfig = useRuntimeConfig();
|
|
10
|
+
const directiveName = normalizeDirectiveName(
|
|
11
|
+
runtimeConfig.public?.jctrans?.tracking?.directiveName
|
|
12
|
+
);
|
|
13
|
+
nuxtApp.vueApp.directive("gio-track", {});
|
|
14
|
+
if (directiveName !== "gio-track") {
|
|
15
|
+
nuxtApp.vueApp.directive(directiveName, {});
|
|
16
|
+
}
|
|
17
|
+
const mockGio = {
|
|
18
|
+
init: () => {
|
|
19
|
+
},
|
|
20
|
+
track: () => {
|
|
21
|
+
},
|
|
22
|
+
isInitialized: () => false,
|
|
23
|
+
isBrowser: () => false,
|
|
24
|
+
setUserId: () => {
|
|
25
|
+
},
|
|
26
|
+
clearUserId: () => {
|
|
27
|
+
},
|
|
28
|
+
setGeneralProps: () => {
|
|
29
|
+
},
|
|
30
|
+
setPageAttributes: () => {
|
|
31
|
+
},
|
|
32
|
+
sendPage: () => {
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
provide: {
|
|
37
|
+
gio: mockGio,
|
|
38
|
+
trackEvent: () => {
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineNuxtPlugin, useRuntimeConfig, useRouter } from "#app";
|
|
2
2
|
import { tracker } from "@jctrans-materials/shared";
|
|
3
|
+
import { nextTick } from "vue";
|
|
3
4
|
const pickString = (...values) => {
|
|
4
5
|
for (const value of values) {
|
|
5
6
|
if (typeof value === "string") {
|
|
@@ -21,6 +22,7 @@ const pickBoolean = (...values) => {
|
|
|
21
22
|
return void 0;
|
|
22
23
|
};
|
|
23
24
|
const getGlobalTrackingConfig = (globalVarName) => {
|
|
25
|
+
if (typeof window === "undefined") return {};
|
|
24
26
|
const currentWindow = window;
|
|
25
27
|
const fromCustom = currentWindow?.[globalVarName];
|
|
26
28
|
const fromJctrans = currentWindow?.__JCTRANS_GIO_CONFIG__;
|
|
@@ -189,7 +191,9 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
189
191
|
bindTrackHandler(element, binding, gio);
|
|
190
192
|
},
|
|
191
193
|
updated(element, binding) {
|
|
192
|
-
|
|
194
|
+
if (JSON.stringify(binding.value) !== JSON.stringify(binding.oldValue)) {
|
|
195
|
+
bindTrackHandler(element, binding, gio);
|
|
196
|
+
}
|
|
193
197
|
},
|
|
194
198
|
beforeUnmount(element) {
|
|
195
199
|
removeElementHandler(element);
|
|
@@ -197,13 +201,18 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
197
201
|
};
|
|
198
202
|
nuxtApp.vueApp.directive(directiveName, trackDirective);
|
|
199
203
|
if (initOptions.trackPage === false && initOptions.autoTrackPage) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
+
if (import.meta.client) {
|
|
205
|
+
router.afterEach((to) => {
|
|
206
|
+
setTimeout(async () => {
|
|
207
|
+
await nextTick();
|
|
208
|
+
gio.setPageAttributes({
|
|
209
|
+
route_name: String(to.name || ""),
|
|
210
|
+
route_path: to.path
|
|
211
|
+
});
|
|
212
|
+
gio.sendPage();
|
|
213
|
+
}, 50);
|
|
204
214
|
});
|
|
205
|
-
|
|
206
|
-
});
|
|
215
|
+
}
|
|
207
216
|
}
|
|
208
217
|
return {
|
|
209
218
|
provide: {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jctrans-materials/nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.37-beta.
|
|
4
|
+
"version": "1.0.37-beta.8",
|
|
5
5
|
"description": "Nuxt module for JCtrans UI components",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -22,13 +22,14 @@
|
|
|
22
22
|
"nuxt": "^3.0.0",
|
|
23
23
|
"vue": "^3.5.26",
|
|
24
24
|
"vue-router": "^4.6.4",
|
|
25
|
-
"@jctrans-materials/
|
|
26
|
-
"@jctrans-materials/
|
|
25
|
+
"@jctrans-materials/shared": "1.0.37-beta.8",
|
|
26
|
+
"@jctrans-materials/comps-vue3": "1.0.37-beta.8"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
+
"gio-webjs-sdk": "^4.0.0",
|
|
29
30
|
"nuxt": "^3.0.0",
|
|
30
|
-
"@jctrans-materials/
|
|
31
|
-
"@jctrans-materials/
|
|
31
|
+
"@jctrans-materials/shared": "1.0.37-beta.8",
|
|
32
|
+
"@jctrans-materials/comps-vue3": "1.0.37-beta.8"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@nuxt/module-builder": "latest",
|