@inzombieland/nuxt-common 1.18.16 → 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/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: {
|
|
@@ -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
|
};
|