@smart100/spu-web-plugin 0.0.22 → 0.0.24

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": "0.0.22",
3
+ "version": "0.0.24",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "dev": "rollup -c -w",
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@amap/amap-jsapi-loader": "^1.0.1",
40
- "@smart100/wxworksuite-plugin": "^0.0.3",
40
+ "@smart100/wxworksuite-plugin": "^0.0.4",
41
41
  "axios": "^1.6.0",
42
42
  "co": "^4.6.0",
43
43
  "dayjs": "^1.11.10",
package/src/axios.ts CHANGED
@@ -16,7 +16,7 @@ interface Response {
16
16
  msg: string
17
17
  }
18
18
 
19
- const createAxiosInstance = (type: 'spu' | 'apaas' = 'spu', options: SPUWebPluginOptions) => {
19
+ const createAxiosInstance = (type: 'spu' | 'normal' = 'spu', options: SPUWebPluginOptions) => {
20
20
  const axiosInstance: AxiosInstance = axios.create({
21
21
  baseURL: type === 'spu' ? `/api/${options.modulekey}/${options.moduleversion}` : '',
22
22
  // baseURL: '',
@@ -88,7 +88,7 @@ const createAxiosInstance = (type: 'spu' | 'apaas' = 'spu', options: SPUWebPlugi
88
88
  }
89
89
  return Promise.reject(realRes) as any
90
90
  }
91
- } else if (type === 'apaas') {
91
+ } else if (type === 'normal') {
92
92
  realRes = {
93
93
  code: res.status || 200,
94
94
  data: res.data?.resp_data || res.data,
@@ -118,7 +118,7 @@ const createAxiosInstance = (type: 'spu' | 'apaas' = 'spu', options: SPUWebPlugi
118
118
  } else {
119
119
  return false
120
120
  }
121
- } else if (type === 'apaas') {
121
+ } else if (type === 'normal') {
122
122
  if (msg.indexOf('token is invalid(decode).') !== -1 || msg.indexOf('token is invalid(null).') !== -1 || msg === 'token无效,请重新登录' || msg === 'jwt token无效') {
123
123
  return true
124
124
  } else {
@@ -139,19 +139,16 @@ const createAxiosInstance = (type: 'spu' | 'apaas' = 'spu', options: SPUWebPlugi
139
139
  return axiosInstance
140
140
  }
141
141
 
142
- // const spuAxios: AxiosInstance = createAxiosInstance('spu')
143
- // const apaasAxios: AxiosInstance = createAxiosInstance('apaas')
144
-
145
142
  let spuAxios: any = null
146
- let apaasAxios: any = null
143
+ let normalAxios: any = null
147
144
 
148
145
  function initAxios (options: SPUWebPluginOptions) {
149
146
  spuAxios = createAxiosInstance('spu', options)
150
- apaasAxios = createAxiosInstance('apaas', options)
147
+ normalAxios = createAxiosInstance('normal', options)
151
148
  }
152
149
 
153
150
  export {
154
151
  initAxios,
155
152
  spuAxios,
156
- apaasAxios
153
+ normalAxios as axios
157
154
  }
package/src/cloudServ.ts CHANGED
@@ -1,63 +1,5 @@
1
1
  import { lsProxy } from './storageProxy'
2
2
 
3
- // let cacheStorage: NormalizedCloudServ | null = null
4
-
5
- // const CLOUDSERVE = 'cloudserv'
6
-
7
- // const set = (storage: NormalizedCloudServ | string) => {
8
- // if (typeof storage === 'object') {
9
- // cacheStorage = storage
10
- // storage = JSON.stringify(storage)
11
- // }
12
- // lsProxy.setItem(CLOUDSERVE, storage)
13
- // }
14
-
15
- // const get = (key: StorageType = 'storage'): NormalizedCloudServItem | null => {
16
- // if (cacheStorage) {
17
- // return cacheStorage[key as StorageType] || null
18
- // }
19
- // const storageStr = lsProxy.getItem(CLOUDSERVE)
20
- // if (!storageStr) {
21
- // return null
22
- // }
23
- // const storage = JSON.parse(storageStr)
24
- // cacheStorage = storage
25
- // return storage[key]
26
- // }
27
-
28
- // const getProvider = (sign: StorageType = 'storage') => {
29
- // const storage: NormalizedCloudServItem | null = get(sign)
30
- // if (!storage) {
31
- // return false
32
- // }
33
- // return storage.cloudserv_storage_provider
34
- // }
35
-
36
- // const isAliyun = (sign: StorageType = 'storage') => {
37
- // return getProvider(sign) === 'aliyun'
38
- // }
39
-
40
- // const isAzure = (sign: StorageType = 'storage') => {
41
- // return getProvider(sign) === 'azure'
42
- // }
43
-
44
- // const isAwss3 = (sign: StorageType = 'storage') => {
45
- // return getProvider(sign) === 'awss3'
46
- // }
47
-
48
- // const isHuawei = (sign: StorageType = 'storage') => {
49
- // return getProvider(sign) === 'huawei'
50
- // }
51
-
52
- // export default {
53
- // set,
54
- // get,
55
- // isAliyun,
56
- // isAzure,
57
- // isAwss3,
58
- // isHuawei
59
- // }
60
-
61
3
  class CloudServ {
62
4
  CLOUD_SERVE_KEY = 'cloudserv'
63
5
 
@@ -3,11 +3,12 @@ import renderTemplate from './template'
3
3
  import { Step } from './step'
4
4
  import { cloneDeep, merge } from 'lodash-es'
5
5
  import { fixFileName, dealFileSize, dealResultMessage } from './util'
6
- import { apaasAxios } from '../../axios'
6
+ import { axios } from '../../axios'
7
7
  import core, { Module } from '../../core'
8
8
  import login from '../../login'
9
9
  import { downloadService } from '../../oss'
10
10
  import { apaasSpuTrackSendLog } from '../../apaasSpuTrack'
11
+ import { isWxworkSuiteTenant } from '@smart100/wxworksuite-plugin'
11
12
 
12
13
  export default class SpuExpandexp extends HTMLElement {
13
14
 
@@ -67,9 +68,10 @@ export default class SpuExpandexp extends HTMLElement {
67
68
  fileName: '',
68
69
  fileSize: '',
69
70
  runningTaskCount: 0,
70
- isOldVersionService: false
71
+ isOldVersionService: false,
72
+ isWxworkSuiteTenant: isWxworkSuiteTenant()
71
73
  }, (key: string, value: any) => {
72
- const { exportConfigInit, stepName, stepText, exportcontentArray, exportcontent, isOldVersionService, runningTaskCount, fileName, filetype, fileSize, exportDataItem, percentage, resultMessage } = this.data
74
+ const { exportConfigInit, stepName, stepText, exportcontentArray, exportcontent, isOldVersionService, runningTaskCount, fileName, filetype, fileSize, exportDataItem, percentage, resultMessage, isWxworkSuiteTenant } = this.data
73
75
 
74
76
  // debugger
75
77
  const $exportSel = this.shadow.querySelector('.export-sel') as any
@@ -89,6 +91,12 @@ export default class SpuExpandexp extends HTMLElement {
89
91
  const $filesize = this.shadow.querySelector('.export-file-l-filesize') as any
90
92
  const $wait = this.shadow.querySelector('.export-wait') as any
91
93
  const $waitSpan = this.shadow.querySelector('.export-wait span') as any
94
+ const $exportWxworkTip = this.shadow.querySelector('.export-wxwork-tip') as any
95
+
96
+
97
+ if (key === 'isWxworkSuiteTenant') {
98
+ this.vIf($exportWxworkTip, isWxworkSuiteTenant)
99
+ }
92
100
 
93
101
  if (key === 'exportConfigInit') {
94
102
  this.vIf($exportSelCon, exportConfigInit)
@@ -324,8 +332,6 @@ export default class SpuExpandexp extends HTMLElement {
324
332
  this.handleCencel()
325
333
  })
326
334
 
327
-
328
-
329
335
  this.shadow.querySelector('.export-btn')!.addEventListener('click', () => {
330
336
  // console.log('导出')
331
337
  this.handleExport()
@@ -379,7 +385,7 @@ export default class SpuExpandexp extends HTMLElement {
379
385
  event: 'exportopenmodal'
380
386
  })
381
387
  } else {
382
- apaasAxios
388
+ axios
383
389
  .post('/api/expandexp/global/searchExpGloConfig', {
384
390
  key: 'export-config-switch',
385
391
  tenantcode: login.getUser('tenantcode'),
@@ -416,7 +422,7 @@ export default class SpuExpandexp extends HTMLElement {
416
422
  this.data.iscompress = '1'
417
423
 
418
424
  // 获取文件水印开关
419
- apaasAxios
425
+ axios
420
426
  .post('/api/expandexp/global/searchWatermarkConfig', '', {
421
427
  isShowLoading: false
422
428
  })
@@ -486,7 +492,7 @@ export default class SpuExpandexp extends HTMLElement {
486
492
  }
487
493
  }
488
494
  const finallyPost = mergedata ? merge(mergedata, post) : post
489
- apaasAxios
495
+ axios
490
496
  .post(this.props.exportapi, finallyPost)
491
497
  .then((res: any) => {
492
498
  // console.log(res)
@@ -606,7 +612,7 @@ export default class SpuExpandexp extends HTMLElement {
606
612
  // console.log(this.data)
607
613
  // console.log(this.data.exportDataItem)
608
614
 
609
- apaasAxios
615
+ axios
610
616
  .post('/api/teapi/queue/impexp/cancel', {
611
617
  dynamicid: this.data.exportId
612
618
  })
@@ -653,7 +659,7 @@ export default class SpuExpandexp extends HTMLElement {
653
659
  }
654
660
 
655
661
  async updateStatus () {
656
- apaasAxios
662
+ axios
657
663
  .post(`/api/teapi/queue/impexp/expStatus?dynamicid=${this.data.exportId}`, {}, {
658
664
  isShowLoading: false
659
665
  })
@@ -173,6 +173,11 @@ export default (ele: SpuExpandexp) => {
173
173
  height: 32px;
174
174
  }
175
175
 
176
+ .export-wxwork-tip {
177
+ margin-bottom: 12px;
178
+ font-size: 14px;
179
+ }
180
+
176
181
  .export-sel {
177
182
  margin-bottom: 12px;
178
183
  }
@@ -420,6 +425,8 @@ export default (ele: SpuExpandexp) => {
420
425
  导出等待队列中:还有<span></span>位,请耐心稍等...
421
426
  </div>
422
427
 
428
+ <div class="export-wxwork-tip hide">提醒:导出前请联系管理员确认已在人员管理模块进行了同步企微端人员和组织名称的操作,否则导出字段将会显示异常!</div>
429
+
423
430
  <div class="export-sel hide">
424
431
  <div class="export-sel-title">请选择导出内容</div>
425
432
  <div class="export-sel-con hide"></div>
package/src/core.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { globalOptions } from './install'
2
2
  import { get, cloneDeep } from 'lodash-es'
3
- import { apaasAxios as axios } from './axios'
3
+ import { axios } from './axios'
4
4
  import login from './login'
5
5
 
6
6
  const urlIsIp = (url) => {
@@ -462,7 +462,7 @@ const Module = {
462
462
  // linkToPage: core.linkToPage.bind(core),
463
463
  // linkToModule: core.linkToModule.bind(core),
464
464
  getModuleData: core.getModuleData.bind(core),
465
- getContext: core.getContext.bind(core),
465
+ // getContext: core.getContext.bind(core),
466
466
  getEnvData: core.getEnvData.bind(core),
467
467
  apiRequest: core.apiRequest.bind(core),
468
468
  checkModule: core.checkModule.bind(core)
package/src/index.ts CHANGED
@@ -2,7 +2,7 @@ import { version } from '../package.json'
2
2
  import { install } from './install'
3
3
  import { lsProxy, ssProxy } from './storageProxy'
4
4
  import { getLocation, getDistance } from './location'
5
- import { spuAxios, apaasAxios } from './axios'
5
+ import { spuAxios, axios } from './axios'
6
6
  import { spuConfig } from './spuConfig'
7
7
  import { downloadService, uploadService } from './oss'
8
8
  import { getUniqueid, functionCheck } from './utils'
@@ -12,8 +12,7 @@ import { v4 as getUuid } from 'uuid'
12
12
  import { Module } from './core'
13
13
  import components from './components'
14
14
  import { expandexp } from './components/expandexp'
15
- import { jssdk } from '@smart100/wxworksuite-plugin'
16
-
15
+ import { jssdk, isWxworkSuiteTenant, isWxwork, isWxworkPc, isWxworkApp } from '@smart100/wxworksuite-plugin'
17
16
 
18
17
  // class SPUWebPlugin {
19
18
  // static install = install
@@ -34,7 +33,10 @@ const getUser = login.getUser.bind(login)
34
33
  const checkLogin = login.checkLogin.bind(login)
35
34
  const wxworkSuite = {
36
35
  JSSDK: jssdk,
37
- isWxworkSuiteTenant: jssdk.checkData
36
+ isWxworkSuiteTenant,
37
+ isWxwork,
38
+ isWxworkPc,
39
+ isWxworkApp
38
40
  }
39
41
 
40
42
  export {
@@ -44,7 +46,8 @@ export {
44
46
  getLocation,
45
47
  getDistance,
46
48
  spuAxios,
47
- apaasAxios,
49
+ axios,
50
+ axios as apaasAxios,
48
51
  spuConfig,
49
52
  downloadService,
50
53
  uploadService,
package/src/install.ts CHANGED
@@ -12,6 +12,7 @@ const globalOptions: SPUWebPluginOptions = {
12
12
  modulekey: 'demospu',
13
13
  modulename: 'demospu',
14
14
  moduleversion: 'v1.0',
15
+ storageproxyprefix: '',
15
16
  router: null
16
17
  }
17
18
 
package/src/login.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { cloneDeep } from 'lodash-es'
2
2
  import jwtDecode from 'jwt-decode'
3
- import { apaasAxios } from './axios'
3
+ import { axios } from './axios'
4
4
  import tenantInfo from './tenantInfo'
5
5
  import { lsProxy } from './storageProxy'
6
6
  // import { functionCheck } from './utils'
@@ -99,7 +99,7 @@ class Login {
99
99
  }
100
100
 
101
101
  private updateToken () {
102
- return apaasAxios.get('/api/auth/refreshtoken', {
102
+ return axios.get('/api/auth/refreshtoken', {
103
103
  params: {
104
104
  refreshtoken: this.getRefreshToken()
105
105
  },
@@ -211,7 +211,7 @@ class Login {
211
211
 
212
212
  // 接口请求回来的 userInfo 有 functioncodes 以便做权限校验
213
213
  async getAndSetUserInfo () {
214
- // return apaasAxios.post('/api/teapi/rolepermission/account/getaccountinfo', {
214
+ // return axios.post('/api/teapi/rolepermission/account/getaccountinfo', {
215
215
  // positionid: this.getUser('positioncode'),
216
216
  // deviceinfo: '',
217
217
  // sysversion: '',
@@ -228,7 +228,7 @@ class Login {
228
228
  // })
229
229
 
230
230
  try {
231
- const accountinfo: null | any = await apaasAxios.post('/api/teapi/rolepermission/account/getaccountinfo', {
231
+ const accountinfo: null | any = await axios.post('/api/teapi/rolepermission/account/getaccountinfo', {
232
232
  positionid: this.getUser('positioncode'),
233
233
  deviceinfo: '',
234
234
  sysversion: '',
@@ -8,7 +8,7 @@ import ObsClient from '../package/huaweicloud-obs/esdk-obs-browserjs.3.22.3.min.
8
8
  // const ObsClient = require('../package/huaweicloud-obs/esdk-obs-browserjs.3.22.3.min.js')
9
9
  import dayjs from 'dayjs'
10
10
  import login from '../login'
11
- import { apaasAxios } from '../axios'
11
+ import { axios } from '../axios'
12
12
  // import { get } from 'lodash-es'
13
13
  // import qs from 'qs'
14
14
 
@@ -245,7 +245,7 @@ const downloadFile = async ({
245
245
  filename: realFilename,
246
246
  cope
247
247
  })
248
- // apaasAxios.get(url, {
248
+ // axios.get(url, {
249
249
  // responseType: 'blob',
250
250
  // isSendToken: false,
251
251
  // isShowErrorMessage: false
@@ -263,7 +263,7 @@ const downloadFile = async ({
263
263
  if (isAliYun) {
264
264
  downloadFileByUrl(url, filename)
265
265
  } else {
266
- apaasAxios.get(url, {
266
+ axios.get(url, {
267
267
  responseType: 'blob',
268
268
  isSendToken: false,
269
269
  isShowErrorMessage: false
@@ -1,5 +1,5 @@
1
1
  // import { noBaseRequest } from '@/service/http'
2
- import { apaasAxios } from '../axios'
2
+ import { axios } from '../axios'
3
3
 
4
4
  export type ServToken = {
5
5
  accesskeyid: string
@@ -21,7 +21,7 @@ let xhr: Promise<ServToken> | null = null
21
21
 
22
22
  const getServToken = async () => {
23
23
  try {
24
- const response: ServToken = await apaasAxios.get('/api/teapi/auth/servtoken', {}).then((res: any) => res.data)
24
+ const response: ServToken = await axios.get('/api/teapi/auth/servtoken', {}).then((res: any) => res.data)
25
25
  // debugger
26
26
  return response
27
27
  } catch (e) {
@@ -39,7 +39,7 @@ const lsProxy: StorageProxy = new StorageProxy('local')
39
39
  const ssProxy: StorageProxy = new StorageProxy('session')
40
40
 
41
41
  function initStorageProxy (options: SPUWebPluginOptions) {
42
- STORAGENAMESPACE = options.modulekey
42
+ STORAGENAMESPACE = options.storageproxyprefix || options.modulekey
43
43
  }
44
44
 
45
45
  export {
package/src/tenantInfo.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { apaasAxios } from './axios'
1
+ import { axios } from './axios'
2
2
  import cloudServ from './cloudServ'
3
3
  import { lsProxy } from './storageProxy'
4
4
 
5
5
  class TenantInfo {
6
6
  async get (tenantCode?: string) {
7
7
  try {
8
- const tenants: null | ITenantInfo[] = await apaasAxios.get('/api/auth/tenantlist', {}).then((res: any) => {
8
+ const tenants: null | ITenantInfo[] = await axios.get('/api/auth/tenantlist', {}).then((res: any) => {
9
9
  // debugger
10
10
  return res?.data?.tenants
11
11
  })
@@ -6,6 +6,7 @@ interface SPUWebPluginOptions {
6
6
  modulekey: string;
7
7
  modulename: string;
8
8
  moduleversion: string;
9
+ storageproxyprefix?: string
9
10
  router?: any;
10
11
  }
11
12
 
package/src/utils.ts CHANGED
@@ -5,21 +5,6 @@ const isIOS = () => {
5
5
  return /(iPhone|iPad|iPod|IOS)/i.test(ua)
6
6
  }
7
7
 
8
- // 是否企微软件内 包括电脑端和APP端
9
- const isInWxwork = () => {
10
- return navigator.userAgent.indexOf('wxwork') >= 0
11
- }
12
-
13
- // 是否在电脑端企微软件内
14
- const isInPcWxwork = () => {
15
- return isInWxwork() && navigator.userAgent.indexOf('Mobile') === -1
16
- }
17
-
18
- // 是否在企微APP内
19
- const isInAppWxwork = () => {
20
- return isInWxwork() && navigator.userAgent.indexOf('Mobile') >= 0
21
- }
22
-
23
8
  // 生成唯一id
24
9
  const getUniqueid = () => {
25
10
  const random = Math.ceil(Math.random() * 100000)
@@ -40,9 +25,6 @@ const functionCheck = (functioncode?: string): boolean => {
40
25
 
41
26
  export {
42
27
  isIOS,
43
- isInWxwork,
44
- isInPcWxwork,
45
- isInAppWxwork,
46
28
  getUniqueid,
47
29
  functionCheck
48
30
  }