jmash-core-mp 0.1.3 → 0.1.5

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 (54) hide show
  1. package/lib/api/auth/index.d.ts +21 -0
  2. package/lib/api/auth/index.js +187 -0
  3. package/lib/api/auth/types.d.ts +86 -0
  4. package/lib/api/auth/types.js +9 -0
  5. package/lib/api/cms/index.d.ts +9 -0
  6. package/lib/api/cms/index.js +42 -0
  7. package/lib/api/cms/types.d.ts +72 -0
  8. package/lib/api/cms/types.js +1 -0
  9. package/lib/api/constant.d.ts +5 -0
  10. package/lib/api/constant.js +6 -0
  11. package/lib/api/dict/index.d.ts +18 -0
  12. package/lib/api/dict/index.js +34 -0
  13. package/lib/api/dict/types.d.ts +28 -0
  14. package/lib/api/dict/types.js +1 -0
  15. package/lib/api/dicts.d.ts +18 -0
  16. package/lib/api/dicts.js +67 -0
  17. package/lib/api/files/index.d.ts +25 -0
  18. package/lib/api/files/index.js +131 -0
  19. package/lib/api/files/types.d.ts +38 -0
  20. package/lib/api/files/types.js +1 -0
  21. package/lib/api/index.d.ts +4 -0
  22. package/lib/api/index.js +6 -0
  23. package/lib/api/myorgan/index.d.ts +0 -0
  24. package/lib/api/myorgan/index.js +0 -0
  25. package/lib/api/myorgan/types.d.ts +22 -0
  26. package/lib/api/myorgan/types.js +1 -0
  27. package/lib/app.mpx.d.ts +1 -0
  28. package/lib/components/auth-user/jmash-update-user.mpx.d.ts +1 -0
  29. package/lib/components/auth-user/jmash-update-user.web.mpx.d.ts +1 -0
  30. package/lib/components/auth-user/jmash-user.mpx.d.ts +1 -0
  31. package/lib/components/core/jmash-login.ali.mpx.d.ts +1 -0
  32. package/lib/components/core/jmash-login.mpx.d.ts +1 -0
  33. package/lib/components/core/jmash-login.web.mpx.d.ts +1 -0
  34. package/lib/index.d.ts +13 -0
  35. package/lib/index.js +10 -0
  36. package/lib/store/user.d.ts +31 -0
  37. package/lib/store/user.js +224 -0
  38. package/lib/types/core.d.ts +21 -0
  39. package/lib/types/core.js +1 -0
  40. package/lib/utils/config.d.ts +3 -0
  41. package/lib/utils/config.js +30 -0
  42. package/lib/utils/db.d.ts +21 -0
  43. package/lib/utils/db.js +84 -0
  44. package/lib/utils/grpc.d.ts +5 -0
  45. package/lib/utils/grpc.js +20 -0
  46. package/lib/utils/net.d.ts +7 -0
  47. package/lib/utils/net.js +15 -0
  48. package/lib/utils/request.d.ts +2 -0
  49. package/lib/utils/request.js +122 -0
  50. package/package.json +5 -2
  51. package/src/api/auth/index.ts +9 -6
  52. package/src/api/auth/types.ts +1 -1
  53. package/src/api/files/index.ts +1 -1
  54. package/src/index.ts +3 -0
@@ -0,0 +1,21 @@
1
+ import { ResponseData } from "../../types/core";
2
+ import type { LoginReq, LoginRes, RolesPerms, WebLoginReq, TokenModel, PhoneRegisterReq, PhoneReplaceReq, UpdateUserReq, UserInfoReq, UserInfo } from "./types";
3
+ declare class AuthApi {
4
+ mpLogin(data: LoginReq): Promise<ResponseData<LoginRes>>;
5
+ mpPhoneRegister(data: PhoneRegisterReq): Promise<ResponseData<LoginRes>>;
6
+ replaceBindphone(data: PhoneReplaceReq): Promise<ResponseData<string>>;
7
+ webLogin(data: WebLoginReq): Promise<ResponseData<TokenModel>>;
8
+ refreshToken(): Promise<ResponseData<TokenModel>>;
9
+ userInfo(): Promise<ResponseData<UserInfo>>;
10
+ userRolesPerms(): Promise<ResponseData<RolesPerms>>;
11
+ allowRunAsUser(): Promise<ResponseData<any[]>>;
12
+ runAsUser(userId: string): Promise<ResponseData<any>>;
13
+ updateUser(data: any): Promise<ResponseData<any>>;
14
+ updatePwd(encodeOldPwd: string, encodeNewPwd: string): Promise<ResponseData<any>>;
15
+ deptTree(deptId?: string, tenant?: string): Promise<ResponseData<any[]>>;
16
+ jobTree(jobId?: string, tenant?: string): Promise<ResponseData<any[]>>;
17
+ updateUserInfo(data: UpdateUserReq): Promise<ResponseData<UserInfo>>;
18
+ findUserInfo(data: UserInfoReq): Promise<ResponseData<UserInfo>>;
19
+ }
20
+ export declare const authApi: AuthApi;
21
+ export {};
@@ -0,0 +1,187 @@
1
+ import { OpensType } from "./types";
2
+ import { db } from "../../utils/db";
3
+ import { grpc } from "../../utils/grpc";
4
+ import { config } from "../../utils/config";
5
+ import mpx from "@mpxjs/core";
6
+ class AuthApi {
7
+ // 小程序静默登录
8
+ mpLogin(data) {
9
+ if (__mpx_mode__ === "wx") {
10
+ data.opensType = OpensType.wechat;
11
+ }
12
+ if (__mpx_mode__ === "ali") {
13
+ data.opensType = OpensType.ali_pay;
14
+ }
15
+ return mpx.xfetch.fetch({
16
+ url: "/v1/front/rbac/miniapp_login/" + config.tenant,
17
+ method: "POST",
18
+ data,
19
+ header: {
20
+ "content-type": "application/json",
21
+ Authorization: false,
22
+ },
23
+ });
24
+ }
25
+ // 手机号注册登录
26
+ mpPhoneRegister(data) {
27
+ if (__mpx_mode__ === "wx") {
28
+ data.opensType = OpensType.wechat;
29
+ }
30
+ if (__mpx_mode__ === "ali") {
31
+ data.opensType = OpensType.ali_pay;
32
+ }
33
+ return mpx.xfetch.fetch({
34
+ url: "/v1/front/rbac/miniapp_phonenumber/" + config.tenant,
35
+ method: "POST",
36
+ data: data,
37
+ header: {
38
+ Authorization: false,
39
+ },
40
+ });
41
+ }
42
+ // 已登陆状态小程序更换绑定手机号
43
+ replaceBindphone(data) {
44
+ data.tenant = config.tenant;
45
+ if (__mpx_mode__ === "wx") {
46
+ data.opensType = OpensType.wechat;
47
+ }
48
+ if (__mpx_mode__ === "ali") {
49
+ data.opensType = OpensType.ali_pay;
50
+ }
51
+ grpc.clearEmpty(data);
52
+ return mpx.xfetch.fetch({
53
+ url: "/v1/front/rbac/miniapp_bindphone",
54
+ method: "POST",
55
+ data: data,
56
+ });
57
+ }
58
+ //web登录.
59
+ webLogin(data) {
60
+ data.tenant = config.tenant;
61
+ data.directoryId = "user";
62
+ data.clientId = config.appId ? config.appId : "h5";
63
+ data.captchaId = "1";
64
+ data.captchaCode = "1";
65
+ return mpx.xfetch.fetch({
66
+ url: "/v1/rbac/auth/login",
67
+ method: "POST",
68
+ data: data,
69
+ header: {
70
+ Authorization: false,
71
+ },
72
+ });
73
+ }
74
+ // 刷新token
75
+ refreshToken() {
76
+ return mpx.xfetch.fetch({
77
+ url: "/v1/front/rbac/auth/refresh_token",
78
+ method: "POST",
79
+ data: {
80
+ refreshToken: db.getRefreshToken(),
81
+ tenant: config.tenant,
82
+ clientId: config.appId,
83
+ },
84
+ header: { "content-type": "application/json" },
85
+ });
86
+ }
87
+ // 获取当前会话用户
88
+ userInfo() {
89
+ return mpx.xfetch.fetch({
90
+ url: "/v1/rbac/auth/user?tenant=" + config.tenant,
91
+ method: "GET",
92
+ });
93
+ }
94
+ // 当前用户角色权限
95
+ userRolesPerms() {
96
+ return mpx.xfetch.fetch({
97
+ url: "/v1/rbac/auth/roles_perms?tenant=" + config.tenant,
98
+ method: "GET",
99
+ });
100
+ }
101
+ // 允许切换身份的用户列表
102
+ allowRunAsUser() {
103
+ return mpx.xfetch.fetch({
104
+ url: "/v1/rbac/auth/allow_run_as_user?tenant=" + config.tenant,
105
+ method: "GET",
106
+ });
107
+ }
108
+ // 运行某种身份
109
+ runAsUser(userId) {
110
+ const data = {
111
+ tenant: config.tenant,
112
+ userId: userId,
113
+ };
114
+ return mpx.xfetch.fetch({
115
+ url: "/v1/rbac/auth/run_as",
116
+ method: "POST",
117
+ data: data,
118
+ });
119
+ }
120
+ // 更新用户
121
+ updateUser(data) {
122
+ return mpx.xfetch.fetch({
123
+ url: "/v1/rbac/auth/user",
124
+ method: "PATCH",
125
+ data: data,
126
+ });
127
+ }
128
+ // 修改密码
129
+ updatePwd(encodeOldPwd, encodeNewPwd) {
130
+ const data = {
131
+ tenant: db.getUserTenant(),
132
+ encodeOldPwd: encodeOldPwd,
133
+ encodeNewPwd: encodeNewPwd,
134
+ };
135
+ return mpx.xfetch.fetch({
136
+ url: "/v1/rbac/auth/change_pwd",
137
+ method: "PATCH",
138
+ data: data,
139
+ });
140
+ }
141
+ // 部门Tree
142
+ deptTree(deptId, tenant) {
143
+ const query = {
144
+ tenant: tenant ? tenant : config.tenant,
145
+ excludeId: deptId,
146
+ };
147
+ return mpx.xfetch.fetch({
148
+ url: "/v1/rbac/dept/treelist",
149
+ method: "GET",
150
+ data: query,
151
+ });
152
+ }
153
+ // 职务Tree
154
+ jobTree(jobId, tenant) {
155
+ const query = {
156
+ tenant: tenant ? tenant : config.tenant,
157
+ roleType: "job",
158
+ hasRoleType: true,
159
+ excludeId: jobId,
160
+ };
161
+ return mpx.xfetch.fetch({
162
+ url: "/v1/rbac/role/treelist",
163
+ method: "GET",
164
+ data: query,
165
+ });
166
+ }
167
+ // 修改个人信息
168
+ updateUserInfo(data) {
169
+ data.tenant = config.tenant;
170
+ grpc.clearEmpty(data);
171
+ return mpx.xfetch.fetch({
172
+ url: "/v1/rbac/auth/user",
173
+ method: "PATCH",
174
+ data: data,
175
+ });
176
+ }
177
+ // 获取当前会话用户的信息
178
+ findUserInfo(data) {
179
+ data.tenant = config.tenant;
180
+ return mpx.xfetch.fetch({
181
+ url: "/v1/front/rbac/auth/user",
182
+ method: "GET",
183
+ data,
184
+ });
185
+ }
186
+ }
187
+ export const authApi = new AuthApi();
@@ -0,0 +1,86 @@
1
+ export interface TokenModel {
2
+ accessToken: string;
3
+ expiresIn: number;
4
+ refreshToken: string;
5
+ tokenType: string;
6
+ }
7
+ export declare enum OpensType {
8
+ wechat = 0,
9
+ ali_pay = 1,
10
+ union_pay = 2
11
+ }
12
+ export interface LoginReq {
13
+ appId: string;
14
+ loginCode: string;
15
+ componentAppid?: string;
16
+ opensType?: OpensType;
17
+ }
18
+ /**
19
+ * 登录请求参数
20
+ */
21
+ export interface WebLoginReq {
22
+ tenant?: string;
23
+ directoryId?: string;
24
+ scope?: string;
25
+ userName: string;
26
+ encodePwd: string;
27
+ captchaId?: string;
28
+ captchaCode?: string;
29
+ clientId?: string;
30
+ }
31
+ export interface LoginRes {
32
+ cacheKey?: string;
33
+ token: TokenModel;
34
+ status: boolean;
35
+ message: string;
36
+ }
37
+ export interface PhoneRegisterReq {
38
+ tenant?: string;
39
+ appId: string;
40
+ loginCode?: string;
41
+ phoneCode: string;
42
+ nickName?: string;
43
+ avatar?: string;
44
+ componentAppid?: string;
45
+ opensType?: OpensType;
46
+ }
47
+ export interface PhoneReplaceReq {
48
+ tenant?: string;
49
+ appId: string;
50
+ phoneCode: string;
51
+ componentAppid?: string;
52
+ opensType?: OpensType;
53
+ }
54
+ export interface RefreshTokenReq {
55
+ tenant: string;
56
+ refreshToken: string;
57
+ clientId: string;
58
+ }
59
+ export interface UserInfo {
60
+ userId: string;
61
+ loginName: string;
62
+ nickName: string;
63
+ realName: string;
64
+ avatar: string;
65
+ mobilePhone: string;
66
+ mobilePhoneIns: string;
67
+ storage: string;
68
+ unifiedId: string;
69
+ }
70
+ export interface RolesPerms {
71
+ roleCodes: string[];
72
+ permCodes: string[];
73
+ }
74
+ export interface UpdateUserReq {
75
+ tenant?: string;
76
+ requestId?: string;
77
+ updateMask?: string;
78
+ nickName?: string;
79
+ avatar?: string;
80
+ realName?: string;
81
+ gender?: string;
82
+ birthDate?: string;
83
+ }
84
+ export interface UserInfoReq {
85
+ tenant?: string;
86
+ }
@@ -0,0 +1,9 @@
1
+ export var OpensType;
2
+ (function (OpensType) {
3
+ //微信
4
+ OpensType[OpensType["wechat"] = 0] = "wechat";
5
+ //支付宝
6
+ OpensType[OpensType["ali_pay"] = 1] = "ali_pay";
7
+ //云闪付
8
+ OpensType[OpensType["union_pay"] = 2] = "union_pay";
9
+ })(OpensType || (OpensType = {}));
@@ -0,0 +1,9 @@
1
+ import { CmsSiteList, CmsChannelReq, CmsChannelList, CmsContentInfoReq, CmsContentInfoModel } from "./types";
2
+ import { ResponseData } from "../../types/core";
3
+ declare class CmsApiImpl {
4
+ findCmsSiteList(tenant: string): Promise<ResponseData<CmsSiteList>>;
5
+ findCmsChannelList(data: CmsChannelReq): Promise<ResponseData<CmsChannelList>>;
6
+ findCmsContentInfo(data: CmsContentInfoReq): Promise<ResponseData<CmsContentInfoModel>>;
7
+ }
8
+ declare const cmsApi: CmsApiImpl;
9
+ export { cmsApi };
@@ -0,0 +1,42 @@
1
+ import { grpc } from "../../utils/grpc";
2
+ import { config } from "../../utils/config";
3
+ import mpx from "@mpxjs/core";
4
+ // 获取网站内容信息
5
+ class CmsApiImpl {
6
+ // 查询企业官网、微网站列表
7
+ findCmsSiteList(tenant) {
8
+ return mpx.xfetch.fetch({
9
+ url: "/v1/front/cms/cms_site/list/" + tenant,
10
+ method: "GET",
11
+ });
12
+ }
13
+ // 查询列表信息网站栏目 (没有传递别名就是将所有的栏目信息查询出来,给了栏目别名查询传递别名的栏目信息)
14
+ findCmsChannelList(data) {
15
+ grpc.clearEmpty(data);
16
+ if (data) {
17
+ data.hasStatus = data.status !== undefined;
18
+ data.hasIsOpen = data.isOpen !== undefined;
19
+ }
20
+ return mpx.xfetch.fetch({
21
+ url: "/v1/front/cms/cms_channel/list/" + data.tenant,
22
+ method: "GET",
23
+ data,
24
+ });
25
+ }
26
+ // 根据栏目别名查询翻页信息信息主表-单页栏目内容
27
+ findCmsContentInfo(data) {
28
+ data.tenant = data.tenant || config.tenant;
29
+ grpc.clearEmpty(data);
30
+ return mpx.xfetch.fetch({
31
+ url: "/v1/front/cms/cms_info/alias/" +
32
+ data.tenant +
33
+ "/" +
34
+ data.siteId +
35
+ "/" +
36
+ data.channelAlias,
37
+ method: "GET",
38
+ });
39
+ }
40
+ }
41
+ const cmsApi = new CmsApiImpl();
42
+ export { cmsApi };
@@ -0,0 +1,72 @@
1
+ export interface CmsSiteList {
2
+ results: Array<CmsSiteModel>;
3
+ }
4
+ export interface CmsSiteModel {
5
+ siteId?: string;
6
+ siteName?: string;
7
+ }
8
+ export interface CmsChannelReq {
9
+ tenant?: string;
10
+ siteId?: string;
11
+ alias?: string;
12
+ status?: boolean;
13
+ hasStatus?: boolean;
14
+ isOpen?: boolean;
15
+ hasIsOpen?: boolean;
16
+ channelId?: string;
17
+ }
18
+ export interface CmsChannelModel {
19
+ channelId: string;
20
+ siteId?: string;
21
+ modelCode?: string;
22
+ channelName: string;
23
+ alias?: string;
24
+ parentId?: string;
25
+ seoTitle?: string;
26
+ seoDescription?: string;
27
+ status?: boolean;
28
+ children?: Array<CmsChannelModel>;
29
+ isOpen?: boolean;
30
+ isSelect?: boolean;
31
+ url: string;
32
+ type?: string;
33
+ }
34
+ export interface CmsChannelList {
35
+ results: Array<CmsChannelModel>;
36
+ }
37
+ export interface CmsContentInfoReq {
38
+ tenant?: string;
39
+ siteId?: string;
40
+ channelAlias: string;
41
+ }
42
+ export interface CmsContentInfoModel {
43
+ cmsInfo?: CmsInfoModel;
44
+ infoContentResults?: Array<CmsInfoContentModel>;
45
+ }
46
+ export interface CmsInfoModel {
47
+ infoId?: string;
48
+ modelCode?: string;
49
+ infoTitle: string;
50
+ imgUrl?: string;
51
+ author?: string;
52
+ intro?: string;
53
+ top?: number;
54
+ status?: string;
55
+ publishDate?: string;
56
+ dueTime?: string;
57
+ channelId: Array<string>;
58
+ sourceName?: string;
59
+ siteId: string;
60
+ }
61
+ export interface CmsInfoContentModel {
62
+ imagePath?: Array<string>;
63
+ videoPath?: Array<string>;
64
+ contentId?: string;
65
+ infoId?: string;
66
+ infoContent?: string;
67
+ infoType?: string;
68
+ orderBy?: number;
69
+ infoContentList?: {
70
+ path: string;
71
+ }[];
72
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ declare class Constant {
2
+ static readonly MODULE_RBAC = "rbac";
3
+ static readonly ENUM_GENDER = "jmash.protobuf.Gender";
4
+ }
5
+ export { Constant };
@@ -0,0 +1,6 @@
1
+ class Constant {
2
+ static MODULE_RBAC = "rbac"; // rbac
3
+ // 性别
4
+ static ENUM_GENDER = "jmash.protobuf.Gender";
5
+ }
6
+ export { Constant };
@@ -0,0 +1,18 @@
1
+ import { ResponseData } from "../../types/core";
2
+ import { EnumRes, DictEntryReq, DictEntryList } from "./types";
3
+ declare class DictApiImpl {
4
+ /**
5
+ * 枚举
6
+ * @param data 查询条件
7
+ * @returns 返回Promise<Entry[]>的对象
8
+ */
9
+ enumApi(module: string, className: string, type?: number): Promise<ResponseData<EnumRes>>;
10
+ /**
11
+ * 普通字典
12
+ * @param data 查询条件
13
+ * @returns 返回Promise<Entry[]>的对象
14
+ */
15
+ dictEntryApi(data: DictEntryReq): Promise<ResponseData<DictEntryList>>;
16
+ }
17
+ declare const dictApi: DictApiImpl;
18
+ export { dictApi };
@@ -0,0 +1,34 @@
1
+ import { config } from "../../utils/config";
2
+ import mpx from "@mpxjs/core";
3
+ class DictApiImpl {
4
+ /**
5
+ * 枚举
6
+ * @param data 查询条件
7
+ * @returns 返回Promise<Entry[]>的对象
8
+ */
9
+ enumApi(module, className, type) {
10
+ const data = { className, type };
11
+ return mpx.xfetch.fetch({
12
+ url: "/v1/" + module + "/enum/entry",
13
+ method: "GET",
14
+ data,
15
+ });
16
+ }
17
+ /**
18
+ * 普通字典
19
+ * @param data 查询条件
20
+ * @returns 返回Promise<Entry[]>的对象
21
+ */
22
+ dictEntryApi(data) {
23
+ if (data) {
24
+ data.hasEnable = data.enable !== undefined;
25
+ }
26
+ return mpx.xfetch.fetch({
27
+ url: "/v1/dict/dict_entry/list/" + config.tenant,
28
+ method: "GET",
29
+ data,
30
+ });
31
+ }
32
+ }
33
+ const dictApi = new DictApiImpl();
34
+ export { dictApi };
@@ -0,0 +1,28 @@
1
+ export interface Entry {
2
+ key?: string;
3
+ value?: string;
4
+ }
5
+ export interface EnumEntryReq {
6
+ className?: string;
7
+ type?: number;
8
+ }
9
+ export interface EnumRes {
10
+ values: Array<Entry>;
11
+ }
12
+ export interface DictEntryModel {
13
+ typeCode?: string;
14
+ dictCode?: string;
15
+ dictName?: string;
16
+ listOrder?: number;
17
+ enable?: boolean;
18
+ description?: string;
19
+ }
20
+ export interface DictEntryList {
21
+ results: Array<DictEntryModel>;
22
+ }
23
+ export interface DictEntryReq {
24
+ typeCode?: string;
25
+ dictCode?: string;
26
+ hasEnable?: boolean;
27
+ enable?: boolean;
28
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ import { Entry, DictEntryModel } 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
+ }
@@ -0,0 +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
+ }
@@ -0,0 +1,25 @@
1
+ import { FileInfo, FileBase64Req, FileDownInfo, FileWebReq } from "./types";
2
+ import { ResponseData } from "../../types/core";
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 };