MCPcopy
hub / github.com/Tencent/CodeAnalysis / check

Function check

web/packages/framework/src/support/version-checking/index.tsx:26–43  ·  view source on GitHub ↗
(mountedApps: string[])

Source from the content-addressed store, hash-verified

24 * @param mountedApps
25 */
26const 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
45const VersionChecking = () => {
46 useInterval(() => {

Callers 1

VersionCheckingFunction · 0.85

Calls 1

errorFunction · 0.90

Tested by

no test coverage detected