(callbackFun)
| 100 | |
| 101 | // 获取必要的数据 |
| 102 | const checkNecessaryData = (callbackFun) => { |
| 103 | const promiseList = [] |
| 104 | if (promiseList.length > 0) { |
| 105 | Promise.all(promiseList) |
| 106 | .then((res) => { |
| 107 | localStorage.removeItem('getInitDataErrorCount') |
| 108 | callbackFun && callbackFun() |
| 109 | }) |
| 110 | .catch((res) => { |
| 111 | const errorCount = localStorage.getItem( |
| 112 | 'getInitDataErrorCount' |
| 113 | ) |
| 114 | if (errorCount) { |
| 115 | let count = Number.parseInt(errorCount) |
| 116 | if (count <= 3) { |
| 117 | localStorage.setItem('getInitDataErrorCount', ++count) |
| 118 | // 菜单或者用户角色列表数据请求失败,就刷新页面 |
| 119 | window.location.reload(window.location.href) |
| 120 | } |
| 121 | } else { |
| 122 | localStorage.setItem('getInitDataErrorCount', 1) |
| 123 | // 菜单或者用户角色列表数据请求失败,就刷新页面 |
| 124 | window.location.reload(window.location.href) |
| 125 | } |
| 126 | }) |
| 127 | } else { |
| 128 | callbackFun && callbackFun() |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | router.beforeEach((to, from, next) => { |
| 133 | checkNecessaryData(() => { |
no outgoing calls
no test coverage detected
searching dependent graphs…