agilebuilder-ui 1.0.69 → 1.0.71

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.
@@ -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
  )