jmash-core-mp 0.1.76 → 0.1.78

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 (201) hide show
  1. package/.editorconfig +9 -9
  2. package/.gitignore +8 -0
  3. package/.npmignore +44 -0
  4. package/README.md +60 -60
  5. package/babel.config.json +34 -34
  6. package/eslint.config.mjs +7 -7
  7. package/lib/api/auth/index.d.ts +22 -22
  8. package/lib/api/auth/index.js +211 -211
  9. package/lib/api/auth/types.d.ts +90 -90
  10. package/lib/api/auth/types.js +9 -9
  11. package/lib/api/cms/index.d.ts +20 -20
  12. package/lib/api/cms/index.js +161 -161
  13. package/lib/api/cms/types.d.ts +201 -201
  14. package/lib/api/cms/types.js +1 -1
  15. package/lib/api/constant.d.ts +6 -6
  16. package/lib/api/constant.js +8 -8
  17. package/lib/api/dict/index.d.ts +24 -24
  18. package/lib/api/dict/index.js +51 -51
  19. package/lib/api/dict/types.d.ts +40 -40
  20. package/lib/api/dict/types.js +1 -1
  21. package/lib/api/dicts.d.ts +32 -32
  22. package/lib/api/dicts.js +118 -118
  23. package/lib/api/files/index.d.ts +25 -25
  24. package/lib/api/files/index.js +134 -134
  25. package/lib/api/files/types.d.ts +38 -38
  26. package/lib/api/files/types.js +1 -1
  27. package/lib/api/index.d.ts +5 -5
  28. package/lib/api/index.js +8 -8
  29. package/lib/api/myorgan/index.d.ts +8 -8
  30. package/lib/api/myorgan/index.js +24 -24
  31. package/lib/api/myorgan/types.d.ts +22 -22
  32. package/lib/api/myorgan/types.js +1 -1
  33. package/lib/api/region/index.d.ts +7 -7
  34. package/lib/api/region/index.js +20 -20
  35. package/lib/api/region/types.d.ts +19 -19
  36. package/lib/api/region/types.js +1 -1
  37. package/lib/api/shop/index.d.ts +11 -11
  38. package/lib/api/shop/index.js +53 -53
  39. package/lib/api/shop/types.d.ts +123 -123
  40. package/lib/api/shop/types.js +1 -1
  41. package/lib/api/storage/index.d.ts +11 -11
  42. package/lib/api/storage/index.js +53 -53
  43. package/lib/api/storage/types.d.ts +39 -39
  44. package/lib/api/storage/types.js +1 -1
  45. package/lib/api/types.d.ts +43 -43
  46. package/lib/api/types.js +1 -1
  47. package/lib/components/organ/browser-organ-list.mpx.d.ts +1 -1
  48. package/lib/components/organ/my-organ-list.mpx.d.ts +1 -1
  49. package/lib/components/{auth-user/jmash-update-user.mpx.d.ts → organ/organ-search.mpx.d.ts} +1 -1
  50. package/lib/components/{auth-user/jmash-user.mpx.d.ts → shop/branch-search.mpx.d.ts} +1 -1
  51. package/lib/components/{core/jmash-login.mpx.d.ts → shop/shop-search.mpx.d.ts} +1 -1
  52. package/lib/index.d.ts +28 -28
  53. package/lib/index.js +23 -23
  54. package/lib/{packages/pages/auth/setting-page.mpx.d.ts → pages/branch-search.mpx.d.ts} +1 -1
  55. package/lib/pages/organ-search.mpx.d.ts +1 -0
  56. package/lib/pages/organ.mpx.d.ts +1 -1
  57. package/lib/pages/shop-search.mpx.d.ts +1 -0
  58. package/lib/store/organ.d.ts +19 -19
  59. package/lib/store/organ.js +83 -83
  60. package/lib/store/shop.d.ts +18 -18
  61. package/lib/store/shop.js +104 -104
  62. package/lib/store/user.d.ts +35 -35
  63. package/lib/store/user.js +243 -243
  64. package/lib/utils/common.d.ts +37 -35
  65. package/lib/utils/common.js +178 -165
  66. package/lib/utils/config.d.ts +5 -5
  67. package/lib/utils/config.js +36 -36
  68. package/lib/utils/db.d.ts +52 -52
  69. package/lib/utils/db.js +202 -202
  70. package/lib/utils/grpc.d.ts +5 -5
  71. package/lib/utils/grpc.js +20 -20
  72. package/lib/utils/net.d.ts +7 -7
  73. package/lib/utils/net.js +15 -15
  74. package/lib/utils/request.d.ts +2 -2
  75. package/lib/utils/request.js +114 -114
  76. package/lib/utils/share.d.ts +16 -16
  77. package/lib/utils/share.js +196 -196
  78. package/mpx.config.js +38 -38
  79. package/package.json +1 -1
  80. package/pnpm-workspace.yaml +5 -0
  81. package/postcss.config.js +11 -11
  82. package/project.config.json +24 -24
  83. package/project.private.config.json +13 -13
  84. package/public/index.html +15 -15
  85. package/src/api/auth/index.ts +241 -241
  86. package/src/api/auth/types.ts +173 -173
  87. package/src/api/cms/index.ts +218 -218
  88. package/src/api/cms/types.ts +385 -385
  89. package/src/api/constant.ts +8 -8
  90. package/src/api/dict/index.ts +68 -68
  91. package/src/api/dict/types.ts +73 -73
  92. package/src/api/dicts.ts +132 -132
  93. package/src/api/files/index.ts +162 -162
  94. package/src/api/files/types.ts +67 -67
  95. package/src/api/index.ts +15 -15
  96. package/src/api/myorgan/index.ts +29 -29
  97. package/src/api/myorgan/types.ts +42 -42
  98. package/src/api/region/index.ts +24 -24
  99. package/src/api/region/types.ts +36 -36
  100. package/src/api/shop/index.ts +74 -74
  101. package/src/api/shop/types.ts +244 -244
  102. package/src/api/storage/index.ts +74 -74
  103. package/src/api/storage/types.ts +74 -74
  104. package/src/api/types.ts +74 -74
  105. package/src/app.mpx +78 -78
  106. package/src/components/auth-user/jmash-logout.mpx +93 -93
  107. package/src/components/auth-user/jmash-update-user.mpx +387 -387
  108. package/src/components/auth-user/jmash-update-user.web.mpx +367 -367
  109. package/src/components/auth-user/jmash-user.mpx +310 -310
  110. package/src/components/cms/jmash-cms-activity-item.mpx +207 -207
  111. package/src/components/cms/jmash-cms-activity-list.mpx +357 -357
  112. package/src/components/cms/jmash-cms-article-item.mpx +221 -221
  113. package/src/components/cms/jmash-cms-article-list.mpx +248 -248
  114. package/src/components/cms/jmash-cms-article-view.mpx +131 -131
  115. package/src/components/cms/jmash-cms-article.mpx +231 -231
  116. package/src/components/cms/jmash-cms-like.mpx +151 -151
  117. package/src/components/cms/jmash-cms-location-list.mpx +286 -286
  118. package/src/components/cms/jmash-cms-location.mpx +256 -256
  119. package/src/components/cms/jmash-cms-product-item.mpx +185 -185
  120. package/src/components/cms/jmash-cms-product-list.mpx +230 -230
  121. package/src/components/common/jmash-avatar-edit.mpx +154 -154
  122. package/src/components/common/jmash-cascader-region.mpx +118 -118
  123. package/src/components/common/jmash-cell-group.mpx +206 -206
  124. package/src/components/common/jmash-code-interest-popup.mpx +223 -223
  125. package/src/components/common/jmash-form-cell.mpx +491 -525
  126. package/src/components/common/jmash-menu.mpx +129 -129
  127. package/src/components/common/jmash-none-data.mpx +95 -95
  128. package/src/components/common/jmash-pic-swiper.mpx +72 -72
  129. package/src/components/common/jmash-popup.mpx +138 -138
  130. package/src/components/common/jmash-search.mpx +130 -130
  131. package/src/components/common/jmash-single-btn.mpx +53 -53
  132. package/src/components/common/jmash-stepper.mpx +236 -236
  133. package/src/components/common/jmash-swipe-cell.mpx +153 -153
  134. package/src/components/common/jmash-tab-bar.mpx +58 -58
  135. package/src/components/common/jmash-textarea.mpx +88 -88
  136. package/src/components/common/jmash-top-navigation.mpx +203 -203
  137. package/src/components/common/jmash-upload-picture.mpx +199 -199
  138. package/src/components/core/jmash-cms-protocol.mpx +72 -72
  139. package/src/components/core/jmash-login.ali.mpx +284 -284
  140. package/src/components/core/jmash-login.mpx +378 -378
  141. package/src/components/core/jmash-login.web.mpx +420 -420
  142. package/src/components/core/jmash-popup-login.ali.mpx +312 -312
  143. package/src/components/core/jmash-popup-login.mpx +414 -416
  144. package/src/components/core/jmash-popup-login.web.mpx +389 -389
  145. package/src/components/organ/browser-organ-list.mpx +66 -66
  146. package/src/components/organ/my-organ-list.mpx +67 -67
  147. package/src/components/organ/organ-item.mpx +124 -124
  148. package/src/components/organ/organ-search.mpx +148 -148
  149. package/src/components/organ/organ-selected-item.mpx +88 -88
  150. package/src/components/shop/branch-item.mpx +111 -111
  151. package/src/components/shop/branch-search.mpx +142 -142
  152. package/src/components/shop/shop-item.mpx +112 -112
  153. package/src/components/shop/shop-search.mpx +142 -142
  154. package/src/components/shop/shop-selected-item.mpx +89 -89
  155. package/src/custom-tab-bar/index.mpx +10 -10
  156. package/src/global.d.ts +11 -11
  157. package/src/index.ts +94 -94
  158. package/src/packages/index.mpx +16 -16
  159. package/src/packages/pages/auth/cms-protocol.mpx +35 -35
  160. package/src/packages/pages/auth/login.mpx +62 -62
  161. package/src/packages/pages/auth/setting-page.mpx +134 -134
  162. package/src/packages/pages/auth/update-user.mpx +17 -17
  163. package/src/packages/pages/cms/cms-activity-list.mpx +86 -86
  164. package/src/packages/pages/cms/cms-article-list.mpx +88 -88
  165. package/src/packages/pages/cms/cms-article.mpx +32 -32
  166. package/src/packages/pages/cms/cms-location-list.mpx +83 -83
  167. package/src/packages/pages/cms/cms-location.mpx +32 -32
  168. package/src/packages/pages/cms/cms-product-list.mpx +88 -88
  169. package/src/packages/pages/share/scan.mpx +103 -103
  170. package/src/pages/basic-component.mpx +30 -30
  171. package/src/pages/branch-search.mpx +60 -60
  172. package/src/pages/half-home.mpx +58 -58
  173. package/src/pages/home.mpx +54 -54
  174. package/src/pages/home2.mpx +45 -45
  175. package/src/pages/index.mpx +43 -43
  176. package/src/pages/organ-search.mpx +60 -60
  177. package/src/pages/organ.mpx +105 -105
  178. package/src/pages/shop-search.mpx +60 -60
  179. package/src/pages/tabbar/home.mpx +114 -114
  180. package/src/pages/tabbar/mall.mpx +87 -87
  181. package/src/pages/tabbar/my.mpx +79 -79
  182. package/src/pages/tabbar/organ.mpx +86 -86
  183. package/src/store/organ.ts +100 -100
  184. package/src/store/shop.ts +130 -130
  185. package/src/store/user.ts +288 -288
  186. package/src/styles/index.scss +20 -20
  187. package/src/styles/vars.scss +27 -27
  188. package/src/utils/common.ts +196 -178
  189. package/src/utils/config.ts +43 -43
  190. package/src/utils/db.ts +229 -229
  191. package/src/utils/grpc.ts +21 -21
  192. package/src/utils/net.ts +18 -18
  193. package/src/utils/request.ts +126 -126
  194. package/src/utils/share.ts +194 -194
  195. package/static/ali/mini.project.json +4 -4
  196. package/static/dd/project.config.json +15 -15
  197. package/static/swan/project.swan.json +14 -14
  198. package/static/tt/project.config.json +11 -11
  199. package/static/wx/project.config.json +40 -40
  200. package/uno.config.js +9 -9
  201. package/lib/packages/pages/share/scan.mpx.d.ts +0 -1
@@ -1,32 +1,32 @@
1
- import { Entry, DictEntryModel, DictEntryLayModel } from "./dict/types";
2
- export declare class EnumDict {
3
- module: string;
4
- enumClass: string;
5
- type: number;
6
- values: Entry[];
7
- constructor(module: string, enumClass: string, type?: number);
8
- useEnumValues(): Promise<Entry[]>;
9
- getEnumValue(key: string): string;
10
- }
11
- export declare class EntryDict {
12
- typeCode: string;
13
- enable?: boolean;
14
- values: DictEntryModel[];
15
- constructor(typeCode: string, enable?: boolean);
16
- useDictValues(): Promise<DictEntryModel[]>;
17
- getDictValue(key: string): string;
18
- }
19
- export declare class EntryLayDict {
20
- typeCode: string;
21
- enable?: boolean;
22
- values: DictEntryLayModel[];
23
- constructor(typeCode: string, enable?: boolean);
24
- useDictValues(): Promise<DictEntryLayModel[]>;
25
- getDictValue(key: string): string;
26
- }
27
- export declare class CustomBizDict {
28
- values: Entry[];
29
- query: any;
30
- constructor(results: any, query: any);
31
- getValue(key: string | boolean): string;
32
- }
1
+ import { Entry, DictEntryModel, DictEntryLayModel } from "./dict/types";
2
+ export declare class EnumDict {
3
+ module: string;
4
+ enumClass: string;
5
+ type: number;
6
+ values: Entry[];
7
+ constructor(module: string, enumClass: string, type?: number);
8
+ useEnumValues(): Promise<Entry[]>;
9
+ getEnumValue(key: string): string;
10
+ }
11
+ export declare class EntryDict {
12
+ typeCode: string;
13
+ enable?: boolean;
14
+ values: DictEntryModel[];
15
+ constructor(typeCode: string, enable?: boolean);
16
+ useDictValues(): Promise<DictEntryModel[]>;
17
+ getDictValue(key: string): string;
18
+ }
19
+ export declare class EntryLayDict {
20
+ typeCode: string;
21
+ enable?: boolean;
22
+ values: DictEntryLayModel[];
23
+ constructor(typeCode: string, enable?: boolean);
24
+ useDictValues(): Promise<DictEntryLayModel[]>;
25
+ getDictValue(key: string): string;
26
+ }
27
+ export declare class CustomBizDict {
28
+ values: Entry[];
29
+ query: any;
30
+ constructor(results: any, query: any);
31
+ getValue(key: string | boolean): string;
32
+ }
package/lib/api/dicts.js CHANGED
@@ -1,118 +1,118 @@
1
- import { dictApi } from "./dict/index";
2
- //枚举字典类.
3
- export class EnumDict {
4
- //模块名
5
- module;
6
- //枚举类名
7
- enumClass;
8
- //枚举类型
9
- type;
10
- //枚举值
11
- values = [];
12
- constructor(module, enumClass, type = 0) {
13
- this.module = module;
14
- this.enumClass = enumClass;
15
- this.type = type;
16
- }
17
- useEnumValues() {
18
- return new Promise((resolve) => {
19
- dictApi
20
- .enumApi(this.module, this.enumClass, this.type)
21
- .then(({ data }) => {
22
- this.values.length = 0;
23
- this.values.push(...data.values);
24
- resolve(this.values);
25
- });
26
- });
27
- }
28
- getEnumValue(key) {
29
- for (const obj of this.values) {
30
- if (obj.key === key) {
31
- return obj.value;
32
- }
33
- }
34
- return "";
35
- }
36
- }
37
- // 普通字典类
38
- export class EntryDict {
39
- typeCode;
40
- enable;
41
- values = [];
42
- constructor(typeCode, enable = true) {
43
- // 字典类型编码
44
- this.typeCode = typeCode;
45
- // 是否启用
46
- this.enable = enable;
47
- }
48
- // 加载数据字典
49
- useDictValues() {
50
- return new Promise((resolve) => {
51
- const req = {
52
- typeCode: this.typeCode,
53
- enable: this.enable,
54
- };
55
- dictApi.dictEntryApi(req).then(({ data }) => {
56
- this.values.length = 0;
57
- this.values.push(...data.results);
58
- resolve(this.values);
59
- });
60
- });
61
- }
62
- //获取字典值
63
- getDictValue(key) {
64
- const entry = this.values.find((entrys) => entrys.dictCode === key);
65
- return entry?.dictName ? entry.dictName : "";
66
- }
67
- }
68
- // 带子集字典类
69
- export class EntryLayDict {
70
- typeCode;
71
- enable;
72
- values = [];
73
- constructor(typeCode, enable = true) {
74
- // 字典类型编码
75
- this.typeCode = typeCode;
76
- // 是否启用
77
- this.enable = enable;
78
- }
79
- // 加载数据字典
80
- useDictValues() {
81
- return new Promise((resolve) => {
82
- const req = {
83
- typeCode: this.typeCode,
84
- enable: this.enable,
85
- };
86
- dictApi.dictLayEntryApi(req).then(({ data }) => {
87
- this.values.length = 0;
88
- this.values.push(...data.results);
89
- resolve(this.values);
90
- });
91
- });
92
- }
93
- //获取字典值
94
- getDictValue(key) {
95
- const entry = this.values.find((entrys) => entrys.dictCode === key);
96
- return entry?.dictName ? entry.dictName : "";
97
- }
98
- }
99
- // 自定义
100
- export class CustomBizDict {
101
- values = [];
102
- // 查询条件
103
- query;
104
- constructor(results, query) {
105
- this.values.length = 0;
106
- this.values.push(...(results || []));
107
- this.query = query;
108
- }
109
- // 根据给定键获取业务数据项的值的方法
110
- getValue(key) {
111
- for (const obj of this.values) {
112
- if (obj.key === key) {
113
- return obj.value;
114
- }
115
- }
116
- return "";
117
- }
118
- }
1
+ import { dictApi } from "./dict/index";
2
+ //枚举字典类.
3
+ export class EnumDict {
4
+ //模块名
5
+ module;
6
+ //枚举类名
7
+ enumClass;
8
+ //枚举类型
9
+ type;
10
+ //枚举值
11
+ values = [];
12
+ constructor(module, enumClass, type = 0) {
13
+ this.module = module;
14
+ this.enumClass = enumClass;
15
+ this.type = type;
16
+ }
17
+ useEnumValues() {
18
+ return new Promise((resolve) => {
19
+ dictApi
20
+ .enumApi(this.module, this.enumClass, this.type)
21
+ .then(({ data }) => {
22
+ this.values.length = 0;
23
+ this.values.push(...data.values);
24
+ resolve(this.values);
25
+ });
26
+ });
27
+ }
28
+ getEnumValue(key) {
29
+ for (const obj of this.values) {
30
+ if (obj.key === key) {
31
+ return obj.value;
32
+ }
33
+ }
34
+ return "";
35
+ }
36
+ }
37
+ // 普通字典类
38
+ export class EntryDict {
39
+ typeCode;
40
+ enable;
41
+ values = [];
42
+ constructor(typeCode, enable = true) {
43
+ // 字典类型编码
44
+ this.typeCode = typeCode;
45
+ // 是否启用
46
+ this.enable = enable;
47
+ }
48
+ // 加载数据字典
49
+ useDictValues() {
50
+ return new Promise((resolve) => {
51
+ const req = {
52
+ typeCode: this.typeCode,
53
+ enable: this.enable,
54
+ };
55
+ dictApi.dictEntryApi(req).then(({ data }) => {
56
+ this.values.length = 0;
57
+ this.values.push(...data.results);
58
+ resolve(this.values);
59
+ });
60
+ });
61
+ }
62
+ //获取字典值
63
+ getDictValue(key) {
64
+ const entry = this.values.find((entrys) => entrys.dictCode === key);
65
+ return entry?.dictName ? entry.dictName : "";
66
+ }
67
+ }
68
+ // 带子集字典类
69
+ export class EntryLayDict {
70
+ typeCode;
71
+ enable;
72
+ values = [];
73
+ constructor(typeCode, enable = true) {
74
+ // 字典类型编码
75
+ this.typeCode = typeCode;
76
+ // 是否启用
77
+ this.enable = enable;
78
+ }
79
+ // 加载数据字典
80
+ useDictValues() {
81
+ return new Promise((resolve) => {
82
+ const req = {
83
+ typeCode: this.typeCode,
84
+ enable: this.enable,
85
+ };
86
+ dictApi.dictLayEntryApi(req).then(({ data }) => {
87
+ this.values.length = 0;
88
+ this.values.push(...data.results);
89
+ resolve(this.values);
90
+ });
91
+ });
92
+ }
93
+ //获取字典值
94
+ getDictValue(key) {
95
+ const entry = this.values.find((entrys) => entrys.dictCode === key);
96
+ return entry?.dictName ? entry.dictName : "";
97
+ }
98
+ }
99
+ // 自定义
100
+ export class CustomBizDict {
101
+ values = [];
102
+ // 查询条件
103
+ query;
104
+ constructor(results, query) {
105
+ this.values.length = 0;
106
+ this.values.push(...(results || []));
107
+ this.query = query;
108
+ }
109
+ // 根据给定键获取业务数据项的值的方法
110
+ getValue(key) {
111
+ for (const obj of this.values) {
112
+ if (obj.key === key) {
113
+ return obj.value;
114
+ }
115
+ }
116
+ return "";
117
+ }
118
+ }
@@ -1,25 +1,25 @@
1
- import { FileInfo, FileBase64Req, FileDownInfo, FileWebReq } from "./types";
2
- import { ResponseData } from "../../api/types";
3
- declare class FileApi {
4
- baseApiUrl(): string;
5
- uploadUrl(): string;
6
- /**
7
- * url 获取图片Full路径
8
- * @param type resize 等比例缩放,white 补白,trans 补透明,clip 裁剪
9
- */
10
- imageUrl(imageUrl: string, width?: number, height?: number, type?: string): string;
11
- /**
12
- * Id 获取图片Full路径
13
- * @param type resize 等比例缩放,white 补白,trans 补透明,clip 裁剪
14
- */
15
- imageIdUrl(imageId: string, width?: number, height?: number, type?: string): string;
16
- fileUrl(fileUrl?: string): string;
17
- fileIdUrl(fileId?: string): string;
18
- uploadBase64File(base64: FileBase64Req): Promise<ResponseData<FileInfo>>;
19
- uploadFile(file: string): Promise<FileInfo>;
20
- downloadFile(url: string): Promise<FileDownInfo>;
21
- uploadWebFile(data: FileWebReq): Promise<ResponseData<FileInfo>>;
22
- deleteFile(filePath?: string): Promise<ResponseData<FileInfo>>;
23
- }
24
- declare const fileApi: FileApi;
25
- export { fileApi };
1
+ import { FileInfo, FileBase64Req, FileDownInfo, FileWebReq } from "./types";
2
+ import { ResponseData } from "../../api/types";
3
+ declare class FileApi {
4
+ baseApiUrl(): string;
5
+ uploadUrl(): string;
6
+ /**
7
+ * url 获取图片Full路径
8
+ * @param type resize 等比例缩放,white 补白,trans 补透明,clip 裁剪
9
+ */
10
+ imageUrl(imageUrl: string, width?: number, height?: number, type?: string): string;
11
+ /**
12
+ * Id 获取图片Full路径
13
+ * @param type resize 等比例缩放,white 补白,trans 补透明,clip 裁剪
14
+ */
15
+ imageIdUrl(imageId: string, width?: number, height?: number, type?: string): string;
16
+ fileUrl(fileUrl?: string): string;
17
+ fileIdUrl(fileId?: string): string;
18
+ uploadBase64File(base64: FileBase64Req): Promise<ResponseData<FileInfo>>;
19
+ uploadFile(file: string): Promise<FileInfo>;
20
+ downloadFile(url: string): Promise<FileDownInfo>;
21
+ uploadWebFile(data: FileWebReq): Promise<ResponseData<FileInfo>>;
22
+ deleteFile(filePath?: string): Promise<ResponseData<FileInfo>>;
23
+ }
24
+ declare const fileApi: FileApi;
25
+ export { fileApi };
@@ -1,134 +1,134 @@
1
- import { db } from "../../utils/db";
2
- import { grpc } from "../../utils/grpc";
3
- import mpx from "@mpxjs/core";
4
- class FileApi {
5
- baseApiUrl() {
6
- const config = getApp().globalData.config;
7
- let currentBaseURL = config.baseUrl;
8
- // 使用 slice() 方法
9
- if (currentBaseURL.slice(-1) === "/") {
10
- currentBaseURL = currentBaseURL.slice(0, -1);
11
- }
12
- return currentBaseURL;
13
- }
14
- // 上传Url
15
- uploadUrl() {
16
- const config = getApp().globalData.config;
17
- return this.baseApiUrl() + "/v1/file/upload?tenant=" + config.tenant;
18
- }
19
- /**
20
- * url 获取图片Full路径
21
- * @param type resize 等比例缩放,white 补白,trans 补透明,clip 裁剪
22
- */
23
- imageUrl(imageUrl, width = 0, height = 0, type = "clip") {
24
- const regular = /^\//;
25
- if (regular.test(imageUrl)) {
26
- return (this.baseApiUrl() +
27
- `/v1/file/image/${type}/${width}/${height}` +
28
- imageUrl);
29
- }
30
- else {
31
- return (this.baseApiUrl() +
32
- `/v1/file/image/${type}/${width}/${height}/` +
33
- imageUrl);
34
- }
35
- }
36
- /**
37
- * Id 获取图片Full路径
38
- * @param type resize 等比例缩放,white 补白,trans 补透明,clip 裁剪
39
- */
40
- imageIdUrl(imageId, width = 0, height = 0, type = "clip") {
41
- const config = getApp().globalData.config;
42
- return (this.baseApiUrl() +
43
- "/v1/file/image_id/" +
44
- config.tenant +
45
- `/${type}/${width}/${height}/` +
46
- imageId);
47
- }
48
- // url 获取文件Full路径
49
- fileUrl(fileUrl) {
50
- return this.baseApiUrl() + "/v1/file/path/" + fileUrl;
51
- }
52
- // Id 获取文件Full路径
53
- fileIdUrl(fileId) {
54
- const config = getApp().globalData.config;
55
- return this.baseApiUrl() + "/v1/file/id/" + config.tenant + fileId;
56
- }
57
- // 上传文件
58
- uploadBase64File(base64) {
59
- const config = getApp().globalData.config;
60
- base64.tenant = config.tenant;
61
- grpc.clearEmpty(base64);
62
- return mpx.xfetch.fetch({
63
- url: "/v1/file/base64upload",
64
- method: "POST",
65
- data: base64,
66
- });
67
- }
68
- // 上传文件
69
- uploadFile(file) {
70
- const p = mpx.uploadFile({
71
- url: this.uploadUrl(),
72
- filePath: file,
73
- name: "file",
74
- header: {
75
- "Content-Type": "multipart/form-data",
76
- Authorization: db.getBearerToken(),
77
- },
78
- });
79
- return p.then((res) => {
80
- console.log("uploadFile", res);
81
- if (res.statusCode === 200) {
82
- return JSON.parse(res.data);
83
- }
84
- else if (res.statusCode === 401) {
85
- // 清理登录信息
86
- mpx.clearStorage();
87
- throw new Error("登录过期,请重新登录");
88
- }
89
- else {
90
- mpx.showToast({
91
- title: res.errMsg,
92
- icon: "none",
93
- duration: 2000,
94
- });
95
- return JSON.parse(res.data);
96
- }
97
- });
98
- }
99
- // 上传文件
100
- downloadFile(url) {
101
- const p = mpx.downloadFile({
102
- url: url,
103
- header: {
104
- Authorization: db.getBearerToken(),
105
- },
106
- });
107
- return p.then((res) => {
108
- return {
109
- statusCode: res.statusCode,
110
- tempFilePath: res.tempFilePath,
111
- filePath: res.tempFilePath,
112
- };
113
- });
114
- }
115
- // 上传文件
116
- uploadWebFile(data) {
117
- grpc.clearEmpty(data);
118
- return mpx.xfetch.fetch({
119
- url: "/v1/file/webupload",
120
- method: "POST",
121
- data: data,
122
- });
123
- }
124
- // 删除文件
125
- deleteFile(filePath) {
126
- return mpx.xfetch.fetch({
127
- url: "/api/v1/files",
128
- method: "DELETE",
129
- data: { filePath: filePath },
130
- });
131
- }
132
- }
133
- const fileApi = new FileApi();
134
- export { fileApi };
1
+ import { db } from "../../utils/db";
2
+ import { grpc } from "../../utils/grpc";
3
+ import mpx from "@mpxjs/core";
4
+ class FileApi {
5
+ baseApiUrl() {
6
+ const config = getApp().globalData.config;
7
+ let currentBaseURL = config.baseUrl;
8
+ // 使用 slice() 方法
9
+ if (currentBaseURL.slice(-1) === "/") {
10
+ currentBaseURL = currentBaseURL.slice(0, -1);
11
+ }
12
+ return currentBaseURL;
13
+ }
14
+ // 上传Url
15
+ uploadUrl() {
16
+ const config = getApp().globalData.config;
17
+ return this.baseApiUrl() + "/v1/file/upload?tenant=" + config.tenant;
18
+ }
19
+ /**
20
+ * url 获取图片Full路径
21
+ * @param type resize 等比例缩放,white 补白,trans 补透明,clip 裁剪
22
+ */
23
+ imageUrl(imageUrl, width = 0, height = 0, type = "clip") {
24
+ const regular = /^\//;
25
+ if (regular.test(imageUrl)) {
26
+ return (this.baseApiUrl() +
27
+ `/v1/file/image/${type}/${width}/${height}` +
28
+ imageUrl);
29
+ }
30
+ else {
31
+ return (this.baseApiUrl() +
32
+ `/v1/file/image/${type}/${width}/${height}/` +
33
+ imageUrl);
34
+ }
35
+ }
36
+ /**
37
+ * Id 获取图片Full路径
38
+ * @param type resize 等比例缩放,white 补白,trans 补透明,clip 裁剪
39
+ */
40
+ imageIdUrl(imageId, width = 0, height = 0, type = "clip") {
41
+ const config = getApp().globalData.config;
42
+ return (this.baseApiUrl() +
43
+ "/v1/file/image_id/" +
44
+ config.tenant +
45
+ `/${type}/${width}/${height}/` +
46
+ imageId);
47
+ }
48
+ // url 获取文件Full路径
49
+ fileUrl(fileUrl) {
50
+ return this.baseApiUrl() + "/v1/file/path/" + fileUrl;
51
+ }
52
+ // Id 获取文件Full路径
53
+ fileIdUrl(fileId) {
54
+ const config = getApp().globalData.config;
55
+ return this.baseApiUrl() + "/v1/file/id/" + config.tenant + fileId;
56
+ }
57
+ // 上传文件
58
+ uploadBase64File(base64) {
59
+ const config = getApp().globalData.config;
60
+ base64.tenant = config.tenant;
61
+ grpc.clearEmpty(base64);
62
+ return mpx.xfetch.fetch({
63
+ url: "/v1/file/base64upload",
64
+ method: "POST",
65
+ data: base64,
66
+ });
67
+ }
68
+ // 上传文件
69
+ uploadFile(file) {
70
+ const p = mpx.uploadFile({
71
+ url: this.uploadUrl(),
72
+ filePath: file,
73
+ name: "file",
74
+ header: {
75
+ "Content-Type": "multipart/form-data",
76
+ Authorization: db.getBearerToken(),
77
+ },
78
+ });
79
+ return p.then((res) => {
80
+ console.log("uploadFile", res);
81
+ if (res.statusCode === 200) {
82
+ return JSON.parse(res.data);
83
+ }
84
+ else if (res.statusCode === 401) {
85
+ // 清理登录信息
86
+ mpx.clearStorage();
87
+ throw new Error("登录过期,请重新登录");
88
+ }
89
+ else {
90
+ mpx.showToast({
91
+ title: res.errMsg,
92
+ icon: "none",
93
+ duration: 2000,
94
+ });
95
+ return JSON.parse(res.data);
96
+ }
97
+ });
98
+ }
99
+ // 上传文件
100
+ downloadFile(url) {
101
+ const p = mpx.downloadFile({
102
+ url: url,
103
+ header: {
104
+ Authorization: db.getBearerToken(),
105
+ },
106
+ });
107
+ return p.then((res) => {
108
+ return {
109
+ statusCode: res.statusCode,
110
+ tempFilePath: res.tempFilePath,
111
+ filePath: res.tempFilePath,
112
+ };
113
+ });
114
+ }
115
+ // 上传文件
116
+ uploadWebFile(data) {
117
+ grpc.clearEmpty(data);
118
+ return mpx.xfetch.fetch({
119
+ url: "/v1/file/webupload",
120
+ method: "POST",
121
+ data: data,
122
+ });
123
+ }
124
+ // 删除文件
125
+ deleteFile(filePath) {
126
+ return mpx.xfetch.fetch({
127
+ url: "/api/v1/files",
128
+ method: "DELETE",
129
+ data: { filePath: filePath },
130
+ });
131
+ }
132
+ }
133
+ const fileApi = new FileApi();
134
+ export { fileApi };