@rxdrag/website-lib-core 0.0.127 → 0.0.129

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 +111 -101
  22. package/src/entify/IEntify.ts +157 -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 +0 -1
  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
@@ -33,18 +33,12 @@ import { queryWebsite } from "./lib/queryWebsite";
33
33
  import {
34
34
  ImageSize,
35
35
  ImageSizes,
36
- Media,
37
- Page,
38
- PageType,
39
36
  Product,
40
37
  WebsitePart,
41
38
  WebsitePartBoolExp,
42
39
  } from "@rxdrag/rxcms-models";
43
- import { queryPageBySlug } from "./lib/queryPageBySlug";
44
- import { queryPageByType } from "./lib/queryPageByType";
45
40
  import { queryOneMedia } from "./lib/queryOneMedia";
46
- import { DEFAULT_LARGE, DEFAULT_MEDIUM, DEFAULT_SAMLL, DEFUALT_HEIGHT, DEFUALT_WIDTH, FileFieldType, ImageResize } from "../astro/media";
47
- import { queryOneIcon } from "./lib/queryOneIcon";
41
+ import { FileFieldType, ImageResize } from "../astro/media";
48
42
  import { queryBulletin } from "./lib/queryBulletin";
49
43
 
50
44
  export class Entify implements IEntify {
@@ -64,13 +58,63 @@ export class Entify implements IEntify {
64
58
  return result;
65
59
  }
66
60
 
67
- public static getInstance(envVariables: EnvVariables, imageSizes: ImageSizes): Entify {
61
+ /**
62
+ * 获取 Entify 单例实例(无参数,获取已创建的实例)
63
+ */
64
+ public static getInstance(): Entify;
65
+ /**
66
+ * 获取 Entify 单例实例(带参数,创建或更新实例)
67
+ */
68
+ public static getInstance(envVariables: EnvVariables, imageSizes: ImageSizes): Entify;
69
+ public static getInstance(envVariables?: EnvVariables, imageSizes?: ImageSizes): Entify {
70
+ // 无参数调用:获取已创建的实例
71
+ if (envVariables === undefined && imageSizes === undefined) {
72
+ if (!Entify.instance) {
73
+ throw new Error(
74
+ 'Entify instance not initialized. Please call getInstance(envVariables, imageSizes) first.'
75
+ );
76
+ }
77
+ return Entify.instance;
78
+ }
79
+
80
+ // 有参数调用:创建或更新实例
68
81
  if (!Entify.instance) {
69
- Entify.instance = new Entify(envVariables, imageSizes);
82
+ Entify.instance = new Entify(envVariables!, imageSizes!);
83
+ } else {
84
+ Entify.instance.envVariables = envVariables!;
85
+ Entify.instance.imageSizes = imageSizes!;
70
86
  }
71
87
  return Entify.instance;
72
88
  }
73
89
 
90
+ private currentLangAbbr?: string;
91
+
92
+ /**
93
+ * 设置当前语言
94
+ */
95
+ public setLangAbbr(langAbbr: string): void {
96
+ this.currentLangAbbr = langAbbr;
97
+ }
98
+
99
+ /**
100
+ * 获取当前设置的语言缩写
101
+ */
102
+ public getLang(): string {
103
+ return this.ensureLangAbbr();
104
+ }
105
+
106
+ /**
107
+ * 获取当前语言,如果未设置则抛出异常
108
+ */
109
+ private ensureLangAbbr(): string {
110
+ if (!this.currentLangAbbr) {
111
+ throw new Error(
112
+ 'langAbbr is not set. Please call setLangAbbr() before using language-dependent methods.'
113
+ );
114
+ }
115
+ return this.currentLangAbbr;
116
+ }
117
+
74
118
  public setImageSizes(imageSizes: ImageSizes): void {
75
119
  this.imageSizes = imageSizes;
76
120
  }
@@ -100,10 +144,6 @@ export class Entify implements IEntify {
100
144
  );
101
145
  }
102
146
 
103
- public getLang() {
104
- return this.envVariables.language || "en-US";
105
- }
106
-
107
147
  public async getWebsite() {
108
148
  return queryWebsite(this.envVariables);
109
149
  }
@@ -116,39 +156,28 @@ export class Entify implements IEntify {
116
156
  return (await queryLangs(this.envVariables))?.items;
117
157
  }
118
158
 
119
- public async getMedia(ref: string | undefined | null, fileField?: FileFieldType, resize?: ImageResize): Promise<Media | undefined> {
120
- const fields: string[] = []
121
- switch (fileField) {
122
- case "resize":
123
- fields.push(`resize(width: ${resize?.width || DEFUALT_WIDTH}, height: ${resize?.height || DEFUALT_HEIGHT})`)
124
- break;
125
- case "small":
126
- fields.push(`small(width: ${this.imageSizes.small?.width || DEFAULT_SAMLL.width}, height: ${this.imageSizes.small?.height || DEFAULT_SAMLL.height})`)
127
- break;
128
- case "medium":
129
- fields.push(`medium(width: ${this.imageSizes.medium?.width || DEFAULT_MEDIUM.width}, height: ${this.imageSizes.medium?.height || DEFAULT_MEDIUM.height})`)
130
- break;
131
- case "large":
132
- fields.push(`large(width: ${this.imageSizes.large?.width || DEFAULT_LARGE.width}, height: ${this.imageSizes.large?.height || DEFAULT_LARGE.height})`)
133
- break;
134
- }
135
- return await queryOneMedia(ref, fields, this.envVariables);
159
+ public async getBaseLang() {
160
+ const website = await this.getWebsite();
161
+ return website?.baseLang;
136
162
  }
137
163
 
138
- public async getIcon(name: string | undefined | null) {
139
- return await queryOneIcon(name, this.envVariables);
164
+ public async getMedia(ref: string | undefined | null, fileField: FileFieldType = 'thumbnail', resize?: ImageResize) {
165
+ const fields = [fileField];
166
+ return await queryOneMedia(ref, fields, this.envVariables);
140
167
  }
141
168
 
142
169
  public async getBulletin() {
143
- return await queryBulletin(this.envVariables);
170
+ const langAbbr = this.ensureLangAbbr();
171
+ return await queryBulletin(this.envVariables, langAbbr);
144
172
  }
145
173
 
146
174
 
147
175
  public async getFeaturedProducts(
148
- count?: number,
149
- imageSize?: ImageSize,
150
- addonFields?: (keyof Product)[]
176
+ count: number | undefined,
177
+ imageSize: ImageSize | undefined,
178
+ addonFields: (keyof Product)[] | undefined
151
179
  ) {
180
+ const langAbbr = this.ensureLangAbbr();
152
181
  if (!imageSize) {
153
182
  imageSize = this.imageSizes?.productThumbnial;
154
183
  }
@@ -156,76 +185,38 @@ export class Entify implements IEntify {
156
185
  count,
157
186
  imageSize,
158
187
  this.envVariables,
159
- addonFields
188
+ addonFields,
189
+ langAbbr
160
190
  );
161
191
  }
162
192
 
163
- public async getLatestPosts(count?: number, coverSize?: ImageSize) {
193
+ public async getLatestPosts(count: number | undefined, coverSize: ImageSize | undefined) {
194
+ const langAbbr = this.ensureLangAbbr();
164
195
  if (!coverSize) {
165
196
  coverSize = this.imageSizes?.postThumbnial;
166
197
  }
167
- return await queryLatestPosts(count, coverSize, this.envVariables);
198
+ return await queryLatestPosts(count, coverSize, this.envVariables, langAbbr);
168
199
  }
169
200
 
170
- public async getHomePage(): Promise<Page | undefined> {
171
- return await this.getPageByType(PageType.Home);
172
- }
173
- public async getPostPage(): Promise<Page | undefined> {
174
- return await this.getPageByType(PageType.Post);
175
- }
176
- public async getPostListPage(): Promise<Page | undefined> {
177
- return await this.getPageByType(PageType.PostList);
178
- }
179
- public async getPostCategoryPage(): Promise<Page | undefined> {
180
- return await this.getPageByType(PageType.PostCategory);
181
- }
182
- public async getProductPage(): Promise<Page | undefined> {
183
- return await this.getPageByType(PageType.Product);
184
- }
185
- public async getProductListPage(): Promise<Page | undefined> {
186
- return await this.getPageByType(PageType.ProductList);
187
- }
188
- public async getProductCategoryPage(): Promise<Page | undefined> {
189
- return await this.getPageByType(PageType.ProductCategory);
190
- }
191
- public async getSearchPage(): Promise<Page | undefined> {
192
- return await this.getPageByType(PageType.SearchList);
193
- }
194
- public async getProfilePage(): Promise<Page | undefined> {
195
- return await this.getPageByType(PageType.Profile);
196
- }
197
- public async getThanksPage(): Promise<Page | undefined> {
198
- return await this.getPageByType(PageType.Thanks);
199
- }
200
- public async get404Page(): Promise<Page | undefined> {
201
- return await this.getPageByType(PageType.Page404);
202
- }
203
- public async getErrorPage(): Promise<Page | undefined> {
204
- return await this.getPageByType(PageType.PageError);
205
- }
206
- public async getPageBySlug(slug: string): Promise<Page | undefined> {
207
- return await queryPageBySlug(slug, this.envVariables);
208
- }
209
-
210
- public async getPageByType(pageType: PageType): Promise<Page | undefined> {
211
- return await queryPageByType(pageType, this.envVariables);
212
- }
213
201
 
214
202
  public async getPosts(options: PostsOptions) {
203
+ const langAbbr = this.ensureLangAbbr();
215
204
  const { category, coverSize, page, pageSize } = options;
216
205
  const conditions: ListConditions = { category, page, pageSize };
217
- const result = await queryPosts(conditions, coverSize, this.envVariables);
206
+ const result = await queryPosts(conditions, coverSize, this.envVariables, langAbbr);
218
207
  return result?.items;
219
208
  }
220
209
 
221
210
  public async getPostListPaths(options: PostPatinateOptions) {
211
+ const langAbbr = this.ensureLangAbbr();
222
212
  const { category, pageSize } = options;
223
213
  // 获取总文章数据,只需要获取总数
224
214
  // TODO: 目前数据查询有点重复,后续要结合后端优化
225
215
  const postsData = await queryPosts(
226
216
  { category, page: 1, pageSize: 10 },
227
217
  undefined,
228
- this.envVariables
218
+ this.envVariables,
219
+ langAbbr
229
220
  );
230
221
 
231
222
  const totalItems = postsData?.total ?? 0;
@@ -245,10 +236,11 @@ export class Entify implements IEntify {
245
236
  }
246
237
 
247
238
  public async getPostBySlug(slug: string, coverSize: ImageSize | undefined) {
239
+ const langAbbr = this.ensureLangAbbr();
248
240
  if (!coverSize) {
249
241
  coverSize = this.imageSizes.post;
250
242
  }
251
- return await queryOnePostBySlug(slug, coverSize, this.envVariables);
243
+ return await queryOnePostBySlug(slug, coverSize, this.envVariables, langAbbr);
252
244
  }
253
245
 
254
246
  /**
@@ -256,38 +248,44 @@ export class Entify implements IEntify {
256
248
  * 对于大量文章,这个方法会进行优化,只获取 slug 字段
257
249
  */
258
250
  public async getPostSlugs() {
251
+ const langAbbr = this.ensureLangAbbr();
259
252
  // 只获取 slug 字段,减少数据传输量
260
- const result = await queryPostSlugs(this.envVariables);
253
+ const result = await queryPostSlugs(this.envVariables, langAbbr);
261
254
 
262
255
  return result?.items?.map((post) => post.slug) || [];
263
256
  }
264
257
 
265
258
  public async getPostCategories() {
266
- return await queryPostCategories(this.envVariables);
259
+ const langAbbr = this.ensureLangAbbr();
260
+ return await queryPostCategories(this.envVariables, langAbbr);
267
261
  }
268
262
 
269
263
  public async getPostCategoryBySlug(slug: string) {
270
- return await queryOnePostCategoryBySlug(slug, this.envVariables);
264
+ const langAbbr = this.ensureLangAbbr();
265
+ return await queryOnePostCategoryBySlug(slug, this.envVariables, langAbbr);
271
266
  }
272
267
 
273
268
  public async getTagCategories() {
274
- return await queryTagCategories(this.envVariables);
269
+ const langAbbr = this.ensureLangAbbr();
270
+ return await queryTagCategories(this.envVariables, langAbbr);
275
271
  }
276
272
 
277
- public async getTags(categoryId?: string) {
278
- return await queryTags(this.envVariables, categoryId);
273
+ public async getTags(categoryId: string | undefined) {
274
+ const langAbbr = this.ensureLangAbbr();
275
+ return await queryTags(this.envVariables, categoryId, langAbbr);
279
276
  }
280
277
 
281
278
  public async getProducts(
282
279
  conditions: ListConditions,
283
280
  imageSize: ImageSize | undefined,
284
- addonFields?: (keyof Product)[]
281
+ addonFields?: (keyof Product)[] | undefined
285
282
  ) {
283
+ const langAbbr = this.ensureLangAbbr();
286
284
  if (!imageSize) {
287
285
  imageSize = this.imageSizes.productThumbnial;
288
286
  }
289
287
  return (
290
- await queryProducts(conditions, imageSize, this.envVariables, addonFields)
288
+ await queryProducts(conditions, imageSize, this.envVariables, addonFields, langAbbr)
291
289
  )?.items;
292
290
  }
293
291
 
@@ -295,12 +293,15 @@ export class Entify implements IEntify {
295
293
  category?: string;
296
294
  pageSize: number;
297
295
  }) {
296
+ const langAbbr = this.ensureLangAbbr();
298
297
  const { category, pageSize } = options;
299
298
  // 获取总产品数据,只需要获取总数
300
299
  const productsData = await queryProducts(
301
300
  { category, page: 1, pageSize: 10 },
302
301
  undefined,
303
- this.envVariables
302
+ this.envVariables,
303
+ undefined,
304
+ langAbbr
304
305
  );
305
306
 
306
307
  const totalItems = productsData?.total ?? 0;
@@ -309,6 +310,7 @@ export class Entify implements IEntify {
309
310
  }
310
311
 
311
312
  public async getCategoredProductListPaths() {
313
+ const langAbbr = this.ensureLangAbbr();
312
314
  // 获取所有产品分类
313
315
  const categoryTree = await this.getProductCategories();
314
316
  const categories = this.flattenTree(categoryTree);
@@ -374,6 +376,7 @@ export class Entify implements IEntify {
374
376
  * @returns 所有文章分类的分页路径
375
377
  */
376
378
  public async getCategoredPostListPaths() {
379
+ const langAbbr = this.ensureLangAbbr();
377
380
  // 获取所有文章分类
378
381
  const categoryTree = await this.getPostCategories();
379
382
  const categories = this.flattenTree(categoryTree);
@@ -434,10 +437,11 @@ export class Entify implements IEntify {
434
437
  }
435
438
 
436
439
  public async getProductBySlug(slug: string, imageSize: ImageSize | undefined) {
440
+ const langAbbr = this.ensureLangAbbr();
437
441
  if (!imageSize) {
438
442
  imageSize = this.imageSizes.product;
439
443
  }
440
- return await queryOneProductBySlug(slug, imageSize, this.envVariables);
444
+ return await queryOneProductBySlug(slug, imageSize, this.envVariables, langAbbr);
441
445
  }
442
446
 
443
447
  public async getProductPaths() {
@@ -456,22 +460,26 @@ export class Entify implements IEntify {
456
460
  * 对于大量产品,这个方法会进行优化,只获取 slug 字段
457
461
  */
458
462
  public async getProductSlugs() {
463
+ const langAbbr = this.ensureLangAbbr();
459
464
  // 只获取 slug 字段,减少数据传输量
460
- const result = await queryAllProducts(this.envVariables);
465
+ const result = await queryAllProducts(this.envVariables, langAbbr);
461
466
  return result?.items?.map((product) => product.slug) || [];
462
467
  }
463
468
 
464
469
  public async getProductIds() {
465
- const result = await queryAllProducts(this.envVariables);
470
+ const langAbbr = this.ensureLangAbbr();
471
+ const result = await queryAllProducts(this.envVariables, langAbbr);
466
472
  return result?.items?.map((product) => product.id) || [];
467
473
  }
468
474
 
469
475
  public async getProductCategories() {
470
- return await queryProductCategories(this.envVariables);
476
+ const langAbbr = this.ensureLangAbbr();
477
+ return await queryProductCategories(this.envVariables, langAbbr);
471
478
  }
472
479
 
473
480
  public async getProductCategoryBySlug(slug: string) {
474
- return await queryOneProductCategoryBySlug(slug, this.envVariables);
481
+ const langAbbr = this.ensureLangAbbr();
482
+ return await queryOneProductCategoryBySlug(slug, this.envVariables, langAbbr);
475
483
  }
476
484
 
477
485
  public async getOneUser(id: string) {
@@ -479,14 +487,16 @@ export class Entify implements IEntify {
479
487
  }
480
488
 
481
489
  public async getUserPosts(userId: string) {
482
- return (await queryUserPosts({ userId }, this.envVariables))?.items;
490
+ const langAbbr = this.ensureLangAbbr();
491
+ return (await queryUserPosts({ userId }, this.envVariables, langAbbr))?.items;
483
492
  }
484
493
 
485
494
  public async fulltextSearch(keyword: string, imageSize: ImageSize | undefined) {
495
+ const langAbbr = this.ensureLangAbbr();
486
496
  if (!imageSize) {
487
497
  imageSize = this.imageSizes.postThumbnial;
488
498
  }
489
- return await fulltextSearch(keyword, imageSize, this.envVariables);
499
+ return await fulltextSearch(keyword, imageSize, this.envVariables, langAbbr);
490
500
  }
491
501
 
492
502
  public async getUserPaths() {