jmash-core-mp 0.1.18 → 0.1.19
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/lib/api/auth/index.d.ts +3 -1
- package/lib/api/auth/index.js +19 -16
- package/lib/api/cms/index.d.ts +3 -1
- package/lib/api/cms/index.js +5 -2
- package/lib/api/dict/index.d.ts +3 -1
- package/lib/api/dict/index.js +5 -2
- package/lib/api/files/index.d.ts +3 -1
- package/lib/api/files/index.js +9 -6
- package/lib/api/region/index.d.ts +3 -1
- package/lib/api/region/index.js +5 -2
- package/lib/api/storage/index.d.ts +3 -1
- package/lib/api/storage/index.js +8 -5
- package/lib/store/user.js +11 -8
- package/lib/utils/request.js +2 -1
- package/package.json +1 -1
- package/src/api/auth/index.ts +20 -17
- package/src/api/cms/index.ts +6 -3
- package/src/api/dict/index.ts +6 -3
- package/src/api/files/index.ts +10 -7
- package/src/api/region/index.ts +6 -3
- package/src/api/storage/index.ts +9 -6
- package/src/app.mpx +3 -1
- package/src/components/auth-user/jmash-update-user.mpx +5 -4
- package/src/components/auth-user/jmash-update-user.web.mpx +4 -3
- package/src/components/cms/jmash-cms-acticle-list.mpx +1 -1
- package/src/components/cms/jmash-cms-article-item.mpx +2 -1
- package/src/components/cms/jmash-cms-article-view.mpx +1 -1
- package/src/components/cms/jmash-cms-like.mpx +2 -1
- package/src/components/common/jmash-avatar-edit.mpx +1 -1
- package/src/components/common/jmash-none-data.mpx +3 -3
- package/src/components/common/jmash-popup.mpx +1 -1
- package/src/components/common/jmash-search.mpx +1 -1
- package/src/components/common/jmash-upload-picture.mpx +2 -1
- package/src/packages/pages/auth/cms-protocol.mpx +3 -2
- package/src/packages/pages/auth/login.mpx +3 -2
- package/src/packages/pages/cms/cms-article-list.mpx +5 -4
- package/src/packages/pages/cms/cms-article.mpx +4 -3
- package/src/pages/home.mpx +1 -1
- package/src/pages/home2.mpx +48 -0
- package/src/pages/tabbar/home.mpx +7 -1
- package/src/store/user.ts +12 -10
- package/src/utils/request.ts +2 -2
package/lib/api/auth/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { ResponseData } from "../../api/types";
|
|
1
|
+
import { ResponseData, AppConfig } from "../../api/types";
|
|
2
2
|
import type { LoginReq, LoginRes, RolesPerms, WebLoginReq, TokenModel, PhoneRegisterReq, PhoneReplaceReq, UpdateUserReq, UserInfoReq, UserInfo } from "./types";
|
|
3
3
|
declare class AuthApi {
|
|
4
|
+
config: AppConfig;
|
|
5
|
+
constructor();
|
|
4
6
|
mpLogin(data: LoginReq): Promise<ResponseData<LoginRes>>;
|
|
5
7
|
mpPhoneRegister(data: PhoneRegisterReq): Promise<ResponseData<LoginRes>>;
|
|
6
8
|
replaceBindphone(data: PhoneReplaceReq): Promise<ResponseData<string>>;
|
package/lib/api/auth/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { OpensType } from "./types";
|
|
2
2
|
import { db } from "../../utils/db";
|
|
3
3
|
import { grpc } from "../../utils/grpc";
|
|
4
|
-
import { config } from "../../utils/config";
|
|
5
4
|
import mpx from "@mpxjs/core";
|
|
6
5
|
class AuthApi {
|
|
6
|
+
config;
|
|
7
|
+
constructor() {
|
|
8
|
+
this.config = getApp().globalData.config;
|
|
9
|
+
}
|
|
7
10
|
// 小程序静默登录
|
|
8
11
|
mpLogin(data) {
|
|
9
12
|
if (__mpx_mode__ === "wx") {
|
|
@@ -13,7 +16,7 @@ class AuthApi {
|
|
|
13
16
|
data.opensType = OpensType.ali_pay;
|
|
14
17
|
}
|
|
15
18
|
return mpx.xfetch.fetch({
|
|
16
|
-
url: "/v1/front/rbac/miniapp_login/" + config.tenant,
|
|
19
|
+
url: "/v1/front/rbac/miniapp_login/" + this.config.tenant,
|
|
17
20
|
method: "POST",
|
|
18
21
|
data,
|
|
19
22
|
header: {
|
|
@@ -31,7 +34,7 @@ class AuthApi {
|
|
|
31
34
|
data.opensType = OpensType.ali_pay;
|
|
32
35
|
}
|
|
33
36
|
return mpx.xfetch.fetch({
|
|
34
|
-
url: "/v1/front/rbac/miniapp_phonenumber/" + config.tenant,
|
|
37
|
+
url: "/v1/front/rbac/miniapp_phonenumber/" + this.config.tenant,
|
|
35
38
|
method: "POST",
|
|
36
39
|
data: data,
|
|
37
40
|
header: {
|
|
@@ -41,7 +44,7 @@ class AuthApi {
|
|
|
41
44
|
}
|
|
42
45
|
// 已登陆状态小程序更换绑定手机号
|
|
43
46
|
replaceBindphone(data) {
|
|
44
|
-
data.tenant = config.tenant;
|
|
47
|
+
data.tenant = this.config.tenant;
|
|
45
48
|
if (__mpx_mode__ === "wx") {
|
|
46
49
|
data.opensType = OpensType.wechat;
|
|
47
50
|
}
|
|
@@ -57,9 +60,9 @@ class AuthApi {
|
|
|
57
60
|
}
|
|
58
61
|
//web登录.
|
|
59
62
|
webLogin(data) {
|
|
60
|
-
data.tenant = config.tenant;
|
|
63
|
+
data.tenant = this.config.tenant;
|
|
61
64
|
data.directoryId = "user";
|
|
62
|
-
data.clientId = config.appId ? config.appId : "h5";
|
|
65
|
+
data.clientId = this.config.appId ? this.config.appId : "h5";
|
|
63
66
|
data.captchaId = "1";
|
|
64
67
|
data.captchaCode = "1";
|
|
65
68
|
return mpx.xfetch.fetch({
|
|
@@ -78,8 +81,8 @@ class AuthApi {
|
|
|
78
81
|
method: "POST",
|
|
79
82
|
data: {
|
|
80
83
|
refreshToken: db.getRefreshToken(),
|
|
81
|
-
tenant: config.tenant,
|
|
82
|
-
clientId: config.appId,
|
|
84
|
+
tenant: this.config.tenant,
|
|
85
|
+
clientId: this.config.appId,
|
|
83
86
|
},
|
|
84
87
|
header: { "content-type": "application/json" },
|
|
85
88
|
});
|
|
@@ -87,28 +90,28 @@ class AuthApi {
|
|
|
87
90
|
// 获取当前会话用户
|
|
88
91
|
userInfo() {
|
|
89
92
|
return mpx.xfetch.fetch({
|
|
90
|
-
url: "/v1/rbac/auth/user?tenant=" + config.tenant,
|
|
93
|
+
url: "/v1/rbac/auth/user?tenant=" + this.config.tenant,
|
|
91
94
|
method: "GET",
|
|
92
95
|
});
|
|
93
96
|
}
|
|
94
97
|
// 当前用户角色权限
|
|
95
98
|
userRolesPerms() {
|
|
96
99
|
return mpx.xfetch.fetch({
|
|
97
|
-
url: "/v1/rbac/auth/roles_perms?tenant=" + config.tenant,
|
|
100
|
+
url: "/v1/rbac/auth/roles_perms?tenant=" + this.config.tenant,
|
|
98
101
|
method: "GET",
|
|
99
102
|
});
|
|
100
103
|
}
|
|
101
104
|
// 允许切换身份的用户列表
|
|
102
105
|
allowRunAsUser() {
|
|
103
106
|
return mpx.xfetch.fetch({
|
|
104
|
-
url: "/v1/rbac/auth/allow_run_as_user?tenant=" + config.tenant,
|
|
107
|
+
url: "/v1/rbac/auth/allow_run_as_user?tenant=" + this.config.tenant,
|
|
105
108
|
method: "GET",
|
|
106
109
|
});
|
|
107
110
|
}
|
|
108
111
|
// 运行某种身份
|
|
109
112
|
runAsUser(userId) {
|
|
110
113
|
const data = {
|
|
111
|
-
tenant: config.tenant,
|
|
114
|
+
tenant: this.config.tenant,
|
|
112
115
|
userId: userId,
|
|
113
116
|
};
|
|
114
117
|
return mpx.xfetch.fetch({
|
|
@@ -141,7 +144,7 @@ class AuthApi {
|
|
|
141
144
|
// 部门Tree
|
|
142
145
|
deptTree(deptId, tenant) {
|
|
143
146
|
const query = {
|
|
144
|
-
tenant: tenant ? tenant : config.tenant,
|
|
147
|
+
tenant: tenant ? tenant : this.config.tenant,
|
|
145
148
|
excludeId: deptId,
|
|
146
149
|
};
|
|
147
150
|
return mpx.xfetch.fetch({
|
|
@@ -153,7 +156,7 @@ class AuthApi {
|
|
|
153
156
|
// 职务Tree
|
|
154
157
|
jobTree(jobId, tenant) {
|
|
155
158
|
const query = {
|
|
156
|
-
tenant: tenant ? tenant : config.tenant,
|
|
159
|
+
tenant: tenant ? tenant : this.config.tenant,
|
|
157
160
|
roleType: "job",
|
|
158
161
|
hasRoleType: true,
|
|
159
162
|
excludeId: jobId,
|
|
@@ -166,7 +169,7 @@ class AuthApi {
|
|
|
166
169
|
}
|
|
167
170
|
// 修改个人信息
|
|
168
171
|
updateUserInfo(data) {
|
|
169
|
-
data.tenant = config.tenant;
|
|
172
|
+
data.tenant = this.config.tenant;
|
|
170
173
|
grpc.clearEmpty(data);
|
|
171
174
|
return mpx.xfetch.fetch({
|
|
172
175
|
url: "/v1/rbac/auth/user",
|
|
@@ -176,7 +179,7 @@ class AuthApi {
|
|
|
176
179
|
}
|
|
177
180
|
// 获取当前会话用户的信息
|
|
178
181
|
findUserInfo(data) {
|
|
179
|
-
data.tenant = config.tenant;
|
|
182
|
+
data.tenant = this.config.tenant;
|
|
180
183
|
return mpx.xfetch.fetch({
|
|
181
184
|
url: "/v1/front/rbac/auth/user",
|
|
182
185
|
method: "GET",
|
package/lib/api/cms/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { CmsSiteKey, CmsSiteList, CmsSiteModel, CmsChannelReq, CmsChannelList, CmsInfoReq, CmsInfoPage, CmsInfoKey, CmsInfoModel, CmsInfoContentReq, CmsInfoContentList, CmsContentInfoReq, CmsContentInfoModel, CmsInfoFileReq, CmsInfoFileList, FrontInteractKey, FrontInteractModel, FrontLikeKey, FrontLikeModel, FrontLikeCreateReq, FrontBrowseRecordCreateReq, FrontBrowseRecordModel, CmsChannelKey, CmsChannelModel } from "./types";
|
|
2
|
-
import { ResponseData } from "../../api/types";
|
|
2
|
+
import { ResponseData, AppConfig } from "../../api/types";
|
|
3
3
|
declare class CmsApiImpl {
|
|
4
|
+
config: AppConfig;
|
|
5
|
+
constructor();
|
|
4
6
|
findCmsSiteList(tenant: string): Promise<ResponseData<CmsSiteList>>;
|
|
5
7
|
findCmsSite(data: CmsSiteKey): Promise<ResponseData<CmsSiteModel>>;
|
|
6
8
|
findCmsChannelList(data: CmsChannelReq): Promise<ResponseData<CmsChannelList>>;
|
package/lib/api/cms/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { grpc } from "../../utils/grpc";
|
|
2
|
-
import { config } from "../../utils/config";
|
|
3
2
|
import mpx from "@mpxjs/core";
|
|
4
3
|
// 获取网站内容信息
|
|
5
4
|
class CmsApiImpl {
|
|
5
|
+
config;
|
|
6
|
+
constructor() {
|
|
7
|
+
this.config = getApp().globalData.config;
|
|
8
|
+
}
|
|
6
9
|
// 查询企业官网、微网站列表
|
|
7
10
|
findCmsSiteList(tenant) {
|
|
8
11
|
return mpx.xfetch.fetch({
|
|
@@ -46,7 +49,7 @@ class CmsApiImpl {
|
|
|
46
49
|
}
|
|
47
50
|
// 根据栏目别名查询翻页信息信息主表-单页栏目内容
|
|
48
51
|
findCmsContentInfo(data) {
|
|
49
|
-
data.tenant = data.tenant || config.tenant;
|
|
52
|
+
data.tenant = data.tenant || this.config.tenant;
|
|
50
53
|
grpc.clearEmpty(data);
|
|
51
54
|
return mpx.xfetch.fetch({
|
|
52
55
|
url: `/v1/front/cms/cms_info/alias/${data.tenant}/${data.siteId}/${data.channelAlias}`,
|
package/lib/api/dict/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { ResponseData } from "../../api/types";
|
|
1
|
+
import { ResponseData, AppConfig } from "../../api/types";
|
|
2
2
|
import { EnumRes, DictEntryReq, DictEntryList } from "./types";
|
|
3
3
|
declare class DictApiImpl {
|
|
4
|
+
config: AppConfig;
|
|
5
|
+
constructor();
|
|
4
6
|
/**
|
|
5
7
|
* 枚举
|
|
6
8
|
* @param data 查询条件
|
package/lib/api/dict/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { config } from "../../utils/config";
|
|
2
1
|
import mpx from "@mpxjs/core";
|
|
3
2
|
class DictApiImpl {
|
|
3
|
+
config;
|
|
4
|
+
constructor() {
|
|
5
|
+
this.config = getApp().globalData.config;
|
|
6
|
+
}
|
|
4
7
|
/**
|
|
5
8
|
* 枚举
|
|
6
9
|
* @param data 查询条件
|
|
@@ -24,7 +27,7 @@ class DictApiImpl {
|
|
|
24
27
|
data.hasEnable = data.enable !== undefined;
|
|
25
28
|
}
|
|
26
29
|
return mpx.xfetch.fetch({
|
|
27
|
-
url: "/v1/dict/dict_entry/list/" + config.tenant,
|
|
30
|
+
url: "/v1/dict/dict_entry/list/" + this.config.tenant,
|
|
28
31
|
method: "GET",
|
|
29
32
|
data,
|
|
30
33
|
});
|
package/lib/api/files/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { FileInfo, FileBase64Req, FileDownInfo, FileWebReq } from "./types";
|
|
2
|
-
import { ResponseData } from "../../api/types";
|
|
2
|
+
import { ResponseData, AppConfig } from "../../api/types";
|
|
3
3
|
declare class FileApi {
|
|
4
|
+
config: AppConfig;
|
|
5
|
+
constructor();
|
|
4
6
|
baseApiUrl(): string;
|
|
5
7
|
uploadUrl(): string;
|
|
6
8
|
/**
|
package/lib/api/files/index.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { db } from "../../utils/db";
|
|
2
2
|
import { grpc } from "../../utils/grpc";
|
|
3
|
-
import { config } from "../../utils/config";
|
|
4
3
|
import mpx from "@mpxjs/core";
|
|
5
4
|
class FileApi {
|
|
5
|
+
config;
|
|
6
|
+
constructor() {
|
|
7
|
+
this.config = getApp().globalData.config;
|
|
8
|
+
}
|
|
6
9
|
baseApiUrl() {
|
|
7
|
-
let currentBaseURL = config.baseUrl;
|
|
10
|
+
let currentBaseURL = this.config.baseUrl;
|
|
8
11
|
// 使用 slice() 方法
|
|
9
12
|
if (currentBaseURL.slice(-1) === "/") {
|
|
10
13
|
currentBaseURL = currentBaseURL.slice(0, -1);
|
|
@@ -13,7 +16,7 @@ class FileApi {
|
|
|
13
16
|
}
|
|
14
17
|
// 上传Url
|
|
15
18
|
uploadUrl() {
|
|
16
|
-
return this.baseApiUrl() + "/v1/file/upload?tenant=" + config.tenant;
|
|
19
|
+
return this.baseApiUrl() + "/v1/file/upload?tenant=" + this.config.tenant;
|
|
17
20
|
}
|
|
18
21
|
/**
|
|
19
22
|
* url 获取图片Full路径
|
|
@@ -39,7 +42,7 @@ class FileApi {
|
|
|
39
42
|
imageIdUrl(imageId, width = 0, height = 0, type = "clip") {
|
|
40
43
|
return (this.baseApiUrl() +
|
|
41
44
|
"/v1/file/image_id/" +
|
|
42
|
-
config.tenant +
|
|
45
|
+
this.config.tenant +
|
|
43
46
|
`/${type}/${width}/${height}/` +
|
|
44
47
|
imageId);
|
|
45
48
|
}
|
|
@@ -49,11 +52,11 @@ class FileApi {
|
|
|
49
52
|
}
|
|
50
53
|
// Id 获取文件Full路径
|
|
51
54
|
fileIdUrl(fileId) {
|
|
52
|
-
return this.baseApiUrl() + "/v1/file/id/" + config.tenant + fileId;
|
|
55
|
+
return this.baseApiUrl() + "/v1/file/id/" + this.config.tenant + fileId;
|
|
53
56
|
}
|
|
54
57
|
// 上传文件
|
|
55
58
|
uploadBase64File(base64) {
|
|
56
|
-
base64.tenant = config.tenant;
|
|
59
|
+
base64.tenant = this.config.tenant;
|
|
57
60
|
grpc.clearEmpty(base64);
|
|
58
61
|
return mpx.xfetch.fetch({
|
|
59
62
|
url: "/v1/file/base64upload",
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { DictRegionList, DictRegionReq } from "./types";
|
|
2
|
-
import { ResponseData } from "../../api/types";
|
|
2
|
+
import { ResponseData, AppConfig } from "../../api/types";
|
|
3
3
|
declare class RegionApiImpl {
|
|
4
|
+
config: AppConfig;
|
|
5
|
+
constructor();
|
|
4
6
|
findList(query?: DictRegionReq): Promise<ResponseData<DictRegionList>>;
|
|
5
7
|
}
|
|
6
8
|
declare const regionApi: RegionApiImpl;
|
package/lib/api/region/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { grpc } from "../../utils/grpc";
|
|
2
|
-
import { config } from "../../utils/config";
|
|
3
2
|
import mpx from "@mpxjs/core";
|
|
4
3
|
class RegionApiImpl {
|
|
4
|
+
config;
|
|
5
|
+
constructor() {
|
|
6
|
+
this.config = getApp().globalData.config;
|
|
7
|
+
}
|
|
5
8
|
// 查询列表信息地区信息
|
|
6
9
|
findList(query) {
|
|
7
10
|
if (query) {
|
|
@@ -9,7 +12,7 @@ class RegionApiImpl {
|
|
|
9
12
|
}
|
|
10
13
|
grpc.clearEmpty(query);
|
|
11
14
|
return mpx.xfetch.fetch({
|
|
12
|
-
url: "/v1/region/dict_region/list/" + config.tenant,
|
|
15
|
+
url: "/v1/region/dict_region/list/" + this.config.tenant,
|
|
13
16
|
method: "GET",
|
|
14
17
|
data: query,
|
|
15
18
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { ResponseData } from "../../api/types";
|
|
1
|
+
import { ResponseData, AppConfig } from "../../api/types";
|
|
2
2
|
import { StorageOrganInfoReq, StorageOrganInfoList, StorageOrganBrowserUpdateReq, StorageOrganBrowserModel } from "./types";
|
|
3
3
|
declare class StorageApiImpl {
|
|
4
|
+
config: AppConfig;
|
|
5
|
+
constructor();
|
|
4
6
|
findMyOrganList(data: StorageOrganInfoReq): Promise<ResponseData<StorageOrganInfoList>>;
|
|
5
7
|
findStorageBrowserOrganList(data: StorageOrganInfoReq): Promise<ResponseData<StorageOrganInfoList>>;
|
|
6
8
|
findStorageOrganInfoList(data: StorageOrganInfoReq): Promise<ResponseData<StorageOrganInfoList>>;
|
package/lib/api/storage/index.js
CHANGED
|
@@ -1,33 +1,36 @@
|
|
|
1
1
|
import mpx from "@mpxjs/core";
|
|
2
2
|
import { grpc } from "../../utils/grpc";
|
|
3
|
-
import { config } from "../../utils/config";
|
|
4
3
|
class StorageApiImpl {
|
|
4
|
+
config;
|
|
5
|
+
constructor() {
|
|
6
|
+
this.config = getApp().globalData.config;
|
|
7
|
+
}
|
|
5
8
|
// 查询我的组织列表
|
|
6
9
|
findMyOrganList(data) {
|
|
7
10
|
grpc.clearEmpty(data);
|
|
8
11
|
return mpx.xfetch.fetch({
|
|
9
|
-
url: `/v1/storage/storage_organ/my_list/${config.tenant}?&serviceType[]=${data.serviceType}`,
|
|
12
|
+
url: `/v1/storage/storage_organ/my_list/${this.config.tenant}?&serviceType[]=${data.serviceType}`,
|
|
10
13
|
method: "GET",
|
|
11
14
|
});
|
|
12
15
|
}
|
|
13
16
|
// 查询列表信息店铺用户浏览信息
|
|
14
17
|
findStorageBrowserOrganList(data) {
|
|
15
18
|
return mpx.xfetch.fetch({
|
|
16
|
-
url: `/v1/front/storage/storage_organ_browser/my_list/${config.tenant}?&serviceType[]=${data.serviceType}`,
|
|
19
|
+
url: `/v1/front/storage/storage_organ_browser/my_list/${this.config.tenant}?&serviceType[]=${data.serviceType}`,
|
|
17
20
|
method: "GET",
|
|
18
21
|
});
|
|
19
22
|
}
|
|
20
23
|
// 查询列表信息店铺用户浏览信息
|
|
21
24
|
findStorageOrganInfoList(data) {
|
|
22
25
|
return mpx.xfetch.fetch({
|
|
23
|
-
url: `/v1/storage/storage_organ_info/list/${config.tenant}?&serviceType[]=${data.serviceType}`,
|
|
26
|
+
url: `/v1/storage/storage_organ_info/list/${this.config.tenant}?&serviceType[]=${data.serviceType}`,
|
|
24
27
|
method: "GET",
|
|
25
28
|
data: data,
|
|
26
29
|
});
|
|
27
30
|
}
|
|
28
31
|
// 修改组织浏览信息
|
|
29
32
|
updateStorageOrganBrowser(data) {
|
|
30
|
-
data.tenant = config.tenant;
|
|
33
|
+
data.tenant = this.config.tenant;
|
|
31
34
|
grpc.clearEmpty(data);
|
|
32
35
|
return mpx.xfetch.fetch({
|
|
33
36
|
url: "/v1/front/storage/storage_organ_browser/browse",
|
package/lib/store/user.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { defineStore } from "@mpxjs/pinia";
|
|
2
|
-
import { config } from "../utils/config";
|
|
3
2
|
import { authApi } from "../api/auth/index";
|
|
4
3
|
import { db } from "../utils/db";
|
|
5
4
|
import { net } from "../utils/net";
|
|
@@ -19,6 +18,7 @@ export const useUserStore = defineStore("user", {
|
|
|
19
18
|
if (this.checkLogin()) {
|
|
20
19
|
return Promise.resolve(true);
|
|
21
20
|
}
|
|
21
|
+
const config = getApp().globalData.config;
|
|
22
22
|
// 2. 测试环境特殊配置 → 直接返回失败
|
|
23
23
|
if (config.dev && config.testNewUser) {
|
|
24
24
|
return Promise.reject("测试环境,要求用户登录!");
|
|
@@ -36,25 +36,27 @@ export const useUserStore = defineStore("user", {
|
|
|
36
36
|
}
|
|
37
37
|
// 2. 拼接登录跳转地址(抽离公共逻辑)
|
|
38
38
|
const toUrl = `${loginurl}?tabbar=${tabbar}&backurl=${encodeURIComponent(backurl)}`;
|
|
39
|
+
const config = getApp().globalData.config;
|
|
39
40
|
// 3. 测试环境特殊处理
|
|
40
41
|
if (config.dev && config.testNewUser) {
|
|
41
42
|
mpx.navigateTo({ url: toUrl });
|
|
42
43
|
return Promise.resolve(false);
|
|
43
44
|
}
|
|
44
45
|
// 4. 生产环境:执行静默登录
|
|
45
|
-
return this.silentLogin()
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
return this.silentLogin()
|
|
47
|
+
.then((res) => {
|
|
48
|
+
// 静默登录成功
|
|
49
|
+
return Promise.resolve(res.status);
|
|
50
|
+
})
|
|
51
|
+
.catch(() => {
|
|
51
52
|
mpx.navigateTo({ url: toUrl });
|
|
52
|
-
return false;
|
|
53
|
+
return Promise.resolve(false);
|
|
53
54
|
});
|
|
54
55
|
},
|
|
55
56
|
/** 静默登录 */
|
|
56
57
|
silentLogin() {
|
|
57
58
|
const obj = __mpx_mode__ === "ali" ? { scopes: "auth_base" } : {};
|
|
59
|
+
const config = getApp().globalData.config;
|
|
58
60
|
return mpx
|
|
59
61
|
.login(obj)
|
|
60
62
|
.then((res) => {
|
|
@@ -78,6 +80,7 @@ export const useUserStore = defineStore("user", {
|
|
|
78
80
|
// 手机号code 注册登录
|
|
79
81
|
mpRegister(phoneCode, nickName = "", avatar = "") {
|
|
80
82
|
const obj = __mpx_mode__ === "ali" ? { scopes: "auth_user" } : {};
|
|
83
|
+
const config = getApp().globalData.config;
|
|
81
84
|
return mpx
|
|
82
85
|
.login(obj)
|
|
83
86
|
.then((res) => {
|
package/lib/utils/request.js
CHANGED
|
@@ -3,13 +3,13 @@ import { grpc } from "../utils/grpc";
|
|
|
3
3
|
import mpx from "@mpxjs/core";
|
|
4
4
|
import mpxFetch from "@mpxjs/fetch";
|
|
5
5
|
mpx.use(mpxFetch);
|
|
6
|
-
import { config as appconfig } from "../utils/config";
|
|
7
6
|
let isRefreshing = false;
|
|
8
7
|
let requests = [];
|
|
9
8
|
//是否登出.
|
|
10
9
|
let isLogout = false;
|
|
11
10
|
mpx.xfetch.interceptors.request.use(function (config) {
|
|
12
11
|
if (!config.url.startsWith("http")) {
|
|
12
|
+
const appconfig = getApp().globalData.config;
|
|
13
13
|
config.url = appconfig.baseUrl + config.url;
|
|
14
14
|
}
|
|
15
15
|
//console.log("request:", config);
|
|
@@ -108,6 +108,7 @@ mpx.xfetch.interceptors.response.use(function (res) {
|
|
|
108
108
|
});
|
|
109
109
|
//刷新Token
|
|
110
110
|
function refreshToken(refreshToken) {
|
|
111
|
+
const appconfig = getApp().globalData.config;
|
|
111
112
|
return mpx.xfetch.fetch({
|
|
112
113
|
url: appconfig.baseUrl + "/v1/front/rbac/auth/refresh_token",
|
|
113
114
|
method: "POST",
|
package/package.json
CHANGED
package/src/api/auth/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ResponseData } from "../../api/types";
|
|
1
|
+
import { ResponseData, AppConfig } from "../../api/types";
|
|
2
2
|
import { OpensType } from "./types";
|
|
3
3
|
import type {
|
|
4
4
|
LoginReq,
|
|
@@ -14,10 +14,13 @@ import type {
|
|
|
14
14
|
} from "./types";
|
|
15
15
|
import { db } from "../../utils/db";
|
|
16
16
|
import { grpc } from "../../utils/grpc";
|
|
17
|
-
import { config } from "../../utils/config";
|
|
18
17
|
import mpx from "@mpxjs/core";
|
|
19
18
|
|
|
20
19
|
class AuthApi {
|
|
20
|
+
config: AppConfig;
|
|
21
|
+
constructor() {
|
|
22
|
+
this.config = getApp().globalData.config;
|
|
23
|
+
}
|
|
21
24
|
// 小程序静默登录
|
|
22
25
|
mpLogin(data: LoginReq): Promise<ResponseData<LoginRes>> {
|
|
23
26
|
if (__mpx_mode__ === "wx") {
|
|
@@ -27,7 +30,7 @@ class AuthApi {
|
|
|
27
30
|
data.opensType = OpensType.ali_pay;
|
|
28
31
|
}
|
|
29
32
|
return mpx.xfetch.fetch({
|
|
30
|
-
url: "/v1/front/rbac/miniapp_login/" + config.tenant,
|
|
33
|
+
url: "/v1/front/rbac/miniapp_login/" + this.config.tenant,
|
|
31
34
|
method: "POST",
|
|
32
35
|
data,
|
|
33
36
|
header: {
|
|
@@ -46,7 +49,7 @@ class AuthApi {
|
|
|
46
49
|
data.opensType = OpensType.ali_pay;
|
|
47
50
|
}
|
|
48
51
|
return mpx.xfetch.fetch({
|
|
49
|
-
url: "/v1/front/rbac/miniapp_phonenumber/" + config.tenant,
|
|
52
|
+
url: "/v1/front/rbac/miniapp_phonenumber/" + this.config.tenant,
|
|
50
53
|
method: "POST",
|
|
51
54
|
data: data,
|
|
52
55
|
header: {
|
|
@@ -57,7 +60,7 @@ class AuthApi {
|
|
|
57
60
|
|
|
58
61
|
// 已登陆状态小程序更换绑定手机号
|
|
59
62
|
replaceBindphone(data: PhoneReplaceReq): Promise<ResponseData<string>> {
|
|
60
|
-
data.tenant = config.tenant;
|
|
63
|
+
data.tenant = this.config.tenant;
|
|
61
64
|
if (__mpx_mode__ === "wx") {
|
|
62
65
|
data.opensType = OpensType.wechat;
|
|
63
66
|
}
|
|
@@ -74,9 +77,9 @@ class AuthApi {
|
|
|
74
77
|
|
|
75
78
|
//web登录.
|
|
76
79
|
webLogin(data: WebLoginReq): Promise<ResponseData<TokenModel>> {
|
|
77
|
-
data.tenant = config.tenant;
|
|
80
|
+
data.tenant = this.config.tenant;
|
|
78
81
|
data.directoryId = "user";
|
|
79
|
-
data.clientId = config.appId ? config.appId : "h5";
|
|
82
|
+
data.clientId = this.config.appId ? this.config.appId : "h5";
|
|
80
83
|
data.captchaId = "1";
|
|
81
84
|
data.captchaCode = "1";
|
|
82
85
|
return mpx.xfetch.fetch({
|
|
@@ -96,8 +99,8 @@ class AuthApi {
|
|
|
96
99
|
method: "POST",
|
|
97
100
|
data: {
|
|
98
101
|
refreshToken: db.getRefreshToken(),
|
|
99
|
-
tenant: config.tenant,
|
|
100
|
-
clientId: config.appId,
|
|
102
|
+
tenant: this.config.tenant,
|
|
103
|
+
clientId: this.config.appId,
|
|
101
104
|
},
|
|
102
105
|
header: { "content-type": "application/json" },
|
|
103
106
|
});
|
|
@@ -106,7 +109,7 @@ class AuthApi {
|
|
|
106
109
|
// 获取当前会话用户
|
|
107
110
|
userInfo(): Promise<ResponseData<UserInfo>> {
|
|
108
111
|
return mpx.xfetch.fetch({
|
|
109
|
-
url: "/v1/rbac/auth/user?tenant=" + config.tenant,
|
|
112
|
+
url: "/v1/rbac/auth/user?tenant=" + this.config.tenant,
|
|
110
113
|
method: "GET",
|
|
111
114
|
});
|
|
112
115
|
}
|
|
@@ -114,14 +117,14 @@ class AuthApi {
|
|
|
114
117
|
// 当前用户角色权限
|
|
115
118
|
userRolesPerms(): Promise<ResponseData<RolesPerms>> {
|
|
116
119
|
return mpx.xfetch.fetch({
|
|
117
|
-
url: "/v1/rbac/auth/roles_perms?tenant=" + config.tenant,
|
|
120
|
+
url: "/v1/rbac/auth/roles_perms?tenant=" + this.config.tenant,
|
|
118
121
|
method: "GET",
|
|
119
122
|
});
|
|
120
123
|
}
|
|
121
124
|
// 允许切换身份的用户列表
|
|
122
125
|
allowRunAsUser(): Promise<ResponseData<any[]>> {
|
|
123
126
|
return mpx.xfetch.fetch({
|
|
124
|
-
url: "/v1/rbac/auth/allow_run_as_user?tenant=" + config.tenant,
|
|
127
|
+
url: "/v1/rbac/auth/allow_run_as_user?tenant=" + this.config.tenant,
|
|
125
128
|
method: "GET",
|
|
126
129
|
});
|
|
127
130
|
}
|
|
@@ -129,7 +132,7 @@ class AuthApi {
|
|
|
129
132
|
// 运行某种身份
|
|
130
133
|
runAsUser(userId: string): Promise<ResponseData<any>> {
|
|
131
134
|
const data = {
|
|
132
|
-
tenant: config.tenant,
|
|
135
|
+
tenant: this.config.tenant,
|
|
133
136
|
userId: userId,
|
|
134
137
|
};
|
|
135
138
|
return mpx.xfetch.fetch({
|
|
@@ -166,7 +169,7 @@ class AuthApi {
|
|
|
166
169
|
// 部门Tree
|
|
167
170
|
deptTree(deptId?: string, tenant?: string): Promise<ResponseData<any[]>> {
|
|
168
171
|
const query = {
|
|
169
|
-
tenant: tenant ? tenant : config.tenant,
|
|
172
|
+
tenant: tenant ? tenant : this.config.tenant,
|
|
170
173
|
excludeId: deptId,
|
|
171
174
|
};
|
|
172
175
|
return mpx.xfetch.fetch({
|
|
@@ -179,7 +182,7 @@ class AuthApi {
|
|
|
179
182
|
// 职务Tree
|
|
180
183
|
jobTree(jobId?: string, tenant?: string): Promise<ResponseData<any[]>> {
|
|
181
184
|
const query = {
|
|
182
|
-
tenant: tenant ? tenant : config.tenant,
|
|
185
|
+
tenant: tenant ? tenant : this.config.tenant,
|
|
183
186
|
roleType: "job",
|
|
184
187
|
hasRoleType: true,
|
|
185
188
|
excludeId: jobId,
|
|
@@ -192,7 +195,7 @@ class AuthApi {
|
|
|
192
195
|
}
|
|
193
196
|
// 修改个人信息
|
|
194
197
|
updateUserInfo(data: UpdateUserReq): Promise<ResponseData<UserInfo>> {
|
|
195
|
-
data.tenant = config.tenant;
|
|
198
|
+
data.tenant = this.config.tenant;
|
|
196
199
|
grpc.clearEmpty(data);
|
|
197
200
|
return mpx.xfetch.fetch({
|
|
198
201
|
url: "/v1/rbac/auth/user",
|
|
@@ -203,7 +206,7 @@ class AuthApi {
|
|
|
203
206
|
|
|
204
207
|
// 获取当前会话用户的信息
|
|
205
208
|
findUserInfo(data: UserInfoReq): Promise<ResponseData<UserInfo>> {
|
|
206
|
-
data.tenant = config.tenant;
|
|
209
|
+
data.tenant = this.config.tenant;
|
|
207
210
|
return mpx.xfetch.fetch({
|
|
208
211
|
url: "/v1/front/rbac/auth/user",
|
|
209
212
|
method: "GET",
|
package/src/api/cms/index.ts
CHANGED
|
@@ -24,13 +24,16 @@ import {
|
|
|
24
24
|
CmsChannelKey,
|
|
25
25
|
CmsChannelModel,
|
|
26
26
|
} from "./types";
|
|
27
|
-
import { ResponseData } from "../../api/types";
|
|
27
|
+
import { ResponseData, AppConfig } from "../../api/types";
|
|
28
28
|
import { grpc } from "../../utils/grpc";
|
|
29
|
-
import { config } from "../../utils/config";
|
|
30
29
|
import mpx from "@mpxjs/core";
|
|
31
30
|
|
|
32
31
|
// 获取网站内容信息
|
|
33
32
|
class CmsApiImpl {
|
|
33
|
+
config: AppConfig;
|
|
34
|
+
constructor() {
|
|
35
|
+
this.config = getApp().globalData.config;
|
|
36
|
+
}
|
|
34
37
|
// 查询企业官网、微网站列表
|
|
35
38
|
findCmsSiteList(tenant: string): Promise<ResponseData<CmsSiteList>> {
|
|
36
39
|
return mpx.xfetch.fetch({
|
|
@@ -84,7 +87,7 @@ class CmsApiImpl {
|
|
|
84
87
|
findCmsContentInfo(
|
|
85
88
|
data: CmsContentInfoReq
|
|
86
89
|
): Promise<ResponseData<CmsContentInfoModel>> {
|
|
87
|
-
data.tenant = data.tenant || config.tenant;
|
|
90
|
+
data.tenant = data.tenant || this.config.tenant;
|
|
88
91
|
grpc.clearEmpty(data);
|
|
89
92
|
return mpx.xfetch.fetch({
|
|
90
93
|
url: `/v1/front/cms/cms_info/alias/${data.tenant}/${data.siteId}/${data.channelAlias}`,
|
package/src/api/dict/index.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { ResponseData } from "../../api/types";
|
|
1
|
+
import { ResponseData, AppConfig } from "../../api/types";
|
|
2
2
|
import { EnumEntryReq, EnumRes, DictEntryReq, DictEntryList } from "./types";
|
|
3
|
-
import { config } from "../../utils/config";
|
|
4
3
|
import mpx from "@mpxjs/core";
|
|
5
4
|
|
|
6
5
|
class DictApiImpl {
|
|
6
|
+
config: AppConfig;
|
|
7
|
+
constructor() {
|
|
8
|
+
this.config = getApp().globalData.config;
|
|
9
|
+
}
|
|
7
10
|
/**
|
|
8
11
|
* 枚举
|
|
9
12
|
* @param data 查询条件
|
|
@@ -32,7 +35,7 @@ class DictApiImpl {
|
|
|
32
35
|
data.hasEnable = data.enable !== undefined;
|
|
33
36
|
}
|
|
34
37
|
return mpx.xfetch.fetch({
|
|
35
|
-
url: "/v1/dict/dict_entry/list/" + config.tenant,
|
|
38
|
+
url: "/v1/dict/dict_entry/list/" + this.config.tenant,
|
|
36
39
|
method: "GET",
|
|
37
40
|
data,
|
|
38
41
|
});
|