@rxdrag/website-lib-core 0.0.97 → 0.0.99
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 +6 -6
- package/src/entify/Entify.ts +6 -1
- package/src/entify/IEntify.ts +3 -0
- package/src/entify/lib/newQueryPostOptions.ts +3 -1
- package/src/entify/lib/newQueryProductOptions.ts +3 -1
- package/src/entify/lib/queryBulletin.ts +17 -0
- package/src/entify/lib/queryPosts.ts +3 -1
- package/src/entify/lib/queryProducts.ts +2 -1
- package/src/react/components/Bulletin.tsx +30 -0
- package/src/react/components/ToTop/index.tsx +40 -27
- package/src/react/components/index.ts +1 -0
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.99",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.ts"
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"@types/react-dom": "^19.1.0",
|
|
25
25
|
"eslint": "^7.32.0",
|
|
26
26
|
"typescript": "^5",
|
|
27
|
-
"@rxdrag/
|
|
28
|
-
"@rxdrag/slate-preview": "1.2.
|
|
29
|
-
"@rxdrag/
|
|
27
|
+
"@rxdrag/eslint-config-custom": "0.2.12",
|
|
28
|
+
"@rxdrag/slate-preview": "1.2.63",
|
|
29
|
+
"@rxdrag/tsconfig": "0.2.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@iconify/utils": "^3.0.2",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"lodash-es": "^4.17.21",
|
|
37
37
|
"react": "^19.1.0",
|
|
38
38
|
"react-dom": "^19.1.0",
|
|
39
|
-
"@rxdrag/
|
|
40
|
-
"@rxdrag/
|
|
39
|
+
"@rxdrag/rxcms-models": "0.3.95",
|
|
40
|
+
"@rxdrag/entify-lib": "0.0.23"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"astro": "^4.0.0 || ^5.0.0"
|
package/src/entify/Entify.ts
CHANGED
|
@@ -43,12 +43,12 @@ import { queryPageByType } from "./lib/queryPageByType";
|
|
|
43
43
|
import { queryOneMedia } from "./lib/queryOneMedia";
|
|
44
44
|
import { DEFAULT_LARGE, DEFAULT_MEDIUM, DEFAULT_SAMLL, DEFUALT_HEIGHT, DEFUALT_WIDTH, FileFieldType, ImageResize } from "../astro/media";
|
|
45
45
|
import { queryOneIcon } from "./lib/queryOneIcon";
|
|
46
|
+
import { queryBulletin } from "./lib/queryBulletin";
|
|
46
47
|
|
|
47
48
|
export class Entify implements IEntify {
|
|
48
49
|
private static instance: Entify | null = null;
|
|
49
50
|
|
|
50
51
|
private constructor(protected envVariables: EnvVariables, protected imageSizes: ImageSizes) { }
|
|
51
|
-
|
|
52
52
|
private flattenTree<T>(nodes: T[] | undefined): T[] {
|
|
53
53
|
if (!nodes) return [];
|
|
54
54
|
let result: T[] = [];
|
|
@@ -137,6 +137,11 @@ export class Entify implements IEntify {
|
|
|
137
137
|
return await queryOneIcon(name, this.envVariables);
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
public async getBulletin() {
|
|
141
|
+
return await queryBulletin(this.envVariables);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
|
|
140
145
|
public async getFeaturedProducts(
|
|
141
146
|
count?: number,
|
|
142
147
|
imageSize?: ImageSize,
|
package/src/entify/IEntify.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
TUser,
|
|
9
9
|
} from "./view-model";
|
|
10
10
|
import {
|
|
11
|
+
Bulletin,
|
|
11
12
|
ImageSize,
|
|
12
13
|
ImageSizes,
|
|
13
14
|
Lang,
|
|
@@ -64,6 +65,8 @@ export interface IEntify {
|
|
|
64
65
|
|
|
65
66
|
getIcon(name: string | undefined | null): Promise<SvgIcon | undefined>;
|
|
66
67
|
|
|
68
|
+
getBulletin(): Promise<Bulletin | undefined | null>
|
|
69
|
+
|
|
67
70
|
getFeaturedProducts(
|
|
68
71
|
count?: number,
|
|
69
72
|
imageSize?: ImageSize,
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
MediaQueryOptions,
|
|
7
7
|
PostCategoryFields,
|
|
8
8
|
ImageSize,
|
|
9
|
+
TagFields,
|
|
9
10
|
} from "@rxdrag/rxcms-models";
|
|
10
11
|
|
|
11
12
|
import { newPageMetaOptions } from "./newPageMetaOptions";
|
|
@@ -39,5 +40,6 @@ export function newQueryOnePostOptions(coverSize?: ImageSize) {
|
|
|
39
40
|
PostCategoryFields.id,
|
|
40
41
|
PostCategoryFields.slug,
|
|
41
42
|
PostCategoryFields.name,
|
|
42
|
-
])
|
|
43
|
+
])
|
|
44
|
+
.tags([TagFields.id, TagFields.name, TagFields.color]);
|
|
43
45
|
}
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
ProductCategoryFields,
|
|
11
11
|
ProductRelatedPivotQueryOptions,
|
|
12
12
|
ImageSize,
|
|
13
|
+
TagFields,
|
|
13
14
|
} from "@rxdrag/rxcms-models";
|
|
14
15
|
import { newPageMetaOptions } from "./newPageMetaOptions";
|
|
15
16
|
|
|
@@ -92,5 +93,6 @@ export function newQueryProductOptions(imagSize?: ImageSize) {
|
|
|
92
93
|
ProductCategoryFields.id,
|
|
93
94
|
ProductCategoryFields.slug,
|
|
94
95
|
ProductCategoryFields.name,
|
|
95
|
-
])
|
|
96
|
+
])
|
|
97
|
+
.tags([TagFields.id, TagFields.name, TagFields.color]);
|
|
96
98
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BulletinBoolExp, BulletinDistinctExp, BulletinOrderBy, BulletinQueryOptions, BulletinFields, Bulletin } from "@rxdrag/rxcms-models";
|
|
2
|
+
import { EnvVariables } from "../types";
|
|
3
|
+
import { queryOneEntity } from "./queryOneEntity";
|
|
4
|
+
|
|
5
|
+
export const queryBulletin = async (
|
|
6
|
+
envVariables: EnvVariables) => {
|
|
7
|
+
|
|
8
|
+
const bulletin = await queryOneEntity<Bulletin, BulletinBoolExp, BulletinOrderBy, BulletinDistinctExp>(
|
|
9
|
+
new BulletinQueryOptions([
|
|
10
|
+
BulletinFields.id,
|
|
11
|
+
BulletinFields.title,
|
|
12
|
+
BulletinFields.content,
|
|
13
|
+
]),
|
|
14
|
+
envVariables
|
|
15
|
+
);
|
|
16
|
+
return bulletin;
|
|
17
|
+
};
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
PostCategoryOrderBy,
|
|
20
20
|
PostCategoryDistinctExp,
|
|
21
21
|
PostCategoryQueryOptions,
|
|
22
|
+
TagFields,
|
|
22
23
|
} from "@rxdrag/rxcms-models";
|
|
23
24
|
import { queryEntityList } from "./queryEntityList";
|
|
24
25
|
import { ListResult } from "@rxdrag/entify-lib";
|
|
@@ -137,7 +138,8 @@ export async function queryPosts(
|
|
|
137
138
|
[PostFields.updatedAt]: "desc",
|
|
138
139
|
},
|
|
139
140
|
],
|
|
140
|
-
}).category([PostCategoryFields.id, PostCategoryFields.name, PostCategoryFields.slug])
|
|
141
|
+
}).category([PostCategoryFields.id, PostCategoryFields.name, PostCategoryFields.slug])
|
|
142
|
+
.tags([TagFields.id, TagFields.name, TagFields.color]);
|
|
141
143
|
|
|
142
144
|
// 只有在需要查询封面图时才添加封面图查询
|
|
143
145
|
if (!selectFields || selectFields.includes("cover" as keyof Post)) {
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
ProductCategoryDistinctExp,
|
|
14
14
|
ProductCategoryFields,
|
|
15
15
|
ProductCategoryQueryOptions,
|
|
16
|
+
TagFields,
|
|
16
17
|
} from "@rxdrag/rxcms-models";
|
|
17
18
|
import { ListConditions } from "./queryPosts";
|
|
18
19
|
import { queryEntityList } from "./queryEntityList";
|
|
@@ -126,7 +127,7 @@ export async function queryProducts(
|
|
|
126
127
|
{ [ProductFields.seqValue]: "asc" },
|
|
127
128
|
{ [ProductFields.updatedAt]: "desc" },
|
|
128
129
|
],
|
|
129
|
-
});
|
|
130
|
+
}).tags([TagFields.id, TagFields.name, TagFields.color]);
|
|
130
131
|
|
|
131
132
|
// 只有在不指定字段或需要查询媒体时才添加媒体查询
|
|
132
133
|
if (!addonFields || !addonFields.includes("slug" as keyof Product)) {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Bulletin as BulletinModel } from "@rxdrag/rxcms-models";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
|
|
4
|
+
export function Bulletin(props: { className?: string }) {
|
|
5
|
+
const { className, ...rest } = props;
|
|
6
|
+
const [bulletin, setBulletin] = useState<BulletinModel | null>(null);
|
|
7
|
+
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
fetch("/api/get-bulletin")
|
|
10
|
+
.then((res) => res.json())
|
|
11
|
+
.then((res) => {
|
|
12
|
+
if (res.success) {
|
|
13
|
+
setBulletin(res.data);
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
.catch((err) => {
|
|
17
|
+
console.error("Failed to fetch bulletin", err);
|
|
18
|
+
});
|
|
19
|
+
}, []);
|
|
20
|
+
|
|
21
|
+
console.log("====>bulletin", bulletin)
|
|
22
|
+
|
|
23
|
+
if (!bulletin) return null;
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div className={className} {...rest}>
|
|
27
|
+
{bulletin.content}
|
|
28
|
+
</div>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -1,33 +1,46 @@
|
|
|
1
|
-
import clsx from "clsx"
|
|
2
|
-
import { forwardRef } from "react"
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
3
|
|
|
4
4
|
export type ToTopProps = {
|
|
5
|
-
className?: string
|
|
6
|
-
|
|
7
|
-
}
|
|
5
|
+
className?: string;
|
|
6
|
+
svg?: string;
|
|
7
|
+
};
|
|
8
8
|
|
|
9
|
-
export const ToTop = forwardRef<HTMLDivElement, ToTopProps>((
|
|
10
|
-
|
|
11
|
-
const { className, children, ...rest } = props
|
|
9
|
+
export const ToTop = forwardRef<HTMLDivElement, ToTopProps>((props, ref) => {
|
|
10
|
+
const { className, svg, ...rest } = props;
|
|
12
11
|
const handleClick = () => {
|
|
13
|
-
window.scrollTo({ top: 0, behavior: "smooth" })
|
|
14
|
-
}
|
|
12
|
+
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
13
|
+
};
|
|
15
14
|
|
|
16
|
-
return
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
clsx(
|
|
15
|
+
return (
|
|
16
|
+
<div
|
|
17
|
+
ref={ref}
|
|
18
|
+
className={clsx(
|
|
20
19
|
"fixed bottom-4 right-4 hidden user-select-none scrolled:flex cursor-pointer transition duration-300 ease-in-out z-50",
|
|
21
|
-
className
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
20
|
+
className
|
|
21
|
+
)}
|
|
22
|
+
{...rest}
|
|
23
|
+
onClick={handleClick}
|
|
24
|
+
>
|
|
25
|
+
{svg ? (
|
|
26
|
+
<div className="contents" dangerouslySetInnerHTML={{ __html: svg }} />
|
|
27
|
+
) : (
|
|
28
|
+
<svg
|
|
29
|
+
className="h-6 w-6"
|
|
30
|
+
width="1.5rem"
|
|
31
|
+
height="1.5rem"
|
|
32
|
+
fill="none"
|
|
33
|
+
viewBox="0 0 24 24"
|
|
34
|
+
stroke="currentColor"
|
|
35
|
+
>
|
|
36
|
+
<path
|
|
37
|
+
strokeLinecap="round"
|
|
38
|
+
strokeLinejoin="round"
|
|
39
|
+
strokeWidth={2}
|
|
40
|
+
d="M5 15l7-7 7 7"
|
|
41
|
+
/>
|
|
42
|
+
</svg>
|
|
43
|
+
)}
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
});
|
|
@@ -11,6 +11,7 @@ export * from "./SearchInput";
|
|
|
11
11
|
export * from "./ToTop";
|
|
12
12
|
export * from "./BackgroundVideoPlayer";
|
|
13
13
|
export * from "./BackgroundHlsVideoPlayer";
|
|
14
|
+
export * from "./Bulletin";
|
|
14
15
|
export * from "./ReactModalTrigger";
|
|
15
16
|
export * from "./ReactVideoPlayer";
|
|
16
17
|
|