@inzombieland/nuxt-common 1.18.15 → 1.18.17
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/api-client.mjs +4 -1
- package/dist/runtime/packages/core/composables/use-api-actions.d.ts +0 -3
- package/dist/runtime/packages/core/composables/use-api-actions.mjs +1 -1
- package/dist/runtime/packages/core/get-user.mjs +0 -1
- package/dist/runtime/packages/core/get-visitor.mjs +1 -1
- package/dist/runtime/packages/core/index.mjs +3 -6
- package/dist/runtime/packages/core/package.json +1 -1
- package/dist/runtime/packages/layer-manager/LayerComponent.vue +1 -0
- package/dist/runtime/packages/layer-manager/LayersProvider.vue +21 -6
- package/dist/runtime/packages/layer-manager/package.json +1 -1
- package/dist/runtime/packages/layer-manager/types.d.ts +6 -2
- package/package.json +1 -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.17";
|
|
6
6
|
|
|
7
7
|
const module = defineNuxtModule({
|
|
8
8
|
meta: {
|
|
@@ -109,6 +109,10 @@ const optionsHandler = (options = {}, config) => {
|
|
|
109
109
|
};
|
|
110
110
|
const fetchRequest = (url, options = {}, fetch, config) => {
|
|
111
111
|
const request = async () => {
|
|
112
|
+
const apiActions = useApiActions();
|
|
113
|
+
if (typeof window !== "undefined") {
|
|
114
|
+
await apiActions.value?.getVisitorIdentifier?.();
|
|
115
|
+
}
|
|
112
116
|
const opts = optionsHandler(options, config);
|
|
113
117
|
try {
|
|
114
118
|
const response = await fetch.raw(url, opts);
|
|
@@ -116,7 +120,6 @@ const fetchRequest = (url, options = {}, fetch, config) => {
|
|
|
116
120
|
} catch (error) {
|
|
117
121
|
const { status } = error?.response ?? { status: 500 };
|
|
118
122
|
if (status === 401 && url !== "/account/1/offline") {
|
|
119
|
-
const apiActions = useApiActions();
|
|
120
123
|
await apiActions.value?.refreshToken?.();
|
|
121
124
|
return request();
|
|
122
125
|
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
export declare const useApiActions: () => import("vue").Ref<{
|
|
2
|
-
initialized: boolean;
|
|
3
2
|
getVisitorIdentifier?: (() => Promise<void>) | undefined;
|
|
4
3
|
refreshToken?: (() => Promise<string>) | undefined;
|
|
5
4
|
}, {
|
|
6
|
-
initialized: boolean;
|
|
7
5
|
getVisitorIdentifier?: () => Promise<void>;
|
|
8
6
|
refreshToken?: () => Promise<string>;
|
|
9
7
|
} | {
|
|
10
|
-
initialized: boolean;
|
|
11
8
|
getVisitorIdentifier?: (() => Promise<void>) | undefined;
|
|
12
9
|
refreshToken?: (() => Promise<string>) | undefined;
|
|
13
10
|
}>;
|
|
@@ -22,11 +22,7 @@ export function initApiFetch($fetch, config) {
|
|
|
22
22
|
const initApplication = createInitApplication();
|
|
23
23
|
const refreshToken = createApiRefreshToken(fetch, config);
|
|
24
24
|
userActions = ref(createApiUserActions(fetch, config, getUser));
|
|
25
|
-
apiActions.value = {
|
|
26
|
-
initialized: true,
|
|
27
|
-
getVisitorIdentifier,
|
|
28
|
-
refreshToken
|
|
29
|
-
};
|
|
25
|
+
apiActions.value = { getVisitorIdentifier, refreshToken };
|
|
30
26
|
if (typeof window !== "undefined") {
|
|
31
27
|
const loggedIn = useLocalStorage("lin", "no");
|
|
32
28
|
const cometServerURL = config.cometServerURL;
|
|
@@ -45,7 +41,8 @@ export function initApiFetch($fetch, config) {
|
|
|
45
41
|
}
|
|
46
42
|
loggedIn.value = user ? "yes" : "no";
|
|
47
43
|
});
|
|
48
|
-
bus.subscribe("app:beforeMount", () => {
|
|
44
|
+
const subscription = bus.subscribe("app:beforeMount", () => {
|
|
45
|
+
subscription.unsubscribe();
|
|
49
46
|
console.log("Service started in mode", import.meta.env.MODE);
|
|
50
47
|
getVisitorIdentifier();
|
|
51
48
|
initApplication();
|
|
@@ -22,22 +22,31 @@ function getLayerHash(s: string): string {
|
|
|
22
22
|
return Math.abs(hash).toString()
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
const createLayer = (name: string): ActiveLayer => {
|
|
25
|
+
const createLayer = (name: string, params?: { [p: string]: any }): ActiveLayer => {
|
|
26
26
|
return {
|
|
27
27
|
name,
|
|
28
28
|
layerId: getLayerHash(name),
|
|
29
29
|
component: name.charAt(0).toUpperCase() + name.slice(1),
|
|
30
|
-
|
|
30
|
+
params: Object.assign({}, history.value.query, params),
|
|
31
|
+
searchParams: Object.assign({}, history.value.query, params),
|
|
31
32
|
closeLayer: typeof window !== "undefined" ? () => {} : undefined,
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
const resolveLayer = (
|
|
36
|
+
const resolveLayer = (
|
|
37
|
+
layerName: string,
|
|
38
|
+
options: { isCloseOtherLayers: boolean } = { isCloseOtherLayers: false },
|
|
39
|
+
params?: { [p: string]: any }
|
|
40
|
+
) => {
|
|
36
41
|
const activeLayer = activeLayers.value.find(({ name }) => name === layerName)
|
|
37
42
|
if (activeLayer) {
|
|
38
43
|
// слой с таким именем уже есть
|
|
39
44
|
const layer = activeLayers.value.splice(activeLayers.value.indexOf(activeLayer), 1)[0]
|
|
40
45
|
if (layer) {
|
|
46
|
+
if (params) {
|
|
47
|
+
layer.params = params
|
|
48
|
+
layer.searchParams = params
|
|
49
|
+
}
|
|
41
50
|
activeLayers.value.push(layer)
|
|
42
51
|
}
|
|
43
52
|
} else {
|
|
@@ -47,7 +56,7 @@ const resolveLayer = (layerName: string, options: { isCloseOtherLayers: boolean
|
|
|
47
56
|
if (activeLayers.value.length >= layersLimit) {
|
|
48
57
|
activeLayers.value.shift()
|
|
49
58
|
}
|
|
50
|
-
activeLayers.value.push(createLayer(layerName))
|
|
59
|
+
activeLayers.value.push(createLayer(layerName, params))
|
|
51
60
|
}
|
|
52
61
|
}
|
|
53
62
|
|
|
@@ -76,7 +85,7 @@ const closeLayer = (layerId: string) => {
|
|
|
76
85
|
activeLayers.value = activeLayers.value.filter(s => s.layerId !== layerId)
|
|
77
86
|
|
|
78
87
|
const layer = activeLayers.value.at(-1)
|
|
79
|
-
const queryLayer = layer ? { layer: layer.name, ...layer.searchParams } : {}
|
|
88
|
+
const queryLayer = layer ? { layer: layer.name, ...layer.params, ...layer.searchParams } : {}
|
|
80
89
|
const query = { ...(history.value.query?.layer ? queryLayer : {}) }
|
|
81
90
|
|
|
82
91
|
router.push({ path: history.value.path, query })
|
|
@@ -107,6 +116,7 @@ watch(reactiveHistory, (value, prevValue) => {
|
|
|
107
116
|
} else {
|
|
108
117
|
const activeLayer = activeLayers.value.find(({ name }) => name === value.query.layer)
|
|
109
118
|
if (activeLayer) {
|
|
119
|
+
activeLayer.params = value.query
|
|
110
120
|
activeLayer.searchParams = value.query
|
|
111
121
|
}
|
|
112
122
|
}
|
|
@@ -122,7 +132,12 @@ onMounted(() => {
|
|
|
122
132
|
layerActions.value = {
|
|
123
133
|
initialized: true,
|
|
124
134
|
open: (layerName: string, params?: { [p: string]: any }) => {
|
|
125
|
-
|
|
135
|
+
if (params?.mode === "router") {
|
|
136
|
+
const { mode, ...restParams } = params
|
|
137
|
+
router.push({ path: history.value.path, query: { layer: layerName, ...(restParams ?? {}) } })
|
|
138
|
+
} else {
|
|
139
|
+
resolveLayer(layerName, undefined, params)
|
|
140
|
+
}
|
|
126
141
|
},
|
|
127
142
|
getLayer: (layerName: string) => {
|
|
128
143
|
return activeLayers.value.find(({ name }) => name === layerName)
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import type { LocationQuery } from "vue-router";
|
|
2
1
|
export type ActiveLayer = {
|
|
3
2
|
readonly name: string;
|
|
4
3
|
readonly layerId: string;
|
|
5
4
|
readonly component: string;
|
|
6
|
-
|
|
5
|
+
params: {
|
|
6
|
+
[p: string]: any;
|
|
7
|
+
};
|
|
8
|
+
searchParams: {
|
|
9
|
+
[p: string]: any;
|
|
10
|
+
};
|
|
7
11
|
closeLayer: (() => void) | undefined;
|
|
8
12
|
};
|