@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.
Files changed (138) hide show
  1. package/README.md +1 -1
  2. package/index.ts +1 -1
  3. package/package.json +4 -4
  4. package/src/astro/animation.ts +146 -146
  5. package/src/astro/background.ts +82 -86
  6. package/src/astro/base.ts +7 -0
  7. package/src/astro/business.ts +13 -0
  8. package/src/astro/grid/consts.ts +80 -80
  9. package/src/astro/grid/index.ts +2 -2
  10. package/src/astro/grid/types.ts +35 -35
  11. package/src/astro/image.ts +239 -239
  12. package/src/astro/index.ts +12 -10
  13. package/src/astro/link.ts +20 -21
  14. package/src/astro/media.ts +123 -123
  15. package/src/astro/nav.ts +13 -13
  16. package/src/astro/section/index.ts +7 -12
  17. package/src/component-logic/index.ts +1 -1
  18. package/src/component-logic/link-client.ts +32 -32
  19. package/src/component-logic/link.ts +61 -61
  20. package/src/design-tokens.ts +160 -160
  21. package/src/entify/Entify.ts +533 -530
  22. package/src/entify/IEntify.ts +151 -177
  23. package/src/entify/index.ts +4 -4
  24. package/src/entify/lib/collectCategoryIds.ts +20 -20
  25. package/src/entify/lib/fulltextSearch.ts +63 -62
  26. package/src/entify/lib/langFields.ts +14 -14
  27. package/src/entify/lib/listToTree.ts +23 -23
  28. package/src/entify/lib/newAvatarQueryOptions.ts +4 -4
  29. package/src/entify/lib/newOgImageQueryOptions.ts +5 -5
  30. package/src/entify/lib/newQueryPostOptions.ts +42 -45
  31. package/src/entify/lib/newQueryProductOptions.ts +96 -98
  32. package/src/entify/lib/newQueryProductsMediaOptions.ts +28 -28
  33. package/src/entify/lib/queryAllProducts.ts +40 -40
  34. package/src/entify/lib/queryBulletin.ts +28 -16
  35. package/src/entify/lib/queryEntityList.ts +41 -41
  36. package/src/entify/lib/queryFeaturedProducts.ts +69 -68
  37. package/src/entify/lib/queryLangs.ts +36 -60
  38. package/src/entify/lib/queryLatestPosts.ts +92 -91
  39. package/src/entify/lib/queryOneEntity.ts +63 -63
  40. package/src/entify/lib/queryOneMedia.ts +27 -27
  41. package/src/entify/lib/queryOnePostById.ts +21 -21
  42. package/src/entify/lib/queryOnePostBySlug.ts +40 -39
  43. package/src/entify/lib/queryOnePostCategoryBySlug.ts +35 -35
  44. package/src/entify/lib/queryOneProductById.ts +20 -20
  45. package/src/entify/lib/queryOneProductBySlug.ts +53 -52
  46. package/src/entify/lib/queryOneProductCategoryBySlug.ts +50 -49
  47. package/src/entify/lib/queryOneTheme.ts +54 -72
  48. package/src/entify/lib/queryOneUser.ts +38 -38
  49. package/src/entify/lib/queryPostCategories.ts +67 -67
  50. package/src/entify/lib/queryPostSlugs.ts +37 -37
  51. package/src/entify/lib/queryPosts.ts +175 -174
  52. package/src/entify/lib/queryProductCategories.ts +59 -59
  53. package/src/entify/lib/queryProducts.ts +145 -144
  54. package/src/entify/lib/queryProductsInMenu.ts +45 -45
  55. package/src/entify/lib/queryTagCategories.ts +58 -58
  56. package/src/entify/lib/queryTags.ts +57 -57
  57. package/src/entify/lib/queryUserIds.ts +24 -24
  58. package/src/entify/lib/queryUserPosts.ts +80 -79
  59. package/src/entify/lib/queryWebSiteSettings.ts +28 -28
  60. package/src/entify/lib/queryWebsite.ts +43 -43
  61. package/src/entify/lib/sendEmail.ts +7 -7
  62. package/src/entify/lib/toQueryOptions.ts +19 -19
  63. package/src/entify/lib/upsertEntity.ts +8 -8
  64. package/src/entify/types/index.ts +1 -1
  65. package/src/entify/types/utils.ts +11 -6
  66. package/src/entify/types/variables.ts +5 -6
  67. package/src/entify/view-model/funcs.ts +230 -230
  68. package/src/entify/view-model/index.ts +1 -1
  69. package/src/entify/view-model/models.ts +135 -135
  70. package/src/global.d.ts +7 -7
  71. package/src/index.ts +8 -8
  72. package/src/lib/formatDate.ts +15 -15
  73. package/src/lib/index.ts +3 -3
  74. package/src/lib/pagination.ts +114 -114
  75. package/src/lib/utils.ts +135 -135
  76. package/src/react/components/Analytics/eventHandlers.ts +173 -173
  77. package/src/react/components/Analytics/index.tsx +21 -21
  78. package/src/react/components/Analytics/singleton.ts +214 -214
  79. package/src/react/components/Analytics/tracking.ts +221 -221
  80. package/src/react/components/Analytics/types.ts +60 -60
  81. package/src/react/components/Analytics/utils.ts +95 -95
  82. package/src/react/components/AttachmentIcon/index.tsx +53 -53
  83. package/src/react/components/BackgroundHlsVideoPlayer.tsx +97 -97
  84. package/src/react/components/BackgroundVideoPlayer.tsx +32 -32
  85. package/src/react/components/Bulletin.tsx +30 -30
  86. package/src/react/components/ContactForm/ContactForm.tsx +289 -289
  87. package/src/react/components/ContactForm/Input.tsx +48 -48
  88. package/src/react/components/ContactForm/Input2.tsx +59 -59
  89. package/src/react/components/ContactForm/Submit.tsx +48 -48
  90. package/src/react/components/ContactForm/TelInput.tsx +215 -215
  91. package/src/react/components/ContactForm/Textarea.tsx +48 -48
  92. package/src/react/components/ContactForm/Textarea2.tsx +89 -89
  93. package/src/react/components/ContactForm/funcs.ts +64 -64
  94. package/src/react/components/ContactForm/index.ts +7 -7
  95. package/src/react/components/ContactForm/types.ts +68 -68
  96. package/src/react/components/GoogleConsent/CookieItemPanel.tsx +80 -80
  97. package/src/react/components/GoogleConsent/CumtomizedModal.tsx +148 -148
  98. package/src/react/components/GoogleConsent/GoogleConsent.tsx +100 -100
  99. package/src/react/components/GoogleConsent/gtags.ts +67 -67
  100. package/src/react/components/GoogleConsent/index.ts +2 -2
  101. package/src/react/components/GoogleConsent/types.ts +18 -18
  102. package/src/react/components/GoogleConsent//345/217/202/350/200/203.md +4 -4
  103. package/src/react/components/Icon/index.tsx +19 -19
  104. package/src/react/components/Medias/MainMedia.tsx +257 -257
  105. package/src/react/components/Medias/Thumbnail.tsx +62 -62
  106. package/src/react/components/Medias/VideoPlayer.tsx +114 -114
  107. package/src/react/components/Medias/index.tsx +271 -271
  108. package/src/react/components/ProductCard/ProductCard.tsx +24 -24
  109. package/src/react/components/ProductCard/ProductCta/index.tsx +28 -28
  110. package/src/react/components/ProductCard/ProductCta/style.css +3 -3
  111. package/src/react/components/ProductCard/ProductDescription/index.tsx +12 -12
  112. package/src/react/components/ProductCard/ProductDescription/style.css +5 -5
  113. package/src/react/components/ProductCard/ProductMedia/index.tsx +35 -35
  114. package/src/react/components/ProductCard/ProductMedia/style.css +5 -5
  115. package/src/react/components/ProductCard/ProductTitle/index.tsx +7 -7
  116. package/src/react/components/ProductCard/ProductTitle/style.css +3 -3
  117. package/src/react/components/ProductCard/ProductView.tsx +36 -36
  118. package/src/react/components/ProductCard/index.ts +4 -4
  119. package/src/react/components/ProductCard/useQueryProduct.ts +32 -32
  120. package/src/react/components/ReactModalTrigger.tsx +28 -28
  121. package/src/react/components/ReactVideoPlayer.tsx +29 -52
  122. package/src/react/components/RichTextOutline/index.tsx +75 -75
  123. package/src/react/components/RichTextOutline/useAnchorScroll.ts +23 -23
  124. package/src/react/components/Scroller.tsx +39 -39
  125. package/src/react/components/SearchInput.tsx +21 -21
  126. package/src/react/components/Share/index.tsx +86 -86
  127. package/src/react/components/Share/socials.tsx +79 -77
  128. package/src/react/components/Share//350/265/204/346/226/231.md +7 -7
  129. package/src/react/components/ToTop.tsx +72 -72
  130. package/src/react/components/VideoPlayIcon.tsx +43 -0
  131. package/src/react/components/all.ts +38 -38
  132. package/src/react/components/index.ts +16 -16
  133. package/src/robots.ts +4 -4
  134. package/src/entify/lib/newPageMetaOptions.ts +0 -18
  135. package/src/entify/lib/newQueryPageOptions.ts +0 -14
  136. package/src/entify/lib/queryOneIcon.ts +0 -27
  137. package/src/entify/lib/queryPageBySlug.ts +0 -43
  138. package/src/entify/lib/queryPageByType.ts +0 -44
@@ -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
- Page,
19
- PageType,
20
- Product,
21
- SearchIndex,
22
- SvgIcon,
23
- ThemeBranch,
24
- Website,
25
- WebsitePart,
26
- } from "@rxdrag/rxcms-models";
27
- import { WebsitePartBoolExp } from "@rxdrag/rxcms-models/";
28
- import { FileFieldType, ImageResize } from "../astro";
29
-
30
- export type PostsOptions = {
31
- category?: string;
32
- coverSize?: ImageSize | undefined;
33
- page: number;
34
- pageSize: number;
35
- };
36
-
37
- export type PostPatinateOptions = {
38
- pageSize: number;
39
- category?: string;
40
- };
41
-
42
- export interface IEntify {
43
- //从配置文件注入到这里面,供组件使用
44
- setImageSizes(imageSizes: ImageSizes): void;
45
- getImageSizes(): ImageSizes;
46
- getLang(): string;
47
- queryEntityList<
48
- T,
49
- WhereExp = unknown,
50
- OrderBy = unknown,
51
- DistinctExp = unknown
52
- >(
53
- options: IQueryOptions<T, WhereExp, OrderBy, DistinctExp>,
54
- //用于生成静态网站时使用,预览测试也可以用
55
- staticKey?: string
56
- ): Promise<ListResult<unknown> | undefined>;
57
-
58
- queryOneEntity<T extends WebsitePart = WebsitePart>(options: IQueryOptions<T, WebsitePartBoolExp>): Promise<T | undefined>;
59
-
60
- getWebsite(): Promise<Website | undefined>;
61
-
62
- getTheme(): Promise<ThemeBranch | undefined>;
63
-
64
- getLangs(): Promise<Lang[] | undefined>;
65
-
66
- getMedia(ref: string | undefined | null, fileField?: FileFieldType, resize?: ImageResize): Promise<Media | undefined>;
67
-
68
- getIcon(name: string | undefined | null): Promise<SvgIcon | undefined>;
69
-
70
- getBulletin(): Promise<Bulletin | undefined | null>
71
-
72
- getFeaturedProducts(
73
- count?: number,
74
- imageSize?: ImageSize,
75
- addonFields?: (keyof Product)[]
76
- ): Promise<TProduct[] | undefined>;
77
-
78
- getLatestPosts(
79
- count?: number,
80
- coverSize?: ImageSize
81
- ): Promise<TPost[] | undefined>;
82
-
83
- getPosts(options: PostsOptions): Promise<TPost[] | undefined>;
84
-
85
- getHomePage(): Promise<Page | undefined>;
86
-
87
- getPostPage(): Promise<Page | undefined>;
88
-
89
- getPostListPage(): Promise<Page | undefined>;
90
-
91
- getPostCategoryPage(): Promise<Page | undefined>;
92
-
93
- getProductPage(): Promise<Page | undefined>;
94
-
95
- getProductListPage(): Promise<Page | undefined>;
96
-
97
- getProductCategoryPage(): Promise<Page | undefined>;
98
-
99
- getSearchPage(): Promise<Page | undefined>;
100
-
101
- getProfilePage(): Promise<Page | undefined>;
102
-
103
- getThanksPage(): Promise<Page | undefined>;
104
-
105
- get404Page(): Promise<Page | undefined>;
106
-
107
- getErrorPage(): Promise<Page | undefined>;
108
-
109
- getPageBySlug(slug: string): Promise<Page | undefined>;
110
-
111
- getPageByType(pageType: PageType): Promise<Page | undefined>;
112
-
113
- getPostListPaths(options: PostPatinateOptions): Promise<unknown>;
114
-
115
- getPostPaths(): Promise<unknown>;
116
-
117
- getPostBySlug(
118
- slug: string,
119
- coverSize: ImageSize | undefined
120
- ): Promise<TPost | undefined>;
121
-
122
- getPostSlugs(): Promise<Array<string | undefined>>;
123
-
124
- getPostCategories(): Promise<TPostCategory[] | undefined>;
125
-
126
- getPostCategoryBySlug(slug: string): Promise<TPostCategory | undefined>;
127
-
128
- getTagCategories(): Promise<TTagCategory[] | undefined>;
129
-
130
- getTags(categoryId?: string): Promise<TTag[] | undefined>;
131
-
132
- getProducts(
133
- conditions: ListConditions,
134
- imageSize: ImageSize | undefined,
135
- addonFields?: (keyof Product)[]
136
- ): Promise<TProduct[] | undefined>;
137
-
138
- getProductListPaths(options: {
139
- category?: string;
140
- pageSize: number;
141
- }): Promise<unknown>;
142
-
143
- getCategoredProductListPaths(): Promise<unknown>;
144
-
145
- getCategoredPostListPaths(): Promise<unknown>;
146
-
147
- getProductBySlug(
148
- slug: string,
149
- imageSize: ImageSize | undefined
150
- ): Promise<TProduct | undefined>;
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
+ }
@@ -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
- const queryOptions = new SearchIndexQueryOptions(
23
- [
24
- SearchIndexFields.id,
25
- SearchIndexFields.title,
26
- SearchIndexFields.summary,
27
- SearchIndexFields.sourceId,
28
- SearchIndexFields.sourceType,
29
- SearchIndexFields.sourceLang,
30
- SearchIndexFields.sourceSlug,
31
- ],
32
- {
33
- limit: 100,
34
- where: {
35
- sourceLang: {
36
- _eq: envVariables.language,
37
- },
38
- [SearchIndexFields.sourceStatus]: {
39
- _eq: PublishableStatus.published,
40
- },
41
- content: {
42
- _match: keyword?.toLocaleLowerCase(),
43
- },
44
- }
45
- }
46
- ).media(new MediaQueryOptions().file([
47
- "thumbnail(width:400, height:320)",
48
- "url",
49
- imageSize
50
- ? `resize(width:${imageSize.width}, height:${imageSize.height})`
51
- : "resize(width:500, height:400)",
52
- ])).setNoQuery(!keyword);
53
-
54
- const result = await queryEntityList<
55
- SearchIndex,
56
- SearchIndexBoolExp,
57
- SearchIndexOrderBy,
58
- SearchIndexDistinctExp
59
- >(queryOptions, envVariables);
60
-
61
- return result as ListResult<SearchIndex> | undefined;
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
  }