@smart100/spu-web-plugin 1.0.25-beta.5 → 1.0.25-beta.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smart100/spu-web-plugin",
3
- "version": "1.0.25-beta.5",
3
+ "version": "1.0.25-beta.6",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "dev": "npm run build:types && rollup -c -w",
@@ -52,4 +52,4 @@
52
52
  "uuid": "^9.0.1",
53
53
  "vconsole": "^3.15.1"
54
54
  }
55
- }
55
+ }
package/src/axios.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import axios from 'axios'
2
2
  import type { AxiosInstance, AxiosResponse } from 'axios'
3
- import { get } from 'lodash-es'
3
+ import { get, cloneDeep } from 'lodash-es'
4
4
  import { loadding } from './components/loadding'
5
5
  import { getToken, updateToken, getLoginState } from './login'
6
+ import { globalOptions } from './index'
6
7
  import core from './core'
7
8
  import { urlquery } from './urlquery'
8
9
  import { getTecode } from './envService'
@@ -15,8 +16,10 @@ interface Response {
15
16
  message: string
16
17
  }
17
18
 
19
+ type axiosType = 'spu' | 'apaas' | 'normal'
20
+
18
21
  // _encrydata
19
- export const normalizeEncryData = (response: any) => {
22
+ const normalizeEncryData = (response: any) => {
20
23
  if (response.data && response.data._encrydata && typeof response.data._encrydata === 'string') {
21
24
  const res = decrypt(response.data._encrydata)
22
25
  try {
@@ -43,27 +46,56 @@ export const normalizeEncryData = (response: any) => {
43
46
  return response
44
47
  }
45
48
 
46
- const createAxiosInstance = (type: 'spu' | 'normal' = 'spu', options: any) => {
47
- const axiosInstance: AxiosInstance = axios.create({
48
- baseURL: type === 'spu' ? `/api/${options.modulekey}/${options.moduleversion}` : ''
49
- // baseURL: '',
50
- // timeout: 36000000
51
- // withCredentials: true, // 不能开启 影响ali oss
52
- // headers: {
53
- // // 'Content-Type': 'application/json;charset=UTF-8',
54
- // // 'app_id': '100'
55
- // }
56
- })
49
+ // 检查接口错误返回信息是否登录
50
+ const checkErrorResponseIsLogin = (type: axiosType = 'spu', err: any) => {
51
+ if (type === 'spu') {
52
+ if (err.message === '未授权' && get(err, 'response.data.code') === 401) {
53
+ return false
54
+ } else {
55
+ return true
56
+ }
57
+ } else if (type === 'apaas') {
58
+ if (
59
+ err.message.indexOf('token is invalid(decode).') !== -1 ||
60
+ err.message.indexOf('token is invalid(null).') !== -1 ||
61
+ err.message === 'token无效,请重新登录' ||
62
+ err.message === 'jwt token无效'
63
+ ) {
64
+ return false
65
+ } else {
66
+ return true
67
+ }
68
+ }
69
+ }
70
+
71
+ const createAxiosInstance = (type: axiosType = 'spu', config: any = {}) => {
72
+ const axiosInstance: AxiosInstance = axios.create(
73
+ Object.assign(config, {
74
+ baseURL:
75
+ type === 'spu' ? `/api/${globalOptions.modulekey}/${globalOptions.moduleversion}` : ''
76
+ })
77
+ )
57
78
 
58
79
  axiosInstance.interceptors.request.use(
59
80
  async (config: any) => {
60
- // const isShowLoading = typeof config?.isShowLoading !== 'undefined' ? config.isShowLoading : true
61
- // console.error(444444)
62
- // console.log(config)
63
-
64
81
  const isShowLoading = get(config, 'isShowLoading', true)
65
82
  isShowLoading && loadding.open()
66
83
 
84
+ if (type === 'spu' && config.modulekey) {
85
+ const moduleData: any = await core.getModuleData(config.modulekey)
86
+ if (moduleData.data) {
87
+ config.baseURL = `/api/${config.modulekey}/${moduleData.data.moduleversion}`
88
+ } else {
89
+ console.error(moduleData.errorMsg)
90
+ config.baseURL = `/api/${config.modulekey}/v?.?`
91
+ }
92
+ }
93
+
94
+ // if (config.url === 'http://120.46.182.226/api/smartcenter/biz/getTenantWebAndApiDefined') {
95
+ // console.log(config)
96
+ // debugger
97
+ // }
98
+
67
99
  const isSendToken = get(config, 'isSendToken', true)
68
100
  if (isSendToken) {
69
101
  // 请求接口前校验是否过期 如果过期先刷新token
@@ -87,16 +119,6 @@ const createAxiosInstance = (type: 'spu' | 'normal' = 'spu', options: any) => {
87
119
  }
88
120
  }
89
121
 
90
- if (type === 'spu' && config.modulekey) {
91
- const moduleData: any = await core.getModuleData(config.modulekey)
92
- if (moduleData.data) {
93
- config.baseURL = `/api/${config.modulekey}/${moduleData.data.moduleversion}`
94
- } else {
95
- console.error(moduleData.errorMsg)
96
- config.baseURL = `/api/${config.modulekey}/v?.?`
97
- }
98
- }
99
-
100
122
  // 平台的业务接口开了开发者模式后,header带上debug方便查看接口的ide日志
101
123
  if (type !== 'spu' && urlquery.isdebugger && config.url.indexOf('api/teapi/dy-biz/') > -1) {
102
124
  if (config?.headers) {
@@ -117,107 +139,93 @@ const createAxiosInstance = (type: 'spu' | 'normal' = 'spu', options: any) => {
117
139
  return config
118
140
  },
119
141
  (error) => {
142
+ // console.error(error)
143
+ // debugger
120
144
  return Promise.reject(error)
121
145
  }
122
146
  )
123
147
 
124
148
  axiosInstance.interceptors.response.use(
125
- (res: AxiosResponse) => {
126
- // debugger
149
+ async (res: AxiosResponse) => {
127
150
  const isShowLoading = get(res, 'config.isShowLoading', true)
128
151
  isShowLoading && loadding.close()
152
+
153
+ // if (res.config.url === '/api/auth/refreshtoken') {
154
+ // console.log(res)
155
+ // debugger
156
+ // }
157
+
129
158
  normalizeEncryData(res)
130
159
 
131
- let realRes: Response = {
132
- code: 404,
133
- data: '',
134
- msg: '',
135
- message: ''
136
- }
160
+ if (type !== 'normal') {
161
+ let realRes: Response = {
162
+ code: 404,
163
+ data: '',
164
+ msg: '',
165
+ message: ''
166
+ }
137
167
 
138
- if (type === 'spu') {
139
- if (res.data.code === 200) {
140
- // return res.data
141
- realRes = {
142
- code: res.data.code,
143
- data: res.data.data,
144
- msg: res.data.msg,
145
- message: res.data.msg
168
+ if (type === 'spu') {
169
+ if (res.data.code === 200) {
170
+ // return res.data
171
+ realRes = {
172
+ code: res.data.code,
173
+ data: res.data.data,
174
+ msg: res.data.msg,
175
+ message: res.data.msg
176
+ }
177
+ return realRes
178
+ } else {
179
+ realRes = {
180
+ code: res.data.code,
181
+ data: res.data.data,
182
+ msg: res.data.msg || '网络异常,请稍后重试。',
183
+ message: res.data.msg || '网络异常,请稍后重试。'
184
+ }
185
+ return Promise.reject(realRes) as any
146
186
  }
147
- return realRes
148
- } else {
187
+ } else if (type === 'apaas') {
149
188
  realRes = {
150
- code: res.data.code,
151
- data: res.data.data,
152
- msg: res.data.msg || '网络异常,请稍后重试。',
153
- message: res.data.msg || '网络异常,请稍后重试。'
189
+ code: res.status || 200,
190
+ data: res.data?.resp_data || res.data,
191
+ msg: res.data?.error_code || '',
192
+ message: res.data?.error_code || ''
154
193
  }
155
-
156
- // const isShowErrorMessage = get(res, 'config.isShowErrorMessage', true)
157
- // isShowErrorMessage && Message.error(realRes.msg)
158
-
159
- return Promise.reject(realRes) as any
160
- }
161
- } else if (type === 'normal') {
162
- realRes = {
163
- code: res.status || 200,
164
- data: res.data?.resp_data || res.data,
165
- msg: res.data?.error_code || '',
166
- message: res.data?.error_code || ''
194
+ return realRes
167
195
  }
168
- return realRes
196
+ } else {
197
+ return res
169
198
  }
170
199
  },
171
200
  (err: any) => {
172
- // err: AxiosError
173
- // console.log(err)
174
- // debugger
175
201
  const isShowLoading = get(err, 'config.isShowLoading', true)
176
202
  isShowLoading && loadding.close()
177
203
 
204
+ // err: AxiosError
178
205
  // console.log(err)
179
206
  // debugger
180
-
181
- let msg = ''
182
- if (type === 'spu') {
183
- msg = get(err, 'response.data.msg', '')
184
- } else {
185
- msg = get(err, 'response.data.error_code', '')
186
- }
187
-
188
- if (msg) {
189
- err.message = msg
190
- } else {
191
- err.message = err.response?.statusText || err.message || '网络异常,请稍后重试。'
192
- }
193
- err.msg = err.message
194
-
195
- // const isShowErrorMessage = get(err, 'config.isShowErrorMessage', true)
196
- // isShowErrorMessage && Message.error(msg)
197
-
198
- const isNoLogin = () => {
207
+ if (type !== 'normal') {
208
+ let msg = ''
199
209
  if (type === 'spu') {
200
- if (err.message === '未授权' && get(err, 'response.data.code') === 401) {
201
- return true
202
- } else {
203
- return false
204
- }
205
- } else if (type === 'normal') {
206
- if (
207
- err.message.indexOf('token is invalid(decode).') !== -1 ||
208
- err.message.indexOf('token is invalid(null).') !== -1 ||
209
- err.message === 'token无效,请重新登录' ||
210
- err.message === 'jwt token无效'
211
- ) {
212
- return true
213
- } else {
214
- return false
215
- }
210
+ msg = get(err, 'response.data.msg', '')
211
+ } else if (type === 'apaas') {
212
+ msg = get(err, 'response.data.error_code', '')
213
+ } else {
216
214
  }
217
- }
215
+ if (msg) {
216
+ err.message = msg
217
+ } else {
218
+ err.message = err.response?.statusText || err.message || '网络异常,请稍后重试。'
219
+ }
220
+ err.msg = err.message
218
221
 
219
- const noLoginFn = () => {
220
- if (isNoLogin()) {
222
+ // 对接口报错进行处理
223
+ if (!checkErrorResponseIsLogin(type, err)) {
224
+ // 跳登录页面
225
+ } else {
226
+ // 弹出错误提示
227
+ // const isShowErrorMessage = get(err, 'config.isShowErrorMessage', true)
228
+ // isShowErrorMessage && Message.error(err.msg)
221
229
  }
222
230
  }
223
231
 
@@ -228,12 +236,24 @@ const createAxiosInstance = (type: 'spu' | 'normal' = 'spu', options: any) => {
228
236
  return axiosInstance
229
237
  }
230
238
 
239
+ // spuAxios: 针对spu接口的返回形式,调用接口加前缀 `/api/${config.modulekey}/${moduleData.data.moduleversion}` 状态码一直返回200,调用成功/错误基于返回的 data.code【200是成功】判断,返回数据放 data.data,错误信息放 data.msg,对返回数据进行包装,保证一致性
240
+ // apaasAxios: 针对平台接口的返回形式,返回数据放 data.resp_data,错误信息放 data.error_code,对返回数据进行包装,保证一致性
241
+ // normalAxios: 普通接口调用,除了必要的拦截器前置后置处理外,接口返回什么就是什么,不做包装
231
242
  let spuAxios: any = null
243
+ let apaasAxios: any = null
232
244
  let normalAxios: any = null
233
245
 
234
246
  function installAxios(options: any) {
235
- spuAxios = createAxiosInstance('spu', options)
236
- normalAxios = createAxiosInstance('normal', options)
247
+ spuAxios = createAxiosInstance('spu')
248
+ apaasAxios = createAxiosInstance('apaas')
249
+ normalAxios = createAxiosInstance('normal')
237
250
  }
238
251
 
239
- export { installAxios, spuAxios, normalAxios as axios, normalizeEncryData as decryptAxiosResponseData }
252
+ export {
253
+ installAxios,
254
+ createAxiosInstance,
255
+ spuAxios,
256
+ apaasAxios,
257
+ normalAxios,
258
+ normalizeEncryData as decryptAxiosResponseData
259
+ }
@@ -0,0 +1,276 @@
1
+ import localforage from 'localforage'
2
+ import type { AxiosRequestConfig, AxiosInstance } from 'axios'
3
+ import { isOnline } from './utils'
4
+ import { getUser } from './login'
5
+
6
+ const store = localforage.createInstance({
7
+ name: 'spu-db',
8
+ storeName: 'axios-cache'
9
+ })
10
+
11
+ const defaultCachetime = 60 * 1000 * 60 * 24 * 7 // 默认缓存7天
12
+
13
+ // 将数据转换成indexDB能够保存的格式
14
+ // structuredClone 不支持的格式全部转成null
15
+ // Error 类型保留
16
+ const transform2IndexDB = (data: any, reverse = false): any => {
17
+ if (!reverse) {
18
+ if (Object.prototype.toString.call(data) === '[object Array]') {
19
+ return data.map(transform2IndexDB)
20
+ } else if (Object.prototype.toString.call(data) === '[object Object]') {
21
+ return Object.fromEntries(
22
+ new Map(
23
+ Object.entries(data).map((item) => {
24
+ return [item[0], transform2IndexDB(item[1])]
25
+ })
26
+ )
27
+ )
28
+ } else if (Object.prototype.toString.call(data) === '[object Error]') {
29
+ return {
30
+ __error__: true,
31
+ name: data.name,
32
+ message: data.message,
33
+ stack: data.stack,
34
+ // 保留其他自定义属性
35
+ ...Object.fromEntries(
36
+ Object.getOwnPropertyNames(data)
37
+ .filter((prop) => !['name', 'message', 'stack'].includes(prop))
38
+ .map((prop) => [prop, transform2IndexDB(data[prop])])
39
+ )
40
+ }
41
+ } else {
42
+ // 不支持的类型不报错 转换为null
43
+ try {
44
+ return structuredClone(data)
45
+ // return data
46
+ } catch (err) {
47
+ // console.error(err)
48
+ return null
49
+ }
50
+ }
51
+ } else {
52
+ if (Object.prototype.toString.call(data) === '[object Array]') {
53
+ return data.map((item: any) => {
54
+ return transform2IndexDB(item, true)
55
+ })
56
+ } else if (Object.prototype.toString.call(data) === '[object Object]') {
57
+ if (data.__error__) {
58
+ const error: any = new Error(data.message)
59
+ error.name = data.name
60
+ error.stack = data.stack
61
+
62
+ // 恢复其他自定义属性
63
+ Object.keys(data).forEach((key) => {
64
+ if (!['__error__', 'name', 'message', 'stack'].includes(key)) {
65
+ error[key] = transform2IndexDB(data[key], true)
66
+ }
67
+ })
68
+
69
+ return error
70
+ } else {
71
+ return Object.fromEntries(
72
+ new Map(
73
+ Object.entries(data).map((item) => {
74
+ return [item[0], transform2IndexDB(item[1], true)]
75
+ })
76
+ )
77
+ )
78
+ }
79
+ } else {
80
+ // 不支持的类型不报错 转换为null
81
+ try {
82
+ return structuredClone(data)
83
+ // return data
84
+ } catch (err) {
85
+ // console.error(err)
86
+ return null
87
+ }
88
+ }
89
+ }
90
+ }
91
+
92
+ // window.addEventListener('online', () => {
93
+ // console.log('浏览器已恢复在线')
94
+ // })
95
+
96
+ // window.addEventListener('offline', () => {
97
+ // console.log('浏览器已离线')
98
+ // console.log('当前处于离线状态,部分功能受限,恢复联网后将自动同步数据')
99
+ // })
100
+
101
+ // 生成缓存键 缓存区分租户和人员
102
+ const generateCacheKey = (axiosRequestConfig: AxiosRequestConfig): string => {
103
+ const tenantcode = getUser('tenantcode') || ''
104
+ const mbcode = getUser('mbcode') || getUser('membercode') || ''
105
+ const baseURL = axiosRequestConfig?.baseURL || ''
106
+ const url = axiosRequestConfig?.url || ''
107
+ const method = axiosRequestConfig?.method || 'get'
108
+ const params = JSON.stringify(axiosRequestConfig?.params || {})
109
+ const data = JSON.stringify(axiosRequestConfig?.data || {})
110
+
111
+ return `tenantcode=${tenantcode}&mbcode=${mbcode}&baseURL=${baseURL}&url=${url}&method=${method}&params=${params}&data=${data}`
112
+ }
113
+
114
+ interface IAxiosCacheConfig {
115
+ // 缓存策略 cachestrategy:
116
+ // network-only: 不缓存:仅使用联网数据
117
+ // network-first: 网络优先,缓存数据后,下次请求优先使用联网数据,离线才使用缓存数据
118
+ // cache-first: 缓存优先,缓存数据后,下次请求优先使用缓存数据,使用缓存后如果有联网则依然请求最新数据替换旧缓存【比如剑哥需求文档中的表单协议缓存,则属于此策略】【这个策略下需第二次请求接口才能拿到最新数据】
119
+ // d.如果是 b c,支持配置缓存过期时间
120
+ strategy: 'network-only' | 'cache-first' | 'network-first'
121
+ cachetime?: number
122
+ }
123
+
124
+ interface IAxiosCacheData {
125
+ success: boolean
126
+ response: any
127
+ cachetime: number // 缓存过期时间
128
+ expiretime: number // 过期时间
129
+ }
130
+
131
+ const removeCache = async (cachekey: string) => {
132
+ await store.removeItem(cachekey)
133
+ }
134
+
135
+ const setCache = async (cachekey: string, cache: IAxiosCacheData) => {
136
+ await store.setItem(cachekey, transform2IndexDB(cache))
137
+ }
138
+
139
+ const getCache = async (cachekey: string) => {
140
+ const cacheSource: IAxiosCacheData | null = await store.getItem(cachekey)
141
+ const cache: IAxiosCacheData | null = transform2IndexDB(cacheSource, true)
142
+ let isusecache = false
143
+ if (cache && Date.now() <= cache.expiretime) {
144
+ isusecache = true
145
+ } else if (cache && Date.now() > cache.expiretime) {
146
+ isusecache = false
147
+ // 获取缓存时发现数据过期顺便清掉
148
+ await removeCache(cachekey)
149
+ } else {
150
+ isusecache = false
151
+ }
152
+ return isusecache ? cache : null
153
+ }
154
+
155
+ const cacheToAxiosResponse = async (cache: IAxiosCacheData): Promise<any> => {
156
+ return new Promise((resolve, reject) => {
157
+ if (cache.success) {
158
+ return resolve(cache.response)
159
+ } else {
160
+ return reject(cache.response)
161
+ }
162
+ })
163
+ }
164
+
165
+ const axiosPromiseToCache = async (
166
+ axiosPro: Promise<any>,
167
+ cachetime?: number
168
+ ): Promise<IAxiosCacheData> => {
169
+ return new Promise((resolve, reject) => {
170
+ const realCachetime = Number(cachetime || defaultCachetime)
171
+ let success = false
172
+ let response: any = null
173
+ axiosPro
174
+ .then((res: any) => {
175
+ success = true
176
+ response = res
177
+ })
178
+ .catch((err: any) => {
179
+ success = false
180
+ response = err
181
+ })
182
+ .finally(() => {
183
+ resolve({
184
+ cachetime: realCachetime,
185
+ expiretime: Date.now() + realCachetime,
186
+ success,
187
+ response
188
+ })
189
+ })
190
+ })
191
+ }
192
+
193
+ const axiosCache = async (
194
+ config: IAxiosCacheConfig | null,
195
+ axiosInstance: AxiosInstance,
196
+ axiosRequestConfig: AxiosRequestConfig
197
+ ) => {
198
+ // 检查是否启用缓存
199
+ const strategy = config?.strategy || 'network-only'
200
+ const cachekey = generateCacheKey(axiosRequestConfig)
201
+ if (strategy === 'network-first') {
202
+ const online = await isOnline()
203
+ if (online) {
204
+ const cache = await axiosPromiseToCache(axiosInstance(axiosRequestConfig), config?.cachetime)
205
+ setCache(cachekey, cache)
206
+ return cacheToAxiosResponse(cache)
207
+ } else {
208
+ const cache = await getCache(cachekey)
209
+ if (cache) {
210
+ return cacheToAxiosResponse(cache)
211
+ } else {
212
+ return new Error('no cache and offline')
213
+ }
214
+ }
215
+ } else if (strategy === 'cache-first') {
216
+ const cache = await getCache(cachekey)
217
+ const online = await isOnline()
218
+
219
+ const getAndSetCacheIfOnline = async (): Promise<any> => {
220
+ if (online) {
221
+ const cache = await axiosPromiseToCache(
222
+ axiosInstance(axiosRequestConfig),
223
+ config?.cachetime
224
+ )
225
+ setCache(cachekey, cache)
226
+ return cache
227
+ } else {
228
+ return null
229
+ }
230
+ }
231
+
232
+ if (cache) {
233
+ getAndSetCacheIfOnline() // 这里不等返回 是优先使用缓存 但依然在线获取最新数据
234
+ // debugger
235
+ return cacheToAxiosResponse(cache)
236
+ } else {
237
+ if (online) {
238
+ const cache = await getAndSetCacheIfOnline()
239
+ // debugger
240
+ return cacheToAxiosResponse(cache)
241
+ } else {
242
+ return new Error('no cache and offline')
243
+ }
244
+ }
245
+ } else {
246
+ return axiosInstance(axiosRequestConfig)
247
+ }
248
+ }
249
+
250
+ const removeExpireDataByCachekey = async (cachekey: string) => {
251
+ const cacheSource: IAxiosCacheData | null = await store.getItem(cachekey)
252
+ if (cacheSource && Date.now() > cacheSource.expiretime) {
253
+ await removeCache(cachekey)
254
+ }
255
+ }
256
+
257
+ // 清除过期无效数据
258
+ const removeExpireData = async () => {
259
+ store
260
+ .keys()
261
+ .then(async (keys) => {
262
+ for (let i = 0, len = keys.length; i < len; i++) {
263
+ const key = keys[i]
264
+ await removeExpireDataByCachekey(key)
265
+ }
266
+ })
267
+ .catch((err) => {
268
+ console.log(err)
269
+ })
270
+ }
271
+
272
+ const installAxiosCache = () => {
273
+ removeExpireData()
274
+ }
275
+
276
+ export { axiosCache, installAxiosCache }
@@ -1,6 +1,6 @@
1
1
  import { Module } from '../../core'
2
2
  import { wxworkSuite } from '../../wxworksuitePlugin'
3
- import { spuAxios, axios } from '../../axios'
3
+ import { spuAxios, apaasAxios } from '../../axios'
4
4
  import { getUser } from '../../login'
5
5
  import { cloneDeep, merge } from 'lodash-es'
6
6
  import { downloadService } from '../../oss'
@@ -425,7 +425,7 @@ export default class SpuExpandexp extends HTMLElement {
425
425
  event: 'exportopenmodal'
426
426
  })
427
427
  } else {
428
- axios
428
+ apaasAxios
429
429
  .post(
430
430
  '/api/expandexp/global/searchExpGloConfig',
431
431
  {
@@ -468,7 +468,7 @@ export default class SpuExpandexp extends HTMLElement {
468
468
  this.data.iscompress = '1'
469
469
 
470
470
  // 获取文件水印开关
471
- axios
471
+ apaasAxios
472
472
  .post('/api/expandexp/global/searchWatermarkConfig', '', {
473
473
  isShowLoading: false
474
474
  })
@@ -539,7 +539,7 @@ export default class SpuExpandexp extends HTMLElement {
539
539
  }
540
540
  }
541
541
  const finallyPost = mergedata ? merge(mergedata, post) : post
542
- axios
542
+ apaasAxios
543
543
  .post(this.props.exportapi, finallyPost)
544
544
  .then((res: any) => {
545
545
  // console.log(res)
@@ -662,7 +662,7 @@ export default class SpuExpandexp extends HTMLElement {
662
662
  // console.log(this.data)
663
663
  // console.log(this.data.exportDataItem)
664
664
 
665
- axios
665
+ apaasAxios
666
666
  .post('/api/teapi/queue/impexp/cancel', {
667
667
  dynamicid: this.data.exportId
668
668
  })
@@ -708,7 +708,7 @@ export default class SpuExpandexp extends HTMLElement {
708
708
  }
709
709
 
710
710
  async updateStatus() {
711
- axios
711
+ apaasAxios
712
712
  .post(
713
713
  `/api/teapi/queue/impexp/expStatus?dynamicid=${this.data.exportId}`,
714
714
  {},
package/src/core.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { globalOptions } from './index'
2
- import { axios } from './axios'
2
+ import { apaasAxios } from './axios'
3
3
  import { get, cloneDeep } from 'lodash-es'
4
4
  import { urlquery } from './urlquery'
5
5
  import { getToken, getUser, getRefreshToken, getTokenExpires } from './login'
@@ -83,7 +83,7 @@ class Core {
83
83
  // debugger
84
84
  let res
85
85
  try {
86
- res = await axios.post(
86
+ res = await apaasAxios.post(
87
87
  `${smartcenter}/api/smartcenter/biz/getTenantWebAndApiDefined`,
88
88
  {
89
89
  envid: envId,
package/src/envService.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { get, cloneDeep } from 'lodash-es'
2
2
  import { lsProxy } from './storageProxy'
3
- import { axios } from './axios'
3
+ import { apaasAxios } from './axios'
4
4
  import { decrypt } from './crypt'
5
5
  import { toggleHttpOrHttps } from './utils'
6
6
  import { getData, setData, removeData } from './storageCache'
@@ -54,7 +54,7 @@ async function requestEnvdata(envName: string): Promise<IAny | null> {
54
54
  ? 'https://mconfig.xuantongkeji.com'
55
55
  : 'http://mconfig.xuantongkeji.com:8015'
56
56
  try {
57
- const res = await axios.get(`${hostsRoot}/multiplatconfig/env/${envName}`, {
57
+ const res = await apaasAxios.get(`${hostsRoot}/multiplatconfig/env/${envName}`, {
58
58
  isShowLoading: false,
59
59
  isSendToken: false
60
60
  })