jmash-core-mp 0.1.21 → 0.1.22
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/.editorconfig +9 -9
- package/README.md +60 -60
- package/babel.config.json +34 -34
- package/eslint.config.mjs +7 -7
- package/lib/api/auth/index.d.ts +21 -21
- package/lib/api/auth/index.js +199 -199
- package/lib/api/auth/types.d.ts +86 -86
- package/lib/api/auth/types.js +9 -9
- package/lib/api/cms/index.d.ts +20 -20
- package/lib/api/cms/index.js +161 -161
- package/lib/api/cms/types.d.ts +200 -200
- package/lib/api/cms/types.js +1 -1
- package/lib/api/constant.d.ts +5 -5
- package/lib/api/constant.js +6 -6
- package/lib/api/dict/index.d.ts +18 -18
- package/lib/api/dict/index.js +34 -34
- package/lib/api/dict/types.d.ts +28 -28
- package/lib/api/dict/types.js +1 -1
- package/lib/api/dicts.d.ts +18 -18
- package/lib/api/dicts.js +67 -67
- package/lib/api/files/index.d.ts +25 -25
- package/lib/api/files/index.js +135 -135
- package/lib/api/files/types.d.ts +38 -38
- package/lib/api/files/types.js +1 -1
- package/lib/api/index.d.ts +4 -4
- package/lib/api/index.js +6 -6
- package/lib/api/myorgan/types.d.ts +22 -22
- package/lib/api/myorgan/types.js +1 -1
- package/lib/api/region/index.d.ts +7 -7
- package/lib/api/region/index.js +19 -19
- package/lib/api/region/types.d.ts +19 -19
- package/lib/api/region/types.js +1 -1
- package/lib/api/storage/index.d.ts +10 -10
- package/lib/api/storage/index.js +43 -43
- package/lib/api/storage/types.d.ts +28 -28
- package/lib/api/storage/types.js +1 -1
- package/lib/api/types.d.ts +42 -42
- package/lib/api/types.js +1 -1
- package/lib/app.mpx.d.ts +1 -1
- package/lib/components/auth-user/jmash-update-user.mpx.d.ts +1 -1
- package/lib/components/auth-user/jmash-user.mpx.d.ts +1 -1
- package/lib/components/cms/jmash-cms-acticle-list.mpx.d.ts +1 -1
- package/lib/components/cms/jmash-cms-article-item.mpx.d.ts +1 -1
- package/lib/components/cms/jmash-cms-article-view.mpx.d.ts +1 -0
- package/lib/components/cms/jmash-cms-article.mpx.d.ts +1 -1
- package/lib/components/cms/jmash-cms-like.mpx.d.ts +1 -1
- package/lib/components/common/jmash-upload-picture.mpx.d.ts +1 -0
- package/lib/components/core/jmash-login.mpx.d.ts +1 -0
- package/lib/index.d.ts +21 -21
- package/lib/index.js +14 -14
- package/lib/packages/pages/cms/cms-article-list.mpx.d.ts +1 -1
- package/lib/pages/index.mpx.d.ts +1 -0
- package/lib/store/user.d.ts +31 -31
- package/lib/store/user.js +227 -227
- package/lib/utils/common.d.ts +35 -35
- package/lib/utils/common.js +166 -166
- package/lib/utils/config.d.ts +5 -5
- package/lib/utils/config.js +29 -29
- package/lib/utils/db.d.ts +21 -21
- package/lib/utils/db.js +84 -84
- package/lib/utils/grpc.d.ts +5 -5
- package/lib/utils/grpc.js +20 -20
- package/lib/utils/net.d.ts +7 -7
- package/lib/utils/net.js +15 -15
- package/lib/utils/request.d.ts +2 -2
- package/lib/utils/request.js +123 -123
- package/mpx.config.js +27 -27
- package/package.json +1 -1
- package/postcss.config.js +11 -11
- package/project.config.json +24 -24
- package/project.private.config.json +13 -13
- package/public/index.html +15 -15
- package/src/api/auth/index.ts +227 -227
- package/src/api/auth/types.ts +166 -166
- package/src/api/cms/index.ts +218 -218
- package/src/api/cms/types.ts +379 -379
- package/src/api/constant.ts +6 -6
- package/src/api/dict/index.ts +44 -44
- package/src/api/dict/types.ts +49 -49
- package/src/api/dicts.ts +72 -72
- package/src/api/files/index.ts +163 -163
- package/src/api/files/types.ts +67 -67
- package/src/api/index.ts +11 -11
- package/src/api/myorgan/types.ts +42 -42
- package/src/api/region/index.ts +23 -23
- package/src/api/region/types.ts +36 -36
- package/src/api/storage/index.ts +62 -62
- package/src/api/storage/types.ts +54 -54
- package/src/api/types.ts +72 -72
- package/src/app.mpx +71 -71
- package/src/components/auth-user/jmash-logout.mpx +91 -91
- package/src/components/auth-user/jmash-update-user.mpx +386 -386
- package/src/components/auth-user/jmash-update-user.web.mpx +366 -366
- package/src/components/auth-user/jmash-user.mpx +359 -359
- package/src/components/cms/jmash-cms-acticle-list.mpx +182 -182
- package/src/components/cms/jmash-cms-article-item.mpx +241 -241
- package/src/components/cms/jmash-cms-article-view.mpx +131 -131
- package/src/components/cms/jmash-cms-article.mpx +68 -68
- package/src/components/cms/jmash-cms-like.mpx +151 -151
- package/src/components/common/jmash-avatar-edit.mpx +153 -153
- package/src/components/common/jmash-cascader-region.mpx +112 -112
- package/src/components/common/jmash-menu.mpx +129 -129
- package/src/components/common/jmash-none-data.mpx +82 -82
- package/src/components/common/jmash-pic-swiper.mpx +71 -71
- package/src/components/common/jmash-popup.mpx +137 -137
- package/src/components/common/jmash-search.mpx +126 -126
- package/src/components/common/jmash-single-btn.mpx +53 -53
- package/src/components/common/jmash-stepper.mpx +214 -214
- package/src/components/common/jmash-tab-bar.mpx +50 -50
- package/src/components/common/jmash-textarea.mpx +88 -88
- package/src/components/common/jmash-top-navigation.mpx +203 -203
- package/src/components/common/jmash-upload-picture.mpx +129 -126
- package/src/components/core/jmash-cms-protocol.mpx +66 -66
- package/src/components/core/jmash-login.ali.mpx +284 -284
- package/src/components/core/jmash-login.mpx +348 -348
- package/src/components/core/jmash-login.web.mpx +421 -421
- package/src/components/core/jmash-popup-login.ali.mpx +311 -311
- package/src/components/core/jmash-popup-login.mpx +415 -415
- package/src/components/core/jmash-popup-login.web.mpx +389 -389
- package/src/custom-tab-bar/index.mpx +10 -10
- package/src/global.d.ts +11 -11
- package/src/index.ts +71 -71
- package/src/packages/index.mpx +10 -10
- package/src/packages/pages/auth/cms-protocol.mpx +31 -31
- package/src/packages/pages/auth/login.mpx +59 -59
- package/src/packages/pages/auth/update-user.mpx +17 -17
- package/src/packages/pages/cms/cms-article-list.mpx +164 -164
- package/src/packages/pages/cms/cms-article.mpx +32 -32
- package/src/pages/basic-component.mpx +30 -30
- package/src/pages/half-home.mpx +58 -58
- package/src/pages/home.mpx +52 -52
- package/src/pages/home2.mpx +47 -47
- package/src/pages/index.mpx +13 -3
- package/src/pages/tabbar/home.mpx +77 -77
- package/src/pages/tabbar/my.mpx +80 -80
- package/src/store/user.ts +270 -270
- package/src/styles/index.scss +20 -20
- package/src/styles/vars.scss +27 -27
- package/src/utils/common.ts +179 -179
- package/src/utils/config.ts +35 -35
- package/src/utils/db.ts +100 -100
- package/src/utils/grpc.ts +21 -21
- package/src/utils/net.ts +18 -18
- package/src/utils/request.ts +134 -134
- package/static/ali/mini.project.json +4 -4
- package/static/dd/project.config.json +15 -15
- package/static/swan/project.swan.json +14 -14
- package/static/tt/project.config.json +11 -11
- package/static/wx/project.config.json +40 -40
- package/uno.config.js +9 -9
package/lib/api/dicts.js
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
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
|
-
}
|
|
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
|
+
}
|
package/lib/api/files/index.d.ts
CHANGED
|
@@ -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 };
|
package/lib/api/files/index.js
CHANGED
|
@@ -1,135 +1,135 @@
|
|
|
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
|
-
// data.tenant = data.tenant ? config.tenant;
|
|
118
|
-
grpc.clearEmpty(data);
|
|
119
|
-
return mpx.xfetch.fetch({
|
|
120
|
-
url: "/v1/file/webupload",
|
|
121
|
-
method: "POST",
|
|
122
|
-
data: data,
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
// 删除文件
|
|
126
|
-
deleteFile(filePath) {
|
|
127
|
-
return mpx.xfetch.fetch({
|
|
128
|
-
url: "/api/v1/files",
|
|
129
|
-
method: "DELETE",
|
|
130
|
-
data: { filePath: filePath },
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
const fileApi = new FileApi();
|
|
135
|
-
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
|
+
// data.tenant = data.tenant ? config.tenant;
|
|
118
|
+
grpc.clearEmpty(data);
|
|
119
|
+
return mpx.xfetch.fetch({
|
|
120
|
+
url: "/v1/file/webupload",
|
|
121
|
+
method: "POST",
|
|
122
|
+
data: data,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
// 删除文件
|
|
126
|
+
deleteFile(filePath) {
|
|
127
|
+
return mpx.xfetch.fetch({
|
|
128
|
+
url: "/api/v1/files",
|
|
129
|
+
method: "DELETE",
|
|
130
|
+
data: { filePath: filePath },
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const fileApi = new FileApi();
|
|
135
|
+
export { fileApi };
|
package/lib/api/files/types.d.ts
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 文件API类型声明
|
|
3
|
-
*/
|
|
4
|
-
export interface FileInfo {
|
|
5
|
-
fileId: string;
|
|
6
|
-
fileSrc: string;
|
|
7
|
-
contentType: string;
|
|
8
|
-
fileExt: string;
|
|
9
|
-
fileWidth: number;
|
|
10
|
-
fileHeight: number;
|
|
11
|
-
fileSize: number;
|
|
12
|
-
hashSha256: string;
|
|
13
|
-
hashSm3: string;
|
|
14
|
-
createDate: string;
|
|
15
|
-
tempFilePath: string;
|
|
16
|
-
}
|
|
17
|
-
export interface FileBase64Req {
|
|
18
|
-
tenant?: string;
|
|
19
|
-
base64?: string;
|
|
20
|
-
fileName?: string;
|
|
21
|
-
contentType?: string;
|
|
22
|
-
fileDir?: string;
|
|
23
|
-
}
|
|
24
|
-
export interface FileDownInfo {
|
|
25
|
-
tempFilePath: string;
|
|
26
|
-
filePath: string;
|
|
27
|
-
statusCode: number;
|
|
28
|
-
}
|
|
29
|
-
export interface FileWebReq {
|
|
30
|
-
tenant?: string;
|
|
31
|
-
body?: string;
|
|
32
|
-
fileName?: string;
|
|
33
|
-
contentType?: string;
|
|
34
|
-
fileDir?: string;
|
|
35
|
-
fileSize?: number;
|
|
36
|
-
requestId?: string;
|
|
37
|
-
filePart?: number;
|
|
38
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 文件API类型声明
|
|
3
|
+
*/
|
|
4
|
+
export interface FileInfo {
|
|
5
|
+
fileId: string;
|
|
6
|
+
fileSrc: string;
|
|
7
|
+
contentType: string;
|
|
8
|
+
fileExt: string;
|
|
9
|
+
fileWidth: number;
|
|
10
|
+
fileHeight: number;
|
|
11
|
+
fileSize: number;
|
|
12
|
+
hashSha256: string;
|
|
13
|
+
hashSm3: string;
|
|
14
|
+
createDate: string;
|
|
15
|
+
tempFilePath: string;
|
|
16
|
+
}
|
|
17
|
+
export interface FileBase64Req {
|
|
18
|
+
tenant?: string;
|
|
19
|
+
base64?: string;
|
|
20
|
+
fileName?: string;
|
|
21
|
+
contentType?: string;
|
|
22
|
+
fileDir?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface FileDownInfo {
|
|
25
|
+
tempFilePath: string;
|
|
26
|
+
filePath: string;
|
|
27
|
+
statusCode: number;
|
|
28
|
+
}
|
|
29
|
+
export interface FileWebReq {
|
|
30
|
+
tenant?: string;
|
|
31
|
+
body?: string;
|
|
32
|
+
fileName?: string;
|
|
33
|
+
contentType?: string;
|
|
34
|
+
fileDir?: string;
|
|
35
|
+
fileSize?: number;
|
|
36
|
+
requestId?: string;
|
|
37
|
+
filePart?: number;
|
|
38
|
+
}
|
package/lib/api/files/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/lib/api/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EnumDict } from "../api/dicts";
|
|
2
|
-
export declare class Dict {
|
|
3
|
-
static readonly genderDict: EnumDict;
|
|
4
|
-
}
|
|
1
|
+
import { EnumDict } from "../api/dicts";
|
|
2
|
+
export declare class Dict {
|
|
3
|
+
static readonly genderDict: EnumDict;
|
|
4
|
+
}
|
package/lib/api/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Constant } from "../api/constant";
|
|
2
|
-
import { EnumDict } from "../api/dicts";
|
|
3
|
-
export class Dict {
|
|
4
|
-
// 性别
|
|
5
|
-
static genderDict = new EnumDict(Constant.MODULE_RBAC, Constant.ENUM_GENDER);
|
|
6
|
-
}
|
|
1
|
+
import { Constant } from "../api/constant";
|
|
2
|
+
import { EnumDict } from "../api/dicts";
|
|
3
|
+
export class Dict {
|
|
4
|
+
// 性别
|
|
5
|
+
static genderDict = new EnumDict(Constant.MODULE_RBAC, Constant.ENUM_GENDER);
|
|
6
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
export interface BaseOrganModel {
|
|
2
|
-
organId?: string;
|
|
3
|
-
organName?: string;
|
|
4
|
-
organCode?: string;
|
|
5
|
-
pinYin?: string;
|
|
6
|
-
userId?: string;
|
|
7
|
-
shortName?: string;
|
|
8
|
-
organType?: string;
|
|
9
|
-
parentId?: string;
|
|
10
|
-
logoUrl?: string;
|
|
11
|
-
industry?: string;
|
|
12
|
-
address?: string;
|
|
13
|
-
geoLongitude?: string;
|
|
14
|
-
geoLatitude?: string;
|
|
15
|
-
contactPerson?: string;
|
|
16
|
-
contactPersonMobile?: string;
|
|
17
|
-
contactPersonMobileIns?: string;
|
|
18
|
-
perfectStatus?: boolean;
|
|
19
|
-
status?: string;
|
|
20
|
-
tenant: string;
|
|
21
|
-
memberInviteStatus: boolean;
|
|
22
|
-
}
|
|
1
|
+
export interface BaseOrganModel {
|
|
2
|
+
organId?: string;
|
|
3
|
+
organName?: string;
|
|
4
|
+
organCode?: string;
|
|
5
|
+
pinYin?: string;
|
|
6
|
+
userId?: string;
|
|
7
|
+
shortName?: string;
|
|
8
|
+
organType?: string;
|
|
9
|
+
parentId?: string;
|
|
10
|
+
logoUrl?: string;
|
|
11
|
+
industry?: string;
|
|
12
|
+
address?: string;
|
|
13
|
+
geoLongitude?: string;
|
|
14
|
+
geoLatitude?: string;
|
|
15
|
+
contactPerson?: string;
|
|
16
|
+
contactPersonMobile?: string;
|
|
17
|
+
contactPersonMobileIns?: string;
|
|
18
|
+
perfectStatus?: boolean;
|
|
19
|
+
status?: string;
|
|
20
|
+
tenant: string;
|
|
21
|
+
memberInviteStatus: boolean;
|
|
22
|
+
}
|
package/lib/api/myorgan/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DictRegionList, DictRegionReq } from "./types";
|
|
2
|
-
import { ResponseData } from "../../api/types";
|
|
3
|
-
declare class RegionApiImpl {
|
|
4
|
-
findList(query?: DictRegionReq): Promise<ResponseData<DictRegionList>>;
|
|
5
|
-
}
|
|
6
|
-
declare const regionApi: RegionApiImpl;
|
|
7
|
-
export { regionApi };
|
|
1
|
+
import { DictRegionList, DictRegionReq } from "./types";
|
|
2
|
+
import { ResponseData } from "../../api/types";
|
|
3
|
+
declare class RegionApiImpl {
|
|
4
|
+
findList(query?: DictRegionReq): Promise<ResponseData<DictRegionList>>;
|
|
5
|
+
}
|
|
6
|
+
declare const regionApi: RegionApiImpl;
|
|
7
|
+
export { regionApi };
|
package/lib/api/region/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { grpc } from "../../utils/grpc";
|
|
2
|
-
import mpx from "@mpxjs/core";
|
|
3
|
-
class RegionApiImpl {
|
|
4
|
-
// 查询列表信息地区信息
|
|
5
|
-
findList(query) {
|
|
6
|
-
if (query) {
|
|
7
|
-
query.hasEnable = query.enable !== undefined;
|
|
8
|
-
}
|
|
9
|
-
grpc.clearEmpty(query);
|
|
10
|
-
const config = getApp().globalData.config;
|
|
11
|
-
return mpx.xfetch.fetch({
|
|
12
|
-
url: "/v1/region/dict_region/list/" + config.tenant,
|
|
13
|
-
method: "GET",
|
|
14
|
-
data: query,
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
const regionApi = new RegionApiImpl();
|
|
19
|
-
export { regionApi };
|
|
1
|
+
import { grpc } from "../../utils/grpc";
|
|
2
|
+
import mpx from "@mpxjs/core";
|
|
3
|
+
class RegionApiImpl {
|
|
4
|
+
// 查询列表信息地区信息
|
|
5
|
+
findList(query) {
|
|
6
|
+
if (query) {
|
|
7
|
+
query.hasEnable = query.enable !== undefined;
|
|
8
|
+
}
|
|
9
|
+
grpc.clearEmpty(query);
|
|
10
|
+
const config = getApp().globalData.config;
|
|
11
|
+
return mpx.xfetch.fetch({
|
|
12
|
+
url: "/v1/region/dict_region/list/" + config.tenant,
|
|
13
|
+
method: "GET",
|
|
14
|
+
data: query,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const regionApi = new RegionApiImpl();
|
|
19
|
+
export { regionApi };
|