@rxdrag/website-lib-core 0.0.10 → 0.0.12

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.10",
3
+ "version": "0.0.12",
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.55",
27
+ "@rxdrag/entify-hooks": "0.2.42",
28
28
  "@rxdrag/eslint-config-custom": "0.2.12",
29
29
  "@rxdrag/tsconfig": "0.2.0",
30
- "@rxdrag/entify-hooks": "0.2.41"
30
+ "@rxdrag/slate-preview": "1.2.55"
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.47"
38
+ "@rxdrag/rxcms-models": "0.3.48"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "astro": "^4.0.0 || ^5.0.0"
@@ -94,7 +94,7 @@ export class PageLoader implements IPageLoader {
94
94
  if (typeof window !== "undefined") {
95
95
  // 在客户端环境中
96
96
  this.doc.addEventListener("astro:page-load", handleEvent, {
97
- once: true,
97
+ //once: true,
98
98
  });
99
99
  // 只监听页面转场事件
100
100
  this.doc.addEventListener("astro:after-swap", handleEvent);
@@ -23,6 +23,10 @@ import { queryAllProducts } from "./lib/queryAllProducts";
23
23
  import { queryPostSlugs } from "./lib/queryPostSlugs";
24
24
  import { queryUserIds } from "./lib/queryUserIds";
25
25
  import { IEntify, PostPatinateOptions, PostsOptions } from "./IEntify";
26
+ import { queryWebsite } from "./lib/queryWebsite";
27
+ import { Page, PageType } from "@rxdrag/rxcms-models";
28
+ import { queryPageBySlug } from "./lib/queryPageBySlug";
29
+ import { queryPageByType } from "./lib/queryPageByType";
26
30
 
27
31
  export class Entify implements IEntify {
28
32
  private static instance: Entify | null = null;
@@ -48,6 +52,10 @@ export class Entify implements IEntify {
48
52
  );
49
53
  }
50
54
 
55
+ public async getWebsite() {
56
+ return queryWebsite(this.envVariables);
57
+ }
58
+
51
59
  public async getTheme() {
52
60
  return await queryOneTheme(this.envVariables);
53
61
  }
@@ -64,6 +72,50 @@ export class Entify implements IEntify {
64
72
  return await queryLatestPosts(count, this.envVariables);
65
73
  }
66
74
 
75
+ public async getHomePage(): Promise<Page | undefined> {
76
+ return await this.getPageByType(PageType.Home);
77
+ }
78
+ public async getPostPage(): Promise<Page | undefined> {
79
+ return await this.getPageByType(PageType.Post);
80
+ }
81
+ public async getPostListPage(): Promise<Page | undefined> {
82
+ return await this.getPageByType(PageType.PostList);
83
+ }
84
+ public async getPostCategoryPage(): Promise<Page | undefined> {
85
+ return await this.getPageByType(PageType.PostCategory);
86
+ }
87
+ public async getProductPage(): Promise<Page | undefined> {
88
+ return await this.getPageByType(PageType.Product);
89
+ }
90
+ public async getProductListPage(): Promise<Page | undefined> {
91
+ return await this.getPageByType(PageType.ProductList);
92
+ }
93
+ public async getProductCategoryPage(): Promise<Page | undefined> {
94
+ return await this.getPageByType(PageType.ProductCategory);
95
+ }
96
+ public async getSearchPage(): Promise<Page | undefined> {
97
+ return await this.getPageByType(PageType.SearchList);
98
+ }
99
+ public async getProfilePage(): Promise<Page | undefined> {
100
+ return await this.getPageByType(PageType.Profile);
101
+ }
102
+ public async getThanksPage(): Promise<Page | undefined> {
103
+ return await this.getPageByType(PageType.Thanks);
104
+ }
105
+ public async get404Page(): Promise<Page | undefined> {
106
+ return await this.getPageByType(PageType.Page404);
107
+ }
108
+ public async getErrorPage(): Promise<Page | undefined> {
109
+ return await this.getPageByType(PageType.PageError);
110
+ }
111
+ public async getPageBySlug(slug: string): Promise<Page | undefined> {
112
+ return await queryPageBySlug(slug, this.envVariables);
113
+ }
114
+
115
+ public async getPageByType(pageType: PageType): Promise<Page | undefined> {
116
+ return await queryPageByType(pageType, this.envVariables);
117
+ }
118
+
67
119
  public async getPosts(options: PostsOptions) {
68
120
  const { category, coverSize, page, pageSize } = options;
69
121
  const conditions: ListConditions = { category, page, pageSize };
@@ -1,8 +1,14 @@
1
1
  import { IQueryOptions, ListResult } from "@rxdrag/entify-hooks";
2
2
  import { TSize } from "./types";
3
3
  import { ListConditions } from "./lib";
4
- import { TPost, TPostCategory, TProduct, TProductCategory, TUser } from "./view-model";
5
- import { Lang, Theme } from "@rxdrag/rxcms-models";
4
+ import {
5
+ TPost,
6
+ TPostCategory,
7
+ TProduct,
8
+ TProductCategory,
9
+ TUser,
10
+ } from "./view-model";
11
+ import { Lang, Page, PageType, Theme, Website } from "@rxdrag/rxcms-models";
6
12
 
7
13
  export type PostsOptions = {
8
14
  category?: string;
@@ -28,6 +34,8 @@ export interface IEntify {
28
34
  staticKey?: string
29
35
  ): Promise<ListResult<unknown> | undefined>;
30
36
 
37
+ getWebsite(): Promise<Website | undefined>;
38
+
31
39
  getTheme(): Promise<Theme | undefined>;
32
40
 
33
41
  getLangs(): Promise<Lang[] | undefined>;
@@ -38,11 +46,42 @@ export interface IEntify {
38
46
 
39
47
  getPosts(options: PostsOptions): Promise<TPost[] | undefined>;
40
48
 
49
+ getHomePage(): Promise<Page | undefined>;
50
+
51
+ getPostPage(): Promise<Page | undefined>;
52
+
53
+ getPostListPage(): Promise<Page | undefined>;
54
+
55
+ getPostCategoryPage(): Promise<Page | undefined>;
56
+
57
+ getProductPage(): Promise<Page | undefined>;
58
+
59
+ getProductListPage(): Promise<Page | undefined>;
60
+
61
+ getProductCategoryPage(): Promise<Page | undefined>;
62
+
63
+ getSearchPage(): Promise<Page | undefined>;
64
+
65
+ getProfilePage(): Promise<Page | undefined>;
66
+
67
+ getThanksPage(): Promise<Page | undefined>;
68
+
69
+ get404Page(): Promise<Page | undefined>;
70
+
71
+ getErrorPage(): Promise<Page | undefined>;
72
+
73
+ getPageBySlug(slug: string): Promise<Page | undefined>;
74
+
75
+ getPageByType(pageType: PageType): Promise<Page | undefined>;
76
+
41
77
  getPostListPaths(options: PostPatinateOptions): Promise<unknown>;
42
78
 
43
79
  getPostPaths(): Promise<unknown>;
44
80
 
45
- getPostBySlug(slug: string, coverSize: TSize | undefined): Promise<TPost | undefined>;
81
+ getPostBySlug(
82
+ slug: string,
83
+ coverSize: TSize | undefined
84
+ ): Promise<TPost | undefined>;
46
85
 
47
86
  getPostSlugs(): Promise<Array<string | undefined>>;
48
87
 
@@ -9,4 +9,6 @@ export const langFields = [
9
9
  LangFields.localName,
10
10
  LangFields.icon,
11
11
  LangFields.htmlLang,
12
+ //TODO 用枚举有时会出空值
13
+ "urlFragment" as LangFields.urlFragment,
12
14
  ];
@@ -1,8 +1,8 @@
1
- import { PageMetaQueryOptions, PageMetaFields, MediaQueryOptions, MediaFields } from "@rxdrag/rxcms-models";
1
+ import { PageMetaQueryOptions, PageMetaFields } from "@rxdrag/rxcms-models";
2
2
  import { newOgImageQueryOptions } from "./newOgImageQueryOptions";
3
3
 
4
4
  export function newPageMetaOptions() {
5
- return new PageMetaQueryOptions([
5
+ return new PageMetaQueryOptions([
6
6
  PageMetaFields.id,
7
7
  PageMetaFields.seoTitle,
8
8
  PageMetaFields.seoKeywords,
@@ -14,7 +14,5 @@ export function newPageMetaOptions() {
14
14
  PageMetaFields.ogSiteName,
15
15
  PageMetaFields.xCard,
16
16
  PageMetaFields.xSite,
17
- ]).ogImage(
18
- newOgImageQueryOptions()
19
- )
20
- }
17
+ ]).ogImage(newOgImageQueryOptions());
18
+ }
@@ -0,0 +1,14 @@
1
+ import {
2
+ PageQueryOptions,
3
+ PageFields,
4
+ } from "@rxdrag/rxcms-models";
5
+ import { newPageMetaOptions } from "./newPageMetaOptions";
6
+
7
+ //查询一个产品的参数,不带条件
8
+ export function newQueryPageOptions() {
9
+ return new PageQueryOptions([
10
+ PageFields.id,
11
+ PageFields.slug,
12
+ PageFields.title,
13
+ ]).meta(newPageMetaOptions());
14
+ }
@@ -20,6 +20,11 @@ export async function queryAllProducts(envVariables: EnvVariables) {
20
20
  [ProductFields.status]: {
21
21
  _eq: PublishableStatus.published,
22
22
  },
23
+ lang: {
24
+ abbr: {
25
+ _eq: envVariables.language,
26
+ },
27
+ },
23
28
  },
24
29
  orderBy: [{ [ProductFields.seqValue]: "asc" }],
25
30
  }
@@ -37,6 +37,11 @@ export async function queryFeaturedProducts(
37
37
  featured: {
38
38
  _eq: true,
39
39
  },
40
+ lang: {
41
+ abbr: {
42
+ _eq: envVariables.language,
43
+ },
44
+ },
40
45
  },
41
46
  orderBy: [{ [ProductFields.seqValue]: "asc" }],
42
47
  }
@@ -4,12 +4,12 @@ import {
4
4
  LangDistinctExp,
5
5
  LangOrderBy,
6
6
  LangQueryOptions,
7
- LangFields,
8
7
  LangAssciations,
9
8
  } from "@rxdrag/rxcms-models";
10
9
  import { ListResult } from "@rxdrag/entify-hooks";
11
10
  import { EnvVariables } from "../types";
12
11
  import { createEntifyClient } from "./createEntifyClient";
12
+ import { langFields } from "./langFields";
13
13
 
14
14
  export async function queryLangs(envVariables: EnvVariables) {
15
15
  const client = createEntifyClient(envVariables);
@@ -20,28 +20,15 @@ export async function queryLangs(envVariables: EnvVariables) {
20
20
  LangOrderBy,
21
21
  LangDistinctExp
22
22
  >(
23
- new LangQueryOptions(
24
- [
25
- LangFields.id,
26
- LangFields.abbr,
27
- LangFields.circleIcon,
28
- LangFields.cnName,
29
- LangFields.enName,
30
- LangFields.localName,
31
- LangFields.icon,
32
- LangFields.htmlLang,
33
- ],
34
- {
35
- where: {
36
- [LangAssciations.websites]: {
37
- id: {
38
- _eq: envVariables.websiteId,
39
- },
23
+ new LangQueryOptions(langFields, {
24
+ where: {
25
+ [LangAssciations.websites]: {
26
+ id: {
27
+ _eq: envVariables.websiteId,
40
28
  },
41
29
  },
42
- }
43
- ).setNoQuery(!envVariables.websiteId)
30
+ },
31
+ }).setNoQuery(!envVariables.websiteId)
44
32
  );
45
-
46
33
  return result as ListResult<Lang> | undefined;
47
34
  }
@@ -1,4 +1,4 @@
1
- import { ListResult, OrderBy } from "@rxdrag/entify-hooks";
1
+ import { ListResult } from "@rxdrag/entify-hooks";
2
2
  import {
3
3
  PostBoolExp,
4
4
  PostOrderBy,
@@ -45,6 +45,11 @@ export async function queryLatestPosts(
45
45
  [PostFields.status]: {
46
46
  _eq: PublishableStatus.published,
47
47
  },
48
+ lang: {
49
+ abbr: {
50
+ _eq: envVariables.language,
51
+ },
52
+ },
48
53
  },
49
54
  }
50
55
  )
@@ -1,20 +1,37 @@
1
- import { Post, PostBoolExp, PostOrderBy, PostDistinctExp } from "@rxdrag/rxcms-models";
1
+ import {
2
+ Post,
3
+ PostBoolExp,
4
+ PostOrderBy,
5
+ PostDistinctExp,
6
+ } from "@rxdrag/rxcms-models";
2
7
  import { newQueryOnePostOptions } from "./newQueryPostOptions";
3
8
  import { queryOneEntity } from "./queryOneEntity";
4
9
  import { EnvVariables, TSize } from "../types";
5
10
  import { TPost } from "../view-model";
6
11
 
7
- export async function queryOnePostBySlug(slug: string, coverSize: TSize | undefined, envVariables: EnvVariables) {
8
-
9
- const post = await queryOneEntity<Post, PostBoolExp, PostOrderBy, PostDistinctExp>(
10
- newQueryOnePostOptions(coverSize)
11
- .setQueryArgs({
12
- where: {
13
- slug: {
14
- "_eq": slug
12
+ export async function queryOnePostBySlug(
13
+ slug: string,
14
+ coverSize: TSize | undefined,
15
+ envVariables: EnvVariables
16
+ ) {
17
+ const post = await queryOneEntity<
18
+ Post,
19
+ PostBoolExp,
20
+ PostOrderBy,
21
+ PostDistinctExp
22
+ >(
23
+ newQueryOnePostOptions(coverSize).setQueryArgs({
24
+ where: {
25
+ slug: {
26
+ _eq: slug,
27
+ },
28
+ lang: {
29
+ abbr: {
30
+ _eq: envVariables.language,
15
31
  },
16
32
  },
17
- }),
33
+ },
34
+ }),
18
35
  envVariables
19
36
  );
20
37
  return post as TPost | undefined;
@@ -20,6 +20,11 @@ export async function queryOnePostCategoryBySlug(slug: string, envVariables: Env
20
20
  slug: {
21
21
  "_eq": slug
22
22
  },
23
+ lang: {
24
+ abbr: {
25
+ _eq: envVariables.language,
26
+ },
27
+ },
23
28
  },
24
29
  }
25
30
  ),
@@ -26,6 +26,11 @@ export async function queryOneProductBySlug(
26
26
  slug: {
27
27
  _eq: slug,
28
28
  },
29
+ lang: {
30
+ abbr: {
31
+ _eq: envVariables.language,
32
+ },
33
+ },
29
34
  },
30
35
  }),
31
36
  envVariables
@@ -1,11 +1,25 @@
1
- import { ProductCategory, ProductCategoryBoolExp, ProductCategoryOrderBy, ProductCategoryDistinctExp, ProductCategoryQueryOptions, ProductCategoryFields } from "@rxdrag/rxcms-models";
1
+ import {
2
+ ProductCategory,
3
+ ProductCategoryBoolExp,
4
+ ProductCategoryOrderBy,
5
+ ProductCategoryDistinctExp,
6
+ ProductCategoryQueryOptions,
7
+ ProductCategoryFields,
8
+ } from "@rxdrag/rxcms-models";
2
9
  import { queryOneEntity } from "./queryOneEntity";
3
10
  import { EnvVariables } from "../types";
4
11
  import { TProductCategory } from "../view-model";
5
12
 
6
- export async function queryOneProductCategoryBySlug(slug: string, envVariables: EnvVariables) {
7
-
8
- const productCategory = await queryOneEntity<ProductCategory, ProductCategoryBoolExp, ProductCategoryOrderBy, ProductCategoryDistinctExp>(
13
+ export async function queryOneProductCategoryBySlug(
14
+ slug: string,
15
+ envVariables: EnvVariables
16
+ ) {
17
+ const productCategory = await queryOneEntity<
18
+ ProductCategory,
19
+ ProductCategoryBoolExp,
20
+ ProductCategoryOrderBy,
21
+ ProductCategoryDistinctExp
22
+ >(
9
23
  new ProductCategoryQueryOptions(
10
24
  [
11
25
  ProductCategoryFields.id,
@@ -18,7 +32,12 @@ export async function queryOneProductCategoryBySlug(slug: string, envVariables:
18
32
  {
19
33
  where: {
20
34
  slug: {
21
- "_eq": slug
35
+ _eq: slug,
36
+ },
37
+ lang: {
38
+ abbr: {
39
+ _eq: envVariables.language,
40
+ },
22
41
  },
23
42
  },
24
43
  }
@@ -60,7 +60,8 @@ export async function queryOneTheme(envVariables: EnvVariables) {
60
60
  ThemeConfigFields.mobile,
61
61
  ThemeConfigFields.tel,
62
62
  ThemeConfigFields.wechat,
63
- //ThemeConfigFields.websiteName,
63
+ ThemeConfigFields.domain,
64
+ //ThemeConfigFields.websiteName,
64
65
  ]).contactAvatar(new MediaQueryOptions().file(["thumbnail"]))
65
66
  )
66
67
  .lang(langFields)
@@ -0,0 +1,43 @@
1
+ import {
2
+ Page,
3
+ PageBoolExp,
4
+ PageOrderBy,
5
+ PageDistinctExp,
6
+ } from "@rxdrag/rxcms-models";
7
+ import { queryOneEntity } from "./queryOneEntity";
8
+ import { EnvVariables } from "../types";
9
+ import { newQueryPageOptions } from "./newQueryPageOptions";
10
+
11
+ export async function queryPageBySlug(
12
+ slug: string,
13
+ envVariables: EnvVariables
14
+ ) {
15
+ const post = await queryOneEntity<
16
+ Page,
17
+ PageBoolExp,
18
+ PageOrderBy,
19
+ PageDistinctExp
20
+ >(
21
+ newQueryPageOptions().setQueryArgs({
22
+ where: {
23
+ slug: {
24
+ _eq: slug,
25
+ },
26
+ theme: {
27
+ lang: {
28
+ abbr: {
29
+ _eq: envVariables.language,
30
+ },
31
+ },
32
+ website: {
33
+ id: {
34
+ _eq: envVariables.websiteId,
35
+ },
36
+ },
37
+ },
38
+ },
39
+ }),
40
+ { ...envVariables, websiteId: undefined }
41
+ );
42
+ return post as Page | undefined;
43
+ }
@@ -0,0 +1,44 @@
1
+ import {
2
+ Page,
3
+ PageBoolExp,
4
+ PageOrderBy,
5
+ PageDistinctExp,
6
+ PageType,
7
+ } from "@rxdrag/rxcms-models";
8
+ import { queryOneEntity } from "./queryOneEntity";
9
+ import { EnvVariables } from "../types";
10
+ import { newQueryPageOptions } from "./newQueryPageOptions";
11
+
12
+ export async function queryPageByType(
13
+ pageType: PageType,
14
+ envVariables: EnvVariables
15
+ ) {
16
+ const post = await queryOneEntity<
17
+ Page,
18
+ PageBoolExp,
19
+ PageOrderBy,
20
+ PageDistinctExp
21
+ >(
22
+ newQueryPageOptions().setQueryArgs({
23
+ where: {
24
+ pageType: {
25
+ _eq: pageType,
26
+ },
27
+ theme: {
28
+ lang: {
29
+ abbr: {
30
+ _eq: envVariables.language,
31
+ },
32
+ },
33
+ website: {
34
+ id: {
35
+ _eq: envVariables.websiteId,
36
+ },
37
+ },
38
+ },
39
+ },
40
+ }),
41
+ { ...envVariables, websiteId: undefined }
42
+ );
43
+ return post as Page | undefined;
44
+ }
@@ -18,6 +18,11 @@ export async function queryPostSlugs(envVariables: EnvVariables) {
18
18
  [PostFields.status]: {
19
19
  _eq: PublishableStatus.published,
20
20
  },
21
+ lang: {
22
+ abbr: {
23
+ _eq: envVariables.language,
24
+ },
25
+ },
21
26
  },
22
27
  orderBy: [{ [PostFields.seqValue]: "asc" }],
23
28
  });
@@ -1,32 +1,44 @@
1
- import { Post, PostBoolExp, PostOrderBy, PostDistinctExp, PostFields, PublishableStatus, PostAssciations, PostQueryOptions, MediaQueryOptions, UserQueryOptions, UserFields } from "@rxdrag/rxcms-models";
1
+ import {
2
+ Post,
3
+ PostBoolExp,
4
+ PostOrderBy,
5
+ PostDistinctExp,
6
+ PostFields,
7
+ PublishableStatus,
8
+ PostAssciations,
9
+ PostQueryOptions,
10
+ MediaQueryOptions,
11
+ UserQueryOptions,
12
+ UserFields,
13
+ } from "@rxdrag/rxcms-models";
2
14
  import { queryEntityList } from "./queryEntityList";
3
15
  import { ListResult } from "@rxdrag/entify-hooks";
4
16
  import { EnvVariables, TSize } from "../types";
5
17
  import { TPost } from "../view-model";
6
18
 
7
19
  export interface ListConditions {
8
- category?: string;//category slug
20
+ category?: string; //category slug
9
21
  page?: number;
10
22
  pageSize: number;
11
23
  }
12
24
 
13
25
  export async function queryPosts(
14
- conditions: ListConditions,
15
- coverSize: TSize | undefined,
26
+ conditions: ListConditions,
27
+ coverSize: TSize | undefined,
16
28
  envVariables: EnvVariables,
17
29
  selectFields?: (keyof Post)[]
18
30
  ) {
19
31
  const { category: categorySlug, page = 1, pageSize } = conditions;
20
32
 
21
- let where = {}
33
+ let where = {};
22
34
  if (categorySlug) {
23
35
  where = {
24
36
  [PostAssciations.category]: {
25
37
  slug: {
26
- "_eq": categorySlug
27
- }
38
+ _eq: categorySlug,
39
+ },
28
40
  },
29
- }
41
+ };
30
42
  }
31
43
 
32
44
  // 默认查询字段
@@ -44,49 +56,54 @@ export async function queryPosts(
44
56
  // 使用指定的字段或默认字段
45
57
  const fields = selectFields || defaultFields;
46
58
 
47
- const queryOptions = new PostQueryOptions(
48
- fields,
49
- {
50
- offset: (page - 1) * pageSize,
51
- limit: pageSize,
52
- where: {
53
- [PostFields.status]: {
54
- "_eq": PublishableStatus.published
59
+ const queryOptions = new PostQueryOptions(fields, {
60
+ offset: (page - 1) * pageSize,
61
+ limit: pageSize,
62
+ where: {
63
+ [PostFields.status]: {
64
+ _eq: PublishableStatus.published,
65
+ },
66
+ lang: {
67
+ abbr: {
68
+ _eq: envVariables.language,
55
69
  },
56
- ...where,
57
70
  },
58
- orderBy: [
59
- {
60
- [PostFields.createdAt]: "desc"
61
- }
62
- ]
63
- }
64
- );
71
+ ...where,
72
+ },
73
+ orderBy: [
74
+ {
75
+ [PostFields.createdAt]: "desc",
76
+ },
77
+ ],
78
+ });
65
79
 
66
80
  // 只有在需要查询封面图时才添加封面图查询
67
- if (!selectFields || selectFields.includes('cover' as keyof Post)) {
81
+ if (!selectFields || selectFields.includes("cover" as keyof Post)) {
68
82
  queryOptions.cover(
69
- new MediaQueryOptions().file(
70
- [
71
- "thumbnail",
72
- coverSize ? `resize(width:${coverSize.width}, height:${coverSize.height})` : "resize(width:480, height:180)"
73
- ]
74
- )
83
+ new MediaQueryOptions().file([
84
+ "thumbnail",
85
+ coverSize
86
+ ? `resize(width:${coverSize.width}, height:${coverSize.height})`
87
+ : "resize(width:480, height:180)",
88
+ ])
75
89
  );
76
90
  }
77
91
 
78
92
  // 只有在需要查询作者时才添加作者查询
79
- if (!selectFields || selectFields.includes('author' as keyof Post)) {
93
+ if (!selectFields || selectFields.includes("author" as keyof Post)) {
80
94
  queryOptions.author(
81
- new UserQueryOptions([UserFields.id, UserFields.name])
82
- .avatar(new MediaQueryOptions().file(["thumbnail"]))
95
+ new UserQueryOptions([UserFields.id, UserFields.name]).avatar(
96
+ new MediaQueryOptions().file(["thumbnail"])
97
+ )
83
98
  );
84
99
  }
85
100
 
86
- const result = await queryEntityList<Post, PostBoolExp, PostOrderBy, PostDistinctExp>(
87
- queryOptions,
88
- envVariables
89
- );
90
-
101
+ const result = await queryEntityList<
102
+ Post,
103
+ PostBoolExp,
104
+ PostOrderBy,
105
+ PostDistinctExp
106
+ >(queryOptions, envVariables);
107
+
91
108
  return result as ListResult<TPost> | undefined;
92
109
  }
@@ -46,6 +46,11 @@ export async function queryProducts(
46
46
  [ProductFields.status]: {
47
47
  "_eq": PublishableStatus.published
48
48
  },
49
+ lang: {
50
+ abbr: {
51
+ _eq: envVariables.language,
52
+ },
53
+ },
49
54
  ...where,
50
55
  },
51
56
  orderBy: [
@@ -1,4 +1,8 @@
1
- import { ProductFields, ProductQueryOptions, PublishableStatus } from "@rxdrag/rxcms-models";
1
+ import {
2
+ ProductFields,
3
+ ProductQueryOptions,
4
+ PublishableStatus,
5
+ } from "@rxdrag/rxcms-models";
2
6
  import { queryEntityList } from "./queryEntityList";
3
7
  import { EnvVariables } from "../types";
4
8
  import { newQueryProductsMediaOptions } from "./newQueryProductsMediaOptions";
@@ -6,25 +10,23 @@ import { newQueryProductsMediaOptions } from "./newQueryProductsMediaOptions";
6
10
  export async function queryProductsInMenu(envVariables: EnvVariables) {
7
11
  const result = await queryEntityList(
8
12
  new ProductQueryOptions(
9
- [
10
- ProductFields.id,
11
- ProductFields.slug,
12
- ProductFields.title,
13
- ],
13
+ [ProductFields.id, ProductFields.slug, ProductFields.title],
14
14
  {
15
15
  where: {
16
+ lang: {
17
+ abbr: {
18
+ _eq: envVariables.language,
19
+ },
20
+ },
16
21
  showInNavMenu: {
17
- "_eq": true
22
+ _eq: true,
18
23
  },
19
24
  [ProductFields.status]: {
20
- "_eq": PublishableStatus.published
25
+ _eq: PublishableStatus.published,
21
26
  },
22
27
  },
23
28
  }
24
- )
25
- .mediaPivots(
26
- newQueryProductsMediaOptions()
27
- ),
29
+ ).mediaPivots(newQueryProductsMediaOptions()),
28
30
  envVariables
29
31
  );
30
32
  return result;
@@ -53,6 +53,11 @@ export async function queryUserPosts(
53
53
  [PostFields.status]: {
54
54
  _eq: PublishableStatus.published,
55
55
  },
56
+ lang: {
57
+ abbr: {
58
+ _eq: envVariables.language,
59
+ },
60
+ },
56
61
  [PostAssciations.author]: {
57
62
  id: {
58
63
  _eq: userId,
@@ -0,0 +1,43 @@
1
+ import {
2
+ Website,
3
+ WebsiteBoolExp,
4
+ WebsiteOrderBy,
5
+ WebsiteDistinctExp,
6
+ WebsiteQueryOptions,
7
+ WebsiteFields,
8
+ LangFields,
9
+ } from "@rxdrag/rxcms-models";
10
+ import { queryOneEntity } from "./queryOneEntity";
11
+ import { EnvVariables } from "../types";
12
+
13
+ export async function queryWebsite(envVariables: EnvVariables) {
14
+ const website = await queryOneEntity<
15
+ Website,
16
+ WebsiteBoolExp,
17
+ WebsiteOrderBy,
18
+ WebsiteDistinctExp
19
+ >(
20
+ new WebsiteQueryOptions(
21
+ [WebsiteFields.id, WebsiteFields.name, WebsiteFields.title],
22
+ {
23
+ where: {
24
+ id: {
25
+ _eq: envVariables.websiteId,
26
+ },
27
+ },
28
+ }
29
+ )
30
+ .baseLang([
31
+ LangFields.id,
32
+ LangFields.abbr,
33
+ LangFields.localName,
34
+ LangFields.cnName,
35
+ LangFields.urlFragment,
36
+ LangFields.htmlLang,
37
+ ])
38
+ .setNoQuery(!envVariables.websiteId),
39
+ { ...envVariables, websiteId: undefined }
40
+ );
41
+
42
+ return website as Website | undefined;
43
+ }
@@ -48,6 +48,13 @@ export async function searchProducts(
48
48
  limit: 100,
49
49
  where: {
50
50
  _and: [
51
+ {
52
+ lang: {
53
+ abbr: {
54
+ _eq: envVariables.language,
55
+ },
56
+ },
57
+ },
51
58
  {
52
59
  [ProductFields.status]: {
53
60
  _eq: PublishableStatus.published,
@@ -3,5 +3,4 @@ export type EnvVariables = {
3
3
  entifyServerUrl?: string;
4
4
  entifyGuestToken?: string;
5
5
  language?: string;
6
- formSalt: string;
7
6
  };
@@ -120,11 +120,6 @@ export type TBreadcrumbItem = {
120
120
  href?: string;
121
121
  };
122
122
 
123
- export type TPage = {
124
- title?: string;
125
- breadcrumbs?: TBreadcrumbItem[];
126
- };
127
-
128
123
  export type TPagination = {
129
124
  urlPrefix?: string;
130
125
  current?: number;
@@ -138,6 +133,5 @@ export const entityMaps: Record<string, string> = {
138
133
  PostCategory: "TPostCategory",
139
134
  User: "TUser",
140
135
  Media: "TMedia",
141
- Page: "TPage",
142
136
  WebsiteSettings: "TWebsiteSettings",
143
137
  };