@rxdrag/website-lib-core 0.0.127 → 0.0.128
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/README.md +1 -1
- package/index.ts +1 -1
- package/package.json +4 -4
- package/src/astro/animation.ts +146 -146
- package/src/astro/background.ts +82 -86
- package/src/astro/base.ts +7 -0
- package/src/astro/business.ts +13 -0
- package/src/astro/grid/consts.ts +80 -80
- package/src/astro/grid/index.ts +2 -2
- package/src/astro/grid/types.ts +35 -35
- package/src/astro/image.ts +239 -239
- package/src/astro/index.ts +12 -10
- package/src/astro/link.ts +20 -21
- package/src/astro/media.ts +123 -123
- package/src/astro/nav.ts +13 -13
- package/src/astro/section/index.ts +7 -12
- package/src/component-logic/index.ts +1 -1
- package/src/component-logic/link-client.ts +32 -32
- package/src/component-logic/link.ts +61 -61
- package/src/design-tokens.ts +160 -160
- package/src/entify/Entify.ts +533 -530
- package/src/entify/IEntify.ts +151 -177
- package/src/entify/index.ts +4 -4
- package/src/entify/lib/collectCategoryIds.ts +20 -20
- package/src/entify/lib/fulltextSearch.ts +63 -62
- package/src/entify/lib/langFields.ts +14 -14
- package/src/entify/lib/listToTree.ts +23 -23
- package/src/entify/lib/newAvatarQueryOptions.ts +4 -4
- package/src/entify/lib/newOgImageQueryOptions.ts +5 -5
- package/src/entify/lib/newQueryPostOptions.ts +42 -45
- package/src/entify/lib/newQueryProductOptions.ts +96 -98
- package/src/entify/lib/newQueryProductsMediaOptions.ts +28 -28
- package/src/entify/lib/queryAllProducts.ts +40 -40
- package/src/entify/lib/queryBulletin.ts +28 -16
- package/src/entify/lib/queryEntityList.ts +41 -41
- package/src/entify/lib/queryFeaturedProducts.ts +69 -68
- package/src/entify/lib/queryLangs.ts +36 -60
- package/src/entify/lib/queryLatestPosts.ts +92 -91
- package/src/entify/lib/queryOneEntity.ts +63 -63
- package/src/entify/lib/queryOneMedia.ts +27 -27
- package/src/entify/lib/queryOnePostById.ts +21 -21
- package/src/entify/lib/queryOnePostBySlug.ts +40 -39
- package/src/entify/lib/queryOnePostCategoryBySlug.ts +35 -35
- package/src/entify/lib/queryOneProductById.ts +20 -20
- package/src/entify/lib/queryOneProductBySlug.ts +53 -52
- package/src/entify/lib/queryOneProductCategoryBySlug.ts +50 -49
- package/src/entify/lib/queryOneTheme.ts +54 -72
- package/src/entify/lib/queryOneUser.ts +38 -38
- package/src/entify/lib/queryPostCategories.ts +67 -67
- package/src/entify/lib/queryPostSlugs.ts +37 -37
- package/src/entify/lib/queryPosts.ts +175 -174
- package/src/entify/lib/queryProductCategories.ts +59 -59
- package/src/entify/lib/queryProducts.ts +145 -144
- package/src/entify/lib/queryProductsInMenu.ts +45 -45
- package/src/entify/lib/queryTagCategories.ts +58 -58
- package/src/entify/lib/queryTags.ts +57 -57
- package/src/entify/lib/queryUserIds.ts +24 -24
- package/src/entify/lib/queryUserPosts.ts +80 -79
- package/src/entify/lib/queryWebSiteSettings.ts +28 -28
- package/src/entify/lib/queryWebsite.ts +43 -43
- package/src/entify/lib/sendEmail.ts +7 -7
- package/src/entify/lib/toQueryOptions.ts +19 -19
- package/src/entify/lib/upsertEntity.ts +8 -8
- package/src/entify/types/index.ts +1 -1
- package/src/entify/types/utils.ts +11 -6
- package/src/entify/types/variables.ts +5 -6
- package/src/entify/view-model/funcs.ts +230 -230
- package/src/entify/view-model/index.ts +1 -1
- package/src/entify/view-model/models.ts +135 -135
- package/src/global.d.ts +7 -7
- package/src/index.ts +8 -8
- package/src/lib/formatDate.ts +15 -15
- package/src/lib/index.ts +3 -3
- package/src/lib/pagination.ts +114 -114
- package/src/lib/utils.ts +135 -135
- package/src/react/components/Analytics/eventHandlers.ts +173 -173
- package/src/react/components/Analytics/index.tsx +21 -21
- package/src/react/components/Analytics/singleton.ts +214 -214
- package/src/react/components/Analytics/tracking.ts +221 -221
- package/src/react/components/Analytics/types.ts +60 -60
- package/src/react/components/Analytics/utils.ts +95 -95
- package/src/react/components/AttachmentIcon/index.tsx +53 -53
- package/src/react/components/BackgroundHlsVideoPlayer.tsx +97 -97
- package/src/react/components/BackgroundVideoPlayer.tsx +32 -32
- package/src/react/components/Bulletin.tsx +30 -30
- package/src/react/components/ContactForm/ContactForm.tsx +289 -289
- package/src/react/components/ContactForm/Input.tsx +48 -48
- package/src/react/components/ContactForm/Input2.tsx +59 -59
- package/src/react/components/ContactForm/Submit.tsx +48 -48
- package/src/react/components/ContactForm/TelInput.tsx +215 -215
- package/src/react/components/ContactForm/Textarea.tsx +48 -48
- package/src/react/components/ContactForm/Textarea2.tsx +89 -89
- package/src/react/components/ContactForm/funcs.ts +64 -64
- package/src/react/components/ContactForm/index.ts +7 -7
- package/src/react/components/ContactForm/types.ts +68 -68
- package/src/react/components/GoogleConsent/CookieItemPanel.tsx +80 -80
- package/src/react/components/GoogleConsent/CumtomizedModal.tsx +148 -148
- package/src/react/components/GoogleConsent/GoogleConsent.tsx +100 -100
- package/src/react/components/GoogleConsent/gtags.ts +67 -67
- package/src/react/components/GoogleConsent/index.ts +2 -2
- package/src/react/components/GoogleConsent/types.ts +18 -18
- package/src/react/components/GoogleConsent//345/217/202/350/200/203.md +4 -4
- package/src/react/components/Icon/index.tsx +19 -19
- package/src/react/components/Medias/MainMedia.tsx +257 -257
- package/src/react/components/Medias/Thumbnail.tsx +62 -62
- package/src/react/components/Medias/VideoPlayer.tsx +114 -114
- package/src/react/components/Medias/index.tsx +271 -271
- package/src/react/components/ProductCard/ProductCard.tsx +24 -24
- package/src/react/components/ProductCard/ProductCta/index.tsx +28 -28
- package/src/react/components/ProductCard/ProductCta/style.css +3 -3
- package/src/react/components/ProductCard/ProductDescription/index.tsx +12 -12
- package/src/react/components/ProductCard/ProductDescription/style.css +5 -5
- package/src/react/components/ProductCard/ProductMedia/index.tsx +35 -35
- package/src/react/components/ProductCard/ProductMedia/style.css +5 -5
- package/src/react/components/ProductCard/ProductTitle/index.tsx +7 -7
- package/src/react/components/ProductCard/ProductTitle/style.css +3 -3
- package/src/react/components/ProductCard/ProductView.tsx +36 -36
- package/src/react/components/ProductCard/index.ts +4 -4
- package/src/react/components/ProductCard/useQueryProduct.ts +32 -32
- package/src/react/components/ReactModalTrigger.tsx +28 -28
- package/src/react/components/ReactVideoPlayer.tsx +29 -52
- package/src/react/components/RichTextOutline/index.tsx +75 -75
- package/src/react/components/RichTextOutline/useAnchorScroll.ts +23 -23
- package/src/react/components/Scroller.tsx +39 -39
- package/src/react/components/SearchInput.tsx +21 -21
- package/src/react/components/Share/index.tsx +86 -86
- package/src/react/components/Share/socials.tsx +79 -77
- package/src/react/components/Share//350/265/204/346/226/231.md +7 -7
- package/src/react/components/ToTop.tsx +72 -72
- package/src/react/components/VideoPlayIcon.tsx +43 -0
- package/src/react/components/all.ts +38 -38
- package/src/react/components/index.ts +16 -16
- package/src/robots.ts +4 -4
- package/src/entify/lib/newPageMetaOptions.ts +0 -18
- package/src/entify/lib/newQueryPageOptions.ts +0 -14
- package/src/entify/lib/queryOneIcon.ts +0 -27
- package/src/entify/lib/queryPageBySlug.ts +0 -43
- package/src/entify/lib/queryPageByType.ts +0 -44
package/src/entify/IEntify.ts
CHANGED
|
@@ -1,177 +1,151 @@
|
|
|
1
|
-
import { IQueryOptions, ListResult } from "@rxdrag/entify-lib";
|
|
2
|
-
import { ListConditions, UploadOptions, UploadSession } from "./lib";
|
|
3
|
-
import {
|
|
4
|
-
TPost,
|
|
5
|
-
TPostCategory,
|
|
6
|
-
TProduct,
|
|
7
|
-
TProductCategory,
|
|
8
|
-
TTag,
|
|
9
|
-
TTagCategory,
|
|
10
|
-
TUser,
|
|
11
|
-
} from "./view-model";
|
|
12
|
-
import {
|
|
13
|
-
Bulletin,
|
|
14
|
-
ImageSize,
|
|
15
|
-
ImageSizes,
|
|
16
|
-
Lang,
|
|
17
|
-
Media,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
WhereExp
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
): Promise<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
): Promise<
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
getProductPaths(): Promise<unknown>;
|
|
153
|
-
|
|
154
|
-
getProductSlugs(): Promise<Array<string | undefined>>;
|
|
155
|
-
|
|
156
|
-
getProductIds(): Promise<Array<string | null | undefined>>;
|
|
157
|
-
|
|
158
|
-
getProductCategories(): Promise<TProductCategory[] | undefined>;
|
|
159
|
-
|
|
160
|
-
getProductCategoryBySlug(slug: string): Promise<TProductCategory | undefined>;
|
|
161
|
-
|
|
162
|
-
getOneUser(id: string): Promise<TUser | undefined>;
|
|
163
|
-
|
|
164
|
-
getUserPosts(userId: string): Promise<TPost[] | undefined>;
|
|
165
|
-
|
|
166
|
-
fulltextSearch(
|
|
167
|
-
keyword: string,
|
|
168
|
-
imageSize: ImageSize | undefined
|
|
169
|
-
): Promise<ListResult<SearchIndex> | undefined>;
|
|
170
|
-
|
|
171
|
-
getUserPaths(): Promise<unknown>;
|
|
172
|
-
|
|
173
|
-
createPagination(totalItems: number, pageSize: number): unknown;
|
|
174
|
-
|
|
175
|
-
createUploadCredentials(options: UploadOptions): Promise<UploadSession | null>;
|
|
176
|
-
|
|
177
|
-
}
|
|
1
|
+
import { IQueryOptions, ListResult } from "@rxdrag/entify-lib";
|
|
2
|
+
import { ListConditions, UploadOptions, UploadSession } from "./lib";
|
|
3
|
+
import {
|
|
4
|
+
TPost,
|
|
5
|
+
TPostCategory,
|
|
6
|
+
TProduct,
|
|
7
|
+
TProductCategory,
|
|
8
|
+
TTag,
|
|
9
|
+
TTagCategory,
|
|
10
|
+
TUser,
|
|
11
|
+
} from "./view-model";
|
|
12
|
+
import {
|
|
13
|
+
Bulletin,
|
|
14
|
+
ImageSize,
|
|
15
|
+
ImageSizes,
|
|
16
|
+
Lang,
|
|
17
|
+
Media,
|
|
18
|
+
Product,
|
|
19
|
+
SearchIndex,
|
|
20
|
+
ThemeBranch,
|
|
21
|
+
Website,
|
|
22
|
+
WebsitePart,
|
|
23
|
+
} from "@rxdrag/rxcms-models";
|
|
24
|
+
import { WebsitePartBoolExp } from "@rxdrag/rxcms-models/";
|
|
25
|
+
import { FileFieldType, ImageResize } from "../astro";
|
|
26
|
+
|
|
27
|
+
export type PostsOptions = {
|
|
28
|
+
category?: string;
|
|
29
|
+
coverSize?: ImageSize | undefined;
|
|
30
|
+
page: number;
|
|
31
|
+
pageSize: number;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type PostPatinateOptions = {
|
|
35
|
+
pageSize: number;
|
|
36
|
+
category?: string;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export interface IEntify {
|
|
40
|
+
//从配置文件注入到这里面,供组件使用
|
|
41
|
+
setImageSizes(imageSizes: ImageSizes): void;
|
|
42
|
+
getImageSizes(): ImageSizes;
|
|
43
|
+
queryEntityList<
|
|
44
|
+
T,
|
|
45
|
+
WhereExp = unknown,
|
|
46
|
+
OrderBy = unknown,
|
|
47
|
+
DistinctExp = unknown
|
|
48
|
+
>(
|
|
49
|
+
options: IQueryOptions<T, WhereExp, OrderBy, DistinctExp>,
|
|
50
|
+
//用于生成静态网站时使用,预览测试也可以用
|
|
51
|
+
staticKey?: string
|
|
52
|
+
): Promise<ListResult<unknown> | undefined>;
|
|
53
|
+
|
|
54
|
+
queryOneEntity<T extends WebsitePart = WebsitePart>(options: IQueryOptions<T, WebsitePartBoolExp>): Promise<T | undefined>;
|
|
55
|
+
|
|
56
|
+
getWebsite(): Promise<Website | undefined>;
|
|
57
|
+
|
|
58
|
+
getTheme(): Promise<ThemeBranch | undefined>;
|
|
59
|
+
|
|
60
|
+
getLangs(): Promise<Lang[] | undefined>;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 设置当前语言,必须在调用其他需要语言的方法之前设置
|
|
64
|
+
* @param langAbbr 语言缩写,如 "en-US" 或 "zh-CN"
|
|
65
|
+
*/
|
|
66
|
+
setLangAbbr(langAbbr: string): void;
|
|
67
|
+
|
|
68
|
+
getBaseLang(): Promise<Lang | undefined>;
|
|
69
|
+
|
|
70
|
+
getMedia(ref: string | undefined | null, fileField?: FileFieldType, resize?: ImageResize): Promise<Media | undefined>;
|
|
71
|
+
|
|
72
|
+
getBulletin(): Promise<Bulletin | undefined | null>
|
|
73
|
+
|
|
74
|
+
getFeaturedProducts(
|
|
75
|
+
count: number | undefined,
|
|
76
|
+
imageSize: ImageSize | undefined,
|
|
77
|
+
addonFields: (keyof Product)[] | undefined
|
|
78
|
+
): Promise<TProduct[] | undefined>;
|
|
79
|
+
|
|
80
|
+
getLatestPosts(
|
|
81
|
+
count: number | undefined,
|
|
82
|
+
coverSize: ImageSize | undefined
|
|
83
|
+
): Promise<TPost[] | undefined>;
|
|
84
|
+
|
|
85
|
+
getPosts(options: PostsOptions): Promise<TPost[] | undefined>;
|
|
86
|
+
|
|
87
|
+
getPostListPaths(options: PostPatinateOptions): Promise<unknown>;
|
|
88
|
+
|
|
89
|
+
getPostPaths(): Promise<unknown>;
|
|
90
|
+
|
|
91
|
+
getPostBySlug(
|
|
92
|
+
slug: string,
|
|
93
|
+
coverSize: ImageSize | undefined
|
|
94
|
+
): Promise<TPost | undefined>;
|
|
95
|
+
|
|
96
|
+
getPostSlugs(): Promise<Array<string | undefined>>;
|
|
97
|
+
|
|
98
|
+
getPostCategories(): Promise<TPostCategory[] | undefined>;
|
|
99
|
+
|
|
100
|
+
getPostCategoryBySlug(slug: string): Promise<TPostCategory | undefined>;
|
|
101
|
+
|
|
102
|
+
getTagCategories(): Promise<TTagCategory[] | undefined>;
|
|
103
|
+
|
|
104
|
+
getTags(categoryId: string | undefined): Promise<TTag[] | undefined>;
|
|
105
|
+
|
|
106
|
+
getProducts(
|
|
107
|
+
conditions: ListConditions,
|
|
108
|
+
imageSize: ImageSize | undefined,
|
|
109
|
+
addonFields: (keyof Product)[] | undefined
|
|
110
|
+
): Promise<TProduct[] | undefined>;
|
|
111
|
+
|
|
112
|
+
getProductListPaths(options: {
|
|
113
|
+
category?: string;
|
|
114
|
+
pageSize: number;
|
|
115
|
+
}): Promise<unknown>;
|
|
116
|
+
|
|
117
|
+
getCategoredProductListPaths(): Promise<unknown>;
|
|
118
|
+
|
|
119
|
+
getCategoredPostListPaths(): Promise<unknown>;
|
|
120
|
+
|
|
121
|
+
getProductBySlug(
|
|
122
|
+
slug: string,
|
|
123
|
+
imageSize: ImageSize | undefined
|
|
124
|
+
): Promise<TProduct | undefined>;
|
|
125
|
+
|
|
126
|
+
getProductPaths(): Promise<unknown>;
|
|
127
|
+
|
|
128
|
+
getProductSlugs(): Promise<Array<string | undefined>>;
|
|
129
|
+
|
|
130
|
+
getProductIds(): Promise<Array<string | null | undefined>>;
|
|
131
|
+
|
|
132
|
+
getProductCategories(): Promise<TProductCategory[] | undefined>;
|
|
133
|
+
|
|
134
|
+
getProductCategoryBySlug(slug: string): Promise<TProductCategory | undefined>;
|
|
135
|
+
|
|
136
|
+
getOneUser(id: string): Promise<TUser | undefined>;
|
|
137
|
+
|
|
138
|
+
getUserPosts(userId: string): Promise<TPost[] | undefined>;
|
|
139
|
+
|
|
140
|
+
fulltextSearch(
|
|
141
|
+
keyword: string,
|
|
142
|
+
imageSize: ImageSize | undefined
|
|
143
|
+
): Promise<ListResult<SearchIndex> | undefined>;
|
|
144
|
+
|
|
145
|
+
getUserPaths(): Promise<unknown>;
|
|
146
|
+
|
|
147
|
+
createPagination(totalItems: number, pageSize: number): unknown;
|
|
148
|
+
|
|
149
|
+
createUploadCredentials(options: UploadOptions): Promise<UploadSession | null>;
|
|
150
|
+
|
|
151
|
+
}
|
package/src/entify/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from "./lib";
|
|
2
|
-
export * from "./Entify";
|
|
3
|
-
export * from "./types";
|
|
4
|
-
export * from "./IEntify";
|
|
1
|
+
export * from "./lib";
|
|
2
|
+
export * from "./Entify";
|
|
3
|
+
export * from "./types";
|
|
4
|
+
export * from "./IEntify";
|
|
5
5
|
export * from "./view-model";
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export interface CategoryNode {
|
|
2
|
-
id?: string | null;
|
|
3
|
-
children?: CategoryNode[];
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export function collectCategoryIds(category: CategoryNode): string[] {
|
|
7
|
-
const ids: string[] = [];
|
|
8
|
-
if (category.id) ids.push(category.id);
|
|
9
|
-
|
|
10
|
-
const traverse = (node: CategoryNode) => {
|
|
11
|
-
if (node.children) {
|
|
12
|
-
node.children.forEach((child) => {
|
|
13
|
-
if (child.id) ids.push(child.id);
|
|
14
|
-
traverse(child);
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
traverse(category);
|
|
19
|
-
return ids;
|
|
20
|
-
}
|
|
1
|
+
export interface CategoryNode {
|
|
2
|
+
id?: string | null;
|
|
3
|
+
children?: CategoryNode[];
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export function collectCategoryIds(category: CategoryNode): string[] {
|
|
7
|
+
const ids: string[] = [];
|
|
8
|
+
if (category.id) ids.push(category.id);
|
|
9
|
+
|
|
10
|
+
const traverse = (node: CategoryNode) => {
|
|
11
|
+
if (node.children) {
|
|
12
|
+
node.children.forEach((child) => {
|
|
13
|
+
if (child.id) ids.push(child.id);
|
|
14
|
+
traverse(child);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
traverse(category);
|
|
19
|
+
return ids;
|
|
20
|
+
}
|
|
@@ -1,62 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PublishableStatus,
|
|
3
|
-
SearchIndex,
|
|
4
|
-
SearchIndexBoolExp,
|
|
5
|
-
SearchIndexOrderBy,
|
|
6
|
-
SearchIndexDistinctExp,
|
|
7
|
-
SearchIndexQueryOptions,
|
|
8
|
-
SearchIndexFields,
|
|
9
|
-
MediaQueryOptions,
|
|
10
|
-
ImageSize,
|
|
11
|
-
} from "@rxdrag/rxcms-models";
|
|
12
|
-
import { queryEntityList } from "./queryEntityList";
|
|
13
|
-
import { ListResult } from "@rxdrag/entify-lib";
|
|
14
|
-
import { EnvVariables } from "../types";
|
|
15
|
-
|
|
16
|
-
export async function fulltextSearch(
|
|
17
|
-
keyword: string,
|
|
18
|
-
imageSize: ImageSize | undefined,
|
|
19
|
-
envVariables: EnvVariables
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
SearchIndexFields.
|
|
26
|
-
SearchIndexFields.
|
|
27
|
-
SearchIndexFields.
|
|
28
|
-
SearchIndexFields.
|
|
29
|
-
SearchIndexFields.
|
|
30
|
-
SearchIndexFields.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
1
|
+
import {
|
|
2
|
+
PublishableStatus,
|
|
3
|
+
SearchIndex,
|
|
4
|
+
SearchIndexBoolExp,
|
|
5
|
+
SearchIndexOrderBy,
|
|
6
|
+
SearchIndexDistinctExp,
|
|
7
|
+
SearchIndexQueryOptions,
|
|
8
|
+
SearchIndexFields,
|
|
9
|
+
MediaQueryOptions,
|
|
10
|
+
ImageSize,
|
|
11
|
+
} from "@rxdrag/rxcms-models";
|
|
12
|
+
import { queryEntityList } from "./queryEntityList";
|
|
13
|
+
import { ListResult } from "@rxdrag/entify-lib";
|
|
14
|
+
import { EnvVariables } from "../types";
|
|
15
|
+
|
|
16
|
+
export async function fulltextSearch(
|
|
17
|
+
keyword: string,
|
|
18
|
+
imageSize: ImageSize | undefined,
|
|
19
|
+
envVariables: EnvVariables,
|
|
20
|
+
langAbbr: string
|
|
21
|
+
) {
|
|
22
|
+
|
|
23
|
+
const queryOptions = new SearchIndexQueryOptions(
|
|
24
|
+
[
|
|
25
|
+
SearchIndexFields.id,
|
|
26
|
+
SearchIndexFields.title,
|
|
27
|
+
SearchIndexFields.summary,
|
|
28
|
+
SearchIndexFields.sourceId,
|
|
29
|
+
SearchIndexFields.sourceType,
|
|
30
|
+
SearchIndexFields.sourceLang,
|
|
31
|
+
SearchIndexFields.sourceSlug,
|
|
32
|
+
],
|
|
33
|
+
{
|
|
34
|
+
limit: 100,
|
|
35
|
+
where: {
|
|
36
|
+
sourceLang: {
|
|
37
|
+
_eq: langAbbr,
|
|
38
|
+
},
|
|
39
|
+
[SearchIndexFields.sourceStatus]: {
|
|
40
|
+
_eq: PublishableStatus.published,
|
|
41
|
+
},
|
|
42
|
+
content: {
|
|
43
|
+
_match: keyword?.toLocaleLowerCase(),
|
|
44
|
+
},
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
).media(new MediaQueryOptions().file([
|
|
48
|
+
"thumbnail(width:400, height:320)",
|
|
49
|
+
"url",
|
|
50
|
+
imageSize
|
|
51
|
+
? `resize(width:${imageSize.width}, height:${imageSize.height})`
|
|
52
|
+
: "resize(width:500, height:400)",
|
|
53
|
+
])).setNoQuery(!keyword);
|
|
54
|
+
|
|
55
|
+
const result = await queryEntityList<
|
|
56
|
+
SearchIndex,
|
|
57
|
+
SearchIndexBoolExp,
|
|
58
|
+
SearchIndexOrderBy,
|
|
59
|
+
SearchIndexDistinctExp
|
|
60
|
+
>(queryOptions, envVariables);
|
|
61
|
+
|
|
62
|
+
return result as ListResult<SearchIndex> | undefined;
|
|
63
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { LangFields } from "@rxdrag/rxcms-models";
|
|
2
|
-
|
|
3
|
-
export const langFields = [
|
|
4
|
-
LangFields.id,
|
|
5
|
-
LangFields.abbr,
|
|
6
|
-
LangFields.circleIcon,
|
|
7
|
-
LangFields.cnName,
|
|
8
|
-
LangFields.enName,
|
|
9
|
-
LangFields.localName,
|
|
10
|
-
LangFields.icon,
|
|
11
|
-
LangFields.htmlLang,
|
|
12
|
-
//TODO 用枚举有时会出空值
|
|
13
|
-
"urlFragment" as LangFields.urlFragment,
|
|
14
|
-
];
|
|
1
|
+
import { LangFields } from "@rxdrag/rxcms-models";
|
|
2
|
+
|
|
3
|
+
export const langFields = [
|
|
4
|
+
LangFields.id,
|
|
5
|
+
LangFields.abbr,
|
|
6
|
+
LangFields.circleIcon,
|
|
7
|
+
LangFields.cnName,
|
|
8
|
+
LangFields.enName,
|
|
9
|
+
LangFields.localName,
|
|
10
|
+
LangFields.icon,
|
|
11
|
+
LangFields.htmlLang,
|
|
12
|
+
//TODO 用枚举有时会出空值
|
|
13
|
+
"urlFragment" as LangFields.urlFragment,
|
|
14
|
+
];
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
export function listToTree<
|
|
2
|
-
T extends { id?: string | null; parent?: { id?: string | null } | null }
|
|
3
|
-
>(items: T[]): (T & { children: T[] })[] {
|
|
4
|
-
const nodeMap = new Map<string, T & { children: T[] }>();
|
|
5
|
-
|
|
6
|
-
items.forEach((item) => {
|
|
7
|
-
if (item.id) {
|
|
8
|
-
nodeMap.set(item.id, { ...item, children: [] });
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
const tree: (T & { children: T[] })[] = [];
|
|
13
|
-
|
|
14
|
-
nodeMap.forEach((node) => {
|
|
15
|
-
if (node.parent?.id && nodeMap.has(node.parent.id)) {
|
|
16
|
-
nodeMap.get(node.parent.id)!.children.push(node);
|
|
17
|
-
} else {
|
|
18
|
-
tree.push(node);
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
return tree;
|
|
23
|
-
}
|
|
1
|
+
export function listToTree<
|
|
2
|
+
T extends { id?: string | null; parent?: { id?: string | null } | null }
|
|
3
|
+
>(items: T[]): (T & { children: T[] })[] {
|
|
4
|
+
const nodeMap = new Map<string, T & { children: T[] }>();
|
|
5
|
+
|
|
6
|
+
items.forEach((item) => {
|
|
7
|
+
if (item.id) {
|
|
8
|
+
nodeMap.set(item.id, { ...item, children: [] });
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const tree: (T & { children: T[] })[] = [];
|
|
13
|
+
|
|
14
|
+
nodeMap.forEach((node) => {
|
|
15
|
+
if (node.parent?.id && nodeMap.has(node.parent.id)) {
|
|
16
|
+
nodeMap.get(node.parent.id)!.children.push(node);
|
|
17
|
+
} else {
|
|
18
|
+
tree.push(node);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return tree;
|
|
23
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MediaQueryOptions } from "@rxdrag/rxcms-models";
|
|
2
|
-
|
|
3
|
-
export function newAvatarQueryOptions(){
|
|
4
|
-
return new MediaQueryOptions().file(["thumbnail", "url"])
|
|
1
|
+
import { MediaQueryOptions } from "@rxdrag/rxcms-models";
|
|
2
|
+
|
|
3
|
+
export function newAvatarQueryOptions(){
|
|
4
|
+
return new MediaQueryOptions().file(["thumbnail", "url"])
|
|
5
5
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MediaQueryOptions } from "@rxdrag/rxcms-models";
|
|
2
|
-
|
|
3
|
-
// ogImage查询参数,目的是为了共享resize参数
|
|
4
|
-
export function newOgImageQueryOptions(){
|
|
5
|
-
return new MediaQueryOptions().file(["resize(width:1200, height:630)", "url"])
|
|
1
|
+
import { MediaQueryOptions } from "@rxdrag/rxcms-models";
|
|
2
|
+
|
|
3
|
+
// ogImage查询参数,目的是为了共享resize参数
|
|
4
|
+
export function newOgImageQueryOptions(){
|
|
5
|
+
return new MediaQueryOptions().file(["resize(width:1200, height:630)", "url"])
|
|
6
6
|
}
|