jmash-core-mp 0.1.9 → 0.1.10

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.
@@ -1,8 +1,11 @@
1
- import { CmsSiteList, CmsChannelReq, CmsChannelList, CmsContentInfoReq, CmsContentInfoModel } from "./types";
1
+ import { CmsSiteList, CmsChannelReq, CmsChannelList, CmsInfoReq, CmsInfoPage, CmsInfoKey, CmsInfoModel, CmsInfoContentReq, CmsInfoContentList, CmsContentInfoReq, CmsContentInfoModel } from "./types";
2
2
  import { ResponseData } from "../../types/core";
3
3
  declare class CmsApiImpl {
4
4
  findCmsSiteList(tenant: string): Promise<ResponseData<CmsSiteList>>;
5
5
  findCmsChannelList(data: CmsChannelReq): Promise<ResponseData<CmsChannelList>>;
6
+ findCmsInfoPage(data: CmsInfoReq): Promise<ResponseData<CmsInfoPage>>;
7
+ findCmsInfo(data: CmsInfoKey): Promise<ResponseData<CmsInfoModel>>;
8
+ findCmsInfoContent(data: CmsInfoContentReq): Promise<ResponseData<CmsInfoContentList>>;
6
9
  findCmsContentInfo(data: CmsContentInfoReq): Promise<ResponseData<CmsContentInfoModel>>;
7
10
  }
8
11
  declare const cmsApi: CmsApiImpl;
@@ -23,17 +23,42 @@ class CmsApiImpl {
23
23
  data,
24
24
  });
25
25
  }
26
+ // 查询翻页信息信息列表
27
+ findCmsInfoPage(data) {
28
+ if (data) {
29
+ data.hasStatus = data.status !== undefined;
30
+ data.hasIsImg = data.isImg !== undefined;
31
+ }
32
+ grpc.clearEmpty(data);
33
+ return mpx.xfetch.fetch({
34
+ url: "/v1/front/cms/cms_info/page/" + data.tenant,
35
+ method: "GET",
36
+ data,
37
+ });
38
+ }
39
+ // 查询信息主表
40
+ findCmsInfo(data) {
41
+ grpc.clearEmpty(data);
42
+ return mpx.xfetch.fetch({
43
+ url: "/v1/front/cms/cms_info/id/" + data.tenant + "/" + data.infoId,
44
+ method: "GET",
45
+ });
46
+ }
47
+ // 查询列表信息信息内容
48
+ findCmsInfoContent(data) {
49
+ grpc.clearEmpty(data);
50
+ return mpx.xfetch.fetch({
51
+ url: "/v1/front/cms/cms_info_content/list/" + data.tenant,
52
+ method: "GET",
53
+ data,
54
+ });
55
+ }
26
56
  // 根据栏目别名查询翻页信息信息主表-单页栏目内容
27
57
  findCmsContentInfo(data) {
28
58
  data.tenant = data.tenant || config.tenant;
29
59
  grpc.clearEmpty(data);
30
60
  return mpx.xfetch.fetch({
31
- url: "/v1/front/cms/cms_info/alias/" +
32
- data.tenant +
33
- "/" +
34
- data.siteId +
35
- "/" +
36
- data.channelAlias,
61
+ url: `/v1/front/cms/cms_info/alias/${data.tenant}/${data.siteId}/${data.channelAlias}`,
37
62
  method: "GET",
38
63
  });
39
64
  }
@@ -15,6 +15,9 @@ export interface CmsChannelReq {
15
15
  hasIsOpen?: boolean;
16
16
  channelId?: string;
17
17
  }
18
+ export interface CmsChannelList {
19
+ results: Array<CmsChannelModel>;
20
+ }
18
21
  export interface CmsChannelModel {
19
22
  channelId: string;
20
23
  siteId?: string;
@@ -31,17 +34,31 @@ export interface CmsChannelModel {
31
34
  url: string;
32
35
  type?: string;
33
36
  }
34
- export interface CmsChannelList {
35
- results: Array<CmsChannelModel>;
36
- }
37
- export interface CmsContentInfoReq {
37
+ export interface CmsInfoReq {
38
38
  tenant?: string;
39
+ curPage?: number;
40
+ pageSize?: number;
39
41
  siteId?: string;
40
- channelAlias: string;
42
+ channelId?: string;
43
+ channelAlias?: string;
44
+ likeInfoTitle?: string;
45
+ deleted?: boolean;
46
+ hasStatus?: boolean;
47
+ status?: string;
48
+ hasIsImg?: boolean;
49
+ isImg?: boolean;
41
50
  }
42
- export interface CmsContentInfoModel {
43
- cmsInfo?: CmsInfoModel;
44
- infoContentResults?: Array<CmsInfoContentModel>;
51
+ export interface CmsInfoPage {
52
+ results?: Array<CmsInfoModel>;
53
+ curPage?: number;
54
+ pageSize?: number;
55
+ totalSize?: number;
56
+ subTotalDto?: CmsInfoModelTotal;
57
+ totalDto?: CmsInfoModelTotal;
58
+ pageCount?: number;
59
+ }
60
+ export interface CmsInfoModelTotal {
61
+ totalSize?: number;
45
62
  }
46
63
  export interface CmsInfoModel {
47
64
  infoId?: string;
@@ -58,6 +75,17 @@ export interface CmsInfoModel {
58
75
  sourceName?: string;
59
76
  siteId: string;
60
77
  }
78
+ export interface CmsInfoKey {
79
+ tenant?: string;
80
+ infoId: string;
81
+ }
82
+ export interface CmsInfoContentReq {
83
+ tenant?: string;
84
+ infoId?: string;
85
+ }
86
+ export interface CmsInfoContentList {
87
+ results: Array<CmsInfoContentModel>;
88
+ }
61
89
  export interface CmsInfoContentModel {
62
90
  imagePath?: Array<string>;
63
91
  videoPath?: Array<string>;
@@ -70,3 +98,12 @@ export interface CmsInfoContentModel {
70
98
  path: string;
71
99
  }[];
72
100
  }
101
+ export interface CmsContentInfoReq {
102
+ tenant?: string;
103
+ siteId?: string;
104
+ channelAlias: string;
105
+ }
106
+ export interface CmsContentInfoModel {
107
+ cmsInfo?: CmsInfoModel;
108
+ infoContentResults?: Array<CmsInfoContentModel>;
109
+ }
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type { AppConfig, ResponseData, ValidateData, EventBase, EventTarget, CanvasResponse } from "./types/core";
1
+ export type { AppConfig, ResponseData, ValidateData, EventBase, EventTarget, CanvasResponse, } from "./types/core";
2
2
  export type { Entry, DictEntryModel } from "./api/dict/types";
3
3
  export { EntryDict, EnumDict } from "./api/dicts";
4
4
  export { mpxFetch } from "./utils/request";
@@ -8,6 +8,8 @@ export { db } from "./utils/db";
8
8
  export { useUserStore } from "./store/user";
9
9
  export { authApi } from "./api/auth";
10
10
  export { cmsApi } from "./api/cms";
11
+ export type { CmsInfoModel, CmsInfoContentModel } from "./api/cms/types";
11
12
  export { dictApi } from "./api/dict";
12
13
  export { fileApi } from "./api/files";
13
14
  export { net } from "./utils/net";
15
+ export { getHeight, formatDateTime, validateRules, validateRequired, } from "./utils/common";
package/lib/index.js CHANGED
@@ -9,3 +9,4 @@ export { cmsApi } from "./api/cms";
9
9
  export { dictApi } from "./api/dict";
10
10
  export { fileApi } from "./api/files";
11
11
  export { net } from "./utils/net";
12
+ export { getHeight, formatDateTime, validateRules, validateRequired, } from "./utils/common";
@@ -0,0 +1,35 @@
1
+ export declare const getHeight: () => {
2
+ navigationPaddingHeight: number;
3
+ topHeight: number;
4
+ bottomHeight: number;
5
+ MenuButtonRight: number;
6
+ MenuButtonLeft: number;
7
+ MenuButtonTop: number;
8
+ MenuButtonBottom: number;
9
+ MenuButtonWidth: number;
10
+ MenuButtonHeight: number;
11
+ MenuButtonBounding: number;
12
+ screenWidth: number;
13
+ screenHeight: number;
14
+ computeHeightFn: (height: number, stackingHeight: number) => number;
15
+ addition: (height: number, addHeight: number) => number;
16
+ };
17
+ /**
18
+ * 格式化日期时间字符串
19
+ * @param dateTimeString 日期时间字符串
20
+ * @returns 格式化后的日期时间字符串
21
+ */
22
+ export declare const formatDateTime: (dateTimeString: string, format?: any) => string;
23
+ /**
24
+ * 正则校验规则
25
+ * @param {string} value 需要校验的值
26
+ * @param {string} message 错误提示信息
27
+ * @param {string} rules 正则校验规则
28
+ */
29
+ export declare const validateRules: (value: string, message: string, rules: any) => boolean;
30
+ /**
31
+ * 校验必填项
32
+ * @param {string} value 需要校验的值
33
+ * @param {string} message 错误提示信息
34
+ */
35
+ export declare const validateRequired: (value: string | number, message: string) => boolean;
@@ -0,0 +1,163 @@
1
+ import mpx from "@mpxjs/core";
2
+ // 获取不同手机的顶部/底部高度
3
+ export const getHeight = () => {
4
+ // 手机顶部电量等信息的高度+7 状态栏的高度+7
5
+ let navigationPaddingHeight = 0;
6
+ // 顶部整体高度(包括胶囊球高度)
7
+ let topHeight = 0;
8
+ // 手机底部的安全距离
9
+ let bottomHeight = 0;
10
+ // 胶囊球右边界到手机左侧的坐标-坐标信息以屏幕左上角为原点
11
+ let MenuButtonRight = 0;
12
+ // 胶囊球左边界到手机左侧的坐标-坐标信息以屏幕左上角为原点
13
+ let MenuButtonLeft = 0;
14
+ // 胶囊球上边界到手机顶部的坐标-坐标信息以屏幕左上角为原点
15
+ let MenuButtonTop = 0;
16
+ // 胶囊球下边界到手机顶部的坐标-坐标信息以屏幕左上角为原点
17
+ let MenuButtonBottom = 0;
18
+ // 胶囊球宽度
19
+ let MenuButtonWidth = 0;
20
+ // 胶囊球高度
21
+ let MenuButtonHeight = 0;
22
+ // 状态栏的高度
23
+ let MenuButtonBounding = 0;
24
+ // 屏幕宽度
25
+ let screenWidth = 0;
26
+ // 屏幕高度
27
+ let screenHeight = 0;
28
+ try {
29
+ MenuButtonHeight = mpx.getMenuButtonBoundingClientRect().height
30
+ ? mpx.getMenuButtonBoundingClientRect().height
31
+ : 0;
32
+ navigationPaddingHeight =
33
+ mpx.getWindowInfo().statusBarHeight + 7
34
+ ? mpx.getWindowInfo().statusBarHeight + 7
35
+ : 0;
36
+ topHeight = MenuButtonHeight + navigationPaddingHeight;
37
+ bottomHeight =
38
+ mpx.getWindowInfo().screenHeight - mpx.getWindowInfo().safeArea.bottom
39
+ ? mpx.getWindowInfo().screenHeight - mpx.getWindowInfo().safeArea.bottom
40
+ : 0;
41
+ MenuButtonRight = mpx.getMenuButtonBoundingClientRect().right;
42
+ MenuButtonLeft = mpx.getMenuButtonBoundingClientRect().left;
43
+ MenuButtonTop = mpx.getMenuButtonBoundingClientRect().top;
44
+ MenuButtonBottom = mpx.getMenuButtonBoundingClientRect().bottom;
45
+ MenuButtonWidth = mpx.getMenuButtonBoundingClientRect().width;
46
+ MenuButtonBounding = mpx.getWindowInfo().statusBarHeight;
47
+ screenWidth = mpx.getWindowInfo().screenWidth;
48
+ screenHeight = mpx.getWindowInfo().screenHeight;
49
+ }
50
+ catch (error) {
51
+ console.log("getHeight", error);
52
+ }
53
+ /**
54
+ * 判断手机型号如果没有底部横线的时候,添加的默认高度
55
+ * @param height 本身计算的高度
56
+ * @param stackingHeight 需要叠加的高度
57
+ */
58
+ function computeHeightFn(height, stackingHeight) {
59
+ return height !== 0 ? height : height + stackingHeight;
60
+ }
61
+ /**
62
+ * 原有基础上添加高度
63
+ * @param height 本身计算的高度
64
+ * @param addHeight 相加的高度
65
+ */
66
+ function addition(height, addHeight) {
67
+ return height + addHeight;
68
+ }
69
+ return {
70
+ navigationPaddingHeight,
71
+ topHeight,
72
+ bottomHeight,
73
+ MenuButtonRight,
74
+ MenuButtonLeft,
75
+ MenuButtonTop,
76
+ MenuButtonBottom,
77
+ MenuButtonWidth,
78
+ MenuButtonHeight,
79
+ MenuButtonBounding,
80
+ screenWidth,
81
+ screenHeight,
82
+ computeHeightFn,
83
+ addition,
84
+ };
85
+ };
86
+ /**
87
+ * 格式化日期时间字符串
88
+ * @param dateTimeString 日期时间字符串
89
+ * @returns 格式化后的日期时间字符串
90
+ */
91
+ export const formatDateTime = (dateTimeString, format) => {
92
+ const date = new Date(dateTimeString);
93
+ // 如果日期无效(即日期为Invalid Date),则返回一个空字符串或默认值
94
+ if (isNaN(date.getTime())) {
95
+ return "";
96
+ }
97
+ const year = date.getFullYear();
98
+ const month = ("0" + (date.getMonth() + 1)).slice(-2);
99
+ const day = ("0" + date.getDate()).slice(-2);
100
+ const hours = ("0" + date.getHours()).slice(-2);
101
+ const minutes = ("0" + date.getMinutes()).slice(-2);
102
+ const seconds = ("0" + date.getSeconds()).slice(-2);
103
+ if (format === "YYYY-MM-DD HH:mm:ss") {
104
+ return (year +
105
+ "-" +
106
+ month +
107
+ "-" +
108
+ day +
109
+ " " +
110
+ hours +
111
+ ":" +
112
+ minutes +
113
+ ":" +
114
+ seconds);
115
+ }
116
+ if (format === "YYYY-MM-DD HH:mm") {
117
+ return year + "-" + month + "-" + day + " " + hours + ":" + minutes;
118
+ }
119
+ if (format === "YYYY-MM-DD") {
120
+ return year + "-" + month + "-" + day;
121
+ }
122
+ if (format === "HH:mm:ss") {
123
+ return hours + ":" + minutes + ":" + seconds;
124
+ }
125
+ return "";
126
+ };
127
+ /**
128
+ * 正则校验规则
129
+ * @param {string} value 需要校验的值
130
+ * @param {string} message 错误提示信息
131
+ * @param {string} rules 正则校验规则
132
+ */
133
+ export const validateRules = (value, message, rules) => {
134
+ if (value && !rules.test(value)) {
135
+ // 显示错误提示
136
+ mpx.showToast({
137
+ title: message,
138
+ icon: "none",
139
+ duration: 2000,
140
+ });
141
+ return false;
142
+ }
143
+ return true;
144
+ };
145
+ /**
146
+ * 校验必填项
147
+ * @param {string} value 需要校验的值
148
+ * @param {string} message 错误提示信息
149
+ */
150
+ export const validateRequired = (value, message) => {
151
+ console.log(value, message);
152
+ const valueStr = typeof value === "number" ? String(value) : value;
153
+ if (!valueStr || valueStr.trim() === "") {
154
+ // 显示错误提示
155
+ mpx.showToast({
156
+ title: message,
157
+ icon: "none",
158
+ duration: 2000,
159
+ });
160
+ return false;
161
+ }
162
+ return true;
163
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jmash-core-mp",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "private": false,
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -2,6 +2,12 @@ import {
2
2
  CmsSiteList,
3
3
  CmsChannelReq,
4
4
  CmsChannelList,
5
+ CmsInfoReq,
6
+ CmsInfoPage,
7
+ CmsInfoKey,
8
+ CmsInfoModel,
9
+ CmsInfoContentReq,
10
+ CmsInfoContentList,
5
11
  CmsContentInfoReq,
6
12
  CmsContentInfoModel,
7
13
  } from "./types";
@@ -9,6 +15,7 @@ import { ResponseData } from "../../types/core";
9
15
  import { grpc } from "../../utils/grpc";
10
16
  import { config } from "../../utils/config";
11
17
  import mpx from "@mpxjs/core";
18
+
12
19
  // 获取网站内容信息
13
20
  class CmsApiImpl {
14
21
  // 查询企业官网、微网站列表
@@ -35,6 +42,41 @@ class CmsApiImpl {
35
42
  });
36
43
  }
37
44
 
45
+ // 查询翻页信息信息列表
46
+ findCmsInfoPage(data: CmsInfoReq): Promise<ResponseData<CmsInfoPage>> {
47
+ if (data) {
48
+ data.hasStatus = data.status !== undefined;
49
+ data.hasIsImg = data.isImg !== undefined;
50
+ }
51
+ grpc.clearEmpty(data);
52
+ return mpx.xfetch.fetch({
53
+ url: "/v1/front/cms/cms_info/page/" + data.tenant,
54
+ method: "GET",
55
+ data,
56
+ });
57
+ }
58
+
59
+ // 查询信息主表
60
+ findCmsInfo(data: CmsInfoKey): Promise<ResponseData<CmsInfoModel>> {
61
+ grpc.clearEmpty(data);
62
+ return mpx.xfetch.fetch({
63
+ url: "/v1/front/cms/cms_info/id/" + data.tenant + "/" + data.infoId,
64
+ method: "GET",
65
+ });
66
+ }
67
+
68
+ // 查询列表信息信息内容
69
+ findCmsInfoContent(
70
+ data: CmsInfoContentReq
71
+ ): Promise<ResponseData<CmsInfoContentList>> {
72
+ grpc.clearEmpty(data);
73
+ return mpx.xfetch.fetch({
74
+ url: "/v1/front/cms/cms_info_content/list/" + data.tenant,
75
+ method: "GET",
76
+ data,
77
+ });
78
+ }
79
+
38
80
  // 根据栏目别名查询翻页信息信息主表-单页栏目内容
39
81
  findCmsContentInfo(
40
82
  data: CmsContentInfoReq
@@ -42,13 +84,7 @@ class CmsApiImpl {
42
84
  data.tenant = data.tenant || config.tenant;
43
85
  grpc.clearEmpty(data);
44
86
  return mpx.xfetch.fetch({
45
- url:
46
- "/v1/front/cms/cms_info/alias/" +
47
- data.tenant +
48
- "/" +
49
- data.siteId +
50
- "/" +
51
- data.channelAlias,
87
+ url: `/v1/front/cms/cms_info/alias/${data.tenant}/${data.siteId}/${data.channelAlias}`,
52
88
  method: "GET",
53
89
  });
54
90
  }
@@ -3,7 +3,6 @@ export interface CmsSiteList {
3
3
  // 当前内容
4
4
  results: Array<CmsSiteModel>;
5
5
  }
6
-
7
6
  // 网站站点实体
8
7
  export interface CmsSiteModel {
9
8
  // 站点ID
@@ -31,6 +30,11 @@ export interface CmsChannelReq {
31
30
  // 栏目ID
32
31
  channelId?: string;
33
32
  }
33
+ // 网站栏目列表
34
+ export interface CmsChannelList {
35
+ // 当前页内容
36
+ results: Array<CmsChannelModel>;
37
+ }
34
38
  // 网站栏目实体
35
39
  export interface CmsChannelModel {
36
40
  // 栏目ID
@@ -62,30 +66,56 @@ export interface CmsChannelModel {
62
66
  // 类型
63
67
  type?: string;
64
68
  }
65
- // 网站栏目列表
66
- export interface CmsChannelList {
67
- // 当前页内容
68
- results: Array<CmsChannelModel>;
69
- }
70
69
 
71
- // 根据栏目别名查询翻页信息信息主表-单页栏目内容
72
- export interface CmsContentInfoReq {
70
+ // 查询翻页信息信息列表
71
+ export interface CmsInfoReq {
73
72
  // 租户
74
73
  tenant?: string;
74
+ // 当前页码
75
+ curPage?: number;
76
+ // 页尺寸
77
+ pageSize?: number;
75
78
  // 站点ID
76
79
  siteId?: string;
80
+ // 栏目ID
81
+ channelId?: string;
77
82
  // 栏目别名
78
- channelAlias: string;
83
+ channelAlias?: string;
84
+ // 文章标题
85
+ likeInfoTitle?: string;
86
+ // 默认未删除数据,回收站数据
87
+ deleted?: boolean;
88
+ // 是否包含文章状态
89
+ hasStatus?: boolean;
90
+ // 文章状态
91
+ status?: string;
92
+ // 受否查询带有图片的文章
93
+ hasIsImg?: boolean;
94
+ // 是否包含新闻图片
95
+ isImg?: boolean;
79
96
  }
80
-
81
- // 文章详细信息
82
- export interface CmsContentInfoModel {
83
- // cms信息
84
- cmsInfo?: CmsInfoModel;
85
- // 内容信息
86
- infoContentResults?: Array<CmsInfoContentModel>;
97
+ // 信息主表分页
98
+ export interface CmsInfoPage {
99
+ // 当前页内容
100
+ results?: Array<CmsInfoModel>;
101
+ // 当前页码
102
+ curPage?: number;
103
+ // 页尺寸
104
+ pageSize?: number;
105
+ // 总记录数
106
+ totalSize?: number;
107
+ // 本页小计
108
+ subTotalDto?: CmsInfoModelTotal;
109
+ // 合计
110
+ totalDto?: CmsInfoModelTotal;
111
+ // 页面数
112
+ pageCount?: number;
113
+ }
114
+ // 合计
115
+ export interface CmsInfoModelTotal {
116
+ // 总记录数
117
+ totalSize?: number;
87
118
  }
88
-
89
119
  // 信息主表实体
90
120
  export interface CmsInfoModel {
91
121
  // 内容ID
@@ -116,6 +146,26 @@ export interface CmsInfoModel {
116
146
  siteId: string;
117
147
  }
118
148
 
149
+ // 信息主表主键
150
+ export interface CmsInfoKey {
151
+ // 租户
152
+ tenant?: string;
153
+ // 内容ID
154
+ infoId: string;
155
+ }
156
+
157
+ // 信息内容查询
158
+ export interface CmsInfoContentReq {
159
+ // 租户
160
+ tenant?: string;
161
+ // 信息ID
162
+ infoId?: string;
163
+ }
164
+ // 信息内容列表
165
+ export interface CmsInfoContentList {
166
+ // 当前页内容
167
+ results: Array<CmsInfoContentModel>;
168
+ }
119
169
  // 信息内容实体
120
170
  export interface CmsInfoContentModel {
121
171
  // 图片数组
@@ -135,3 +185,20 @@ export interface CmsInfoContentModel {
135
185
  // 信息内容数组
136
186
  infoContentList?: { path: string }[];
137
187
  }
188
+
189
+ // 根据栏目别名查询翻页信息信息主表-单页栏目内容
190
+ export interface CmsContentInfoReq {
191
+ // 租户
192
+ tenant?: string;
193
+ // 站点ID
194
+ siteId?: string;
195
+ // 栏目别名
196
+ channelAlias: string;
197
+ }
198
+ // 文章详细信息
199
+ export interface CmsContentInfoModel {
200
+ // cms信息
201
+ cmsInfo?: CmsInfoModel;
202
+ // 内容信息
203
+ infoContentResults?: Array<CmsInfoContentModel>;
204
+ }