@jctrans-materials/nuxt 1.0.39 → 1.0.40-beta.1
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/README.md +10 -0
- package/dist/module.json +1 -1
- package/dist/runtime/plugin.client.js +22 -2
- package/package.json +9 -10
package/README.md
CHANGED
|
@@ -8,6 +8,16 @@ Nuxt 3 模块,自动注册 `@jctrans-materials/comps-vue3` 组件,并内置
|
|
|
8
8
|
pnpm add @jctrans-materials/nuxt @jctrans-materials/comps-vue3 @jctrans-materials/shared gio-webjs-sdk
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
## 版本兼容要求
|
|
12
|
+
|
|
13
|
+
- 宿主项目需自行安装并锁定 Nuxt 与 Vue 版本。
|
|
14
|
+
- 推荐使用 `pnpm install --frozen-lockfile`,避免 CI 环境重解依赖导致构建漂移。
|
|
15
|
+
- 当前模块要求:
|
|
16
|
+
- `nuxt >=3.12.1 <4`
|
|
17
|
+
- `vue >=3.5.18 <4`
|
|
18
|
+
|
|
19
|
+
说明:`@jctrans-materials/nuxt` 不再在依赖中强行拉起独立 Nuxt/Vue 版本,避免在接入方项目中出现双份框架版本导致的构建失败。
|
|
20
|
+
|
|
11
21
|
## Nuxt 配置
|
|
12
22
|
|
|
13
23
|
```ts
|
package/dist/module.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineNuxtPlugin, useRuntimeConfig, useRouter } from "#app";
|
|
2
|
-
import { tracker } from "@jctrans-materials/shared";
|
|
1
|
+
import { callOnce, defineNuxtPlugin, useRuntimeConfig, useRouter } from "#app";
|
|
2
|
+
import { getOrCreateClientId, tracker } from "@jctrans-materials/shared";
|
|
3
3
|
import { nextTick } from "vue";
|
|
4
4
|
const pickString = (...values) => {
|
|
5
5
|
for (const value of values) {
|
|
@@ -110,6 +110,17 @@ const bindTrackHandler = (element, binding, gio) => {
|
|
|
110
110
|
handler
|
|
111
111
|
};
|
|
112
112
|
};
|
|
113
|
+
const identifyDeviceIfNeeded = async (forceLogin, key = "jctrans-gio-identify-device") => {
|
|
114
|
+
if (!import.meta.client || !forceLogin) return;
|
|
115
|
+
await callOnce(key, () => {
|
|
116
|
+
const deviceId = getOrCreateClientId();
|
|
117
|
+
if (!deviceId) return;
|
|
118
|
+
const gdp = window.gdp;
|
|
119
|
+
if (typeof gdp === "function") {
|
|
120
|
+
gdp("identify", deviceId);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
};
|
|
113
124
|
export default defineNuxtPlugin((nuxtApp) => {
|
|
114
125
|
const runtimeConfig = useRuntimeConfig();
|
|
115
126
|
const router = useRouter();
|
|
@@ -171,12 +182,21 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
171
182
|
runtimeTracking.autoInit,
|
|
172
183
|
globalTracking.autoInit
|
|
173
184
|
);
|
|
185
|
+
const forceLogin = pickBoolean(
|
|
186
|
+
globalTracking.initOptions?.forceLogin,
|
|
187
|
+
runtimeTracking.initOptions?.forceLogin,
|
|
188
|
+
initOptions.forceLogin
|
|
189
|
+
) ?? false;
|
|
174
190
|
if ((autoInit ?? true) && accountId && dataSourceId && !gio.isInitialized()) {
|
|
175
191
|
if (appId) {
|
|
176
192
|
gio.init(accountId, dataSourceId, appId, initOptions);
|
|
177
193
|
} else {
|
|
178
194
|
gio.init(accountId, dataSourceId, initOptions);
|
|
179
195
|
}
|
|
196
|
+
void identifyDeviceIfNeeded(
|
|
197
|
+
forceLogin,
|
|
198
|
+
`jctrans-gio-identify-device:${accountId}:${dataSourceId}`
|
|
199
|
+
);
|
|
180
200
|
}
|
|
181
201
|
const trackEvent = (eventName, attrs) => {
|
|
182
202
|
const normalizedEvent = pickString(eventName);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jctrans-materials/nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.40-beta.1",
|
|
5
5
|
"description": "Nuxt module for JCtrans UI components",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -17,22 +17,21 @@
|
|
|
17
17
|
"dist"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@nuxt/kit": "
|
|
20
|
+
"@nuxt/kit": "3.20.2",
|
|
21
21
|
"defu": "6.1.2",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"vue-router": "^4.6.4",
|
|
25
|
-
"@jctrans-materials/shared": "1.0.39",
|
|
26
|
-
"@jctrans-materials/comps-vue3": "1.0.39"
|
|
22
|
+
"@jctrans-materials/shared": "1.0.40-beta.1",
|
|
23
|
+
"@jctrans-materials/comps-vue3": "1.0.40-beta.1"
|
|
27
24
|
},
|
|
28
25
|
"peerDependencies": {
|
|
29
26
|
"gio-webjs-sdk": "^4.0.0",
|
|
30
|
-
"nuxt": "
|
|
31
|
-
"
|
|
32
|
-
"@jctrans-materials/comps-vue3": "1.0.
|
|
27
|
+
"nuxt": ">=3.12.1 <4",
|
|
28
|
+
"vue": ">=3.5.18 <4",
|
|
29
|
+
"@jctrans-materials/comps-vue3": "1.0.40-beta.1",
|
|
30
|
+
"@jctrans-materials/shared": "1.0.40-beta.1"
|
|
33
31
|
},
|
|
34
32
|
"devDependencies": {
|
|
35
33
|
"@nuxt/module-builder": "latest",
|
|
34
|
+
"nuxt": "3.20.2",
|
|
36
35
|
"unbuild": "^3.6.1"
|
|
37
36
|
},
|
|
38
37
|
"scripts": {
|