@rxdrag/website-lib-core 0.0.19 → 0.0.21
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.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.ts"
|
|
@@ -24,10 +24,10 @@
|
|
|
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/entify-hooks": "0.2.43",
|
|
29
|
-
"@rxdrag/
|
|
30
|
-
"@rxdrag/
|
|
28
|
+
"@rxdrag/tsconfig": "0.2.0",
|
|
29
|
+
"@rxdrag/slate-preview": "1.2.57",
|
|
30
|
+
"@rxdrag/eslint-config-custom": "0.2.12"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"clsx": "^2.1.0",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"lodash-es": "^4.17.21",
|
|
36
36
|
"react": "^18.2.0",
|
|
37
37
|
"react-dom": "^18.2.0",
|
|
38
|
-
"@rxdrag/rxcms-models": "0.3.
|
|
38
|
+
"@rxdrag/rxcms-models": "0.3.50"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"astro": "^4.0.0 || ^5.0.0"
|
|
@@ -15,7 +15,7 @@ export const initLinks = () => {
|
|
|
15
15
|
anchorLink.dataset.activedPath === "true"
|
|
16
16
|
? linkUrl.pathname
|
|
17
17
|
: anchorLink.dataset.activedPath;
|
|
18
|
-
|
|
18
|
+
console.log("====>", linkPath, currentPath);
|
|
19
19
|
// 检查当前路径是否与链接路径匹配或是其子路径
|
|
20
20
|
if (
|
|
21
21
|
currentPath === linkPath ||
|
|
@@ -30,4 +30,4 @@ export const initLinks = () => {
|
|
|
30
30
|
console.warn("Invalid URL:", e, anchorLink);
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
|
-
};
|
|
33
|
+
};
|
|
@@ -5,6 +5,10 @@ import {
|
|
|
5
5
|
LangOrderBy,
|
|
6
6
|
LangQueryOptions,
|
|
7
7
|
LangAssciations,
|
|
8
|
+
ThemeQueryOptions,
|
|
9
|
+
ThemeFields,
|
|
10
|
+
ThemeConfigFields,
|
|
11
|
+
ThemeAssciations,
|
|
8
12
|
} from "@rxdrag/rxcms-models";
|
|
9
13
|
import { ListResult } from "@rxdrag/entify-hooks";
|
|
10
14
|
import { EnvVariables } from "../types";
|
|
@@ -28,7 +32,29 @@ export async function queryLangs(envVariables: EnvVariables) {
|
|
|
28
32
|
},
|
|
29
33
|
},
|
|
30
34
|
},
|
|
31
|
-
})
|
|
35
|
+
})
|
|
36
|
+
.themes(
|
|
37
|
+
new ThemeQueryOptions([ThemeFields.id, ThemeFields.name], {
|
|
38
|
+
where: {
|
|
39
|
+
[ThemeAssciations.website]: {
|
|
40
|
+
id: {
|
|
41
|
+
_eq: envVariables.websiteId,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
}).config([
|
|
46
|
+
ThemeConfigFields.id,
|
|
47
|
+
ThemeConfigFields.address,
|
|
48
|
+
ThemeConfigFields.contact,
|
|
49
|
+
ThemeConfigFields.email,
|
|
50
|
+
ThemeConfigFields.fax,
|
|
51
|
+
ThemeConfigFields.mobile,
|
|
52
|
+
ThemeConfigFields.tel,
|
|
53
|
+
ThemeConfigFields.wechat,
|
|
54
|
+
ThemeConfigFields.domain,
|
|
55
|
+
])
|
|
56
|
+
)
|
|
57
|
+
.setNoQuery(!envVariables.websiteId)
|
|
32
58
|
);
|
|
33
59
|
return result as ListResult<Lang> | undefined;
|
|
34
60
|
}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Product,
|
|
3
|
+
ProductBoolExp,
|
|
4
|
+
ProductOrderBy,
|
|
5
|
+
ProductDistinctExp,
|
|
6
|
+
ProductFields,
|
|
7
|
+
ProductQueryOptions,
|
|
8
|
+
PublishableStatus,
|
|
9
|
+
ProductAssciations,
|
|
10
|
+
} from "@rxdrag/rxcms-models";
|
|
2
11
|
import { ListConditions } from "./queryPosts";
|
|
3
12
|
import { queryEntityList } from "./queryEntityList";
|
|
4
13
|
import { newQueryProductsMediaOptions } from "./newQueryProductsMediaOptions";
|
|
@@ -7,22 +16,22 @@ import { EnvVariables, TSize } from "../types";
|
|
|
7
16
|
import { TProduct } from "../view-model";
|
|
8
17
|
|
|
9
18
|
export async function queryProducts(
|
|
10
|
-
conditions: ListConditions,
|
|
11
|
-
imageSize: TSize | undefined,
|
|
19
|
+
conditions: ListConditions,
|
|
20
|
+
imageSize: TSize | undefined,
|
|
12
21
|
envVariables: EnvVariables,
|
|
13
22
|
selectFields?: (keyof Product)[]
|
|
14
23
|
) {
|
|
15
24
|
const { category: categorySlug, page = 1, pageSize = 10 } = conditions;
|
|
16
25
|
|
|
17
|
-
let where = {}
|
|
26
|
+
let where = {};
|
|
18
27
|
if (categorySlug) {
|
|
19
28
|
where = {
|
|
20
29
|
[ProductAssciations.category]: {
|
|
21
30
|
slug: {
|
|
22
|
-
|
|
23
|
-
}
|
|
31
|
+
_eq: categorySlug,
|
|
32
|
+
},
|
|
24
33
|
},
|
|
25
|
-
}
|
|
34
|
+
};
|
|
26
35
|
}
|
|
27
36
|
|
|
28
37
|
// 默认查询字段
|
|
@@ -37,38 +46,35 @@ export async function queryProducts(
|
|
|
37
46
|
// 使用指定的字段或默认字段
|
|
38
47
|
const fields = selectFields || defaultFields;
|
|
39
48
|
|
|
40
|
-
const queryOptions = new ProductQueryOptions(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
abbr: {
|
|
51
|
-
_eq: envVariables.language,
|
|
52
|
-
},
|
|
49
|
+
const queryOptions = new ProductQueryOptions(fields, {
|
|
50
|
+
offset: (page - 1) * pageSize,
|
|
51
|
+
limit: pageSize,
|
|
52
|
+
where: {
|
|
53
|
+
[ProductFields.status]: {
|
|
54
|
+
_eq: PublishableStatus.published,
|
|
55
|
+
},
|
|
56
|
+
lang: {
|
|
57
|
+
abbr: {
|
|
58
|
+
_eq: envVariables.language,
|
|
53
59
|
},
|
|
54
|
-
...where,
|
|
55
60
|
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
...where,
|
|
62
|
+
},
|
|
63
|
+
orderBy: [
|
|
64
|
+
{ [ProductFields.seqValue]: "asc", [ProductFields.updatedAt]: "desc" },
|
|
65
|
+
],
|
|
66
|
+
});
|
|
61
67
|
|
|
62
68
|
// 只有在不指定字段或需要查询媒体时才添加媒体查询
|
|
63
|
-
if (!selectFields || !selectFields.includes(
|
|
64
|
-
queryOptions.mediaPivots(
|
|
65
|
-
newQueryProductsMediaOptions(imageSize)
|
|
66
|
-
);
|
|
69
|
+
if (!selectFields || !selectFields.includes("slug" as keyof Product)) {
|
|
70
|
+
queryOptions.mediaPivots(newQueryProductsMediaOptions(imageSize));
|
|
67
71
|
}
|
|
68
72
|
|
|
69
|
-
const result = await queryEntityList<
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
const result = await queryEntityList<
|
|
74
|
+
Product,
|
|
75
|
+
ProductBoolExp,
|
|
76
|
+
ProductOrderBy,
|
|
77
|
+
ProductDistinctExp
|
|
78
|
+
>(queryOptions, envVariables);
|
|
73
79
|
return result as ListResult<TProduct> | undefined;
|
|
74
80
|
}
|
|
@@ -254,7 +254,7 @@ export const ContactForm = forwardRef<HTMLDivElement, ContactFormProps>(
|
|
|
254
254
|
<Input
|
|
255
255
|
className="sm:col-span-1"
|
|
256
256
|
inputClassName="mt-2 block w-full rounded-md outline-none border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-sky-600 sm:text-sm sm:leading-6"
|
|
257
|
-
label={
|
|
257
|
+
label={labels?.name || "Your Name"}
|
|
258
258
|
labelClassName="block text-sm font-medium leading-6 text-gray-900"
|
|
259
259
|
name="name"
|
|
260
260
|
value={formData.name}
|
|
@@ -264,7 +264,7 @@ export const ContactForm = forwardRef<HTMLDivElement, ContactFormProps>(
|
|
|
264
264
|
<Input
|
|
265
265
|
className="col-span-full"
|
|
266
266
|
inputClassName="mt-2 block w-full rounded-md outline-none border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-sky-600 sm:text-sm sm:leading-6"
|
|
267
|
-
label={
|
|
267
|
+
label={labels?.company || "Company"}
|
|
268
268
|
labelClassName="block text-sm font-medium leading-6 text-gray-900"
|
|
269
269
|
name="company"
|
|
270
270
|
value={formData.company}
|
|
@@ -8,25 +8,10 @@ export const SearchInput = forwardRef<HTMLInputElement, SearchProps>(
|
|
|
8
8
|
const { children, ...rest } = props;
|
|
9
9
|
const [keyword, setKeyword] = useState<string>();
|
|
10
10
|
|
|
11
|
-
// const navigate = useNavigate();
|
|
12
|
-
// const [, setOpen] = useXModalState();
|
|
13
|
-
|
|
14
|
-
const handleKeyEnter = (event: React.KeyboardEvent<HTMLElement>) => {
|
|
15
|
-
if (event.key !== "Enter" || !keyword) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
// setOpen?.(false);
|
|
19
|
-
const encodedKeyword = encodeURIComponent(keyword || "");
|
|
20
|
-
if (encodedKeyword) {
|
|
21
|
-
//navigate(`/search?keyword=${encodedKeyword}`);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
11
|
return (
|
|
26
12
|
<input
|
|
27
13
|
ref={ref}
|
|
28
14
|
name="q"
|
|
29
|
-
onKeyDown={handleKeyEnter}
|
|
30
15
|
value={keyword}
|
|
31
16
|
onChange={(e) => setKeyword(e.target.value)}
|
|
32
17
|
{...rest}
|