@mundogamernetwork/shared-ui 1.16.0 → 1.16.3
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/components/ui/MgHeaderUIUser.vue +55 -0
- package/nuxt.config.ts +24 -0
- package/package.json +1 -1
- package/services/userStatusService.ts +21 -0
- package/stores/auth.ts +27 -0
|
@@ -293,6 +293,61 @@ const handleToggleOnline = () => {
|
|
|
293
293
|
color: var(--sidebar-menus-fg);
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
+
// Ported here from jobs-frontend's global _layout.scss (the only host
|
|
297
|
+
// that already had it) — .switch/.slider had no definition of their
|
|
298
|
+
// own in this file at all, so hosts without that exact global class
|
|
299
|
+
// pair fell back to a bare unstyled native checkbox. Self-contained
|
|
300
|
+
// now, using the same accent token the rest of this file already
|
|
301
|
+
// falls through (see .plans-pricing-link above), so every front gets
|
|
302
|
+
// a real toggle instead of only the one host that happened to
|
|
303
|
+
// already define it globally.
|
|
304
|
+
.switch {
|
|
305
|
+
position: relative;
|
|
306
|
+
display: inline-block;
|
|
307
|
+
width: 36px;
|
|
308
|
+
height: 20px;
|
|
309
|
+
flex-shrink: 0;
|
|
310
|
+
|
|
311
|
+
input {
|
|
312
|
+
opacity: 0;
|
|
313
|
+
width: 0;
|
|
314
|
+
height: 0;
|
|
315
|
+
|
|
316
|
+
&:checked + .slider {
|
|
317
|
+
background-color: var(--highlight-color, var(--header-active-fg, var(--ck-highlight-marker-blue)));
|
|
318
|
+
|
|
319
|
+
&:before {
|
|
320
|
+
transform: translateX(16px);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
&:focus-visible + .slider {
|
|
325
|
+
box-shadow: 0 0 0 2px var(--ck-highlight-marker-blue);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.slider {
|
|
330
|
+
position: absolute;
|
|
331
|
+
inset: 0;
|
|
332
|
+
cursor: pointer;
|
|
333
|
+
background-color: var(--border-card, rgba(255, 255, 255, 0.2));
|
|
334
|
+
transition: 0.3s;
|
|
335
|
+
border-radius: 999px;
|
|
336
|
+
|
|
337
|
+
&:before {
|
|
338
|
+
position: absolute;
|
|
339
|
+
content: "";
|
|
340
|
+
height: 14px;
|
|
341
|
+
width: 14px;
|
|
342
|
+
left: 3px;
|
|
343
|
+
bottom: 3px;
|
|
344
|
+
background-color: #fff;
|
|
345
|
+
transition: 0.3s;
|
|
346
|
+
border-radius: 50%;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
296
351
|
.btn-primary-outline {
|
|
297
352
|
display: flex;
|
|
298
353
|
align-items: center;
|
package/nuxt.config.ts
CHANGED
|
@@ -72,6 +72,30 @@ export default defineNuxtConfig({
|
|
|
72
72
|
build: {
|
|
73
73
|
transpile: ['@vue-leaflet/vue-leaflet'],
|
|
74
74
|
},
|
|
75
|
+
// pusher-js's browser build is a webpack-bundled UMD file: `module.exports
|
|
76
|
+
// = factory()` where factory() internally does
|
|
77
|
+
// `__webpack_exports__["default"] = Pusher` and returns that object. To a
|
|
78
|
+
// real ES module consumer that looks exactly like "this CJS module wants
|
|
79
|
+
// default-export interop", but esbuild's static CJS/ESM detection doesn't
|
|
80
|
+
// reliably recognize that shape here — on some dep-graph paths (this repo
|
|
81
|
+
// doesn't import pusher-js directly, plugins/echo.client.ts here and in
|
|
82
|
+
// several consuming apps' own copies of the same plugin do) the raw dist
|
|
83
|
+
// file gets served to the browser as-is instead of through Vite's
|
|
84
|
+
// optimized/interop-wrapped dep cache, and `import Pusher from
|
|
85
|
+
// "pusher-js"` throws "does not provide an export named 'default'" at
|
|
86
|
+
// evaluation time — before the plugin's own pusherKey guard ever runs, so
|
|
87
|
+
// it takes the whole plugin down, and on hosts where that happens during
|
|
88
|
+
// app bootstrap it silently breaks ALL click handling on the page (every
|
|
89
|
+
// header dropdown, the sidebar toggle, everything — not just this
|
|
90
|
+
// plugin's own WebSocket setup). needsInterop forces Vite to always
|
|
91
|
+
// treat it as CJS needing the default-export wrapper, which is the fix
|
|
92
|
+
// Vite ships for exactly this class of mismatch.
|
|
93
|
+
vite: {
|
|
94
|
+
optimizeDeps: {
|
|
95
|
+
include: ["pusher-js", "laravel-echo"],
|
|
96
|
+
needsInterop: ["pusher-js"],
|
|
97
|
+
},
|
|
98
|
+
},
|
|
75
99
|
components: [
|
|
76
100
|
{
|
|
77
101
|
path: `${packageRoot}/components`,
|
package/package.json
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import httpService from "./httpService";
|
|
2
|
+
|
|
3
|
+
// httpService's baseURL always ends with /api/v1 (see httpService.ts's
|
|
4
|
+
// getHttpService()), so the path here must NOT repeat that prefix — unlike
|
|
5
|
+
// the per-site copies of this file, whose own httpService.ts instances
|
|
6
|
+
// don't normalize it away.
|
|
7
|
+
export const getUserStatus = async () => {
|
|
8
|
+
const params = {
|
|
9
|
+
platform_id: import.meta.env.VITE_SYSTEM_ID,
|
|
10
|
+
};
|
|
11
|
+
return await httpService.get(`/public/user-status`, { params });
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const userChangeStatus = async (status: boolean) => {
|
|
15
|
+
const params = {
|
|
16
|
+
platform_id: import.meta.env.VITE_SYSTEM_ID,
|
|
17
|
+
hidden_status: status,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return await httpService.post(`/public/user-status`, params);
|
|
21
|
+
};
|
package/stores/auth.ts
CHANGED
|
@@ -13,6 +13,8 @@ export const useAuthStore = defineStore({
|
|
|
13
13
|
signedIn: false,
|
|
14
14
|
initialized: false,
|
|
15
15
|
loading: false,
|
|
16
|
+
showOnline: false,
|
|
17
|
+
statusLoaded: false,
|
|
16
18
|
};
|
|
17
19
|
},
|
|
18
20
|
actions: {
|
|
@@ -65,6 +67,31 @@ export const useAuthStore = defineStore({
|
|
|
65
67
|
this.signedIn = false;
|
|
66
68
|
this.initialized = false;
|
|
67
69
|
this.loading = false;
|
|
70
|
+
this.showOnline = false;
|
|
71
|
+
this.statusLoaded = false;
|
|
72
|
+
},
|
|
73
|
+
// Used by shop-frontend, the one site with no local stores/auth.ts of its
|
|
74
|
+
// own (it re-exports this store directly — see its own file for why).
|
|
75
|
+
// Every other site has its own copy of this same pattern in its local
|
|
76
|
+
// store, wired to its own services/userStatusService.ts.
|
|
77
|
+
async fetchOnlineStatus() {
|
|
78
|
+
if (this.statusLoaded || !this.signedIn) return;
|
|
79
|
+
try {
|
|
80
|
+
const { getUserStatus } = await import("../services/userStatusService");
|
|
81
|
+
const response = await getUserStatus();
|
|
82
|
+
this.showOnline = !response.data.data[0].user_status[0].hidden_status;
|
|
83
|
+
this.statusLoaded = true;
|
|
84
|
+
} catch (e: any) {
|
|
85
|
+
if (e?.response?.status !== 401) {
|
|
86
|
+
this.showOnline = false;
|
|
87
|
+
this.statusLoaded = true;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
async toggleOnlineStatus() {
|
|
92
|
+
this.showOnline = !this.showOnline;
|
|
93
|
+
const { userChangeStatus } = await import("../services/userStatusService");
|
|
94
|
+
await userChangeStatus(!this.showOnline);
|
|
68
95
|
},
|
|
69
96
|
},
|
|
70
97
|
getters: {
|