agilebuilder-ui 1.0.69 → 1.0.71-tmp1

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.
@@ -2,6 +2,8 @@ import * as Vue from 'vue'
2
2
  import authApi from './auth-api'
3
3
  import { getToken, getLanguage, getAllLanguages, setAllLanguages } from './auth'
4
4
  import { v4 as uuidv4 } from 'uuid'
5
+ import { getCookieCache } from './auth'
6
+ import LoadScript from 'vue-plugin-load-script'
5
7
  /**
6
8
  * 获得相对地址
7
9
  */
@@ -22,9 +24,7 @@ export function getRelativeBaseUrl(originalBaseUrl) {
22
24
  if (baseUrls.length >= 3) {
23
25
  const baseUrlPrefix = baseUrls[0] + '//' + baseUrls[2]
24
26
  // console.log('getRelativeBaseUrl---baseUrlPrefix=',baseUrlPrefix)
25
- baseUrlSuffix = originalBaseUrl.substring(
26
- originalBaseUrl.indexOf(baseUrlPrefix) + baseUrlPrefix.length
27
- )
27
+ baseUrlSuffix = originalBaseUrl.substring(originalBaseUrl.indexOf(baseUrlPrefix) + baseUrlPrefix.length)
28
28
  // console.log('getRelativeBaseUrl---baseUrlSuffix=',baseUrlSuffix)
29
29
  }
30
30
  if (relativeUrl.lastIndexOf('/') === relativeUrl.length - 1) {
@@ -83,19 +83,14 @@ export function replacePrefix(originalUrl) {
83
83
  // console.log('replacePrefix---locationPrefixUrl=',locationPrefixUrl)
84
84
  if (orginalPrefixUrl !== locationPrefixUrl) {
85
85
  // 获得/demo/#/notice/task需要替换为http://127.0.0.1/demo/#/notice/task
86
- let suffixUrl = originalUrl.substring(
87
- originalUrl.indexOf(orginalPrefixUrl) + orginalPrefixUrl.length
88
- )
86
+ let suffixUrl = originalUrl.substring(originalUrl.indexOf(orginalPrefixUrl) + orginalPrefixUrl.length)
89
87
  if (suffixUrl.indexOf('/') !== 0) {
90
88
  suffixUrl = '/' + suffixUrl
91
89
  }
92
90
  // console.log('replacePrefix---suffixUrl=',suffixUrl)
93
91
  if (locationPrefixUrl.lastIndexOf('/') === locationPrefixUrl.length - 1) {
94
92
  // 表示以“/”结尾,去掉最后一个“/”
95
- locationPrefixUrl = locationPrefixUrl.substring(
96
- 0,
97
- locationPrefixUrl.lastIndexOf('/')
98
- )
93
+ locationPrefixUrl = locationPrefixUrl.substring(0, locationPrefixUrl.lastIndexOf('/'))
99
94
  }
100
95
  // console.log('replacePrefix---locationPrefixUrl2=',locationPrefixUrl)
101
96
  newUrl = locationPrefixUrl + suffixUrl
@@ -132,12 +127,7 @@ export function getLoginUrl() {
132
127
  }
133
128
  getPortalFrontendUrl()
134
129
  .then((portalUrl) => {
135
- let loginUrl =
136
- portalUrl +
137
- '#/login?systemPath=' +
138
- systemPath +
139
- '&routerPath=' +
140
- routerPath
130
+ let loginUrl = portalUrl + '#/login?systemPath=' + systemPath + '&routerPath=' + routerPath
141
131
  if (param) {
142
132
  loginUrl += '&' + param
143
133
  }
@@ -171,8 +161,7 @@ export function isShowSystemMenu() {
171
161
  export function getSystemFrontendUrl(frontendUrl) {
172
162
  if (
173
163
  window.$vueApp.config.globalProperties.projectModel &&
174
- window.$vueApp.config.globalProperties.projectModel ===
175
- 'developing.model' &&
164
+ window.$vueApp.config.globalProperties.projectModel === 'developing.model' &&
176
165
  window.$vueApp.config.globalProperties.frontUrl
177
166
  ) {
178
167
  return window.$vueApp.config.globalProperties.frontUrl
@@ -184,8 +173,7 @@ export function getSystemFrontendUrl(frontendUrl) {
184
173
  export function getSystemBackendUrl(backendUrl) {
185
174
  if (
186
175
  window.$vueApp.config.globalProperties.projectModel &&
187
- window.$vueApp.config.globalProperties.projectModel ===
188
- 'developing.model' &&
176
+ window.$vueApp.config.globalProperties.projectModel === 'developing.model' &&
189
177
  window.$vueApp.config.globalProperties.baseURL
190
178
  ) {
191
179
  return window.$vueApp.config.globalProperties.baseURL
@@ -263,16 +251,12 @@ export function getTimeZone() {
263
251
  const dateStr = new Date() + ''
264
252
  let timeZone = ''
265
253
  if (dateStr.indexOf('GMT') > 0) {
266
- const timeZoneSuffix = dateStr
267
- .substring(dateStr.indexOf('GMT') + 3, dateStr.indexOf('('))
268
- .trim()
254
+ const timeZoneSuffix = dateStr.substring(dateStr.indexOf('GMT') + 3, dateStr.indexOf('(')).trim()
269
255
  const partPrefix = timeZoneSuffix.substring(0, timeZoneSuffix.length - 2)
270
256
  const partSuffix = timeZoneSuffix.substring(timeZoneSuffix.length - 2)
271
257
  timeZone = 'UTC' + partPrefix + ':' + partSuffix
272
258
  } else if (dateStr.indexOf('UTC') > 0) {
273
- timeZone =
274
- 'UTC' +
275
- dateStr.substring(dateStr.indexOf('UTC') + 3, dateStr.indexOf('(')).trim()
259
+ timeZone = 'UTC' + dateStr.substring(dateStr.indexOf('UTC') + 3, dateStr.indexOf('(')).trim()
276
260
  }
277
261
  return timeZone
278
262
  }
@@ -286,8 +270,7 @@ export function setCustomSystemBackendUrl(customSystem) {
286
270
  // 表示是生产环境时,需要根据数据库配置获得对应的后端地址
287
271
  const backendUrl = window.$authApi.getSystemCacheUrlByCode(customSystem)
288
272
  if (backendUrl) {
289
- window.$vueApp.config.globalProperties.baseURL =
290
- getRelativeBaseUrl(backendUrl)
273
+ window.$vueApp.config.globalProperties.baseURL = getRelativeBaseUrl(backendUrl)
291
274
  }
292
275
  }
293
276
  }
@@ -305,13 +288,13 @@ export function pushCustomControlValidatorRef(pageCode, refName, ref) {
305
288
  pageCustomControlRef.set(refName, ref)
306
289
  }
307
290
 
308
- export function removeCustomControlValidatorRef (pageCode, refName) {
309
- if (window.customValidatorRef) {
310
- const pageCustomControlRef = window.customValidatorRef.get(pageCode)
311
- if (pageCustomControlRef) {
312
- pageCustomControlRef.delete(refName)
313
- }
314
- }
291
+ export function removeCustomControlValidatorRef(pageCode, refName) {
292
+ if (window.customValidatorRef) {
293
+ const pageCustomControlRef = window.customValidatorRef.get(pageCode)
294
+ if (pageCustomControlRef) {
295
+ pageCustomControlRef.delete(refName)
296
+ }
297
+ }
315
298
  }
316
299
 
317
300
  export function isMobileBrowser() {
@@ -379,33 +362,34 @@ export function cacheAllLanguagesUtil(http) {
379
362
  setAllLanguages(cookieCacheLangs)
380
363
  resolve()
381
364
  } else {
382
- http
383
- .get(
384
- window.$vueApp.config.globalProperties.baseAPI +
385
- '/component/all-languages'
386
- )
387
- .then((langList) => {
388
- const langResult = {}
389
- if (langList) {
390
- langList.forEach((item) => {
391
- // 例如:zh_CN、en_US
392
- const lang = item.value
393
- let langShort
394
- if (lang.indexOf('_') > 0) {
395
- langShort = lang.substring(0, lang.indexOf('_'))
396
- }
397
- if (langShort && langShort === 'zh') {
398
- // 中文处理,为了兼容历史逻辑
399
- langShort = 'cn'
400
- }
401
- if (langShort) {
402
- langResult[langShort] = lang
403
- }
404
- })
405
- }
406
- cacheLangs(langResult)
407
- resolve()
408
- })
365
+ // http.get(window.$vueApp.config.globalProperties.baseAPI + '/component/all-languages').then((langList) => {
366
+ http.get(window.$vueApp.config.globalProperties.baseAPI + '/component/i18n/languages').then((langInfo) => {
367
+ debugger
368
+ const langResult = {}
369
+ const langList = langInfo.languages
370
+ if (langList) {
371
+ langList.forEach((item) => {
372
+ // 例如:zh_CN、en_US
373
+ const lang = item.value
374
+ let langShort
375
+ if (lang.indexOf('_') > 0) {
376
+ langShort = lang.substring(0, lang.indexOf('_'))
377
+ }
378
+ if (langShort && langShort === 'zh') {
379
+ // 中文处理,为了兼容历史逻辑
380
+ langShort = 'cn'
381
+ }
382
+ if (langShort) {
383
+ langResult[langShort] = lang
384
+ }
385
+ })
386
+ }
387
+ cacheLangs(langResult)
388
+ if (langInfo.i18nFileUrls && langInfo.i18nFileUrls[window.$locale]) {
389
+ LoadScript(langInfo.i18nFileUrls[window.$locale])
390
+ }
391
+ resolve()
392
+ })
409
393
  }
410
394
  } else {
411
395
  resolve()
@@ -437,8 +421,8 @@ export function windowOpenUrl(url, projectModel) {
437
421
  // _systemName_参数用于设置浏览器页签名的,国际化使用,在imatrix ui的beforeEach中有使用这个参数
438
422
  if (param) {
439
423
  jumpUrl += '&' + param
440
- }
441
- if (jumpUrl.indexOf('_systemName_=') === -1) {
424
+ }
425
+ if (jumpUrl.indexOf('_systemName_=') === -1) {
442
426
  jumpUrl += '&_systemName_=' + systemName
443
427
  }
444
428
  window.open(jumpUrl)
@@ -455,14 +439,13 @@ export function windowOpenUrl(url, projectModel) {
455
439
  }
456
440
  }
457
441
 
458
-
459
442
  // 首次加载业务系统时,缓存当前用户语言
460
443
  export function cacheCurrentLanguageUtil(http) {
461
444
  return new Promise((resolve, reject) => {
462
445
  const token = getToken()
463
446
  if (token) {
464
447
  const currentLanguage = getLanguage()
465
- if (currentLanguage && currentLanguage!=='undefined') {
448
+ if (currentLanguage && currentLanguage !== 'undefined') {
466
449
  resolve(currentLanguage)
467
450
  } else {
468
451
  http.get(window.$vueApp.config.globalProperties.baseAPI + '/acs/user-languages').then((currentLanguage) => {
@@ -476,63 +459,117 @@ export function cacheCurrentLanguageUtil(http) {
476
459
  })
477
460
  }
478
461
  export function setProjectSetting() {
479
- const projectSettingCache = Cookies.get("PROJECT_SETTINGS")
480
- let projectSettings = null
481
- if(projectSettingCache){
482
- projectSettings = JSON.parse(projectSettingCache)
483
- this.setLogoUrl(projectSettings)
484
- } else {
485
- this.$http.get(window.$vueApp.config.globalProperties.baseAPI + '/cfg/project-settings').then((data) => {
486
- Cookies.set("PROJECT_SETTINGS", JSON.stringify(data))
487
- projectSettings = data
488
- })
489
- }
490
- if (projectSettings.browserImageUuid) {
491
- const linkElement = document.getElementById('ambBrowserIcon');
492
- if (linkElement) {
493
- linkElement.href = window.$vueApp.config.globalProperties.baseAPI + '/cfg/project/icon/browserIcon'
494
- }
495
- }
462
+ const projectSettingCache = Cookies.get('PROJECT_SETTINGS')
463
+ let projectSettings = null
464
+ if (projectSettingCache) {
465
+ projectSettings = JSON.parse(projectSettingCache)
466
+ this.setLogoUrl(projectSettings)
467
+ } else {
468
+ this.$http.get(window.$vueApp.config.globalProperties.baseAPI + '/cfg/project-settings').then((data) => {
469
+ Cookies.set('PROJECT_SETTINGS', JSON.stringify(data))
470
+ projectSettings = data
471
+ })
472
+ }
473
+ if (projectSettings.browserImageUuid) {
474
+ const linkElement = document.getElementById('ambBrowserIcon')
475
+ if (linkElement) {
476
+ linkElement.href = window.$vueApp.config.globalProperties.baseAPI + '/cfg/project/icon/browserIcon'
477
+ }
478
+ }
496
479
  }
497
480
 
498
481
  // 动态加载css
499
482
  export function loadCSS() {
500
483
  var theme
501
- if(!theme){
502
- theme = localStorage.getItem('CURRENT_THEME')
503
- }
504
- if(!theme){
505
- console.error('皮肤主题为空!')
506
- return
507
- }
508
- const baseAPI = localStorage.getItem('_baseAPI_')
509
- if(baseAPI){
510
- const href = replacePrefix(baseAPI) + '/component/theme/load-theme?theme=' + theme + '&_t_=' + new Date().getTime()
511
- let isHasLink = true
512
- let cssLink = document.getElementById('_loadTheme_')
513
- if(!cssLink){
514
- cssLink = document.createElement("link")
515
- isHasLink = false
516
- }
517
- cssLink.rel = "stylesheet";
518
- cssLink.type = "text/css";
519
- cssLink.id="_loadTheme_"
520
- cssLink.href = href;
521
- if(!isHasLink){
522
- document.getElementsByTagName("head")[0].appendChild(cssLink)
523
- }
484
+ if (!theme) {
485
+ theme = localStorage.getItem('CURRENT_THEME')
486
+ }
487
+ if (!theme) {
488
+ console.error('皮肤主题为空!')
489
+ return
490
+ }
491
+ const baseAPI = localStorage.getItem('_baseAPI_')
492
+ if (baseAPI) {
493
+ const href = replacePrefix(baseAPI) + '/component/theme/load-theme?theme=' + theme + '&_t_=' + new Date().getTime()
494
+ let isHasLink = true
495
+ let cssLink = document.getElementById('_loadTheme_')
496
+ if (!cssLink) {
497
+ cssLink = document.createElement('link')
498
+ isHasLink = false
524
499
  }
525
- const body = document.querySelector('body')
526
- if(body){
527
- body.setAttribute('class', theme)
500
+ cssLink.rel = 'stylesheet'
501
+ cssLink.type = 'text/css'
502
+ cssLink.id = '_loadTheme_'
503
+ cssLink.href = href
504
+ if (!isHasLink) {
505
+ document.getElementsByTagName('head')[0].appendChild(cssLink)
528
506
  }
529
507
  }
508
+ const body = document.querySelector('body')
509
+ if (body) {
510
+ body.setAttribute('class', theme)
511
+ }
512
+ }
530
513
 
531
-
532
- /**
514
+ /**
533
515
  * 获取UUID,去掉破折号
534
516
  * @returns
535
517
  */
536
518
  export function getUuidv4() {
537
519
  return uuidv4().replace(/-/g, '')
538
- }
520
+ }
521
+
522
+ export function replacePlaceholders(template, ...args) {
523
+ return template.replace(/{(\d+)}/g, (match, index) => {
524
+ return typeof args[index] !== 'undefined' ? args[index] : match
525
+ })
526
+ }
527
+
528
+ function isOpenMobileGateway() {
529
+ // 系统参数设置中配置的是否开启移动网关,没有配置默认是开启的
530
+ let isOpenMobileGatewayCache = getCookieCache('IS_OPEN_MOBILE_GATEWAY')
531
+ if (isOpenMobileGatewayCache === undefined || isOpenMobileGatewayCache === null) {
532
+ isOpenMobileGatewayCache = 'true'
533
+ }
534
+ return isOpenMobileGatewayCache
535
+ }
536
+ /**
537
+ * 获得替换域名后的url
538
+ * @param {*} url
539
+ * @returns
540
+ */
541
+ export function getReplaceUrlDomain(url) {
542
+ const isOpenMobileGatewayCache = isOpenMobileGateway()
543
+ console.log('===getReplaceUrlDomain==isOpenMobileGatewayCache=', isOpenMobileGatewayCache)
544
+ if (isOpenMobileGatewayCache === 'true' && url !== undefined && Vue.prototype.replaceUrl) {
545
+ // 表示需要替换url中的"https://域名"
546
+ const baseApi = Vue.prototype.baseAPI
547
+ if ((url + '').indexOf(Vue.prototype.replaceUrl + '/') < 0 && (url + '').indexOf('://') > 0) {
548
+ // 表示路径还未替换
549
+ console.log('===getReplaceUrlDomain==url.indexOf(Vue.prototype.replaceUrl) !== 0')
550
+ const prefixUrl1 = baseApi.substring(0, baseApi.indexOf('://'))
551
+ const urlSuffix1 = baseApi.substring(baseApi.indexOf('://') + 3)
552
+ const domainUrl1 = urlSuffix1.substring(0, urlSuffix1.indexOf('/'))
553
+ const prefixUrlBase = prefixUrl1 + '://' + domainUrl1
554
+ const prefixUrl2 = baseApi.substring(0, baseApi.indexOf('://'))
555
+ let urlSuffix = url.substring(url.indexOf('://') + 3)
556
+ const domainUrl2 = urlSuffix.substring(0, urlSuffix.indexOf('/'))
557
+ const prefixUrl = prefixUrl2 + '://' + domainUrl2
558
+ if (prefixUrl === prefixUrlBase) {
559
+ urlSuffix = urlSuffix.substring(urlSuffix.indexOf('/'))
560
+ url = Vue.prototype.replaceUrl + urlSuffix
561
+ console.log('===getReplaceUrlDomain==url=', url)
562
+ }
563
+ } else {
564
+ console.log('===getReplaceUrlDomain==has-replace-url=', url)
565
+ }
566
+ }
567
+ return url
568
+ }
569
+
570
+ export function formatFileName(fileName) {
571
+ if (fileName) {
572
+ fileName = fileName.replace('#', '~~').replace('?', '~$').replace('&', '$')
573
+ }
574
+ return fileName
575
+ }
@@ -5,7 +5,7 @@ import {
5
5
  getEntityFieldValue,
6
6
  setEntityFieldValue,
7
7
  } from './util'
8
- import { getSystemFrontendUrl, getUuidv4 } from './common-util'
8
+ import { getSystemFrontendUrl, getUuidv4, isMobileBrowser } from './common-util'
9
9
  // 解析初始化条件,api方法;additionalParamMap是上个页面传过来的附加参数集合
10
10
  export function initialization(
11
11
  jumpPage,
@@ -365,6 +365,7 @@ function jumpToPageTwo(
365
365
  if (!jumpPageUrl) {
366
366
  return
367
367
  }
368
+ const isMobile = isMobileBrowser()
368
369
  if (jumpPageUrl.indexOf('page:') === 0) {
369
370
  // 表示是自定义系统跳转页面编码
370
371
  jumpWithSuperPage(
@@ -374,7 +375,8 @@ function jumpToPageTwo(
374
375
  jumpPageSetting,
375
376
  ids,
376
377
  buttonCode,
377
- isHasIdParam
378
+ isHasIdParam,
379
+ isMobile
378
380
  ).then((openPageParams) => {
379
381
  resolve(openPageParams)
380
382
  })
@@ -398,7 +400,8 @@ function jumpToPageTwo(
398
400
  path = frontendUrl + '/#' + path
399
401
  }
400
402
  const systemName = getSystemNameWithLanguage(system)
401
- jumpToPageWithFullPath(
403
+ // 移动端时会有返回值
404
+ const fullPath = jumpToPageWithFullPath(
402
405
  dataId,
403
406
  path,
404
407
  additionalParameterStr,
@@ -406,9 +409,14 @@ function jumpToPageTwo(
406
409
  ids,
407
410
  buttonCode,
408
411
  isHasIdParam,
409
- systemName
412
+ systemName,
413
+ isMobile
410
414
  )
411
- resolve()
415
+ if(fullPath){
416
+ // 移动端时返回的全路径
417
+ jumpPageSetting._path = fullPath
418
+ }
419
+ resolve(jumpPageSetting)
412
420
  }
413
421
  })
414
422
  }
@@ -427,7 +435,8 @@ function jumpToPageWithFullPath(
427
435
  ids,
428
436
  buttonCode,
429
437
  isHasIdParam,
430
- systemName
438
+ systemName,
439
+ isMobile
431
440
  ) {
432
441
  path = packagePathParams(
433
442
  dataId,
@@ -451,6 +460,10 @@ function jumpToPageWithFullPath(
451
460
  path += additionalParameterStr + systemNameParam
452
461
  }
453
462
  }
463
+ if(isMobile){
464
+ // 如果是移动端返回全路径即可
465
+ return path
466
+ }
454
467
  let jumpMode = 'refresh'
455
468
  if (jumpPage) {
456
469
  if (jumpPage.jumpPageOpenMode) {
@@ -574,7 +587,8 @@ function jumpWithSuperPage(
574
587
  jumpPageSetting,
575
588
  ids,
576
589
  buttonCode,
577
- isHasIdParam
590
+ isHasIdParam,
591
+ isMobile
578
592
  ) {
579
593
  return new Promise((resolve, reject) => {
580
594
  // 表示是自定义系统跳转页面编码
@@ -587,10 +601,8 @@ function jumpWithSuperPage(
587
601
  )
588
602
  const pageCode = getPageCode(jumpPageUrl)
589
603
  let jumpMode = 'refresh'
590
- if (jumpPageSetting) {
591
- if (jumpPageSetting.jumpPageOpenMode) {
604
+ if (jumpPageSetting && jumpPageSetting.jumpPageOpenMode) {
592
605
  jumpMode = jumpPageSetting.jumpPageOpenMode
593
- }
594
606
  }
595
607
  const jumpJsonData = {
596
608
  jumpMode: jumpMode,
@@ -626,6 +638,7 @@ function jumpWithSuperPage(
626
638
  popPageSetting.isRefreshWhenClosePopup = jumpPageSetting.isRefreshWhenClosePopup
627
639
  }
628
640
  popPageSetting._path = path
641
+ popPageSetting.customSystem = system.code
629
642
  resolve(popPageSetting)
630
643
  } else if (jumpMode === 'newTab') {
631
644
  // 新页签打开
@@ -642,8 +655,16 @@ function jumpWithSuperPage(
642
655
  ) +
643
656
  '&_t_=' +
644
657
  new Date().getTime()
645
- window.open(path)
646
- resolve()
658
+ const popPageSetting = {
659
+ _path: path,
660
+ pageCode: pageCode,
661
+ customSystem: system.code
662
+ }
663
+ if(!isMobile){
664
+ // 不是移动端时直接open打开pc新页签
665
+ window.open(path)
666
+ }
667
+ resolve(popPageSetting)
647
668
  } else {
648
669
  // 刷新页面
649
670
  const queryParam = {
@@ -651,7 +672,7 @@ function jumpWithSuperPage(
651
672
  customSystem: system.code,
652
673
  jumpMode: jumpMode,
653
674
  buttonCode: buttonCode,
654
- ids: ids ? ids.join(',') : '',
675
+ ids: ids ? ids.join(',') : ''
655
676
  }
656
677
  if (
657
678
  jumpPageSetting.isNeedId === undefined ||
@@ -1,11 +1,13 @@
1
1
  import * as Vue from 'vue'
2
2
  import {getSessionCache, getRunInfoKey} from './auth'
3
+ import { isMobileBrowser } from './common-util'
3
4
 
4
5
  const permissionKey = 'PERMISSION-'
5
6
  const permissionMenuKey = 'PERMISSION_MENU-'
6
7
  const _RUN_PERMISSION = '_RUN_PERMISSION'
7
8
 
8
9
  const permissionAllSystemKey = 'PERMISSION_All_SYSTSEM_KEY'
10
+ const mobilePermissionKey = 'PERMISSION-MOBILE-WEB'
9
11
  export function getSystemCode() {
10
12
  let systemCode
11
13
  if (window.$vueApp.config.globalProperties.customSystem) {
@@ -23,13 +25,27 @@ export function getSystemCode() {
23
25
  }
24
26
 
25
27
  export function getPermissions() {
28
+ let totalPermissions = null
26
29
  const systemCode = getSystemCode()
27
30
  let permissions = localStorage.getItem(permissionKey + systemCode)
28
31
  if (permissions) {
29
- permissions = JSON.parse(permissions)
30
- return permissions
32
+ if(!totalPermissions){
33
+ totalPermissions = {}
34
+ }
35
+ Object.assign(totalPermissions,JSON.parse(permissions))
31
36
  }
32
- return null
37
+
38
+ const isMobile = isMobileBrowser()
39
+ if(isMobile){
40
+ const permissions = localStorage.getItem(mobilePermissionKey)
41
+ if (permissions) {
42
+ if(!totalPermissions){
43
+ totalPermissions = {}
44
+ }
45
+ Object.assign(totalPermissions,JSON.parse(permissions))
46
+ }
47
+ }
48
+ return totalPermissions
33
49
  }
34
50
 
35
51
  export function getTotalPermissions() {
@@ -45,6 +61,15 @@ export function getTotalPermissions() {
45
61
  if (sysetemPermissions) {
46
62
  sysetemPermissionsObj = JSON.parse(sysetemPermissions)
47
63
  }
64
+
65
+ let mobilePermissionsObj
66
+ const isMobile = isMobileBrowser()
67
+ if(isMobile){
68
+ const mobilePermissions = localStorage.getItem(mobilePermissionKey)
69
+ if (mobilePermissions) {
70
+ mobilePermissionsObj = JSON.parse(mobilePermissions)
71
+ }
72
+ }
48
73
  const b = new Date().getTime()
49
74
  if(runPermissionsObj || sysetemPermissionsObj) {
50
75
  let permissions = {}
@@ -54,6 +79,9 @@ export function getTotalPermissions() {
54
79
  if(sysetemPermissionsObj){
55
80
  Object.assign(permissions, sysetemPermissionsObj)
56
81
  }
82
+ if(mobilePermissionsObj){
83
+ Object.assign(permissions, mobilePermissionsObj)
84
+ }
57
85
  // console.log('getTotalPermissions----permissions=', permissions )
58
86
  return permissions
59
87
  }
@@ -61,8 +89,21 @@ export function getTotalPermissions() {
61
89
  }
62
90
 
63
91
  export function setPermissions(permissions) {
64
- const a = new Date().getTime()
65
- const systemCode = getSystemCode()
92
+ const isMobile = isMobileBrowser()
93
+ let key
94
+ const permissionObjs = getPermissionObjs(permissions)
95
+ if(isMobile){
96
+ key = mobilePermissionKey
97
+ } else {
98
+ const systemCode = getSystemCode()
99
+ key = permissionKey + systemCode
100
+ }
101
+ localStorage.setItem(key, JSON.stringify(permissionObjs))
102
+ setPermissionAllSystemKey(key)
103
+ return permissionObjs
104
+ }
105
+
106
+ function getPermissionObjs(permissions){
66
107
  const permissionObjs = {}
67
108
  for (let i = 0; i < permissions.length; i++) {
68
109
  const functionCode = permissions[i]
@@ -71,9 +112,6 @@ export function setPermissions(permissions) {
71
112
  permissionObjs[permission] = true
72
113
  }
73
114
  }
74
- const key = permissionKey + systemCode
75
- localStorage.setItem(key, JSON.stringify(permissionObjs))
76
- setPermissionAllSystemKey(key)
77
115
  return permissionObjs
78
116
  }
79
117
 
@@ -147,6 +185,7 @@ function rtrim(str) { // 删除右边的空格
147
185
 
148
186
  // 删除缓存的资源和菜单
149
187
  export function removeAllSystemPermissions() {
188
+ localStorage.removeItem(mobilePermissionKey)
150
189
  const systemCode = getSystemCode()
151
190
  localStorage.removeItem(permissionKey + systemCode)
152
191
  const myPermissionMenuKey = getRunInfoKey(permissionMenuKey)
package/src/utils/util.js CHANGED
@@ -965,7 +965,7 @@ export function isImage(fileName) {
965
965
  // const fileType = fileName.substring(fileName.lastIndexOf('.'), fileName.length).toLowerCase()
966
966
  // const imageTypes = ['.jpg', '.JPG', '.png', '.bmp', '.BMP', '.jpeg', '.gif', '.psd', '.tif', '.tga', '.svg', '.eps']
967
967
  // const index = imageTypes.indexOf(fileType)
968
- if (
968
+ if (fileName &&
969
969
  /\.(jpg|JPG|jpeg|JPEG|png|PNG|gif|GIF|bmp|BMP|psd|PSD|tif|TIF)$/.test(
970
970
  fileName
971
971
  )