(mountedApps: string[])
| 24 | * @param mountedApps |
| 25 | */ |
| 26 | const check = async (mountedApps: string[]) => { |
| 27 | try { |
| 28 | const res = await window.fetch(`${MICRO_FRONTEND_API}?time=${new Date().getTime()}`, { method: 'GET' }); |
| 29 | const latestConfig = await res.json(); |
| 30 | const loadedConfig = window.microHook.meta.map(config => config.props); |
| 31 | const diff = xorBy(latestConfig, loadedConfig, 'commitId'); |
| 32 | // TODO: 只检查当前挂载的app,后续看看是存在配置更新就都更新,而不是仅检查当前挂载的app |
| 33 | return diff.reduce((ret, d) => { |
| 34 | if (mountedApps.includes(d.name)) { |
| 35 | return [...ret, d]; |
| 36 | } |
| 37 | return ret; |
| 38 | }, []); |
| 39 | } catch (e) { |
| 40 | error('微前端版本更新失败'); |
| 41 | return []; |
| 42 | } |
| 43 | }; |
| 44 | |
| 45 | const VersionChecking = () => { |
| 46 | useInterval(() => { |
no test coverage detected