feat: 添加GitHub加速方案

This commit is contained in:
neo 2021-03-29 10:46:12 +08:00
parent afdd49c32b
commit 741ff9f637
5 changed files with 91 additions and 0 deletions

View File

@ -0,0 +1,28 @@
.my-code-block-copy-btn {
display: inline-block;
width: 16px;
height: 16px;
border: 0;
outline: none;
cursor: pointer;
opacity: 0.6;
transition: opacity 0.2s, background 0.2s;
&:hover {
opacity: 0.8;
}
&:active {
opacity: 0.9;
}
&[data-status='ready'] {
background-position: -54px 0;
}
&[data-status='copied'] {
opacity: 1;
pointer-events: none;
background-position: -54px -16px;
}
}

View File

@ -0,0 +1,17 @@
import React from 'react';
import { useCopy } from 'dumi/theme';
import './CopyButton.less';
export default (props: { content: string }) => {
const { content } = props;
const [copyCode, copyStatus] = useCopy();
return (
<button
className="__dumi-default-icon my-code-block-copy-btn"
role="copy"
data-status={copyStatus}
onClick={() => copyCode(content)}
/>
);
};

View File

@ -49,6 +49,10 @@ export default defineConfig({
title: '介 绍',
children: ['/guide/index', '/guide/how-it-works', '/guide/start'],
},
{
title: '相 关',
children: ['/guide/github'],
},
{
title: '工 具',
children: ['/guide/change-source'],

View File

@ -8,9 +8,27 @@ order: 4
遇到解决不了的问题,先删除`homebrew`目录再重新运行脚本安装。
删除可以通过脚本或者在文件夹中删除(mac)
```shell
// 默认
rm -rf 目录
// 执行root权限
sudo rm -rf 目录
```
使用`rm -rf`命令是比较危险的行为,请一定要具体指定的、合适的目录。
### macOS
- x86 上安装目录: `/usr/local/Homebrew/`
- arm 上安装目录: `/opt/homebrew`
### Linux
安装目录在`/home/linuxbrew`
## M1 芯片 Mac 如何安装
`Homebrew`已支持在`arm`上安装,但是一些软件兼容性还有待更新,官方查阅地址可看 [说明](https://github.com/Homebrew/brew/issues/7857) 。
@ -142,3 +160,9 @@ xcode-select --install
举例子我的电脑是`Big Sur 11.2`,在版本记录里看到`12.4`就是`Xcode`对应的版本号,然后我们找到"Command Line Tools for Xcode 12.4"下载。
[hosts]: https://mp.weixin.qq.com/s/gFNP2Pk81vg7nE1XsDingg
## raw.githubusercontent.com 无法访问
这是典型的`GitHub`不稳定的表现,你可以通过设置`hosts`缓解该问题。
参考 [GitHub 加速教程](/guide/github/) 。

18
docs/guide/github.md Normal file
View File

@ -0,0 +1,18 @@
# GitHub 加速教程
[GitHub Hosts](https://github.com/ineo6/hosts) 仓库提供最新的`GitHub hosts`地址。
你可以自行配置`hosts`,但是最佳实践是使用 [SwitchHosts!](https://oldj.github.io/SwitchHosts/#cn) 管理你的 `hosts`
可以阅读文章 [SwitchHosts! 还能这样管理 hosts后悔没早点用](https://mp.weixin.qq.com/s/A37XnD3HdcGSWUflj6JujQ) 了解详情,里面有介绍以及各个平台刷新 `DNS` 缓存的方法。
安装好 `SwitchHosts!` 后,新建一个规则:
- 方案名GitHub可以自行命名
- 类型:远程
- URL 地址https://cdn.jsdelivr.net/gh/ineo6/hosts/hosts <CopyButton content='https://cdn.jsdelivr.net/gh/ineo6/hosts/hosts' />
- 自动更新1 小时
这样就可以和仓库中最新的`hosts`保持同步。
![switchhost-github.png](https://i.loli.net/2021/03/28/XnHW5xCEzel36fA.png)