@mundogamernetwork/shared-ui 1.1.35 → 1.1.37
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/assets/kit/kit-base.css +661 -0
- package/assets/kit/kit-theme.css +57 -8
- package/components/ui/MgAppInstallBanner.vue +1 -14
- package/components/ui/MgCampaignBannerCarousel.vue +6 -23
- package/nuxt.config.ts +6 -1
- package/package.json +1 -1
- package/pages/presskit/[slug].vue +214 -1389
- package/plugins/auth.client.ts +1 -1
- package/plugins/echo.client.ts +5 -0
- package/services/campaignBannersService.ts +2 -7
- package/services/httpService.ts +12 -11
- package/stores/appInstallBanner.ts +7 -23
package/plugins/auth.client.ts
CHANGED
package/plugins/echo.client.ts
CHANGED
|
@@ -77,9 +77,11 @@ export default defineNuxtPlugin({
|
|
|
77
77
|
});
|
|
78
78
|
|
|
79
79
|
window.Echo.connector.pusher.connection.bind("connected", () => {
|
|
80
|
+
console.log("[WebSocket] Connected", new Date().toISOString());
|
|
80
81
|
});
|
|
81
82
|
|
|
82
83
|
window.Echo.connector.pusher.connection.bind("disconnected", () => {
|
|
84
|
+
console.log("[WebSocket] Disconnected", new Date().toISOString());
|
|
83
85
|
});
|
|
84
86
|
|
|
85
87
|
window.Echo.connector.pusher.connection.bind("error", (error: any) => {
|
|
@@ -92,11 +94,13 @@ export default defineNuxtPlugin({
|
|
|
92
94
|
|
|
93
95
|
window.Echo.connector.pusher.connection.bind("state_change", (states: any) => {
|
|
94
96
|
const { previous, current } = states;
|
|
97
|
+
console.log(`[WebSocket] State changed: ${previous} -> ${current}`);
|
|
95
98
|
|
|
96
99
|
if (current === "disconnected" || current === "failed" || current === "unavailable") {
|
|
97
100
|
// Stop reconnecting after max attempts to avoid infinite loop
|
|
98
101
|
// (e.g. when user is not authenticated)
|
|
99
102
|
if (reconnectAttempts >= MAX_RECONNECT_ATTEMPTS) {
|
|
103
|
+
console.log("[WebSocket] Max reconnect attempts reached, stopping.");
|
|
100
104
|
if (reconnectTimer) {
|
|
101
105
|
clearTimeout(reconnectTimer);
|
|
102
106
|
reconnectTimer = null;
|
|
@@ -106,6 +110,7 @@ export default defineNuxtPlugin({
|
|
|
106
110
|
|
|
107
111
|
reconnectAttempts++;
|
|
108
112
|
const delay = Math.min(1000 * Math.pow(2, reconnectAttempts - 1), 30000);
|
|
113
|
+
console.log(`[WebSocket] Reconnecting in ${delay / 1000}s (attempt ${reconnectAttempts}/${MAX_RECONNECT_ATTEMPTS})...`);
|
|
109
114
|
|
|
110
115
|
if (reconnectTimer) clearTimeout(reconnectTimer);
|
|
111
116
|
reconnectTimer = window.setTimeout(() => {
|
|
@@ -34,11 +34,6 @@ export const fetchCampaignBanners = (
|
|
|
34
34
|
.then((r) => r.data?.data ?? [])
|
|
35
35
|
.catch((): CampaignBanner[] => []);
|
|
36
36
|
|
|
37
|
-
export const clickCampaignBanner = (id: number
|
|
38
|
-
axios
|
|
39
|
-
.put(`${getNetworkBaseUrl()}/public/campaigns-banners/${id}/click`, null, {
|
|
40
|
-
params: { ...(platform ? { platform } : {}), ...(page ? { page } : {}) },
|
|
41
|
-
withCredentials: false,
|
|
42
|
-
})
|
|
43
|
-
.catch(() => {});
|
|
37
|
+
export const clickCampaignBanner = (id: number): void => {
|
|
38
|
+
axios.put(`${getNetworkBaseUrl()}/public/campaigns-banners/${id}/click`).catch(() => {});
|
|
44
39
|
};
|
package/services/httpService.ts
CHANGED
|
@@ -40,11 +40,12 @@ export function getHttpService(): AxiosInstance {
|
|
|
40
40
|
_httpService.interceptors.response.use(
|
|
41
41
|
(response) => response,
|
|
42
42
|
(error) => {
|
|
43
|
+
const url: string = error.config?.url ?? "";
|
|
44
|
+
// The auth/user (or /users/me) probe is the canonical session check.
|
|
45
|
+
const isAuthProbe = /\/auth\/user(\?|$)|\/users\/me(\?|$)/.test(url);
|
|
46
|
+
|
|
43
47
|
if (typeof window !== "undefined" && error?.response) {
|
|
44
48
|
const status = error.response.status;
|
|
45
|
-
const url: string = error.config?.url ?? "";
|
|
46
|
-
// The auth/user (or /users/me) probe is the canonical session check.
|
|
47
|
-
const isAuthProbe = /\/auth\/user(\?|$)|\/users\/me(\?|$)/.test(url);
|
|
48
49
|
|
|
49
50
|
// 401 on the auth probe = the session is genuinely gone (expired/invalid
|
|
50
51
|
// token). Clear the stale credentials so the loop breaks and the user
|
|
@@ -66,6 +67,14 @@ export function getHttpService(): AxiosInstance {
|
|
|
66
67
|
console.error(`[HTTP] Error ${status}:`, error.response?.data?.message || "");
|
|
67
68
|
}
|
|
68
69
|
}
|
|
70
|
+
|
|
71
|
+
// A stale auth cookie can make the API fatal before CORS headers are
|
|
72
|
+
// rendered. Axios reports that as ERR_NETWORK, so clear auth only when
|
|
73
|
+
// the failed request was the canonical auth probe.
|
|
74
|
+
if (typeof window !== "undefined" && !error?.response && isAuthProbe) {
|
|
75
|
+
recoverFromSessionLoss();
|
|
76
|
+
}
|
|
77
|
+
|
|
69
78
|
return Promise.reject(error);
|
|
70
79
|
},
|
|
71
80
|
);
|
|
@@ -85,14 +94,6 @@ export function getHttpService(): AxiosInstance {
|
|
|
85
94
|
config.headers.set("X-Timezone", Intl.DateTimeFormat().resolvedOptions().timeZone);
|
|
86
95
|
}
|
|
87
96
|
|
|
88
|
-
// Live Analytics: send current page route and platform ID so the
|
|
89
|
-
// GeoAnalyticsMiddleware on each service-api can record session activity.
|
|
90
|
-
if (typeof window !== "undefined") {
|
|
91
|
-
config.headers.set("X-Page-Route", window.location.pathname);
|
|
92
|
-
const systemId = import.meta.env.VITE_SYSTEM_ID;
|
|
93
|
-
if (systemId) config.headers.set("X-System-Id", String(systemId));
|
|
94
|
-
}
|
|
95
|
-
|
|
96
97
|
return config;
|
|
97
98
|
});
|
|
98
99
|
|
|
@@ -72,28 +72,16 @@ export const useAppInstallBannerStore = defineStore("app-install-banner-store",
|
|
|
72
72
|
}),
|
|
73
73
|
|
|
74
74
|
actions: {
|
|
75
|
-
async fetchBanner(
|
|
75
|
+
async fetchBanner() {
|
|
76
76
|
if (this.loaded) return;
|
|
77
77
|
|
|
78
78
|
const runtimeConfig = useRuntimeConfig();
|
|
79
|
-
const cfg = runtimeConfig.public;
|
|
80
|
-
// Priority: explicit props from layout > shared-ui namespace > flat runtimeConfig keys > build-time env vars
|
|
81
79
|
const networkBaseUrl =
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
(import.meta.env.VITE_BASE_URL_NETWORK as string) ||
|
|
88
|
-
(import.meta.env.VITE_API_BASE_URL as string);
|
|
89
|
-
const platformId =
|
|
90
|
-
overridePlatformId ||
|
|
91
|
-
Number(
|
|
92
|
-
cfg.mgSharedUi?.systemId ||
|
|
93
|
-
cfg.platformId ||
|
|
94
|
-
cfg.systemId ||
|
|
95
|
-
import.meta.env.VITE_SYSTEM_ID,
|
|
96
|
-
);
|
|
80
|
+
runtimeConfig.public.mgSharedUi?.networkBaseUrl ||
|
|
81
|
+
import.meta.env.VITE_BASE_URL_NETWORK;
|
|
82
|
+
const platformId = Number(
|
|
83
|
+
runtimeConfig.public.mgSharedUi?.systemId || import.meta.env.VITE_SYSTEM_ID,
|
|
84
|
+
);
|
|
97
85
|
|
|
98
86
|
if (!networkBaseUrl || !platformId) {
|
|
99
87
|
this.loaded = true;
|
|
@@ -131,12 +119,8 @@ export const useAppInstallBannerStore = defineStore("app-install-banner-store",
|
|
|
131
119
|
|
|
132
120
|
dismiss() {
|
|
133
121
|
const runtimeConfig = useRuntimeConfig();
|
|
134
|
-
const cfg = runtimeConfig.public;
|
|
135
122
|
const platformId = Number(
|
|
136
|
-
|
|
137
|
-
cfg.platformId ||
|
|
138
|
-
cfg.systemId ||
|
|
139
|
-
import.meta.env.VITE_SYSTEM_ID,
|
|
123
|
+
runtimeConfig.public.mgSharedUi?.systemId || import.meta.env.VITE_SYSTEM_ID,
|
|
140
124
|
);
|
|
141
125
|
if (platformId) writeDismiss(platformId);
|
|
142
126
|
this.dismissed = true;
|