MCPcopy Create free account
hub / github.com/OpenSIST/OpenSIST.github.io / WelcomeBlock

Function WelcomeBlock

src/Components/Home/home.jsx:356–439  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

354}
355
356function WelcomeBlock() {
357 const dark = useTheme().palette.mode === 'dark';
358 // seed from cache so we never block the first paint on the network
359 const [stars, setStars] = useState(() => readCachedStars()?.count ?? null);
360
361 useEffect(() => {
362 let alive = true;
363 const cached = readCachedStars();
364 // cache still fresh — already shown as initial state, skip the request
365 if (cached && Date.now() - cached.at < GITHUB_STARS_TTL) return;
366 fetch('https://api.github.com/repos/opensist/opensist.github.io')
367 .then((r) => (r.ok ? r.json() : null))
368 .then((d) => {
369 if (alive && d && typeof d.stargazers_count === 'number') {
370 setStars(d.stargazers_count);
371 try {
372 localStorage.setItem(GITHUB_STARS_CACHE_KEY, JSON.stringify({count: d.stargazers_count, at: Date.now()}));
373 } catch {
374 /* ignore write failures (private mode / quota) */
375 }
376 }
377 })
378 .catch(() => {
379 });
380 return () => {
381 alive = false;
382 };
383 }, []);
384
385 return (
386 <Box className="GlassCard" sx={{
387 width: {xs: '100%', sm: '80%', md: '62%', lg: '52%'},
388 maxWidth: '100%',
389 minWidth: 0,
390 p: {xs: '1.25rem', md: '1.25rem 2.25rem'},
391 bgcolor: dark ? 'rgba(21,25,32,0.55)' : 'rgba(255,255,255,0.42)',
392 border: dark ? '1px solid rgba(255,255,255,0.06)' : '1px solid rgba(255,255,255,0.5)',
393 boxShadow: dark ? '0 10px 40px rgba(0,0,0,0.45)' : '0 10px 40px rgba(16,24,40,0.12)',
394 }}>
395 <Typography variant='h6' sx={{fontFamily: 'Merriweather', color: 'text.secondary', mb: '0.15rem'}}>
396 Welcome to
397 </Typography>
398 <OpenSIST props={{variant: 'h2'}} sx={{
399 display: 'inline-block',
400 fontSize: {xs: '2.4rem', sm: '2.8rem', md: '3rem'},
401 background: dark ? 'linear-gradient(120deg, #93C0F2, #6BA6E8)' : 'linear-gradient(120deg, #1C5BAA, #4F86CE)',
402 backgroundClip: 'text',
403 WebkitBackgroundClip: 'text',
404 color: 'transparent',
405 WebkitTextFillColor: 'transparent',
406 }}/>
407 <Typography sx={{mt: '0.4rem', color: 'text.secondary', letterSpacing: '0.02em'}}>
408 上海科技大学留学申请信息分享平台
409 </Typography>
410 <Divider sx={{my: '0.85rem', borderColor: 'divider'}}/>
411 <Typography sx={{mb: '1rem', lineHeight: 1.7}}>
412 OpenSIST由上海科技大学2020级信息学院同学自发创建,旨在为上科大学子提供一个更加开放的留学申请信息分享平台,帮助大家更好地规划自己的留学申请。如果喜欢,欢迎给我们一个 Star ⭐
413 </Typography>

Callers

nothing calls this directly

Calls 1

readCachedStarsFunction · 0.85

Tested by

no test coverage detected