@rxdrag/website-lib-core 0.0.47 → 0.0.49
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rxdrag/website-lib-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.49",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.ts"
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"@types/react-dom": "^18.2.7",
|
|
25
25
|
"eslint": "^7.32.0",
|
|
26
26
|
"typescript": "^5",
|
|
27
|
-
"@rxdrag/slate-preview": "1.2.57",
|
|
28
27
|
"@rxdrag/eslint-config-custom": "0.2.12",
|
|
29
|
-
"@rxdrag/tsconfig": "0.2.0"
|
|
28
|
+
"@rxdrag/tsconfig": "0.2.0",
|
|
29
|
+
"@rxdrag/slate-preview": "1.2.57"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"clsx": "^2.1.0",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"lodash-es": "^4.17.21",
|
|
35
35
|
"react": "^18.2.0",
|
|
36
36
|
"react-dom": "^18.2.0",
|
|
37
|
-
"@rxdrag/
|
|
38
|
-
"@rxdrag/
|
|
37
|
+
"@rxdrag/entify-lib": "0.0.8",
|
|
38
|
+
"@rxdrag/rxcms-models": "0.3.76"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"astro": "^4.0.0 || ^5.0.0"
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
AttachmentOnProductQueryOptions,
|
|
9
9
|
AttachmentOnProductFields,
|
|
10
10
|
ProductCategoryFields,
|
|
11
|
+
ProductRelatedPivotQueryOptions,
|
|
11
12
|
} from "@rxdrag/rxcms-models";
|
|
12
13
|
import { TSize } from "../types";
|
|
13
14
|
import { newPageMetaOptions } from "./newPageMetaOptions";
|
|
@@ -52,7 +53,6 @@ export function newQueryProductOptions(imagSize?: TSize) {
|
|
|
52
53
|
ProductFields.description,
|
|
53
54
|
ProductFields.features,
|
|
54
55
|
ProductFields.relatedSlugs,
|
|
55
|
-
ProductFields.relatedSlugs,
|
|
56
56
|
])
|
|
57
57
|
.meta(newPageMetaOptions())
|
|
58
58
|
.mediaPivots(creatProductMediaOptions(imagSize))
|
|
@@ -72,6 +72,20 @@ export function newQueryProductOptions(imagSize?: TSize) {
|
|
|
72
72
|
]).file(["url"])
|
|
73
73
|
)
|
|
74
74
|
)
|
|
75
|
+
.relatedPivots(
|
|
76
|
+
new ProductRelatedPivotQueryOptions([ProductFields.id]).product(
|
|
77
|
+
new ProductQueryOptions(
|
|
78
|
+
[ProductFields.id, ProductFields.slug, ProductFields.title],
|
|
79
|
+
{
|
|
80
|
+
orderBy: [
|
|
81
|
+
{
|
|
82
|
+
[ProductFields.id]: "asc",
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
}
|
|
86
|
+
).mediaPivots(creatProductMediaOptions(imagSize))
|
|
87
|
+
)
|
|
88
|
+
)
|
|
75
89
|
.category([
|
|
76
90
|
ProductCategoryFields.id,
|
|
77
91
|
ProductCategoryFields.slug,
|
|
@@ -8,7 +8,6 @@ import { newQueryProductOptions } from "./newQueryProductOptions";
|
|
|
8
8
|
import { queryOneEntity } from "./queryOneEntity";
|
|
9
9
|
import { EnvVariables, TSize } from "../types";
|
|
10
10
|
import { productToViewModel, TProduct } from "../view-model";
|
|
11
|
-
import { queryEntityList } from "./queryEntityList";
|
|
12
11
|
|
|
13
12
|
export async function queryOneProductBySlug(
|
|
14
13
|
slug: string,
|
|
@@ -42,37 +41,11 @@ export async function queryOneProductBySlug(
|
|
|
42
41
|
|
|
43
42
|
const tProduct = productToViewModel(product)!;
|
|
44
43
|
|
|
45
|
-
if (product?.
|
|
46
|
-
const result = await queryEntityList<
|
|
47
|
-
Product,
|
|
48
|
-
ProductBoolExp,
|
|
49
|
-
ProductOrderBy,
|
|
50
|
-
ProductDistinctExp
|
|
51
|
-
>(
|
|
52
|
-
newQueryProductOptions(imageSize).setQueryArgs({
|
|
53
|
-
where: {
|
|
54
|
-
slug: {
|
|
55
|
-
_in: product?.relatedSlugs,
|
|
56
|
-
},
|
|
57
|
-
lang: {
|
|
58
|
-
abbr: {
|
|
59
|
-
_eq: envVariables.language,
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
}),
|
|
64
|
-
envVariables
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
const relatedProducts = result?.items?.map((pro) =>
|
|
68
|
-
productToViewModel(pro)
|
|
69
|
-
) as TProduct[] | undefined;
|
|
70
|
-
|
|
44
|
+
if (product?.relatedPivots?.length) {
|
|
71
45
|
//重新排序后赋值
|
|
72
|
-
tProduct.related = product?.
|
|
73
|
-
|
|
46
|
+
tProduct.related = product?.relatedPivots.map((pv) =>
|
|
47
|
+
productToViewModel(pv.product)
|
|
74
48
|
) as TProduct[] | undefined;
|
|
75
49
|
}
|
|
76
|
-
|
|
77
50
|
return tProduct;
|
|
78
51
|
}
|