-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
> 首页内容添加 + 样式优化 * 🧶 添加站点介绍、使用说明、安装帮助、registry 实时状态等内容 * 🧶 添加 cnpmweb、cnpmcore 开源地址链接 * 💄 添加统一导航,首页部分也一并添加
- Loading branch information
Showing
9 changed files
with
184 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
'use client'; | ||
import React from 'react'; | ||
import { Divider, Tooltip, Typography } from 'antd'; | ||
import useRegistry from '@/hooks/useRegistry'; | ||
const { Title, Paragraph, Text, Link } = Typography; | ||
|
||
export default function Introduce() { | ||
const { data } = useRegistry(); | ||
return ( | ||
<Typography style={{ textAlign: 'left', marginTop: '32px' }}> | ||
<Title level={2}>站点介绍</Title> | ||
<Paragraph> | ||
<blockquote> | ||
这是一个完整 | ||
<Link target={'_blank'} href='https://www.npmjs.com'> | ||
npmjs.org | ||
</Link>{' '} | ||
镜像,你可以用此代替官方版本(只读),我们将尽量与官方服务 | ||
<Text strong>实时同步</Text>。 | ||
<br/> | ||
我们的前后端应用代码均已开源,前端应用为{' '} | ||
<Link target='_blank' href='https://github.com/cnpm/cnpmweb'> | ||
cnpmweb | ||
</Link> | ||
,服务端应用为{' '} | ||
<Link target='_blank' href='https://github.com/cnpm/cnpmcore'> | ||
cnpmcore | ||
</Link>{' '} | ||
欢迎共建。 | ||
</blockquote> | ||
目前我们已累积同步了 <Text strong>{data?.doc_count || '-'}</Text>{' '} | ||
个包,近7日下载量为 <Text strong>{data?.download.thisweek || '-'}</Text> | ||
。 | ||
<Divider /> | ||
<ul> | ||
<li> | ||
最近更新的包为 | ||
<Link | ||
href={`/${data?.sync_changes_steam.last_package}`} | ||
style={{ marginLeft: 8 }} | ||
disabled={!data} | ||
> | ||
{data?.sync_changes_steam.last_package || '-'} | ||
</Link> | ||
</li> | ||
<li> | ||
最近同步的时间为 | ||
<Tooltip title={'由于近期功能升级,同步预计与8月26日凌晨恢复'}> | ||
<Text strong style={{ paddingLeft: 8 }}> | ||
{data?.sync_changes_steam.last_package_created || '-'} | ||
</Text> | ||
</Tooltip> | ||
</li> | ||
</ul> | ||
</Paragraph> | ||
|
||
<Title level={2}>使用说明</Title> | ||
<Paragraph> | ||
你可以使用我们定制的 <Link href='/cnpm'>cnpm</Link> 命令行工具代替默认的 | ||
npm。 | ||
<br /> | ||
cnpm 支持了写相关操作外的所有命令,例如 install、info、view 等。 | ||
<br /> | ||
<pre> | ||
$ npm install -g cnpm --registry=https://registry.npmmirror.com | ||
</pre> | ||
或者你直接通过添加 npm 参数 alias 一个新命令: | ||
<pre> | ||
alias cnpm="npm --registry=https://registry.npmmirror.com \ | ||
--cache=$HOME/.npm/.cache/cnpm \ | ||
--disturl=https://npmmirror.com/mirrors/node \ | ||
--userconfig=$HOME/.cnpmrc" | ||
</pre> | ||
当然,你也可以使用任意你心仪的命令行工具,只要配置 registry 即可 | ||
<pre>$ npm config set registry https://registry.npmmirror.com</pre> | ||
</Paragraph> | ||
|
||
<Title level={3}>安装模块</Title> | ||
<Paragraph> | ||
<pre>$ cnpm install [name]</pre> | ||
</Paragraph> | ||
<Title level={3}>同步模块</Title> | ||
<Paragraph> | ||
<pre>$ cnpm sync cnpmcore</pre> | ||
当然, 你可以直接通过 web 方式来同步, 界面打开时会自动比对版本信息 | ||
<pre>$ open https://npmmirror.com/sync/cnpmcore</pre> | ||
</Paragraph> | ||
|
||
<Paragraph> | ||
<ul> | ||
<li> | ||
<Link href='https://registry.npmmiorror.com' target='_blank'> | ||
registry 站点 | ||
</Link> | ||
</li> | ||
<li> | ||
<Link href='/'>web 站点</Link> | ||
</li> | ||
<li> | ||
<Link href='/mirrors'>二进制文件镜像</Link> | ||
</li> | ||
</ul> | ||
</Paragraph> | ||
<Divider /> | ||
</Typography> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import useSwr from 'swr'; | ||
|
||
const REGISTRY = 'https://registry.npmmirror.com'; | ||
|
||
|
||
export default function useRegistry() { | ||
return useSwr('registry', async () => { | ||
return fetch(`${REGISTRY}`) | ||
.then((res) => res.json()); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ThemeMode } from "antd-style"; | ||
import { useEffect, useState } from "react"; | ||
|
||
const LOCAL_STORAGE_THEME = 'themeMode'; | ||
|
||
export function useTheme() { | ||
const [themeMode, setThemeMode] = useState<ThemeMode>('light'); | ||
useEffect(() => { | ||
const themeMode = localStorage.getItem(LOCAL_STORAGE_THEME) as ThemeMode; | ||
if (themeMode) { | ||
setThemeMode(themeMode); | ||
} | ||
}, []); | ||
useEffect(() => { | ||
document | ||
.querySelector('html') | ||
?.setAttribute('style', `color-scheme: ${themeMode};`); | ||
}, [themeMode]); | ||
|
||
return [themeMode, (v: ThemeMode) => { | ||
localStorage.setItem(LOCAL_STORAGE_THEME, v); | ||
setThemeMode(v); | ||
}]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
.search { | ||
width: 40rem; | ||
width: 760px; | ||
text-align: center; | ||
margin: 0 auto; | ||
margin-top: 15rem; | ||
margin-top: 16px; | ||
} | ||
|
||
.main { | ||
min-height: calc(100vh - 32px); | ||
margin-bottom: 32px; | ||
} |