jmash-core-mp 0.1.18 → 0.1.20

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 (39) hide show
  1. package/lib/api/auth/index.js +13 -1
  2. package/lib/api/cms/index.js +1 -1
  3. package/lib/api/dict/index.js +1 -1
  4. package/lib/api/files/index.js +5 -1
  5. package/lib/api/region/index.js +1 -1
  6. package/lib/api/storage/index.js +4 -1
  7. package/lib/store/user.js +11 -8
  8. package/lib/utils/request.js +2 -1
  9. package/package.json +1 -1
  10. package/src/api/auth/index.ts +14 -2
  11. package/src/api/cms/index.ts +2 -2
  12. package/src/api/dict/index.ts +2 -2
  13. package/src/api/files/index.ts +6 -2
  14. package/src/api/region/index.ts +2 -2
  15. package/src/api/storage/index.ts +5 -2
  16. package/src/app.mpx +1 -0
  17. package/src/components/auth-user/jmash-update-user.mpx +5 -4
  18. package/src/components/auth-user/jmash-update-user.web.mpx +4 -3
  19. package/src/components/cms/jmash-cms-acticle-list.mpx +1 -1
  20. package/src/components/cms/jmash-cms-article-item.mpx +2 -1
  21. package/src/components/cms/jmash-cms-article-view.mpx +1 -1
  22. package/src/components/cms/jmash-cms-like.mpx +2 -1
  23. package/src/components/common/jmash-avatar-edit.mpx +1 -1
  24. package/src/components/common/jmash-none-data.mpx +3 -3
  25. package/src/components/common/jmash-popup.mpx +1 -1
  26. package/src/components/common/jmash-search.mpx +1 -1
  27. package/src/components/common/jmash-upload-picture.mpx +2 -1
  28. package/src/packages/pages/auth/cms-protocol.mpx +3 -2
  29. package/src/packages/pages/auth/login.mpx +3 -2
  30. package/src/packages/pages/cms/cms-article-list.mpx +5 -4
  31. package/src/packages/pages/cms/cms-article.mpx +4 -3
  32. package/src/pages/home.mpx +1 -1
  33. package/src/pages/home2.mpx +48 -0
  34. package/src/pages/tabbar/home.mpx +7 -1
  35. package/src/store/user.ts +12 -10
  36. package/src/utils/request.ts +2 -2
  37. package/lib/components/auth-user/jmash-user.mpx.d.ts +0 -1
  38. package/lib/components/cms/jmash-cms-article-view.mpx.d.ts +0 -1
  39. package/lib/components/core/jmash-login.mpx.d.ts +0 -1
@@ -1,7 +1,6 @@
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 {
7
6
  // 小程序静默登录
@@ -12,6 +11,7 @@ class AuthApi {
12
11
  if (__mpx_mode__ === "ali") {
13
12
  data.opensType = OpensType.ali_pay;
14
13
  }
14
+ const config = getApp().globalData.config;
15
15
  return mpx.xfetch.fetch({
16
16
  url: "/v1/front/rbac/miniapp_login/" + config.tenant,
17
17
  method: "POST",
@@ -30,6 +30,7 @@ class AuthApi {
30
30
  if (__mpx_mode__ === "ali") {
31
31
  data.opensType = OpensType.ali_pay;
32
32
  }
33
+ const config = getApp().globalData.config;
33
34
  return mpx.xfetch.fetch({
34
35
  url: "/v1/front/rbac/miniapp_phonenumber/" + config.tenant,
35
36
  method: "POST",
@@ -41,6 +42,7 @@ class AuthApi {
41
42
  }
42
43
  // 已登陆状态小程序更换绑定手机号
43
44
  replaceBindphone(data) {
45
+ const config = getApp().globalData.config;
44
46
  data.tenant = config.tenant;
45
47
  if (__mpx_mode__ === "wx") {
46
48
  data.opensType = OpensType.wechat;
@@ -57,6 +59,7 @@ class AuthApi {
57
59
  }
58
60
  //web登录.
59
61
  webLogin(data) {
62
+ const config = getApp().globalData.config;
60
63
  data.tenant = config.tenant;
61
64
  data.directoryId = "user";
62
65
  data.clientId = config.appId ? config.appId : "h5";
@@ -73,6 +76,7 @@ class AuthApi {
73
76
  }
74
77
  // 刷新token
75
78
  refreshToken() {
79
+ const config = getApp().globalData.config;
76
80
  return mpx.xfetch.fetch({
77
81
  url: "/v1/front/rbac/auth/refresh_token",
78
82
  method: "POST",
@@ -86,6 +90,7 @@ class AuthApi {
86
90
  }
87
91
  // 获取当前会话用户
88
92
  userInfo() {
93
+ const config = getApp().globalData.config;
89
94
  return mpx.xfetch.fetch({
90
95
  url: "/v1/rbac/auth/user?tenant=" + config.tenant,
91
96
  method: "GET",
@@ -93,6 +98,7 @@ class AuthApi {
93
98
  }
94
99
  // 当前用户角色权限
95
100
  userRolesPerms() {
101
+ const config = getApp().globalData.config;
96
102
  return mpx.xfetch.fetch({
97
103
  url: "/v1/rbac/auth/roles_perms?tenant=" + config.tenant,
98
104
  method: "GET",
@@ -100,6 +106,7 @@ class AuthApi {
100
106
  }
101
107
  // 允许切换身份的用户列表
102
108
  allowRunAsUser() {
109
+ const config = getApp().globalData.config;
103
110
  return mpx.xfetch.fetch({
104
111
  url: "/v1/rbac/auth/allow_run_as_user?tenant=" + config.tenant,
105
112
  method: "GET",
@@ -107,6 +114,7 @@ class AuthApi {
107
114
  }
108
115
  // 运行某种身份
109
116
  runAsUser(userId) {
117
+ const config = getApp().globalData.config;
110
118
  const data = {
111
119
  tenant: config.tenant,
112
120
  userId: userId,
@@ -140,6 +148,7 @@ class AuthApi {
140
148
  }
141
149
  // 部门Tree
142
150
  deptTree(deptId, tenant) {
151
+ const config = getApp().globalData.config;
143
152
  const query = {
144
153
  tenant: tenant ? tenant : config.tenant,
145
154
  excludeId: deptId,
@@ -152,6 +161,7 @@ class AuthApi {
152
161
  }
153
162
  // 职务Tree
154
163
  jobTree(jobId, tenant) {
164
+ const config = getApp().globalData.config;
155
165
  const query = {
156
166
  tenant: tenant ? tenant : config.tenant,
157
167
  roleType: "job",
@@ -166,6 +176,7 @@ class AuthApi {
166
176
  }
167
177
  // 修改个人信息
168
178
  updateUserInfo(data) {
179
+ const config = getApp().globalData.config;
169
180
  data.tenant = config.tenant;
170
181
  grpc.clearEmpty(data);
171
182
  return mpx.xfetch.fetch({
@@ -176,6 +187,7 @@ class AuthApi {
176
187
  }
177
188
  // 获取当前会话用户的信息
178
189
  findUserInfo(data) {
190
+ const config = getApp().globalData.config;
179
191
  data.tenant = config.tenant;
180
192
  return mpx.xfetch.fetch({
181
193
  url: "/v1/front/rbac/auth/user",
@@ -1,5 +1,4 @@
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 {
@@ -46,6 +45,7 @@ class CmsApiImpl {
46
45
  }
47
46
  // 根据栏目别名查询翻页信息信息主表-单页栏目内容
48
47
  findCmsContentInfo(data) {
48
+ const config = getApp().globalData.config;
49
49
  data.tenant = data.tenant || config.tenant;
50
50
  grpc.clearEmpty(data);
51
51
  return mpx.xfetch.fetch({
@@ -1,4 +1,3 @@
1
- import { config } from "../../utils/config";
2
1
  import mpx from "@mpxjs/core";
3
2
  class DictApiImpl {
4
3
  /**
@@ -23,6 +22,7 @@ class DictApiImpl {
23
22
  if (data) {
24
23
  data.hasEnable = data.enable !== undefined;
25
24
  }
25
+ const config = getApp().globalData.config;
26
26
  return mpx.xfetch.fetch({
27
27
  url: "/v1/dict/dict_entry/list/" + config.tenant,
28
28
  method: "GET",
@@ -1,9 +1,9 @@
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 {
6
5
  baseApiUrl() {
6
+ const config = getApp().globalData.config;
7
7
  let currentBaseURL = config.baseUrl;
8
8
  // 使用 slice() 方法
9
9
  if (currentBaseURL.slice(-1) === "/") {
@@ -13,6 +13,7 @@ class FileApi {
13
13
  }
14
14
  // 上传Url
15
15
  uploadUrl() {
16
+ const config = getApp().globalData.config;
16
17
  return this.baseApiUrl() + "/v1/file/upload?tenant=" + config.tenant;
17
18
  }
18
19
  /**
@@ -37,6 +38,7 @@ class FileApi {
37
38
  * @param type resize 等比例缩放,white 补白,trans 补透明,clip 裁剪
38
39
  */
39
40
  imageIdUrl(imageId, width = 0, height = 0, type = "clip") {
41
+ const config = getApp().globalData.config;
40
42
  return (this.baseApiUrl() +
41
43
  "/v1/file/image_id/" +
42
44
  config.tenant +
@@ -49,10 +51,12 @@ class FileApi {
49
51
  }
50
52
  // Id 获取文件Full路径
51
53
  fileIdUrl(fileId) {
54
+ const config = getApp().globalData.config;
52
55
  return this.baseApiUrl() + "/v1/file/id/" + config.tenant + fileId;
53
56
  }
54
57
  // 上传文件
55
58
  uploadBase64File(base64) {
59
+ const config = getApp().globalData.config;
56
60
  base64.tenant = config.tenant;
57
61
  grpc.clearEmpty(base64);
58
62
  return mpx.xfetch.fetch({
@@ -1,5 +1,4 @@
1
1
  import { grpc } from "../../utils/grpc";
2
- import { config } from "../../utils/config";
3
2
  import mpx from "@mpxjs/core";
4
3
  class RegionApiImpl {
5
4
  // 查询列表信息地区信息
@@ -8,6 +7,7 @@ class RegionApiImpl {
8
7
  query.hasEnable = query.enable !== undefined;
9
8
  }
10
9
  grpc.clearEmpty(query);
10
+ const config = getApp().globalData.config;
11
11
  return mpx.xfetch.fetch({
12
12
  url: "/v1/region/dict_region/list/" + config.tenant,
13
13
  method: "GET",
@@ -1,10 +1,10 @@
1
1
  import mpx from "@mpxjs/core";
2
2
  import { grpc } from "../../utils/grpc";
3
- import { config } from "../../utils/config";
4
3
  class StorageApiImpl {
5
4
  // 查询我的组织列表
6
5
  findMyOrganList(data) {
7
6
  grpc.clearEmpty(data);
7
+ const config = getApp().globalData.config;
8
8
  return mpx.xfetch.fetch({
9
9
  url: `/v1/storage/storage_organ/my_list/${config.tenant}?&serviceType[]=${data.serviceType}`,
10
10
  method: "GET",
@@ -12,6 +12,7 @@ class StorageApiImpl {
12
12
  }
13
13
  // 查询列表信息店铺用户浏览信息
14
14
  findStorageBrowserOrganList(data) {
15
+ const config = getApp().globalData.config;
15
16
  return mpx.xfetch.fetch({
16
17
  url: `/v1/front/storage/storage_organ_browser/my_list/${config.tenant}?&serviceType[]=${data.serviceType}`,
17
18
  method: "GET",
@@ -19,6 +20,7 @@ class StorageApiImpl {
19
20
  }
20
21
  // 查询列表信息店铺用户浏览信息
21
22
  findStorageOrganInfoList(data) {
23
+ const config = getApp().globalData.config;
22
24
  return mpx.xfetch.fetch({
23
25
  url: `/v1/storage/storage_organ_info/list/${config.tenant}?&serviceType[]=${data.serviceType}`,
24
26
  method: "GET",
@@ -27,6 +29,7 @@ class StorageApiImpl {
27
29
  }
28
30
  // 修改组织浏览信息
29
31
  updateStorageOrganBrowser(data) {
32
+ const config = getApp().globalData.config;
30
33
  data.tenant = config.tenant;
31
34
  grpc.clearEmpty(data);
32
35
  return mpx.xfetch.fetch({
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().then((res) => {
46
- if (res.status) {
47
- // 静默登录成功
48
- return true;
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) => {
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jmash-core-mp",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "private": false,
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -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,7 +14,6 @@ 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 {
@@ -26,6 +25,7 @@ class AuthApi {
26
25
  if (__mpx_mode__ === "ali") {
27
26
  data.opensType = OpensType.ali_pay;
28
27
  }
28
+ const config = getApp().globalData.config;
29
29
  return mpx.xfetch.fetch({
30
30
  url: "/v1/front/rbac/miniapp_login/" + config.tenant,
31
31
  method: "POST",
@@ -45,6 +45,7 @@ class AuthApi {
45
45
  if (__mpx_mode__ === "ali") {
46
46
  data.opensType = OpensType.ali_pay;
47
47
  }
48
+ const config = getApp().globalData.config;
48
49
  return mpx.xfetch.fetch({
49
50
  url: "/v1/front/rbac/miniapp_phonenumber/" + config.tenant,
50
51
  method: "POST",
@@ -57,6 +58,7 @@ class AuthApi {
57
58
 
58
59
  // 已登陆状态小程序更换绑定手机号
59
60
  replaceBindphone(data: PhoneReplaceReq): Promise<ResponseData<string>> {
61
+ const config = getApp().globalData.config;
60
62
  data.tenant = config.tenant;
61
63
  if (__mpx_mode__ === "wx") {
62
64
  data.opensType = OpensType.wechat;
@@ -74,6 +76,7 @@ class AuthApi {
74
76
 
75
77
  //web登录.
76
78
  webLogin(data: WebLoginReq): Promise<ResponseData<TokenModel>> {
79
+ const config = getApp().globalData.config;
77
80
  data.tenant = config.tenant;
78
81
  data.directoryId = "user";
79
82
  data.clientId = config.appId ? config.appId : "h5";
@@ -91,6 +94,7 @@ class AuthApi {
91
94
 
92
95
  // 刷新token
93
96
  refreshToken(): Promise<ResponseData<TokenModel>> {
97
+ const config = getApp().globalData.config;
94
98
  return mpx.xfetch.fetch({
95
99
  url: "/v1/front/rbac/auth/refresh_token",
96
100
  method: "POST",
@@ -105,6 +109,7 @@ class AuthApi {
105
109
 
106
110
  // 获取当前会话用户
107
111
  userInfo(): Promise<ResponseData<UserInfo>> {
112
+ const config = getApp().globalData.config;
108
113
  return mpx.xfetch.fetch({
109
114
  url: "/v1/rbac/auth/user?tenant=" + config.tenant,
110
115
  method: "GET",
@@ -113,6 +118,7 @@ class AuthApi {
113
118
 
114
119
  // 当前用户角色权限
115
120
  userRolesPerms(): Promise<ResponseData<RolesPerms>> {
121
+ const config = getApp().globalData.config;
116
122
  return mpx.xfetch.fetch({
117
123
  url: "/v1/rbac/auth/roles_perms?tenant=" + config.tenant,
118
124
  method: "GET",
@@ -120,6 +126,7 @@ class AuthApi {
120
126
  }
121
127
  // 允许切换身份的用户列表
122
128
  allowRunAsUser(): Promise<ResponseData<any[]>> {
129
+ const config = getApp().globalData.config;
123
130
  return mpx.xfetch.fetch({
124
131
  url: "/v1/rbac/auth/allow_run_as_user?tenant=" + config.tenant,
125
132
  method: "GET",
@@ -128,6 +135,7 @@ class AuthApi {
128
135
 
129
136
  // 运行某种身份
130
137
  runAsUser(userId: string): Promise<ResponseData<any>> {
138
+ const config = getApp().globalData.config;
131
139
  const data = {
132
140
  tenant: config.tenant,
133
141
  userId: userId,
@@ -165,6 +173,7 @@ class AuthApi {
165
173
  }
166
174
  // 部门Tree
167
175
  deptTree(deptId?: string, tenant?: string): Promise<ResponseData<any[]>> {
176
+ const config = getApp().globalData.config;
168
177
  const query = {
169
178
  tenant: tenant ? tenant : config.tenant,
170
179
  excludeId: deptId,
@@ -178,6 +187,7 @@ class AuthApi {
178
187
 
179
188
  // 职务Tree
180
189
  jobTree(jobId?: string, tenant?: string): Promise<ResponseData<any[]>> {
190
+ const config = getApp().globalData.config;
181
191
  const query = {
182
192
  tenant: tenant ? tenant : config.tenant,
183
193
  roleType: "job",
@@ -192,6 +202,7 @@ class AuthApi {
192
202
  }
193
203
  // 修改个人信息
194
204
  updateUserInfo(data: UpdateUserReq): Promise<ResponseData<UserInfo>> {
205
+ const config = getApp().globalData.config;
195
206
  data.tenant = config.tenant;
196
207
  grpc.clearEmpty(data);
197
208
  return mpx.xfetch.fetch({
@@ -203,6 +214,7 @@ class AuthApi {
203
214
 
204
215
  // 获取当前会话用户的信息
205
216
  findUserInfo(data: UserInfoReq): Promise<ResponseData<UserInfo>> {
217
+ const config = getApp().globalData.config;
206
218
  data.tenant = config.tenant;
207
219
  return mpx.xfetch.fetch({
208
220
  url: "/v1/front/rbac/auth/user",
@@ -24,9 +24,8 @@ 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
  // 获取网站内容信息
@@ -84,6 +83,7 @@ class CmsApiImpl {
84
83
  findCmsContentInfo(
85
84
  data: CmsContentInfoReq
86
85
  ): Promise<ResponseData<CmsContentInfoModel>> {
86
+ const config = getApp().globalData.config;
87
87
  data.tenant = data.tenant || config.tenant;
88
88
  grpc.clearEmpty(data);
89
89
  return mpx.xfetch.fetch({
@@ -1,6 +1,5 @@
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 {
@@ -31,6 +30,7 @@ class DictApiImpl {
31
30
  if (data) {
32
31
  data.hasEnable = data.enable !== undefined;
33
32
  }
33
+ const config = getApp().globalData.config;
34
34
  return mpx.xfetch.fetch({
35
35
  url: "/v1/dict/dict_entry/list/" + config.tenant,
36
36
  method: "GET",
@@ -1,12 +1,12 @@
1
1
  import { FileInfo, FileBase64Req, FileDownInfo, FileWebReq } from "./types";
2
- import { ResponseData } from "../../api/types";
2
+ import { ResponseData, AppConfig } from "../../api/types";
3
3
  import { db } from "../../utils/db";
4
4
  import { grpc } from "../../utils/grpc";
5
- import { config } from "../../utils/config";
6
5
  import mpx from "@mpxjs/core";
7
6
 
8
7
  class FileApi {
9
8
  baseApiUrl(): string {
9
+ const config = getApp().globalData.config;
10
10
  let currentBaseURL = config.baseUrl as string;
11
11
  // 使用 slice() 方法
12
12
  if (currentBaseURL.slice(-1) === "/") {
@@ -17,6 +17,7 @@ class FileApi {
17
17
 
18
18
  // 上传Url
19
19
  uploadUrl(): string {
20
+ const config = getApp().globalData.config;
20
21
  return this.baseApiUrl() + "/v1/file/upload?tenant=" + config.tenant;
21
22
  }
22
23
 
@@ -56,6 +57,7 @@ class FileApi {
56
57
  height: number = 0,
57
58
  type: string = "clip"
58
59
  ): string {
60
+ const config = getApp().globalData.config;
59
61
  return (
60
62
  this.baseApiUrl() +
61
63
  "/v1/file/image_id/" +
@@ -72,11 +74,13 @@ class FileApi {
72
74
 
73
75
  // Id 获取文件Full路径
74
76
  fileIdUrl(fileId?: string): string {
77
+ const config = getApp().globalData.config;
75
78
  return this.baseApiUrl() + "/v1/file/id/" + config.tenant + fileId;
76
79
  }
77
80
 
78
81
  // 上传文件
79
82
  uploadBase64File(base64: FileBase64Req): Promise<ResponseData<FileInfo>> {
83
+ const config = getApp().globalData.config;
80
84
  base64.tenant = config.tenant;
81
85
  grpc.clearEmpty(base64);
82
86
  return mpx.xfetch.fetch({
@@ -1,7 +1,6 @@
1
1
  import { DictRegionList, DictRegionReq } from "./types";
2
- import { ResponseData } from "../../api/types";
2
+ import { ResponseData, AppConfig } from "../../api/types";
3
3
  import { grpc } from "../../utils/grpc";
4
- import { config } from "../../utils/config";
5
4
  import mpx from "@mpxjs/core";
6
5
 
7
6
  class RegionApiImpl {
@@ -11,6 +10,7 @@ class RegionApiImpl {
11
10
  query.hasEnable = query.enable !== undefined;
12
11
  }
13
12
  grpc.clearEmpty(query);
13
+ const config = getApp().globalData.config;
14
14
  return mpx.xfetch.fetch({
15
15
  url: "/v1/region/dict_region/list/" + config.tenant,
16
16
  method: "GET",
@@ -1,7 +1,6 @@
1
1
  import mpx from "@mpxjs/core";
2
- import { ResponseData } from "../../api/types";
2
+ import { ResponseData, AppConfig } from "../../api/types";
3
3
  import { grpc } from "../../utils/grpc";
4
- import { config } from "../../utils/config";
5
4
  import {
6
5
  StorageOrganInfoReq,
7
6
  StorageOrganInfoList,
@@ -15,6 +14,7 @@ class StorageApiImpl {
15
14
  data: StorageOrganInfoReq
16
15
  ): Promise<ResponseData<StorageOrganInfoList>> {
17
16
  grpc.clearEmpty(data);
17
+ const config = getApp().globalData.config;
18
18
  return mpx.xfetch.fetch({
19
19
  url: `/v1/storage/storage_organ/my_list/${config.tenant}?&serviceType[]=${data.serviceType}`,
20
20
  method: "GET",
@@ -25,6 +25,7 @@ class StorageApiImpl {
25
25
  findStorageBrowserOrganList(
26
26
  data: StorageOrganInfoReq
27
27
  ): Promise<ResponseData<StorageOrganInfoList>> {
28
+ const config = getApp().globalData.config;
28
29
  return mpx.xfetch.fetch({
29
30
  url: `/v1/front/storage/storage_organ_browser/my_list/${config.tenant}?&serviceType[]=${data.serviceType}`,
30
31
  method: "GET",
@@ -35,6 +36,7 @@ class StorageApiImpl {
35
36
  findStorageOrganInfoList(
36
37
  data: StorageOrganInfoReq
37
38
  ): Promise<ResponseData<StorageOrganInfoList>> {
39
+ const config = getApp().globalData.config;
38
40
  return mpx.xfetch.fetch({
39
41
  url: `/v1/storage/storage_organ_info/list/${config.tenant}?&serviceType[]=${data.serviceType}`,
40
42
  method: "GET",
@@ -46,6 +48,7 @@ class StorageApiImpl {
46
48
  updateStorageOrganBrowser(
47
49
  data: StorageOrganBrowserUpdateReq
48
50
  ): Promise<ResponseData<StorageOrganBrowserModel>> {
51
+ const config = getApp().globalData.config;
49
52
  data.tenant = config.tenant;
50
53
  grpc.clearEmpty(data);
51
54
  return mpx.xfetch.fetch({
package/src/app.mpx CHANGED
@@ -28,6 +28,7 @@ createApp({
28
28
  "pages": [
29
29
  "./pages/index",
30
30
  "./pages/home",
31
+ "./pages/home2",
31
32
  "./pages/half-home",
32
33
  "./pages/basic-component",
33
34
  "./pages/tabbar/home",
@@ -61,7 +61,6 @@
61
61
 
62
62
  <script lang="ts">
63
63
  import mpx, { createComponent } from '@mpxjs/core'
64
- import { config } from '../../utils/config'
65
64
  import { UpdateUserReq, UserInfo } from '../../api/auth/types'
66
65
  import { authApi } from '../../api/auth/index'
67
66
  import { fileApi } from '../../api/files/index';
@@ -97,10 +96,10 @@ createComponent({
97
96
  }
98
97
  },
99
98
  data: {
100
- resourceUrl: config.resourceUrl + "/images",
101
- imageUrl: config.baseUrl + "/v1/file/path/",
99
+ resourceUrl: getApp().globalData.config.resourceUrl + "/images",
100
+ imageUrl: getApp().globalData.config.baseUrl + "/v1/file/path/",
102
101
  userInfo: {} as UserInfo,
103
- userStore: {} as any
102
+ userStore: {} as any,
104
103
  },
105
104
  ready() {
106
105
  this.userStore = useUserStore();
@@ -131,6 +130,7 @@ createComponent({
131
130
  // 更换手机号
132
131
  getPhoneNumberWechat(e: any) {
133
132
  console.log("getPhoneNumber", e);
133
+ const config = getApp().globalData.config;
134
134
  if (e.detail.errMsg === "getPhoneNumber:ok") {
135
135
  // 授权成功后,调用rbac模块接口 已登陆状态小程序更换绑定手机号
136
136
  authApi.replaceBindphone({
@@ -146,6 +146,7 @@ createComponent({
146
146
  },
147
147
  getPhoneNumberAli(e: any) {
148
148
  console.log("getPhoneNumber", e);
149
+ const config = getApp().globalData.config;
149
150
  // 支付宝小程序获取手机号
150
151
  my.getPhoneNumber({
151
152
  success: (res: any) => {
@@ -45,7 +45,6 @@
45
45
 
46
46
  <script lang="ts">
47
47
  import mpx, { createComponent } from '@mpxjs/core'
48
- import { config } from '../../utils/config'
49
48
  import { UpdateUserReq, UserInfo } from '../../api/auth/types'
50
49
  import { authApi } from '../../api/auth/index'
51
50
  import { fileApi } from '../../api/files/index';
@@ -81,8 +80,8 @@ createComponent({
81
80
  }
82
81
  },
83
82
  data: {
84
- resourceUrl: config.resourceUrl + "/images",
85
- imageUrl: config.baseUrl + "/v1/file/path/",
83
+ resourceUrl: getApp().globalData.config.resourceUrl + "/images",
84
+ imageUrl: getApp().globalData.config.baseUrl + "/v1/file/path/",
86
85
  userInfo: {} as UserInfo,
87
86
  userStore: {} as any
88
87
  },
@@ -115,6 +114,7 @@ createComponent({
115
114
  // 更换手机号
116
115
  getPhoneNumberWechat(e: any) {
117
116
  console.log("getPhoneNumber", e);
117
+ const config = getApp().globalData.config;
118
118
  if (e.detail.errMsg === "getPhoneNumber:ok") {
119
119
  // 授权成功后,调用rbac模块接口 已登陆状态小程序更换绑定手机号
120
120
  authApi.replaceBindphone({
@@ -130,6 +130,7 @@ createComponent({
130
130
  },
131
131
  getPhoneNumberAli(e: any) {
132
132
  console.log("getPhoneNumber", e);
133
+ const config = getApp().globalData.config;
133
134
  // 支付宝小程序获取手机号
134
135
  my.getPhoneNumber({
135
136
  success: (res: any) => {
@@ -29,7 +29,6 @@
29
29
  <script lang="ts">
30
30
  import mpx, { createComponent, ref, onMounted } from "@mpxjs/core";
31
31
  import { EventBase } from "../../api/types";
32
- import { config } from '../../utils/config';
33
32
  import { cmsApi } from '../../api/cms';
34
33
  import { CmsInfoModel } from '../../api/cms/types';
35
34
 
@@ -67,6 +66,7 @@ createComponent({
67
66
  },
68
67
  },
69
68
  setup(props) {
69
+ let config = getApp().globalData.config;
70
70
  // 资源路径
71
71
  let resourceUrl = config.resourceUrl + '/images/';
72
72
  // 文章列表
@@ -58,7 +58,6 @@
58
58
  <script lang="ts">
59
59
  import mpx, { createComponent, ref, onMounted } from "@mpxjs/core";
60
60
  import { EventBase } from "../../api/types";
61
- import { config } from '../../utils/config';
62
61
  import { cmsApi } from '../../api/cms';
63
62
  import { CmsInfoModel } from '../../api/cms/types';
64
63
 
@@ -101,6 +100,7 @@ createComponent({
101
100
  },
102
101
  },
103
102
  setup(props) {
103
+ let config = getApp().globalData.config;
104
104
  // 资源路径
105
105
  let resourceUrl = config.resourceUrl + '/images';
106
106
  // 文章列表
@@ -127,6 +127,7 @@ createComponent({
127
127
  methods: {
128
128
  // 点击详情事件
129
129
  handleInfo(e: EventBase) {
130
+ let config = getApp().globalData.config;
130
131
  let item = e.currentTarget.dataset.item;
131
132
  mpx.navigateTo({
132
133
  url: '/jmash/pages/cms/cms-article?siteId=' + this.siteId + '&infoId=' + item.infoId,
@@ -21,7 +21,6 @@
21
21
  <script lang="ts">
22
22
  import mpx, { createComponent } from "@mpxjs/core";
23
23
  import { EventBase } from "../../api/types";
24
- import { config } from '../../utils/config';
25
24
 
26
25
  createComponent({
27
26
  properties: {
@@ -67,6 +66,7 @@ createComponent({
67
66
  },
68
67
  },
69
68
  setup(props) {
69
+ let config = getApp().globalData.config;
70
70
  // 资源路径
71
71
  let resourceUrl = config.resourceUrl + '/images';
72
72
  return { resourceUrl }
@@ -30,7 +30,6 @@
30
30
  <script lang="ts">
31
31
  import { createComponent, ref, toRefs, watch, computed } from '@mpxjs/core'
32
32
  import { cmsApi } from '../../api/cms/index'
33
- import { config } from '../../utils/config';
34
33
  import { FrontLikeCreateReq } from '../../api/cms/types'
35
34
  import { EventBase } from '../../api/types'
36
35
 
@@ -53,6 +52,7 @@ createComponent({
53
52
  }
54
53
  },
55
54
  setup(props) {
55
+ let config = getApp().globalData.config;
56
56
  let browseCount = ref(0);
57
57
  let likeCount = ref(0);
58
58
  let isLikeStatus = ref(false);
@@ -86,6 +86,7 @@ createComponent({
86
86
  methods: {
87
87
  // 点赞/取消点赞
88
88
  handleLike(e: EventBase) {
89
+ let config = getApp().globalData.config;
89
90
  const tempData = {
90
91
  // 用于检测重复请求的唯一字符串ID
91
92
  requestId: Math.random() * 10 + "",
@@ -10,7 +10,6 @@
10
10
 
11
11
  <script lang="ts">
12
12
  import mpx, { createComponent, ref } from "@mpxjs/core";
13
- import { config } from "../../utils/config";
14
13
  import { fileApi } from "../../api/files/index";
15
14
  import { EventBase } from "../../api/types";
16
15
 
@@ -47,6 +46,7 @@ createComponent({
47
46
  }
48
47
  },
49
48
  setup() {
49
+ let config = getApp().globalData.config;
50
50
  let resourceUrl = config.resourceUrl + "/images/icon_image/";
51
51
  // 默认头像图片
52
52
  let avatar = ref(resourceUrl + "/images/components/gray_head2x.png");
@@ -6,11 +6,11 @@
6
6
  </template>
7
7
  <script lang="ts">
8
8
  import { createComponent } from "@mpxjs/core"
9
- import { config } from "../../utils/config";
9
+
10
10
 
11
11
  createComponent({
12
12
  properties: {
13
- // 图片与文本之间的间距
13
+ // 图片与文本之间的间距
14
14
  imgTextGap: {
15
15
  type: Number,
16
16
  value: 0
@@ -51,8 +51,8 @@ createComponent({
51
51
  }
52
52
  },
53
53
  setup() {
54
+ let config = getApp().globalData.config;
54
55
  let resourceUrl = config.resourceUrl + "/images/"
55
-
56
56
  return {
57
57
  resourceUrl
58
58
  }
@@ -15,7 +15,6 @@
15
15
 
16
16
  <script lang="ts">
17
17
  import { createComponent } from "@mpxjs/core"
18
- import { config } from "../../utils/config";
19
18
 
20
19
  createComponent({
21
20
  properties: {
@@ -57,6 +56,7 @@ createComponent({
57
56
  }
58
57
  },
59
58
  setup() {
59
+ let config = getApp().globalData.config;
60
60
  let resourceUrl = config.resourceUrl + "/images/icon_image/"
61
61
  let popupStyle = {
62
62
  mask: {
@@ -14,7 +14,6 @@
14
14
 
15
15
  <script lang="ts">
16
16
  import { createComponent } from "@mpxjs/core";
17
- import { config } from "../../utils/config";
18
17
  import { EventBase } from "../../api/types";
19
18
 
20
19
  createComponent({
@@ -64,6 +63,7 @@ createComponent({
64
63
  }
65
64
  },
66
65
  setup() {
66
+ let config = getApp().globalData.config;
67
67
  // 资源路径
68
68
  let resourceUrl = config.resourceUrl + "/images";
69
69
 
@@ -18,7 +18,6 @@
18
18
 
19
19
  <script lang="ts">
20
20
  import mpx, { createComponent, ref } from "@mpxjs/core";
21
- import { config } from "../../utils/config";
22
21
  import { EventBase } from "../../api/types";
23
22
 
24
23
  createComponent({
@@ -30,6 +29,7 @@ createComponent({
30
29
  }
31
30
  },
32
31
  setup() {
32
+ let config = getApp().globalData.config;
33
33
  // 资源路径
34
34
  let resourceUrl = config.resourceUrl + "/images/mall/";
35
35
  // 图片路径
@@ -66,6 +66,7 @@ createComponent({
66
66
  });
67
67
  },
68
68
  chooseWxHeadImage: function (type: any) {
69
+ let config = getApp().globalData.config;
69
70
  const token: string = mpx.getStorageSync("token") ? "Bearer " + mpx.getStorageSync("token") : "";
70
71
  mpx.chooseMedia({
71
72
  count: this.limit,
@@ -8,8 +8,9 @@ import { createPage, ref, onLoad } from '@mpxjs/core'
8
8
  createPage({
9
9
  setup(props) {
10
10
  //console.log("123", props);
11
- let siteId = ref(getApp().globalData.config.siteId);
12
- let tenant = ref(getApp().globalData.config.tenant);
11
+ let config = getApp().globalData.config;
12
+ let siteId = ref(config.siteId);
13
+ let tenant = ref(config.tenant);
13
14
  let channelAlias = ref('');
14
15
  onLoad((options) => {
15
16
  console.log(options);
@@ -12,8 +12,9 @@ import { createPage, ref, onLoad } from '@mpxjs/core'
12
12
 
13
13
  createPage({
14
14
  setup(props) {
15
- let resourceUrl = ref(getApp().globalData.config.resourceUrl);
16
- let appName = ref(getApp().globalData.config.name);
15
+ let config = getApp().globalData.config;
16
+ let resourceUrl = ref(config.resourceUrl);
17
+ let appName = ref(config.name);
17
18
  let linkType = ref("redirectTo");
18
19
  let backurl = ref("/pages/home");
19
20
  onLoad((options) => {
@@ -25,12 +25,12 @@ import mpx, { createPage, ref, onLoad, onPullDownRefresh } from '@mpxjs/core'
25
25
  import { EventBase } from '../../../api/types';
26
26
  import { cmsApi } from '../../../api/cms';
27
27
  import { CmsInfoModel } from '../../../api/cms/types';
28
- import { config } from '../../../utils/config';
29
28
 
30
29
  createPage({
31
30
  setup(props) {
32
- let organTenant = ref(getApp().globalData.config.tenant);
33
- let siteId = ref(getApp().globalData.config.siteId);
31
+ let config = getApp().globalData.config;
32
+ let organTenant = ref(config.tenant);
33
+ let siteId = ref(config.siteId);
34
34
  let channelId = ref('');
35
35
  let channelAlias = ref('');
36
36
  let curPage = ref(1);
@@ -54,7 +54,7 @@ createPage({
54
54
  }
55
55
  onLoad((options) => {
56
56
  console.log("article-list", options);
57
- siteId.value = options.siteId || getApp().globalData.config.siteId;
57
+ siteId.value = options.siteId || config.siteId;
58
58
  channelId.value = options.channelId || '';
59
59
  channelAlias.value = options.channelAlias || '';
60
60
  curPage.value = 1;
@@ -68,6 +68,7 @@ createPage({
68
68
  methods: {
69
69
  // 点击详情事件
70
70
  handleInfo(e: EventBase) {
71
+ let config = getApp().globalData.config;
71
72
  let item = e.currentTarget.dataset.item;
72
73
  mpx.navigateTo({
73
74
  url: '/jmash/pages/cms/cms-article?siteId=' + this.siteId + '&infoId=' + item.infoId,
@@ -8,12 +8,13 @@ import { createPage, ref, onLoad } from '@mpxjs/core'
8
8
  createPage({
9
9
  setup(props) {
10
10
  //console.log("123", props);
11
- let siteId = ref(getApp().globalData.config.siteId);
12
- let tenant = ref(getApp().globalData.config.tenant);
11
+ let config = getApp().globalData.config;
12
+ let siteId = ref(config.siteId);
13
+ let tenant = ref(config.tenant);
13
14
  let infoId = ref('');
14
15
  onLoad((options) => {
15
16
  console.log(options);
16
- siteId.value = options.siteId || getApp().globalData.config.siteId;
17
+ siteId.value = options.siteId || config.siteId;
17
18
  infoId.value = options.infoId || '';
18
19
  })
19
20
  return { siteId, tenant, infoId };
@@ -10,10 +10,10 @@
10
10
  <script>
11
11
  import mpx, { createPage, onShow, ref } from '@mpxjs/core'
12
12
  import { useUserStore } from '../store/user'
13
- import { config } from '../utils/config';
14
13
 
15
14
  createPage({
16
15
  setup() {
16
+ let config = getApp().globalData.config;
17
17
  let userStore = useUserStore();
18
18
  //强制登录.
19
19
  onShow(() => {
@@ -0,0 +1,48 @@
1
+ <template>
2
+ <view class="home-page">
3
+ <text>主页(全屏登录)</text>
4
+ <cms-acticle-list organTenant="xyvcard" siteId="{{ siteId }}" channelAlias="{{ channelAlias }}"></cms-acticle-list>
5
+ <cms-article-view title="企业动态" isInfo="{{ true }}" organTenant="xyvcard" siteId="{{ siteId }}"
6
+ channelAlias="{{ channelAlias }}" style="1"></cms-article-view>
7
+ </view>
8
+ </template>
9
+
10
+ <script>
11
+ import { createPage, onShow, ref } from '@mpxjs/core'
12
+ import { useUserStore } from '../store/user'
13
+
14
+ createPage({
15
+ setup() {
16
+ let config = getApp().globalData.config;
17
+ let userStore = useUserStore();
18
+ //强制登录.
19
+ onShow(() => {
20
+ //检查登录并跳转登录
21
+ userStore.loginAC("/pages/home2", false).then((res) => {
22
+ console.log(res);
23
+ });
24
+ });
25
+ let siteId = ref(config.siteId);
26
+ let channelAlias = ref("gzdt");
27
+ return { siteId, channelAlias }
28
+ }
29
+ })
30
+ </script>
31
+
32
+ <style lang="scss">
33
+ .home-page {
34
+ padding: 40rpx;
35
+ text-align: center;
36
+ font-size: 32rpx;
37
+ color: #333;
38
+ }
39
+ </style>
40
+
41
+ <script type="application/json">
42
+ {
43
+ "usingComponents": {
44
+ "cms-acticle-list": "../components/cms/jmash-cms-acticle-list",
45
+ "cms-article-view": "../components/cms/jmash-cms-article-view"
46
+ }
47
+ }
48
+ </script>
@@ -1,6 +1,7 @@
1
1
  <template>
2
2
  <view class="page-body">
3
- <button type="default" bind:tap="toHomePage">主页(全屏登录)</button>
3
+ <button type="default" bind:tap="toHomePage">主页(全屏登录检查)</button>
4
+ <button type="default" bind:tap="toHome2Page">主页(全屏登录)</button>
4
5
  <button type="default" bind:tap="toHalfHomePage">主页(半屏登录)</button>
5
6
  <button type="default" bind:tap="toCompTestPage">组件演示</button>
6
7
  <button type="default" bind:tap="loginOut">退出</button>
@@ -28,6 +29,11 @@ createPage({
28
29
  url: '/pages/home'
29
30
  })
30
31
  },
32
+ toHome2Page() {
33
+ mpx.navigateTo({
34
+ url: '/pages/home2'
35
+ })
36
+ },
31
37
  toHalfHomePage() {
32
38
  mpx.navigateTo({
33
39
  url: '/pages/half-home'
package/src/store/user.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { defineStore } from "@mpxjs/pinia";
2
- import { config } from "../utils/config";
3
2
  import {
4
3
  LoginReq,
5
4
  PhoneRegisterReq,
@@ -43,7 +42,7 @@ export const useUserStore = defineStore("user", {
43
42
  if (this.checkLogin()) {
44
43
  return Promise.resolve(true);
45
44
  }
46
-
45
+ const config = getApp().globalData.config;
47
46
  // 2. 测试环境特殊配置 → 直接返回失败
48
47
  if (config.dev && config.testNewUser) {
49
48
  return Promise.reject("测试环境,要求用户登录!");
@@ -69,6 +68,7 @@ export const useUserStore = defineStore("user", {
69
68
  const toUrl = `${loginurl}?tabbar=${tabbar}&backurl=${encodeURIComponent(
70
69
  backurl
71
70
  )}`;
71
+ const config = getApp().globalData.config;
72
72
 
73
73
  // 3. 测试环境特殊处理
74
74
  if (config.dev && config.testNewUser) {
@@ -77,20 +77,21 @@ export const useUserStore = defineStore("user", {
77
77
  }
78
78
 
79
79
  // 4. 生产环境:执行静默登录
80
- return this.silentLogin().then((res) => {
81
- if (res.status) {
80
+ return this.silentLogin()
81
+ .then((res) => {
82
82
  // 静默登录成功
83
- return true;
84
- }
85
- // 静默登录失败 → 跳转登录页
86
- mpx.navigateTo({ url: toUrl });
87
- return false;
88
- });
83
+ return Promise.resolve(res.status);
84
+ })
85
+ .catch(() => {
86
+ mpx.navigateTo({ url: toUrl });
87
+ return Promise.resolve(false);
88
+ });
89
89
  },
90
90
 
91
91
  /** 静默登录 */
92
92
  silentLogin(): Promise<LoginRes> {
93
93
  const obj = __mpx_mode__ === "ali" ? { scopes: "auth_base" } : {};
94
+ const config = getApp().globalData.config;
94
95
  return mpx
95
96
  .login(obj as WechatMiniprogram.LoginOption)
96
97
  .then((res: any) => {
@@ -118,6 +119,7 @@ export const useUserStore = defineStore("user", {
118
119
  avatar: string = ""
119
120
  ): Promise<LoginRes> {
120
121
  const obj = __mpx_mode__ === "ali" ? { scopes: "auth_user" } : {};
122
+ const config = getApp().globalData.config;
121
123
  return mpx
122
124
  .login(obj as WechatMiniprogram.LoginOption)
123
125
  .then((res: any) => {
@@ -7,8 +7,6 @@ import mpx from "@mpxjs/core";
7
7
  import mpxFetch from "@mpxjs/fetch";
8
8
  mpx.use(mpxFetch);
9
9
 
10
- import { config as appconfig } from "../utils/config";
11
-
12
10
  let isRefreshing = false;
13
11
  type TokenCallBackFunc = (token: string) => void;
14
12
  let requests: TokenCallBackFunc[] = [];
@@ -17,6 +15,7 @@ let isLogout = false;
17
15
 
18
16
  mpx.xfetch.interceptors.request.use(function (config) {
19
17
  if (!config.url.startsWith("http")) {
18
+ const appconfig = getApp().globalData.config;
20
19
  config.url = appconfig.baseUrl + config.url;
21
20
  }
22
21
  //console.log("request:", config);
@@ -119,6 +118,7 @@ mpx.xfetch.interceptors.response.use(function (res) {
119
118
 
120
119
  //刷新Token
121
120
  function refreshToken(refreshToken: string) {
121
+ const appconfig = getApp().globalData.config;
122
122
  return mpx.xfetch.fetch<TokenModel>({
123
123
  url: appconfig.baseUrl + "/v1/front/rbac/auth/refresh_token",
124
124
  method: "POST",
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};