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/src/api/auth/index.ts
CHANGED
|
@@ -1,227 +1,227 @@
|
|
|
1
|
-
import { ResponseData, AppConfig } from "../../api/types";
|
|
2
|
-
import { OpensType } from "./types";
|
|
3
|
-
import type {
|
|
4
|
-
LoginReq,
|
|
5
|
-
LoginRes,
|
|
6
|
-
RolesPerms,
|
|
7
|
-
WebLoginReq,
|
|
8
|
-
TokenModel,
|
|
9
|
-
PhoneRegisterReq,
|
|
10
|
-
PhoneReplaceReq,
|
|
11
|
-
UpdateUserReq,
|
|
12
|
-
UserInfoReq,
|
|
13
|
-
UserInfo,
|
|
14
|
-
} from "./types";
|
|
15
|
-
import { db } from "../../utils/db";
|
|
16
|
-
import { grpc } from "../../utils/grpc";
|
|
17
|
-
import mpx from "@mpxjs/core";
|
|
18
|
-
|
|
19
|
-
class AuthApi {
|
|
20
|
-
// 小程序静默登录
|
|
21
|
-
mpLogin(data: LoginReq): Promise<ResponseData<LoginRes>> {
|
|
22
|
-
if (__mpx_mode__ === "wx") {
|
|
23
|
-
data.opensType = OpensType.wechat;
|
|
24
|
-
}
|
|
25
|
-
if (__mpx_mode__ === "ali") {
|
|
26
|
-
data.opensType = OpensType.ali_pay;
|
|
27
|
-
}
|
|
28
|
-
const config = getApp().globalData.config;
|
|
29
|
-
return mpx.xfetch.fetch({
|
|
30
|
-
url: "/v1/front/rbac/miniapp_login/" + config.tenant,
|
|
31
|
-
method: "POST",
|
|
32
|
-
data,
|
|
33
|
-
header: {
|
|
34
|
-
"content-type": "application/json",
|
|
35
|
-
Authorization: false,
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// 手机号注册登录
|
|
41
|
-
mpPhoneRegister(data: PhoneRegisterReq): Promise<ResponseData<LoginRes>> {
|
|
42
|
-
if (__mpx_mode__ === "wx") {
|
|
43
|
-
data.opensType = OpensType.wechat;
|
|
44
|
-
}
|
|
45
|
-
if (__mpx_mode__ === "ali") {
|
|
46
|
-
data.opensType = OpensType.ali_pay;
|
|
47
|
-
}
|
|
48
|
-
const config = getApp().globalData.config;
|
|
49
|
-
return mpx.xfetch.fetch({
|
|
50
|
-
url: "/v1/front/rbac/miniapp_phonenumber/" + config.tenant,
|
|
51
|
-
method: "POST",
|
|
52
|
-
data: data,
|
|
53
|
-
header: {
|
|
54
|
-
Authorization: false,
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// 已登陆状态小程序更换绑定手机号
|
|
60
|
-
replaceBindphone(data: PhoneReplaceReq): Promise<ResponseData<string>> {
|
|
61
|
-
const config = getApp().globalData.config;
|
|
62
|
-
data.tenant = config.tenant;
|
|
63
|
-
if (__mpx_mode__ === "wx") {
|
|
64
|
-
data.opensType = OpensType.wechat;
|
|
65
|
-
}
|
|
66
|
-
if (__mpx_mode__ === "ali") {
|
|
67
|
-
data.opensType = OpensType.ali_pay;
|
|
68
|
-
}
|
|
69
|
-
grpc.clearEmpty(data);
|
|
70
|
-
return mpx.xfetch.fetch({
|
|
71
|
-
url: "/v1/front/rbac/miniapp_bindphone",
|
|
72
|
-
method: "POST",
|
|
73
|
-
data: data,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
//web登录.
|
|
78
|
-
webLogin(data: WebLoginReq): Promise<ResponseData<TokenModel>> {
|
|
79
|
-
const config = getApp().globalData.config;
|
|
80
|
-
data.tenant = config.tenant;
|
|
81
|
-
data.directoryId = "user";
|
|
82
|
-
data.clientId = config.appId ? config.appId : "h5";
|
|
83
|
-
data.captchaId = "1";
|
|
84
|
-
data.captchaCode = "1";
|
|
85
|
-
return mpx.xfetch.fetch({
|
|
86
|
-
url: "/v1/rbac/auth/login",
|
|
87
|
-
method: "POST",
|
|
88
|
-
data: data,
|
|
89
|
-
header: {
|
|
90
|
-
Authorization: false,
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// 刷新token
|
|
96
|
-
refreshToken(): Promise<ResponseData<TokenModel>> {
|
|
97
|
-
const config = getApp().globalData.config;
|
|
98
|
-
return mpx.xfetch.fetch({
|
|
99
|
-
url: "/v1/front/rbac/auth/refresh_token",
|
|
100
|
-
method: "POST",
|
|
101
|
-
data: {
|
|
102
|
-
refreshToken: db.getRefreshToken(),
|
|
103
|
-
tenant: config.tenant,
|
|
104
|
-
clientId: config.appId,
|
|
105
|
-
},
|
|
106
|
-
header: { "content-type": "application/json" },
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// 获取当前会话用户
|
|
111
|
-
userInfo(): Promise<ResponseData<UserInfo>> {
|
|
112
|
-
const config = getApp().globalData.config;
|
|
113
|
-
return mpx.xfetch.fetch({
|
|
114
|
-
url: "/v1/rbac/auth/user?tenant=" + config.tenant,
|
|
115
|
-
method: "GET",
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// 当前用户角色权限
|
|
120
|
-
userRolesPerms(): Promise<ResponseData<RolesPerms>> {
|
|
121
|
-
const config = getApp().globalData.config;
|
|
122
|
-
return mpx.xfetch.fetch({
|
|
123
|
-
url: "/v1/rbac/auth/roles_perms?tenant=" + config.tenant,
|
|
124
|
-
method: "GET",
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
// 允许切换身份的用户列表
|
|
128
|
-
allowRunAsUser(): Promise<ResponseData<any[]>> {
|
|
129
|
-
const config = getApp().globalData.config;
|
|
130
|
-
return mpx.xfetch.fetch({
|
|
131
|
-
url: "/v1/rbac/auth/allow_run_as_user?tenant=" + config.tenant,
|
|
132
|
-
method: "GET",
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// 运行某种身份
|
|
137
|
-
runAsUser(userId: string): Promise<ResponseData<any>> {
|
|
138
|
-
const config = getApp().globalData.config;
|
|
139
|
-
const data = {
|
|
140
|
-
tenant: config.tenant,
|
|
141
|
-
userId: userId,
|
|
142
|
-
};
|
|
143
|
-
return mpx.xfetch.fetch({
|
|
144
|
-
url: "/v1/rbac/auth/run_as",
|
|
145
|
-
method: "POST",
|
|
146
|
-
data: data,
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
// 更新用户
|
|
150
|
-
updateUser(data: any): Promise<ResponseData<any>> {
|
|
151
|
-
return mpx.xfetch.fetch({
|
|
152
|
-
url: "/v1/rbac/auth/user",
|
|
153
|
-
method: "PATCH",
|
|
154
|
-
data: data,
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// 修改密码
|
|
159
|
-
updatePwd(
|
|
160
|
-
encodeOldPwd: string,
|
|
161
|
-
encodeNewPwd: string
|
|
162
|
-
): Promise<ResponseData<any>> {
|
|
163
|
-
const data = {
|
|
164
|
-
tenant: db.getUserTenant(),
|
|
165
|
-
encodeOldPwd: encodeOldPwd,
|
|
166
|
-
encodeNewPwd: encodeNewPwd,
|
|
167
|
-
};
|
|
168
|
-
return mpx.xfetch.fetch({
|
|
169
|
-
url: "/v1/rbac/auth/change_pwd",
|
|
170
|
-
method: "PATCH",
|
|
171
|
-
data: data,
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
// 部门Tree
|
|
175
|
-
deptTree(deptId?: string, tenant?: string): Promise<ResponseData<any[]>> {
|
|
176
|
-
const config = getApp().globalData.config;
|
|
177
|
-
const query = {
|
|
178
|
-
tenant: tenant ? tenant : config.tenant,
|
|
179
|
-
excludeId: deptId,
|
|
180
|
-
};
|
|
181
|
-
return mpx.xfetch.fetch({
|
|
182
|
-
url: "/v1/rbac/dept/treelist",
|
|
183
|
-
method: "GET",
|
|
184
|
-
data: query,
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// 职务Tree
|
|
189
|
-
jobTree(jobId?: string, tenant?: string): Promise<ResponseData<any[]>> {
|
|
190
|
-
const config = getApp().globalData.config;
|
|
191
|
-
const query = {
|
|
192
|
-
tenant: tenant ? tenant : config.tenant,
|
|
193
|
-
roleType: "job",
|
|
194
|
-
hasRoleType: true,
|
|
195
|
-
excludeId: jobId,
|
|
196
|
-
};
|
|
197
|
-
return mpx.xfetch.fetch({
|
|
198
|
-
url: "/v1/rbac/role/treelist",
|
|
199
|
-
method: "GET",
|
|
200
|
-
data: query,
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
// 修改个人信息
|
|
204
|
-
updateUserInfo(data: UpdateUserReq): Promise<ResponseData<UserInfo>> {
|
|
205
|
-
const config = getApp().globalData.config;
|
|
206
|
-
data.tenant = config.tenant;
|
|
207
|
-
grpc.clearEmpty(data);
|
|
208
|
-
return mpx.xfetch.fetch({
|
|
209
|
-
url: "/v1/rbac/auth/user",
|
|
210
|
-
method: "PATCH",
|
|
211
|
-
data: data,
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// 获取当前会话用户的信息
|
|
216
|
-
findUserInfo(data: UserInfoReq): Promise<ResponseData<UserInfo>> {
|
|
217
|
-
const config = getApp().globalData.config;
|
|
218
|
-
data.tenant = config.tenant;
|
|
219
|
-
return mpx.xfetch.fetch({
|
|
220
|
-
url: "/v1/front/rbac/auth/user",
|
|
221
|
-
method: "GET",
|
|
222
|
-
data,
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
export const authApi = new AuthApi();
|
|
1
|
+
import { ResponseData, AppConfig } from "../../api/types";
|
|
2
|
+
import { OpensType } from "./types";
|
|
3
|
+
import type {
|
|
4
|
+
LoginReq,
|
|
5
|
+
LoginRes,
|
|
6
|
+
RolesPerms,
|
|
7
|
+
WebLoginReq,
|
|
8
|
+
TokenModel,
|
|
9
|
+
PhoneRegisterReq,
|
|
10
|
+
PhoneReplaceReq,
|
|
11
|
+
UpdateUserReq,
|
|
12
|
+
UserInfoReq,
|
|
13
|
+
UserInfo,
|
|
14
|
+
} from "./types";
|
|
15
|
+
import { db } from "../../utils/db";
|
|
16
|
+
import { grpc } from "../../utils/grpc";
|
|
17
|
+
import mpx from "@mpxjs/core";
|
|
18
|
+
|
|
19
|
+
class AuthApi {
|
|
20
|
+
// 小程序静默登录
|
|
21
|
+
mpLogin(data: LoginReq): Promise<ResponseData<LoginRes>> {
|
|
22
|
+
if (__mpx_mode__ === "wx") {
|
|
23
|
+
data.opensType = OpensType.wechat;
|
|
24
|
+
}
|
|
25
|
+
if (__mpx_mode__ === "ali") {
|
|
26
|
+
data.opensType = OpensType.ali_pay;
|
|
27
|
+
}
|
|
28
|
+
const config = getApp().globalData.config;
|
|
29
|
+
return mpx.xfetch.fetch({
|
|
30
|
+
url: "/v1/front/rbac/miniapp_login/" + config.tenant,
|
|
31
|
+
method: "POST",
|
|
32
|
+
data,
|
|
33
|
+
header: {
|
|
34
|
+
"content-type": "application/json",
|
|
35
|
+
Authorization: false,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 手机号注册登录
|
|
41
|
+
mpPhoneRegister(data: PhoneRegisterReq): Promise<ResponseData<LoginRes>> {
|
|
42
|
+
if (__mpx_mode__ === "wx") {
|
|
43
|
+
data.opensType = OpensType.wechat;
|
|
44
|
+
}
|
|
45
|
+
if (__mpx_mode__ === "ali") {
|
|
46
|
+
data.opensType = OpensType.ali_pay;
|
|
47
|
+
}
|
|
48
|
+
const config = getApp().globalData.config;
|
|
49
|
+
return mpx.xfetch.fetch({
|
|
50
|
+
url: "/v1/front/rbac/miniapp_phonenumber/" + config.tenant,
|
|
51
|
+
method: "POST",
|
|
52
|
+
data: data,
|
|
53
|
+
header: {
|
|
54
|
+
Authorization: false,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// 已登陆状态小程序更换绑定手机号
|
|
60
|
+
replaceBindphone(data: PhoneReplaceReq): Promise<ResponseData<string>> {
|
|
61
|
+
const config = getApp().globalData.config;
|
|
62
|
+
data.tenant = config.tenant;
|
|
63
|
+
if (__mpx_mode__ === "wx") {
|
|
64
|
+
data.opensType = OpensType.wechat;
|
|
65
|
+
}
|
|
66
|
+
if (__mpx_mode__ === "ali") {
|
|
67
|
+
data.opensType = OpensType.ali_pay;
|
|
68
|
+
}
|
|
69
|
+
grpc.clearEmpty(data);
|
|
70
|
+
return mpx.xfetch.fetch({
|
|
71
|
+
url: "/v1/front/rbac/miniapp_bindphone",
|
|
72
|
+
method: "POST",
|
|
73
|
+
data: data,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//web登录.
|
|
78
|
+
webLogin(data: WebLoginReq): Promise<ResponseData<TokenModel>> {
|
|
79
|
+
const config = getApp().globalData.config;
|
|
80
|
+
data.tenant = config.tenant;
|
|
81
|
+
data.directoryId = "user";
|
|
82
|
+
data.clientId = config.appId ? config.appId : "h5";
|
|
83
|
+
data.captchaId = "1";
|
|
84
|
+
data.captchaCode = "1";
|
|
85
|
+
return mpx.xfetch.fetch({
|
|
86
|
+
url: "/v1/rbac/auth/login",
|
|
87
|
+
method: "POST",
|
|
88
|
+
data: data,
|
|
89
|
+
header: {
|
|
90
|
+
Authorization: false,
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// 刷新token
|
|
96
|
+
refreshToken(): Promise<ResponseData<TokenModel>> {
|
|
97
|
+
const config = getApp().globalData.config;
|
|
98
|
+
return mpx.xfetch.fetch({
|
|
99
|
+
url: "/v1/front/rbac/auth/refresh_token",
|
|
100
|
+
method: "POST",
|
|
101
|
+
data: {
|
|
102
|
+
refreshToken: db.getRefreshToken(),
|
|
103
|
+
tenant: config.tenant,
|
|
104
|
+
clientId: config.appId,
|
|
105
|
+
},
|
|
106
|
+
header: { "content-type": "application/json" },
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// 获取当前会话用户
|
|
111
|
+
userInfo(): Promise<ResponseData<UserInfo>> {
|
|
112
|
+
const config = getApp().globalData.config;
|
|
113
|
+
return mpx.xfetch.fetch({
|
|
114
|
+
url: "/v1/rbac/auth/user?tenant=" + config.tenant,
|
|
115
|
+
method: "GET",
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// 当前用户角色权限
|
|
120
|
+
userRolesPerms(): Promise<ResponseData<RolesPerms>> {
|
|
121
|
+
const config = getApp().globalData.config;
|
|
122
|
+
return mpx.xfetch.fetch({
|
|
123
|
+
url: "/v1/rbac/auth/roles_perms?tenant=" + config.tenant,
|
|
124
|
+
method: "GET",
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
// 允许切换身份的用户列表
|
|
128
|
+
allowRunAsUser(): Promise<ResponseData<any[]>> {
|
|
129
|
+
const config = getApp().globalData.config;
|
|
130
|
+
return mpx.xfetch.fetch({
|
|
131
|
+
url: "/v1/rbac/auth/allow_run_as_user?tenant=" + config.tenant,
|
|
132
|
+
method: "GET",
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// 运行某种身份
|
|
137
|
+
runAsUser(userId: string): Promise<ResponseData<any>> {
|
|
138
|
+
const config = getApp().globalData.config;
|
|
139
|
+
const data = {
|
|
140
|
+
tenant: config.tenant,
|
|
141
|
+
userId: userId,
|
|
142
|
+
};
|
|
143
|
+
return mpx.xfetch.fetch({
|
|
144
|
+
url: "/v1/rbac/auth/run_as",
|
|
145
|
+
method: "POST",
|
|
146
|
+
data: data,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
// 更新用户
|
|
150
|
+
updateUser(data: any): Promise<ResponseData<any>> {
|
|
151
|
+
return mpx.xfetch.fetch({
|
|
152
|
+
url: "/v1/rbac/auth/user",
|
|
153
|
+
method: "PATCH",
|
|
154
|
+
data: data,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// 修改密码
|
|
159
|
+
updatePwd(
|
|
160
|
+
encodeOldPwd: string,
|
|
161
|
+
encodeNewPwd: string
|
|
162
|
+
): Promise<ResponseData<any>> {
|
|
163
|
+
const data = {
|
|
164
|
+
tenant: db.getUserTenant(),
|
|
165
|
+
encodeOldPwd: encodeOldPwd,
|
|
166
|
+
encodeNewPwd: encodeNewPwd,
|
|
167
|
+
};
|
|
168
|
+
return mpx.xfetch.fetch({
|
|
169
|
+
url: "/v1/rbac/auth/change_pwd",
|
|
170
|
+
method: "PATCH",
|
|
171
|
+
data: data,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
// 部门Tree
|
|
175
|
+
deptTree(deptId?: string, tenant?: string): Promise<ResponseData<any[]>> {
|
|
176
|
+
const config = getApp().globalData.config;
|
|
177
|
+
const query = {
|
|
178
|
+
tenant: tenant ? tenant : config.tenant,
|
|
179
|
+
excludeId: deptId,
|
|
180
|
+
};
|
|
181
|
+
return mpx.xfetch.fetch({
|
|
182
|
+
url: "/v1/rbac/dept/treelist",
|
|
183
|
+
method: "GET",
|
|
184
|
+
data: query,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// 职务Tree
|
|
189
|
+
jobTree(jobId?: string, tenant?: string): Promise<ResponseData<any[]>> {
|
|
190
|
+
const config = getApp().globalData.config;
|
|
191
|
+
const query = {
|
|
192
|
+
tenant: tenant ? tenant : config.tenant,
|
|
193
|
+
roleType: "job",
|
|
194
|
+
hasRoleType: true,
|
|
195
|
+
excludeId: jobId,
|
|
196
|
+
};
|
|
197
|
+
return mpx.xfetch.fetch({
|
|
198
|
+
url: "/v1/rbac/role/treelist",
|
|
199
|
+
method: "GET",
|
|
200
|
+
data: query,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
// 修改个人信息
|
|
204
|
+
updateUserInfo(data: UpdateUserReq): Promise<ResponseData<UserInfo>> {
|
|
205
|
+
const config = getApp().globalData.config;
|
|
206
|
+
data.tenant = config.tenant;
|
|
207
|
+
grpc.clearEmpty(data);
|
|
208
|
+
return mpx.xfetch.fetch({
|
|
209
|
+
url: "/v1/rbac/auth/user",
|
|
210
|
+
method: "PATCH",
|
|
211
|
+
data: data,
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// 获取当前会话用户的信息
|
|
216
|
+
findUserInfo(data: UserInfoReq): Promise<ResponseData<UserInfo>> {
|
|
217
|
+
const config = getApp().globalData.config;
|
|
218
|
+
data.tenant = config.tenant;
|
|
219
|
+
return mpx.xfetch.fetch({
|
|
220
|
+
url: "/v1/front/rbac/auth/user",
|
|
221
|
+
method: "GET",
|
|
222
|
+
data,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export const authApi = new AuthApi();
|