agilebuilder-ui 1.0.2 → 1.0.5

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": "agilebuilder-ui",
3
- "version": "1.0.2",
3
+ "version": "1.0.5",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./lib/super-ui.js",
package/src/permission.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import NProgress from 'nprogress' // Progress 进度条
2
2
  import 'nprogress/nprogress.css' // Progress 进度条样式
3
- import { getToken, setToken } from './utils/auth' // 验权
3
+ import { getToken, setToken, isDevpSystem } from './utils/auth' // 验权
4
4
  import store from './store'
5
5
  import router, { errorRouterMap } from './router'
6
6
  NProgress.configure({ showSpinner: false }) // NProgress Configuration
@@ -46,22 +46,23 @@ router.beforeEach((to, from, next) => {
46
46
  // console.log('router.beforeEach-to.path=', to.path)
47
47
  console.log('router.beforeEach-to.query=', to.query)
48
48
  if (to.query && to.query[devpJWTKey]) {
49
+ // 表示开发平台点击了运行平台的菜单传过来的JWT,该JWT需要作为后续的权限验证凭证
49
50
  console.log('router.beforeEach-to.query[_devpJWT])=', to.query[devpJWTKey])
50
51
  // setToken(to.query[devpJWTKey])
51
52
  authApi.setSessionCache(runDevpJWTKey, to.query[devpJWTKey])
52
53
  }
53
54
  if (to.query && to.query[currentRoleKey]) {
55
+ // 表示开发平台中设计项目时传过来的岗位编码“开发者”、“观察者”
54
56
  console.log('router.beforeEach-to.query[_CURRENT_ROLE])=', to.query[currentRoleKey])
55
57
  authApi.setSessionCache(runCurrentRoleKey, to.query[currentRoleKey])
56
58
  }
57
59
  let token
58
60
  // 是否是开发环境功能
59
- let isDevp = false
61
+ let isDevp = isDevpSystem()
60
62
  if(authApi.getSessionCache(runDevpJWTKey)) {
61
63
  // setToken(authApi.getSessionCache(runDevpJWTKey))
62
64
  token = authApi.getSessionCache(runDevpJWTKey)
63
65
  console.log('router.beforeEach-authApi.getSessionCache(_runDevpJWT)=', authApi.getSessionCache(runDevpJWTKey))
64
- isDevp = true
65
66
  }
66
67
  if(!token) {
67
68
  token = getToken()
@@ -141,19 +142,22 @@ router.beforeEach((to, from, next) => {
141
142
  })
142
143
  }).then((user)=>{
143
144
  console.log('router.beforeEach-getCurrentUser')
144
- const devpRoleCodes = authApi.getSessionCache(runCurrentRoleKey)
145
- if(isDevp && devpRoleCodes){
146
- // 表示是开发环境JWT
145
+ const devpRoleCodes = authApi.getSessionCache(runCurrentRoleKey)
146
+ if(!isDevp && devpRoleCodes){
147
+ // 表示是开发环境设计时生成的运行平台的JWT,且缓存了项目权限编码,对应运行平台的岗位编码
148
+ console.log('开发环境设计时生成的运行平台的JWT,且缓存了项目权限编码时,!isDevp && devpRoleCodes')
147
149
  return store.dispatch(
148
- 'getDevPlatformPermissions',
149
- devpRoleCodes
150
+ 'getDevPlatformPermissions',
151
+ devpRoleCodes
150
152
  )
151
- } else {
152
- return store.dispatch(
153
- 'getCurrentUserPermissions',
154
- user.loginName
155
- )
156
- }
153
+ } else {
154
+ // 开发平台本身的功能或直接平台功能时
155
+ console.log('开发平台本身的功能或直接平台功能时')
156
+ return store.dispatch(
157
+ 'getCurrentUserPermissions',
158
+ user.loginName
159
+ )
160
+ }
157
161
  })
158
162
  .then((permissions) => {
159
163
  return store.dispatch('generateRoutes', permissions)
@@ -9,16 +9,35 @@ const langKey = 'CURRENT_LANGUAGE'
9
9
  const allLangKey = 'AMB_LANG_INFO'
10
10
  const versionEnv = 'VERSION_ENVIRONMENT'
11
11
  const userVersion = 'CURRENT_USER_SYSTEM_VERSION'
12
+ const runDevpJwtKey = '_runDevpJWT'
12
13
 
13
14
  function getToken() {
14
- let runDevpJWTKey = '_runDevpJWT'
15
- let token = getSessionCache(runDevpJWTKey)
16
- if(!token) {
17
- // 开发平台iframe访问运行平台token不存在,则表示是正常访问系统
15
+ // 是否是开发平台功能
16
+ let isDevp = isDevpSystem()
17
+ let token
18
+ if(isDevp) {
19
+ // 表示是开发平台功能,从JWT参数中获得token
18
20
  token = getMyToken()
21
+ } else {
22
+ // 表示是运行平台,先从runJwt参数获得,如果没有再从JWT参数获得
23
+ token = getSessionCache(runDevpJwtKey)
24
+ if(!token) {
25
+ // 开发平台iframe访问运行平台token不存在,则表示是正常访问系统
26
+ token = getMyToken()
27
+ }
19
28
  }
20
29
  return token
21
30
  }
31
+ // 是否是开发平台
32
+ function isDevpSystem() {
33
+ // 是否是开发平台
34
+ let isDevp = false
35
+ const systemCode = window.$vueApp.config.globalProperties.systemCode
36
+ if(systemCode && systemCode === 'devp') {
37
+ isDevp = true
38
+ }
39
+ return isDevp
40
+ }
22
41
 
23
42
  function getMyToken() {
24
43
  let token = getCookieCache(jwtKey)
@@ -43,13 +62,7 @@ function removeToken() {
43
62
  }
44
63
 
45
64
  function getUsername() {
46
- let runDevpJWTKey = '_runDevpJWT'
47
- let token = getSessionCache(runDevpJWTKey)
48
- let myCurrentUserNameKey = currentUserNameKey
49
- if(token) {
50
- // 表示是开发平台iframe访问时
51
- myCurrentUserNameKey = '_run_' + myCurrentUserNameKey
52
- }
65
+ let myCurrentUserNameKey = getRunInfoKey(currentUserNameKey)
53
66
  let username = getCookieCache(myCurrentUserNameKey)
54
67
  if (!username) {
55
68
  username = getSessionCache(myCurrentUserNameKey)
@@ -58,13 +71,7 @@ function getUsername() {
58
71
  }
59
72
 
60
73
  function setUsername(username) {
61
- let runDevpJWTKey = '_runDevpJWT'
62
- let token = getSessionCache(runDevpJWTKey)
63
- let myCurrentUserNameKey = currentUserNameKey
64
- if(token) {
65
- // 表示是开发平台iframe访问时
66
- myCurrentUserNameKey = '_run_' + myCurrentUserNameKey
67
- }
74
+ let myCurrentUserNameKey = getRunInfoKey(currentUserNameKey)
68
75
  setSessionCache(myCurrentUserNameKey, username)
69
76
  setCookieCache(myCurrentUserNameKey, username)
70
77
  }
@@ -75,13 +82,7 @@ function removeUsername() {
75
82
  }
76
83
 
77
84
  function getCurrentUser() {
78
- let runDevpJWTKey = '_runDevpJWT'
79
- let token = getSessionCache(runDevpJWTKey)
80
- let myCurrentUserInfoKey = currentUserInfoKey
81
- if(token) {
82
- // 表示是开发平台iframe访问时
83
- myCurrentUserInfoKey = '_run_' + myCurrentUserInfoKey
84
- }
85
+ const myCurrentUserInfoKey = getRunInfoKey(currentUserInfoKey)
85
86
  return getCurrentUserByKey(myCurrentUserInfoKey)
86
87
  }
87
88
 
@@ -96,13 +97,7 @@ function getCurrentUserByKey(key) {
96
97
  }
97
98
 
98
99
  function setCurrentUser(userInfo) {
99
- let runDevpJWTKey = '_runDevpJWT'
100
- let token = getSessionCache(runDevpJWTKey)
101
- let myCurrentUserInfoKey = currentUserInfoKey
102
- if(token) {
103
- // 表示是开发平台iframe访问时
104
- myCurrentUserInfoKey = '_run_' + myCurrentUserInfoKey
105
- }
100
+ const myCurrentUserInfoKey = getRunInfoKey(currentUserInfoKey)
106
101
  if (userInfo) {
107
102
  if (userInfo.password) {
108
103
  userInfo.password = null
@@ -112,6 +107,24 @@ function setCurrentUser(userInfo) {
112
107
  setCookieCache(myCurrentUserInfoKey, userinfoStr)
113
108
  }
114
109
  }
110
+ /**
111
+ * 获得缓存的key。判断运行平台还是开发平台
112
+ * @param {} orgKey
113
+ * @returns
114
+ */
115
+ function getRunInfoKey(orgKey) {
116
+ let newKey = orgKey
117
+ let isDevp = isDevpSystem()
118
+ if(!isDevp) {
119
+ // 表示不是开发平台功能时,运行平台或直接访问平台功能时
120
+ let token = getSessionCache(runDevpJwtKey)
121
+ if(token) {
122
+ // 表示是开发平台iframe访问时
123
+ newKey = '_run_' + newKey
124
+ }
125
+ }
126
+ return newKey
127
+ }
115
128
 
116
129
  function removeCurrentUser() {
117
130
  removeSessionCache(currentUserInfoKey)
@@ -255,5 +268,7 @@ export default {
255
268
  getAllLanguages,
256
269
  setAllLanguages,
257
270
  removeAllLanguages,
258
- removePublishControl
271
+ removePublishControl,
272
+ isDevpSystem,
273
+ getRunInfoKey
259
274
  }
package/src/utils/auth.js CHANGED
@@ -95,4 +95,12 @@ export function removeDevpPermissions() {
95
95
  let currentRoleKey = '_CURRENT_ROLE'
96
96
  authApi.removeSessionCache(devpJWTKey)
97
97
  authApi.removeSessionCache(currentRoleKey)
98
+ }
99
+
100
+ export function isDevpSystem() {
101
+ return authApi.isDevpSystem()
102
+ }
103
+
104
+ export function getRunInfoKey() {
105
+ return authApi.getRunInfoKey()
98
106
  }
@@ -1,5 +1,5 @@
1
1
  import * as Vue from 'vue'
2
- import {getSessionCache} from './auth'
2
+ import {getSessionCache, getRunInfoKey} from './auth'
3
3
 
4
4
  const permissionKey = 'PERMISSION-'
5
5
  const permissionMenuKey = 'PERMISSION_MENU-'
@@ -63,14 +63,8 @@ export function removePermissions() {
63
63
  export function getMenus(systemCode) {
64
64
  if (!systemCode) {
65
65
  systemCode = getSystemCode()
66
- }
67
- let myPermissionMenuKey = permissionMenuKey
68
- let runDevpJWTKey = '_runDevpJWT'
69
- let token = getSessionCache(runDevpJWTKey)
70
- if(!token) {
71
- // 开发平台iframe访问运行平台token不存在,则表示是正常访问系统
72
- myPermissionMenuKey = '_run_' + myPermissionMenuKey
73
- }
66
+ }
67
+ const myPermissionMenuKey = getRunInfoKey(permissionMenuKey)
74
68
  const permissions = window.sessionStorage.getItem(
75
69
  myPermissionMenuKey + systemCode
76
70
  )
@@ -85,13 +79,7 @@ export function setMenus(menus, systemCode) {
85
79
  if (!systemCode) {
86
80
  systemCode = getSystemCode()
87
81
  }
88
- let myPermissionMenuKey = permissionMenuKey
89
- let runDevpJWTKey = '_runDevpJWT'
90
- let token = getSessionCache(runDevpJWTKey)
91
- if(!token) {
92
- // 开发平台iframe访问运行平台token不存在,则表示是正常访问系统
93
- myPermissionMenuKey = '_run_' + myPermissionMenuKey
94
- }
82
+ const myPermissionMenuKey = getRunInfoKey(permissionMenuKey)
95
83
  window.sessionStorage.setItem(
96
84
  myPermissionMenuKey + systemCode,
97
85
  JSON.stringify(menus)
@@ -104,13 +92,7 @@ export function removeMenus(systemCode) {
104
92
  if (!systemCode) {
105
93
  systemCode = getSystemCode()
106
94
  }
107
- let myPermissionMenuKey = permissionMenuKey
108
- let runDevpJWTKey = '_runDevpJWT'
109
- let token = getSessionCache(runDevpJWTKey)
110
- if(!token) {
111
- // 开发平台iframe访问运行平台token不存在,则表示是正常访问系统
112
- myPermissionMenuKey = '_run_' + myPermissionMenuKey
113
- }
95
+ const myPermissionMenuKey = getRunInfoKey(permissionMenuKey)
114
96
  window.sessionStorage.removeItem(myPermissionMenuKey + systemCode)
115
97
  for (var i = 0; i < window.sessionStorage.length; i++) {
116
98
  var key = window.sessionStorage.key(i)
@@ -25,12 +25,7 @@ service.interceptors.request.use(
25
25
  store.commit('togglePreventReclick', true)
26
26
  const timeZone = getTimeZone()
27
27
  config.headers['timeZone'] = timeZone
28
- let runDevpJWTKey = '_runDevpJWT'
29
- let token = authApi.getSessionCache(runDevpJWTKey)
30
- if(!token) {
31
- // 开发平台iframe访问运行平台token不存在,则表示是正常访问系统
32
- token = getToken()
33
- }
28
+ const token = getToken()
34
29
  if (token) {
35
30
  config.headers['Authorization'] = token // 让每个请求携带自定义token 请根据实际情况自行修改
36
31
  }
@@ -170,6 +165,7 @@ export const apiUrlMappings = {}
170
165
  * @param {*} options 是一个对象,包括data和param两个子对象属性,形如{param:{},data:{}}
171
166
  */
172
167
  export function request(code, options) {
168
+ let requestParam
173
169
  const config = {}
174
170
  if (options) {
175
171
  if (options.data) {
@@ -193,6 +189,9 @@ export function request(code, options) {
193
189
  if (options.url) {
194
190
  config.url = options.url
195
191
  }
192
+ if (options.requestParam) {
193
+ requestParam = options.requestParam
194
+ }
196
195
  }
197
196
  if (code) {
198
197
  if (!checkPermission(code)) {
@@ -226,6 +225,16 @@ export function request(code, options) {
226
225
  showClose: true,
227
226
  })
228
227
  }
228
+ if(requestParam) {
229
+ for(let key in requestParam) {
230
+ if (config.url.indexOf('?') > 0) {
231
+ // 表示有参数
232
+ config.url = config.url + '&' + key + '=' + requestParam[key]
233
+ } else {
234
+ config.url = config.url + '?' + key + '=' + requestParam[key]
235
+ }
236
+ }
237
+ }
229
238
  if (config.method && config.method.toLowerCase() === 'get') {
230
239
  if (config.url.indexOf('?') > 0) {
231
240
  // 表示有参数
@@ -68,6 +68,11 @@ export default {
68
68
  type: String,
69
69
  default: "",
70
70
  },
71
+ // 是否是开发平台使用
72
+ isDevp:{
73
+ type: Boolean,
74
+ default:false
75
+ }
71
76
  },
72
77
  data() {
73
78
  let frontendUrlKey = '_PLAT_FORM_FRONTEND_URL'
@@ -110,19 +115,17 @@ export default {
110
115
  return false;
111
116
  },
112
117
  toPath(menu) {
113
- this.platFrontUrl= authApi.getSessionCache(this.frontendUrlKey)
114
- this.platBackendUrl= authApi.getSessionCache(this.backendUrlKey)
115
- this.devpJWT= authApi.getSessionCache(this.devpJWTKey)
116
- this.currentRole= authApi.getSessionCache(this.currentRoleKey)
117
- this.runDevpJWT= authApi.getSessionCache(this.runDevpJWTKey)
118
+ if(this.isDevp) {
119
+ // 开发平台中访问运行平台的菜单需要的参数
120
+ this.platFrontUrl= authApi.getSessionCache(this.frontendUrlKey)
121
+ this.platBackendUrl= authApi.getSessionCache(this.backendUrlKey)
122
+ this.devpJWT= authApi.getSessionCache(this.devpJWTKey)
123
+ this.currentRole= authApi.getSessionCache(this.currentRoleKey)
124
+ this.runDevpJWT= authApi.getSessionCache(this.runDevpJWTKey)
125
+ }
118
126
  const toPathObj = {};
119
127
  let routePath
120
128
  toPathObj.openWay = menu.openWay;
121
- let isDevp = false
122
- if (this.devpJWT) {
123
- // 开发平台中访问运行平台的菜单需要的参数
124
- isDevp = true
125
- }
126
129
  if (this.isExternalLink(menu.pageType)) {
127
130
  routePath = menu.path
128
131
  if(!routePath) {
@@ -143,7 +146,7 @@ export default {
143
146
  }
144
147
  routePath = this.getRoutePath(routePath)
145
148
  toPathObj.path = "/tab-content-index"
146
- if(isDevp){
149
+ if(this.isDevp){
147
150
  // 如果是开发平台,进入开发平台设置首页
148
151
  toPathObj.path = "/devp-project/setting"
149
152
  }
@@ -167,7 +170,7 @@ export default {
167
170
  }
168
171
  routePath = routePath + '_isNeedMenu_=false'
169
172
  toPathObj.path = "/tab-content-index";
170
- if(isDevp){
173
+ if(this.isDevp){
171
174
  // 如果是开发平台,进入开发平台设置首页
172
175
  toPathObj.path = "/devp-project/setting"
173
176
  }
@@ -53,6 +53,11 @@ export default {
53
53
  type: Boolean,
54
54
  default: false,
55
55
  },
56
+ // 是否是开发平台使用
57
+ isDevp:{
58
+ type: Boolean,
59
+ default:false
60
+ }
56
61
  },
57
62
  data() {
58
63
  let systemName
@@ -31,6 +31,13 @@ export default {
31
31
  Breadcrumb,
32
32
  TabContent,
33
33
  },
34
+ props:{
35
+ // 是否是开发平台使用
36
+ isDevp:{
37
+ type: Boolean,
38
+ default:false
39
+ }
40
+ },
34
41
  mixins: [ResizeMixin],
35
42
  data() {
36
43
  // 是否显示菜单路径,默认是不显示