@rxdrag/website-lib-core 0.0.96 → 0.0.98

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.96",
3
+ "version": "0.0.98",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.ts"
@@ -24,9 +24,9 @@
24
24
  "@types/react-dom": "^19.1.0",
25
25
  "eslint": "^7.32.0",
26
26
  "typescript": "^5",
27
- "@rxdrag/slate-preview": "1.2.61",
27
+ "@rxdrag/eslint-config-custom": "0.2.12",
28
28
  "@rxdrag/tsconfig": "0.2.0",
29
- "@rxdrag/eslint-config-custom": "0.2.12"
29
+ "@rxdrag/slate-preview": "1.2.63"
30
30
  },
31
31
  "dependencies": {
32
32
  "@iconify/utils": "^3.0.2",
@@ -37,7 +37,7 @@
37
37
  "react": "^19.1.0",
38
38
  "react-dom": "^19.1.0",
39
39
  "@rxdrag/entify-lib": "0.0.23",
40
- "@rxdrag/rxcms-models": "0.3.94"
40
+ "@rxdrag/rxcms-models": "0.3.95"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "astro": "^4.0.0 || ^5.0.0"
@@ -43,12 +43,12 @@ import { queryPageByType } from "./lib/queryPageByType";
43
43
  import { queryOneMedia } from "./lib/queryOneMedia";
44
44
  import { DEFAULT_LARGE, DEFAULT_MEDIUM, DEFAULT_SAMLL, DEFUALT_HEIGHT, DEFUALT_WIDTH, FileFieldType, ImageResize } from "../astro/media";
45
45
  import { queryOneIcon } from "./lib/queryOneIcon";
46
+ import { queryBulletin } from "./lib/queryBulletin";
46
47
 
47
48
  export class Entify implements IEntify {
48
49
  private static instance: Entify | null = null;
49
50
 
50
51
  private constructor(protected envVariables: EnvVariables, protected imageSizes: ImageSizes) { }
51
-
52
52
  private flattenTree<T>(nodes: T[] | undefined): T[] {
53
53
  if (!nodes) return [];
54
54
  let result: T[] = [];
@@ -137,6 +137,11 @@ export class Entify implements IEntify {
137
137
  return await queryOneIcon(name, this.envVariables);
138
138
  }
139
139
 
140
+ public async getBulletin() {
141
+ return await queryBulletin(this.envVariables);
142
+ }
143
+
144
+
140
145
  public async getFeaturedProducts(
141
146
  count?: number,
142
147
  imageSize?: ImageSize,
@@ -8,6 +8,7 @@ import {
8
8
  TUser,
9
9
  } from "./view-model";
10
10
  import {
11
+ Bulletin,
11
12
  ImageSize,
12
13
  ImageSizes,
13
14
  Lang,
@@ -64,6 +65,8 @@ export interface IEntify {
64
65
 
65
66
  getIcon(name: string | undefined | null): Promise<SvgIcon | undefined>;
66
67
 
68
+ getBulletin(): Promise<Bulletin | undefined | null>
69
+
67
70
  getFeaturedProducts(
68
71
  count?: number,
69
72
  imageSize?: ImageSize,
@@ -6,6 +6,7 @@ import {
6
6
  MediaQueryOptions,
7
7
  PostCategoryFields,
8
8
  ImageSize,
9
+ TagFields,
9
10
  } from "@rxdrag/rxcms-models";
10
11
 
11
12
  import { newPageMetaOptions } from "./newPageMetaOptions";
@@ -39,5 +40,6 @@ export function newQueryOnePostOptions(coverSize?: ImageSize) {
39
40
  PostCategoryFields.id,
40
41
  PostCategoryFields.slug,
41
42
  PostCategoryFields.name,
42
- ]);
43
+ ])
44
+ .tags([TagFields.id, TagFields.name, TagFields.color]);
43
45
  }
@@ -10,6 +10,7 @@ import {
10
10
  ProductCategoryFields,
11
11
  ProductRelatedPivotQueryOptions,
12
12
  ImageSize,
13
+ TagFields,
13
14
  } from "@rxdrag/rxcms-models";
14
15
  import { newPageMetaOptions } from "./newPageMetaOptions";
15
16
 
@@ -92,5 +93,6 @@ export function newQueryProductOptions(imagSize?: ImageSize) {
92
93
  ProductCategoryFields.id,
93
94
  ProductCategoryFields.slug,
94
95
  ProductCategoryFields.name,
95
- ]);
96
+ ])
97
+ .tags([TagFields.id, TagFields.name, TagFields.color]);
96
98
  }
@@ -0,0 +1,17 @@
1
+ import { BulletinBoolExp, BulletinDistinctExp, BulletinOrderBy, BulletinQueryOptions, BulletinFields, Bulletin } from "@rxdrag/rxcms-models";
2
+ import { EnvVariables } from "../types";
3
+ import { queryOneEntity } from "./queryOneEntity";
4
+
5
+ export const queryBulletin = async (
6
+ envVariables: EnvVariables) => {
7
+
8
+ const bulletin = await queryOneEntity<Bulletin, BulletinBoolExp, BulletinOrderBy, BulletinDistinctExp>(
9
+ new BulletinQueryOptions([
10
+ BulletinFields.id,
11
+ BulletinFields.title,
12
+ BulletinFields.content,
13
+ ]),
14
+ envVariables
15
+ );
16
+ return bulletin;
17
+ };
@@ -46,6 +46,18 @@ export async function queryFeaturedProducts(
46
46
  _eq: envVariables.language,
47
47
  },
48
48
  },
49
+ _or: [
50
+ {
51
+ [ProductFields.isDeleted]: {
52
+ _eq: false,
53
+ },
54
+ },
55
+ {
56
+ [ProductFields.isDeleted]: {
57
+ _isNull: true,
58
+ },
59
+ },
60
+ ],
49
61
  },
50
62
  orderBy: [{ [ProductFields.seqValue]: "asc" }],
51
63
  }
@@ -53,6 +53,18 @@ export async function queryLatestPosts(
53
53
  _eq: envVariables.language,
54
54
  },
55
55
  },
56
+ _or: [
57
+ {
58
+ [PostFields.isDeleted]: {
59
+ _eq: false,
60
+ },
61
+ },
62
+ {
63
+ [PostFields.isDeleted]: {
64
+ _isNull: true,
65
+ },
66
+ },
67
+ ],
56
68
  },
57
69
  }
58
70
  )
@@ -64,8 +76,7 @@ export async function queryLatestPosts(
64
76
  .cover(
65
77
  new MediaQueryOptions().file([
66
78
  "thumbnail",
67
- `resize(width:${coverSize?.width || 480}, height:${
68
- coverSize?.height || 180
79
+ `resize(width:${coverSize?.width || 480}, height:${coverSize?.height || 180
69
80
  })`,
70
81
  ])
71
82
  )
@@ -19,6 +19,7 @@ import {
19
19
  PostCategoryOrderBy,
20
20
  PostCategoryDistinctExp,
21
21
  PostCategoryQueryOptions,
22
+ TagFields,
22
23
  } from "@rxdrag/rxcms-models";
23
24
  import { queryEntityList } from "./queryEntityList";
24
25
  import { ListResult } from "@rxdrag/entify-lib";
@@ -112,6 +113,18 @@ export async function queryPosts(
112
113
  _eq: envVariables.language,
113
114
  },
114
115
  },
116
+ _or: [
117
+ {
118
+ [PostFields.isDeleted]: {
119
+ _eq: false,
120
+ },
121
+ },
122
+ {
123
+ [PostFields.isDeleted]: {
124
+ _isNull: true,
125
+ },
126
+ },
127
+ ],
115
128
  ...where,
116
129
  },
117
130
  orderBy: [
@@ -125,7 +138,8 @@ export async function queryPosts(
125
138
  [PostFields.updatedAt]: "desc",
126
139
  },
127
140
  ],
128
- }).category([PostCategoryFields.id, PostCategoryFields.name, PostCategoryFields.slug]);
141
+ }).category([PostCategoryFields.id, PostCategoryFields.name, PostCategoryFields.slug])
142
+ .tags([TagFields.id, TagFields.name, TagFields.color]);
129
143
 
130
144
  // 只有在需要查询封面图时才添加封面图查询
131
145
  if (!selectFields || selectFields.includes("cover" as keyof Post)) {
@@ -13,6 +13,7 @@ import {
13
13
  ProductCategoryDistinctExp,
14
14
  ProductCategoryFields,
15
15
  ProductCategoryQueryOptions,
16
+ TagFields,
16
17
  } from "@rxdrag/rxcms-models";
17
18
  import { ListConditions } from "./queryPosts";
18
19
  import { queryEntityList } from "./queryEntityList";
@@ -108,13 +109,25 @@ export async function queryProducts(
108
109
  _eq: envVariables.language,
109
110
  },
110
111
  },
112
+ _or: [
113
+ {
114
+ [ProductFields.isDeleted]: {
115
+ _eq: false,
116
+ },
117
+ },
118
+ {
119
+ [ProductFields.isDeleted]: {
120
+ _isNull: true,
121
+ },
122
+ },
123
+ ],
111
124
  ...where,
112
125
  },
113
126
  orderBy: orderBy || [
114
127
  { [ProductFields.seqValue]: "asc" },
115
128
  { [ProductFields.updatedAt]: "desc" },
116
129
  ],
117
- });
130
+ }).tags([TagFields.id, TagFields.name, TagFields.color]);
118
131
 
119
132
  // 只有在不指定字段或需要查询媒体时才添加媒体查询
120
133
  if (!addonFields || !addonFields.includes("slug" as keyof Product)) {
@@ -18,6 +18,18 @@ export async function queryProductsInMenu(envVariables: EnvVariables) {
18
18
  _eq: envVariables.language,
19
19
  },
20
20
  },
21
+ _or: [
22
+ {
23
+ [ProductFields.isDeleted]: {
24
+ _eq: false,
25
+ },
26
+ },
27
+ {
28
+ [ProductFields.isDeleted]: {
29
+ _isNull: true,
30
+ },
31
+ },
32
+ ],
21
33
  showInNavMenu: {
22
34
  _eq: true,
23
35
  },
@@ -0,0 +1,30 @@
1
+ import { Bulletin as BulletinModel } from "@rxdrag/rxcms-models";
2
+ import { useEffect, useState } from "react";
3
+
4
+ export function Bulletin(props: { className?: string }) {
5
+ const { className, ...rest } = props;
6
+ const [bulletin, setBulletin] = useState<BulletinModel | null>(null);
7
+
8
+ useEffect(() => {
9
+ fetch("/api/get-bulletin")
10
+ .then((res) => res.json())
11
+ .then((res) => {
12
+ if (res.success) {
13
+ setBulletin(res.data);
14
+ }
15
+ })
16
+ .catch((err) => {
17
+ console.error("Failed to fetch bulletin", err);
18
+ });
19
+ }, []);
20
+
21
+ console.log("====>bulletin", bulletin)
22
+
23
+ if (!bulletin) return null;
24
+
25
+ return (
26
+ <div className={className} {...rest}>
27
+ {bulletin.content}
28
+ </div>
29
+ );
30
+ }
@@ -11,6 +11,7 @@ export * from "./SearchInput";
11
11
  export * from "./ToTop";
12
12
  export * from "./BackgroundVideoPlayer";
13
13
  export * from "./BackgroundHlsVideoPlayer";
14
+ export * from "./Bulletin";
14
15
  export * from "./ReactModalTrigger";
15
16
  export * from "./ReactVideoPlayer";
16
17