jmash-core-mp 0.1.12 → 0.1.13
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 +187 -187
- 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 +198 -207
- 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 +131 -131
- 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 +40 -40
- package/lib/api/storage/types.d.ts +28 -28
- package/lib/api/storage/types.js +1 -1
- package/lib/api/types.d.ts +41 -41
- 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.mpx.d.ts +1 -1
- package/lib/components/core/jmash-login.mpx.d.ts +1 -1
- package/lib/index.d.ts +21 -21
- package/lib/index.js +14 -14
- package/lib/store/user.d.ts +31 -31
- package/lib/store/user.js +224 -224
- package/lib/types/core.d.ts +41 -41
- package/lib/types/core.js +1 -1
- package/lib/utils/common.d.ts +35 -35
- package/lib/utils/common.js +163 -163
- package/lib/utils/config.d.ts +3 -3
- package/lib/utils/config.js +30 -30
- 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 +122 -122
- 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 +215 -215
- package/src/api/auth/types.ts +166 -166
- package/src/api/cms/index.ts +218 -218
- package/src/api/cms/types.ts +375 -392
- 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 +159 -159
- 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 +59 -59
- package/src/api/storage/types.ts +54 -54
- package/src/api/types.ts +70 -70
- package/src/app.mpx +72 -72
- package/src/components/auth-user/jmash-logout.mpx +91 -91
- package/src/components/auth-user/jmash-update-user.mpx +381 -381
- package/src/components/auth-user/jmash-update-user.web.mpx +365 -365
- package/src/components/auth-user/jmash-user.mpx +355 -355
- package/src/components/cms/jmash-cms-acticle-list.mpx +181 -181
- package/src/components/cms/jmash-cms-article.mpx +68 -68
- 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 +77 -77
- 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 +170 -170
- 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 -70
- package/src/packages/index.mpx +9 -9
- package/src/packages/pages/auth/cms-protocol.mpx +30 -30
- package/src/packages/pages/auth/login.mpx +58 -58
- package/src/packages/pages/auth/update-user.mpx +17 -17
- package/src/packages/pages/cms/cms-article.mpx +31 -31
- package/src/pages/basic-component.mpx +30 -30
- package/src/pages/half-home.mpx +58 -58
- package/src/pages/home.mpx +49 -49
- package/src/pages/index.mpx +43 -43
- package/src/pages/tabbar/home.mpx +71 -71
- package/src/pages/tabbar/my.mpx +80 -80
- package/src/store/user.ts +268 -268
- package/src/styles/index.scss +20 -20
- package/src/styles/vars.scss +27 -27
- package/src/utils/common.ts +176 -176
- package/src/utils/config.ts +31 -31
- 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/components/cms/cms-acticle-list.mpx.d.ts +0 -1
package/.editorconfig
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
root = true
|
|
2
|
-
|
|
3
|
-
[*]
|
|
4
|
-
charset = utf-8
|
|
5
|
-
indent_style = space
|
|
6
|
-
indent_size = 2
|
|
7
|
-
end_of_line = lf
|
|
8
|
-
insert_final_newline = true
|
|
9
|
-
trim_trailing_whitespace = true
|
|
1
|
+
root = true
|
|
2
|
+
|
|
3
|
+
[*]
|
|
4
|
+
charset = utf-8
|
|
5
|
+
indent_style = space
|
|
6
|
+
indent_size = 2
|
|
7
|
+
end_of_line = lf
|
|
8
|
+
insert_final_newline = true
|
|
9
|
+
trim_trailing_whitespace = true
|
package/README.md
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
# jmash-core-mp
|
|
2
|
-
|
|
3
|
-
采用 MPX 构建的 Jmash 高性能跨端小程序。
|
|
4
|
-
https://mpxjs.cn/
|
|
5
|
-
|
|
6
|
-
## Project setup
|
|
7
|
-
|
|
8
|
-
```javascript
|
|
9
|
-
// 开发构建,默认输出微信小程序
|
|
10
|
-
npm run serve
|
|
11
|
-
|
|
12
|
-
// 开发构建,跨平台输出支付宝小程序
|
|
13
|
-
npm run serve:ali
|
|
14
|
-
|
|
15
|
-
// 开发构建,跨平台输出 Web
|
|
16
|
-
npm run serve:web
|
|
17
|
-
|
|
18
|
-
// 开发构建,跨平台输出其他平台小程序target = swan|tt|qq|jd|ks
|
|
19
|
-
npm run serve -- --targets={target}
|
|
20
|
-
|
|
21
|
-
// 开发构建,同时输出多平台产物
|
|
22
|
-
npm run serve -- --targets=wx,ali,web
|
|
23
|
-
|
|
24
|
-
// 生产构建,默认输出微信小程序
|
|
25
|
-
npm run build
|
|
26
|
-
|
|
27
|
-
// 生产构建,跨平台输出
|
|
28
|
-
npm run build:ali
|
|
29
|
-
npm run build:web
|
|
30
|
-
npm run build -- --targets=wx,ali,web
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
# ALi 小程序
|
|
34
|
-
|
|
35
|
-
登录
|
|
36
|
-
minidev login
|
|
37
|
-
|
|
38
|
-
调试开发
|
|
39
|
-
minidev dev
|
|
40
|
-
|
|
41
|
-
本地 IP 调试
|
|
42
|
-
minidev dev --host 192.168.1.154
|
|
43
|
-
|
|
44
|
-
真机调试
|
|
45
|
-
minidev remote-debug -a 2021006137629651
|
|
46
|
-
|
|
47
|
-
Web 端调试
|
|
48
|
-
minidev dev
|
|
49
|
-
web -a 2021006137629651
|
|
50
|
-
真机预览
|
|
51
|
-
minidev preview -a 2021006137629651
|
|
52
|
-
|
|
53
|
-
# pnpm publish --no-git-checks
|
|
54
|
-
|
|
55
|
-
官方镜像
|
|
56
|
-
npm config set registry https://registry.npmjs.org/
|
|
57
|
-
国内镜像
|
|
58
|
-
npm config set registry https://registry.npmmirror.com/
|
|
59
|
-
代理镜像
|
|
60
|
-
npm config set registry https://npm.crenjoy.com/
|
|
1
|
+
# jmash-core-mp
|
|
2
|
+
|
|
3
|
+
采用 MPX 构建的 Jmash 高性能跨端小程序。
|
|
4
|
+
https://mpxjs.cn/
|
|
5
|
+
|
|
6
|
+
## Project setup
|
|
7
|
+
|
|
8
|
+
```javascript
|
|
9
|
+
// 开发构建,默认输出微信小程序
|
|
10
|
+
npm run serve
|
|
11
|
+
|
|
12
|
+
// 开发构建,跨平台输出支付宝小程序
|
|
13
|
+
npm run serve:ali
|
|
14
|
+
|
|
15
|
+
// 开发构建,跨平台输出 Web
|
|
16
|
+
npm run serve:web
|
|
17
|
+
|
|
18
|
+
// 开发构建,跨平台输出其他平台小程序target = swan|tt|qq|jd|ks
|
|
19
|
+
npm run serve -- --targets={target}
|
|
20
|
+
|
|
21
|
+
// 开发构建,同时输出多平台产物
|
|
22
|
+
npm run serve -- --targets=wx,ali,web
|
|
23
|
+
|
|
24
|
+
// 生产构建,默认输出微信小程序
|
|
25
|
+
npm run build
|
|
26
|
+
|
|
27
|
+
// 生产构建,跨平台输出
|
|
28
|
+
npm run build:ali
|
|
29
|
+
npm run build:web
|
|
30
|
+
npm run build -- --targets=wx,ali,web
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
# ALi 小程序
|
|
34
|
+
|
|
35
|
+
登录
|
|
36
|
+
minidev login
|
|
37
|
+
|
|
38
|
+
调试开发
|
|
39
|
+
minidev dev
|
|
40
|
+
|
|
41
|
+
本地 IP 调试
|
|
42
|
+
minidev dev --host 192.168.1.154
|
|
43
|
+
|
|
44
|
+
真机调试
|
|
45
|
+
minidev remote-debug -a 2021006137629651
|
|
46
|
+
|
|
47
|
+
Web 端调试
|
|
48
|
+
minidev dev
|
|
49
|
+
web -a 2021006137629651
|
|
50
|
+
真机预览
|
|
51
|
+
minidev preview -a 2021006137629651
|
|
52
|
+
|
|
53
|
+
# pnpm publish --no-git-checks
|
|
54
|
+
|
|
55
|
+
官方镜像
|
|
56
|
+
npm config set registry https://registry.npmjs.org/
|
|
57
|
+
国内镜像
|
|
58
|
+
npm config set registry https://registry.npmmirror.com/
|
|
59
|
+
代理镜像
|
|
60
|
+
npm config set registry https://npm.crenjoy.com/
|
package/babel.config.json
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
{
|
|
2
|
-
"presets": [
|
|
3
|
-
[
|
|
4
|
-
"@babel/preset-env",
|
|
5
|
-
{
|
|
6
|
-
"modules": false,
|
|
7
|
-
"shippedProposals": true
|
|
8
|
-
}
|
|
9
|
-
],
|
|
10
|
-
],
|
|
11
|
-
"plugins": [
|
|
12
|
-
[
|
|
13
|
-
"@babel/transform-runtime",
|
|
14
|
-
{
|
|
15
|
-
"corejs": 3,
|
|
16
|
-
"version": "^7.10.4"
|
|
17
|
-
}
|
|
18
|
-
],
|
|
19
|
-
"@mpxjs/babel-plugin-inject-page-events",
|
|
20
|
-
],
|
|
21
|
-
"sourceType": "unambiguous",
|
|
22
|
-
"env": {
|
|
23
|
-
"test": {
|
|
24
|
-
"presets": [
|
|
25
|
-
[
|
|
26
|
-
"@babel/env",
|
|
27
|
-
{
|
|
28
|
-
"shippedProposals": true
|
|
29
|
-
}
|
|
30
|
-
]
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"presets": [
|
|
3
|
+
[
|
|
4
|
+
"@babel/preset-env",
|
|
5
|
+
{
|
|
6
|
+
"modules": false,
|
|
7
|
+
"shippedProposals": true
|
|
8
|
+
}
|
|
9
|
+
],
|
|
10
|
+
],
|
|
11
|
+
"plugins": [
|
|
12
|
+
[
|
|
13
|
+
"@babel/transform-runtime",
|
|
14
|
+
{
|
|
15
|
+
"corejs": 3,
|
|
16
|
+
"version": "^7.10.4"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"@mpxjs/babel-plugin-inject-page-events",
|
|
20
|
+
],
|
|
21
|
+
"sourceType": "unambiguous",
|
|
22
|
+
"env": {
|
|
23
|
+
"test": {
|
|
24
|
+
"presets": [
|
|
25
|
+
[
|
|
26
|
+
"@babel/env",
|
|
27
|
+
{
|
|
28
|
+
"shippedProposals": true
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
package/eslint.config.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { mpxConfig } from '@mpxjs/eslint-config'
|
|
2
|
-
export default mpxConfig(
|
|
3
|
-
{
|
|
4
|
-
mpx: true,
|
|
5
|
-
typescript: true
|
|
6
|
-
}
|
|
7
|
-
)
|
|
1
|
+
import { mpxConfig } from '@mpxjs/eslint-config'
|
|
2
|
+
export default mpxConfig(
|
|
3
|
+
{
|
|
4
|
+
mpx: true,
|
|
5
|
+
typescript: true
|
|
6
|
+
}
|
|
7
|
+
)
|
package/lib/api/auth/index.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { ResponseData } from "../../api/types";
|
|
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 {};
|
|
1
|
+
import { ResponseData } from "../../api/types";
|
|
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 {};
|
package/lib/api/auth/index.js
CHANGED
|
@@ -1,187 +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();
|
|
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();
|