@inzombieland/nuxt-common 1.18.33 → 1.18.35
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.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/packages/core/composables/index.d.ts +1 -0
- package/dist/runtime/packages/core/composables/index.mjs +1 -0
- package/dist/runtime/packages/core/composables/use-dayjs.d.ts +2 -0
- package/dist/runtime/packages/core/composables/use-dayjs.mjs +4 -0
- package/dist/runtime/packages/core/get-visitor.mjs +7 -4
- package/dist/runtime/packages/core/init-application.mjs +39 -10
- package/dist/runtime/packages/core/package.json +2 -1
- package/package.json +3 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
2
2
|
import { defineNuxtModule, createResolver, addServerHandler, addImportsDir, addPlugin, addComponent } from '@nuxt/kit';
|
|
3
3
|
|
|
4
4
|
const name = "@inzombieland/nuxt-common";
|
|
5
|
-
const version = "1.18.
|
|
5
|
+
const version = "1.18.35";
|
|
6
6
|
|
|
7
7
|
const module = defineNuxtModule({
|
|
8
8
|
meta: {
|
|
@@ -3,6 +3,7 @@ export { useActiveSessions } from "./use-active-sessions";
|
|
|
3
3
|
export { useApiActions } from "./use-api-actions";
|
|
4
4
|
export { useAppLocale } from "./use-app-locale";
|
|
5
5
|
export { useCookies } from "./use-cookies";
|
|
6
|
+
export { useDayjs } from "./use-dayjs";
|
|
6
7
|
export { useSubscribe } from "./use-subscribe";
|
|
7
8
|
export { useThemeMode } from "./use-theme-mode";
|
|
8
9
|
export { useUser } from "./use-user";
|
|
@@ -3,6 +3,7 @@ export { useActiveSessions } from "./use-active-sessions.mjs";
|
|
|
3
3
|
export { useApiActions } from "./use-api-actions.mjs";
|
|
4
4
|
export { useAppLocale } from "./use-app-locale.mjs";
|
|
5
5
|
export { useCookies } from "./use-cookies.mjs";
|
|
6
|
+
export { useDayjs } from "./use-dayjs.mjs";
|
|
6
7
|
export { useSubscribe } from "./use-subscribe.mjs";
|
|
7
8
|
export { useThemeMode } from "./use-theme-mode.mjs";
|
|
8
9
|
export { useUser } from "./use-user.mjs";
|
|
@@ -15,10 +15,13 @@ const getVisitorRequest = async (config) => {
|
|
|
15
15
|
const result = await fp.get();
|
|
16
16
|
const { canvas, colorDepth, hdr, languages, screenFrame, screenResolution, ...components } = result.components;
|
|
17
17
|
const id = hashComponents(components);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
let ip;
|
|
19
|
+
try {
|
|
20
|
+
const data = await ofetch("https://api.ipify.org?format=json", { timeout: 3e3 });
|
|
21
|
+
ip = data?.ip ?? "unknown";
|
|
22
|
+
} catch {
|
|
23
|
+
ip = "unknown";
|
|
24
|
+
}
|
|
22
25
|
const device = await config.getDevice() || "unknown";
|
|
23
26
|
const appName = config.appName || "unknown";
|
|
24
27
|
setVisitor({ id, ip, device, appName });
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { StyleProvider, Themes, Locale as VarletLocale } from "@varlet/ui";
|
|
2
|
+
import dayjs from "dayjs";
|
|
3
|
+
import localizedFormat from "dayjs/plugin/localizedFormat";
|
|
4
|
+
import relativeTime from "dayjs/plugin/relativeTime";
|
|
2
5
|
import { setNotifyDefaultOptions, Locale as VantLocale } from "vant";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
6
|
+
import VantLocaleEnUS from "vant/es/locale/lang/en-US";
|
|
7
|
+
import VantLocaleRuRU from "vant/es/locale/lang/ru-RU";
|
|
5
8
|
import { watch } from "vue";
|
|
6
9
|
import { useI18n } from "vue-i18n";
|
|
7
10
|
import { useRouter } from "vue-router";
|
|
@@ -54,14 +57,7 @@ function initApplication() {
|
|
|
54
57
|
if ("setLocale" in i18n && typeof i18n.setLocale === "function") {
|
|
55
58
|
i18n.setLocale(locale2?.value);
|
|
56
59
|
}
|
|
57
|
-
|
|
58
|
-
VantLocale.use("en-US", enUS);
|
|
59
|
-
VarletLocale.add("en-US", VarletLocale.enUS);
|
|
60
|
-
}
|
|
61
|
-
if (locale2?.value === "ru") {
|
|
62
|
-
VantLocale.use("ru-RU", ruRU);
|
|
63
|
-
VarletLocale.add("en-US", VarletLocale.enUS);
|
|
64
|
-
}
|
|
60
|
+
loadThirdPartyLocales(locale2?.value);
|
|
65
61
|
const localeCookie = useCookies("locale", { maxAge: 60 * 60 * 24 * 365 });
|
|
66
62
|
localeCookie.value = locale2?.value;
|
|
67
63
|
},
|
|
@@ -95,6 +91,39 @@ function initApplication() {
|
|
|
95
91
|
}
|
|
96
92
|
});
|
|
97
93
|
}
|
|
94
|
+
function loadThirdPartyLocales(locale) {
|
|
95
|
+
loadVantLocale(locale);
|
|
96
|
+
loadVarletLocale(locale);
|
|
97
|
+
loadDayjsLocale(locale);
|
|
98
|
+
}
|
|
99
|
+
function loadVantLocale(locale) {
|
|
100
|
+
if (locale === "en") {
|
|
101
|
+
VantLocale.use("en-US", VantLocaleEnUS);
|
|
102
|
+
}
|
|
103
|
+
if (locale === "ru") {
|
|
104
|
+
VantLocale.use("ru-RU", VantLocaleRuRU);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function loadVarletLocale(locale) {
|
|
108
|
+
if (locale === "en") {
|
|
109
|
+
VarletLocale.add("en-US", VarletLocale.enUS);
|
|
110
|
+
}
|
|
111
|
+
if (locale === "ru") {
|
|
112
|
+
VarletLocale.add("en-US", VarletLocale.enUS);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
async function loadDayjsLocale(lang) {
|
|
116
|
+
let locale;
|
|
117
|
+
if (lang === "en") {
|
|
118
|
+
locale = await import("dayjs/locale/en");
|
|
119
|
+
}
|
|
120
|
+
if (lang === "ru") {
|
|
121
|
+
locale = await import("dayjs/locale/ru");
|
|
122
|
+
}
|
|
123
|
+
dayjs.locale(locale);
|
|
124
|
+
dayjs.extend(localizedFormat);
|
|
125
|
+
dayjs.extend(relativeTime);
|
|
126
|
+
}
|
|
98
127
|
export const createInitApplication = once(() => {
|
|
99
128
|
return () => initApplication();
|
|
100
129
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inzombieland/core",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.35",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"main": "./index.mjs",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"@vueuse/core": "^12.8.2",
|
|
16
16
|
"centrifuge": "^5.3.4",
|
|
17
17
|
"cookie-es": "^2.0.0",
|
|
18
|
+
"dayjs": "^1.11.13",
|
|
18
19
|
"destr": "^2.0.5",
|
|
19
20
|
"klona": "^2.0.6",
|
|
20
21
|
"ofetch": "^1.4.1",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inzombieland/nuxt-common",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.35",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"centrifuge": "^5.3.4",
|
|
40
|
+
"dayjs": "^1.11.13",
|
|
40
41
|
"rxjs": "^7.8.2",
|
|
41
42
|
"ultrahtml": "^1.5.2"
|
|
42
43
|
},
|
|
@@ -44,6 +45,7 @@
|
|
|
44
45
|
"@braintree/sanitize-url": "^7.1.1",
|
|
45
46
|
"@fingerprintjs/fingerprintjs": "^4.6.2",
|
|
46
47
|
"@nuxt/devtools": "latest",
|
|
48
|
+
"@nuxt/icon": "^1.13.0",
|
|
47
49
|
"@nuxt/kit": "^3.17.0",
|
|
48
50
|
"@nuxt/module-builder": "^0.6.0",
|
|
49
51
|
"@nuxt/schema": "^3.17.0",
|