u
No files matched your search
@@ -0,0 +1,50 @@
|
||||
目前使用的 [网站](https://user.mutdot.com/sec.html)
|
||||
|
||||
## windows
|
||||
直接下载安装即可
|
||||
|
||||
## Linux
|
||||
使用 [clash-for-linux-install](https://github.com/nelvko/clash-for-linux-install)
|
||||
|
||||
直接参考官网流程即可。
|
||||
|
||||
如果显示订阅无效的话,则手动导入订阅文件
|
||||
|
||||
将订阅文件内容放到 `/root/clashctl/resources/config.yaml` 文件中
|
||||
``` bash
|
||||
clashsub add "file:///root/clashctl/resources/config.yaml"
|
||||
```
|
||||
|
||||
然后使用这个订阅连接
|
||||
```bash
|
||||
# 查看当前的订阅列表
|
||||
clashsub ls
|
||||
|
||||
# 使用订阅连接
|
||||
clashsub use 1
|
||||
```
|
||||
|
||||
开启代理
|
||||
```bash
|
||||
clashon
|
||||
```
|
||||
|
||||
关闭代理
|
||||
```bash
|
||||
clashoff
|
||||
```
|
||||
|
||||
在线 UI 页面
|
||||
```bash
|
||||
clashui
|
||||
```
|
||||
|
||||
获取密码
|
||||
```bash
|
||||
clashsecret
|
||||
```
|
||||
|
||||
更新密码
|
||||
```bash
|
||||
clashsecret mysecret
|
||||
```
|
||||
@@ -0,0 +1,15 @@
|
||||
Docker 是一个 容器化平台,可以让你把应用程序和它运行所需的环境打包在一起,形成一个独立的“容器”。
|
||||
简单来说,它就像一个轻量级的虚拟机,但比虚拟机更快、更省资源。
|
||||
|
||||
## 概念
|
||||
1. 镜像(Image)
|
||||
- 镜像是一个 只读模板,包含应用程序和依赖环境。
|
||||
- 可以理解为应用的快照,像“配方”。
|
||||
2. 容器(Container)
|
||||
- 容器是镜像的 运行实例,可以启动、停止、删除。
|
||||
- 可以理解为根据配方做出来的“饭菜”。
|
||||
3. Dockerfile
|
||||
- 用来定义镜像内容的文件,相当于“配方清单”。
|
||||
- 里面写明了基础镜像、依赖、环境变量、运行命令等。
|
||||
4. Docker Hub
|
||||
- 官方提供的镜像仓库,可以下载别人已经打包好的镜像,也可以上传自己的镜像。
|
||||
@@ -0,0 +1,291 @@
|
||||
## 快速安装
|
||||
|
||||
轩辕提供的安装脚本:
|
||||
|
||||
```bash
|
||||
bash <(wget -qO- https://xuanyuan.cloud/docker.sh)
|
||||
```
|
||||
|
||||
> 参考网站:https://zhuanlan.zhihu.com/p/24461370776
|
||||
|
||||
## 脚本安装
|
||||
|
||||
### 对于基于Debian的系统(如Ubuntu、Debian)
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------
|
||||
# 1️⃣ 卸载旧版本 Docker
|
||||
# -------------------------
|
||||
sudo apt-get remove -y \
|
||||
docker \
|
||||
docker-engine \
|
||||
docker.io \
|
||||
containerd \
|
||||
runc \
|
||||
docker-ce \
|
||||
docker-ce-cli \
|
||||
containerd.io \
|
||||
docker-compose-plugin
|
||||
|
||||
# 可选:清理残留数据(慎用,会删除容器和镜像)
|
||||
# sudo rm -rf /var/lib/docker /var/lib/containerd
|
||||
|
||||
echo "旧版本 Docker 已卸载(如果存在)"
|
||||
|
||||
# -------------------------
|
||||
# 2️⃣ 更新软件包列表并安装必要依赖
|
||||
# -------------------------
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y ca-certificates curl software-properties-common lsb-release
|
||||
|
||||
# -------------------------
|
||||
# 3️⃣ 创建密钥存储目录
|
||||
# -------------------------
|
||||
sudo install -m 0755 -d /etc/apt/keyrings
|
||||
|
||||
# -------------------------
|
||||
# 4️⃣ 下载Docker官方GPG密钥
|
||||
# -------------------------
|
||||
sudo curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg -o /etc/apt/keyrings/docker.asc
|
||||
sudo chmod a+r /etc/apt/keyrings/docker.asc
|
||||
|
||||
# -------------------------
|
||||
# 5️⃣ 添加 Docker 仓库
|
||||
# -------------------------
|
||||
if [ "$(lsb_release -is)" = "Ubuntu" ]; then
|
||||
echo \
|
||||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
|
||||
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||
elif [ "$(lsb_release -is)" = "Debian" ]; then
|
||||
echo \
|
||||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
|
||||
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||
fi
|
||||
|
||||
sudo apt-get update
|
||||
echo "Docker 仓库已添加。"
|
||||
|
||||
# -------------------------
|
||||
# 6️⃣ 安装 Docker 及相关组件
|
||||
# -------------------------
|
||||
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
||||
|
||||
echo "Docker 安装完成 ✅"
|
||||
```
|
||||
|
||||
### 对于基于RHEL的系统(如CentOS、RHEL)
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------
|
||||
# 1️⃣ 卸载旧版本 Docker
|
||||
# -------------------------
|
||||
sudo yum remove -y docker \
|
||||
docker-client \
|
||||
docker-client-latest \
|
||||
docker-common \
|
||||
docker-latest \
|
||||
docker-latest-logrotate \
|
||||
docker-logrotate \
|
||||
docker-engine \
|
||||
docker-ce \
|
||||
docker-ce-cli \
|
||||
containerd.io \
|
||||
docker-compose-plugin
|
||||
|
||||
echo "旧版本 Docker 已卸载(如果存在)"
|
||||
|
||||
# -------------------------
|
||||
# 2️⃣ 安装 yum 配置管理工具
|
||||
# -------------------------
|
||||
sudo yum install -y yum-utils
|
||||
|
||||
# -------------------------
|
||||
# 3️⃣ 检测系统发行版并添加 Docker 仓库
|
||||
# -------------------------
|
||||
if [ -f /etc/centos-release ]; then
|
||||
# CentOS 系统
|
||||
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
|
||||
elif [ -f /etc/redhat-release ]; then
|
||||
# RHEL 系统
|
||||
# 注意:RHEL 用户需要启用订阅管理仓库
|
||||
sudo yum-config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
|
||||
else
|
||||
echo "未识别的发行版,脚本退出。"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# -------------------------
|
||||
# 4️⃣ 更新 yum 缓存
|
||||
# -------------------------
|
||||
sudo yum makecache fast
|
||||
echo "Docker 仓库已添加。"
|
||||
|
||||
# -------------------------
|
||||
# 5️⃣ 安装 Docker 及相关组件
|
||||
# -------------------------
|
||||
sudo yum install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
||||
|
||||
echo "Docker 安装完成 ✅"
|
||||
```
|
||||
|
||||
### 通用脚本
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# -------------------------
|
||||
# 1️⃣ 卸载旧版本 Docker
|
||||
# -------------------------
|
||||
remove_old_docker() {
|
||||
if command -v apt-get >/dev/null 2>&1; then
|
||||
sudo apt-get remove -y docker docker-engine docker.io containerd runc docker-ce docker-ce-cli containerd.io docker-compose-plugin || true
|
||||
elif command -v yum >/dev/null 2>&1; then
|
||||
sudo yum remove -y docker \
|
||||
docker-client \
|
||||
docker-client-latest \
|
||||
docker-common \
|
||||
docker-latest \
|
||||
docker-latest-logrotate \
|
||||
docker-logrotate \
|
||||
docker-engine \
|
||||
docker-ce \
|
||||
docker-ce-cli \
|
||||
containerd.io \
|
||||
docker-compose-plugin || true
|
||||
fi
|
||||
echo "旧版本 Docker 已卸载(如果存在)"
|
||||
}
|
||||
|
||||
# -------------------------
|
||||
# 2️⃣ 安装 Docker(DEB 系统)
|
||||
# -------------------------
|
||||
install_docker_deb() {
|
||||
local distro=$1
|
||||
local codename=$2
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common lsb-release
|
||||
sudo install -m 0755 -d /etc/apt/keyrings
|
||||
sudo curl -fsSL "https://download.docker.com/linux/$distro/gpg" -o /etc/apt/keyrings/docker.asc
|
||||
sudo chmod a+r /etc/apt/keyrings/docker.asc
|
||||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/$distro $codename stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||||
sudo systemctl enable --now docker
|
||||
}
|
||||
|
||||
# -------------------------
|
||||
# 3️⃣ 安装 Docker(RPM 系统)
|
||||
# -------------------------
|
||||
install_docker_rpm() {
|
||||
local distro=$1
|
||||
if [ "$distro" = "fedora" ]; then
|
||||
sudo dnf -y install dnf-plugins-core
|
||||
else
|
||||
sudo yum install -y yum-utils
|
||||
fi
|
||||
sudo yum-config-manager --add-repo "https://download.docker.com/linux/$distro/docker-ce.repo"
|
||||
sudo yum makecache fast
|
||||
sudo yum install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
||||
sudo systemctl enable --now docker
|
||||
}
|
||||
|
||||
# -------------------------
|
||||
# 4️⃣ 主流程
|
||||
# -------------------------
|
||||
remove_old_docker
|
||||
|
||||
# 检测 Linux 发行版
|
||||
if [ -f /etc/os-release ]; then
|
||||
. /etc/os-release
|
||||
else
|
||||
echo "无法确定您的 Linux 发行版。"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case $ID in
|
||||
ubuntu|debian|raspbian)
|
||||
echo "检测到 $ID $VERSION_CODENAME,开始安装 Docker..."
|
||||
install_docker_deb $ID $VERSION_CODENAME
|
||||
;;
|
||||
centos|rhel|fedora|sles)
|
||||
echo "检测到 $ID,开始安装 Docker..."
|
||||
install_docker_rpm $ID
|
||||
;;
|
||||
*)
|
||||
echo "不支持的 Linux 发行版:$ID"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "Docker 及 Docker Compose 安装完成 ✅"
|
||||
```
|
||||
|
||||
### 运行脚本
|
||||
|
||||
```bash
|
||||
# 1.创建脚本
|
||||
vim docker-script.sh
|
||||
|
||||
# 2.输入内容 i 进行编辑模式, :wq 保存
|
||||
|
||||
# 3.赋予权限
|
||||
chmod +x docker-script.sh
|
||||
|
||||
# 4.运行脚本
|
||||
./docker-script.sh
|
||||
```
|
||||
|
||||
## 镜像设置
|
||||
|
||||
不设置镜像会导致拉取速度非常慢
|
||||
访问 https://api.suoyinmulu.com/open/v1/docker-hub/seeded-up/lists 获取最新的docker镜像,将 list 中的内容拷贝到 docker 中的 registry-mirrors 中。
|
||||
|
||||
```bash
|
||||
sudo vim /etc/docker/daemon.json
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"registry-mirrors": [
|
||||
// list
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
刷新:
|
||||
|
||||
```bash
|
||||
sudo systemctl daemon-reload && sudo systemctl restart docker
|
||||
```
|
||||
|
||||
## 问题
|
||||
### 权限不足
|
||||
1. 添加docker用户组(默认有)
|
||||
|
||||
```
|
||||
sudo groupadd docker
|
||||
```
|
||||
|
||||
2. 添加当前用户到docker组中
|
||||
|
||||
```
|
||||
sudo gpasswd -a $USER docker
|
||||
```
|
||||
|
||||
3. 更新用户组
|
||||
|
||||
```
|
||||
newgrp docker
|
||||
```
|
||||
|
||||
4. 重启生效 或 提前执行(建议重启)
|
||||
|
||||
```
|
||||
sudo chown root:docker /var/run/docker.sock
|
||||
```
|
||||
@@ -0,0 +1,34 @@
|
||||
Docusaurus 是一个开源的静态网站生成器,专注于帮助开发者快速构建、部署和维护文档类网站。
|
||||
> 官网:https://docusaurus.io/zh-CN/
|
||||
|
||||
## 优点
|
||||
- 高度自定义:
|
||||
- 使用 react 开发,并支持自定义扩展组件或自定义页面
|
||||
- 提供 swizzle 命令可完全自定义布局
|
||||
- 基础页面干净整洁,可快速捕捉到关键信息
|
||||
- 社区群庞大,拥有广大的社区支持
|
||||
- 同时支持 docs(文档) 和 blog(博客),能够有更多的选择
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 1.环境要求
|
||||
- Node版本最低 20
|
||||
|
||||
### 2.安装
|
||||
```bash
|
||||
npx create-docusaurus@latest my-website classic
|
||||
```
|
||||
如果需要支持 `typescript`,则使用
|
||||
```bash
|
||||
npx create-docusaurus@latest my-website classic --typescript
|
||||
```
|
||||
|
||||
### 3.运行
|
||||
下载依赖
|
||||
```bash
|
||||
pnpm i
|
||||
```
|
||||
运行项目
|
||||
```bash
|
||||
pnpm run start
|
||||
```
|
||||
@@ -0,0 +1,35 @@
|
||||
默认的项目结构如下
|
||||
```text
|
||||
my-website
|
||||
├── blog
|
||||
│ ├── 2019-05-28-hola.md
|
||||
│ ├── 2019-05-29-hello-world.md
|
||||
│ └── 2020-05-30-welcome.md
|
||||
├── docs
|
||||
│ ├── doc1.md
|
||||
│ ├── doc2.md
|
||||
│ ├── doc3.md
|
||||
│ └── mdx.md
|
||||
├── src
|
||||
│ ├── css
|
||||
│ │ └── custom.css
|
||||
│ └── pages
|
||||
│ ├── styles.module.css
|
||||
│ └── index.ts
|
||||
├── static
|
||||
│ └── img
|
||||
├── docusaurus.config.ts
|
||||
├── package.json
|
||||
├── README.md
|
||||
├── sidebars.ts
|
||||
└── yarn.lock
|
||||
```
|
||||
|
||||
目录介绍:
|
||||
|
||||
- `blog` - 存放博客文章,格式是 Markdown
|
||||
- `docs` - 存放文档内容,也用 Markdown 格式
|
||||
- `src` - 存放自定义的页面和样式。
|
||||
- `static` - 存放自定义的页面和样式
|
||||
- `docusaurus.config.ts` - 配置网站的各种信息
|
||||
- `sidebars.ts` - 配置 docs 侧边栏的内容和结构
|
||||
@@ -0,0 +1,196 @@
|
||||
关于文档的创建和配置
|
||||
|
||||
## navbar 配置
|
||||
|
||||
在 `docusaurus.config.ts` 文件中进行配置, `config` - `themeConfig` - `navbar` - `items`
|
||||
|
||||
### 单级导航
|
||||
|
||||
在 `docs` 文件夹下创建 `test.md` 文件,并在 `items` 配置项中添加:
|
||||
|
||||
```json
|
||||
{
|
||||
// ...
|
||||
"items": [
|
||||
{
|
||||
"to": "/docs/test",
|
||||
"label": "test"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
刷新页面,即可进行预览
|
||||
|
||||
### 多级导航
|
||||
|
||||
docusaurus 的 navbar 最多支持两级导航,比如:
|
||||
|
||||
```json
|
||||
{
|
||||
// ...
|
||||
"items": [
|
||||
{
|
||||
"type": "dropdown",
|
||||
"label": "编程语言",
|
||||
"position": "left",
|
||||
"items": [
|
||||
{
|
||||
"label": "Stack Overflow",
|
||||
"href": "https://stackoverflow.com/questions/tagged/docusaurus"
|
||||
},
|
||||
{
|
||||
"label": "Discord",
|
||||
"href": "https://discordapp.com/invite/docusaurus"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 图标配置
|
||||
|
||||
以 Github 图标为例
|
||||
修改 `docusaurus.config.ts` 文件:
|
||||
|
||||
```json
|
||||
{
|
||||
// ...
|
||||
"items": [
|
||||
{
|
||||
"aria-label": "GitHub Repository",
|
||||
"className": "navbar--github-link",
|
||||
"href": "https://github.com/oneao",
|
||||
"position": "right",
|
||||
"title": "Github"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
在 `src/css/custom.css` 中添加以下内容:
|
||||
|
||||
```css
|
||||
.navbar--github-link {
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
padding: 0.25rem;
|
||||
margin: 0rem 0.2rem;
|
||||
border-radius: 50%;
|
||||
transition: background var(--ifm-transition-fast);
|
||||
}
|
||||
|
||||
.navbar--github-link:hover {
|
||||
background: var(--ifm-color-emphasis-200);
|
||||
}
|
||||
|
||||
.navbar--github-link:before {
|
||||
content: '';
|
||||
height: 100%;
|
||||
display: block;
|
||||
background: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12'/%3E%3C/svg%3E")
|
||||
no-repeat;
|
||||
}
|
||||
|
||||
html[data-theme='dark'] .navbar--github-link:before {
|
||||
background: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='white' d='M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12'/%3E%3C/svg%3E")
|
||||
no-repeat;
|
||||
}
|
||||
|
||||
/* 兼容屏幕过小情况,转为文字 */
|
||||
@media screen and (max-width: 996px) {
|
||||
.navbar--github-link {
|
||||
margin: 0rem;
|
||||
padding: var(--ifm-menu-link-padding-vertical) var(--ifm-menu-link-padding-horizontal);
|
||||
line-height: 1.25;
|
||||
width: 100%;
|
||||
color: var(--ifm-menu-color);
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.navbar--github-link::before {
|
||||
content: 'GitHub';
|
||||
background-image: none;
|
||||
}
|
||||
|
||||
[data-theme='dark'] .navbar--github-link::before {
|
||||
content: 'GitHub';
|
||||
background-image: none;
|
||||
}
|
||||
}
|
||||
```
|
||||
提供两个工具网站仅供参考:
|
||||
- svg 图标库:https://www.svgrepo.com/
|
||||
- svg 转 url 编码:https://yoksel.github.io/url-encoder/zh-cn/
|
||||
|
||||
## 侧边栏配置
|
||||
|
||||
docs 的侧边栏配置主要在 `sidebars.ts` 文件中
|
||||
|
||||
### 自动生成
|
||||
|
||||
在 docs 目录中创建 `coding/java` 目录,在 `sidebar.ts` 文件中添加配置:
|
||||
|
||||
```ts
|
||||
import type { SidebarsConfig } from '@docusaurus/plugin-content-docs'
|
||||
|
||||
const sidebars: SidebarsConfig = {
|
||||
// coding 目录下的自动生成的 Java 相关文档
|
||||
javaSidebar: [{ type: 'autogenerated', dirName: 'coding/java' }]
|
||||
}
|
||||
|
||||
export default sidebars
|
||||
```
|
||||
|
||||
修改 `docusaurus.config.ts` 文件:
|
||||
|
||||
```json
|
||||
{
|
||||
// ...
|
||||
"items": [
|
||||
{
|
||||
"type": "dropdown",
|
||||
"label": "编程语言",
|
||||
"position": "left",
|
||||
"items": [
|
||||
{
|
||||
"type": "docSidebar",
|
||||
"label": "Java",
|
||||
"sidebarId": "javaSidebar"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
提示:
|
||||
|
||||
- `sidebarId` 需要和 `SidebarsConfig` 中的 key 保持一致
|
||||
- `type: 'autogenerated'` 表示自动生成
|
||||
- **自动生成模式下 将自动根据目录和目录下的文件自动构建侧边栏**
|
||||
|
||||
### 手动配置
|
||||
|
||||
```ts
|
||||
import type { SidebarsConfig } from '@docusaurus/plugin-content-docs'
|
||||
|
||||
const sidebars: SidebarsConfig = {
|
||||
// 手动配置的侧边栏
|
||||
javaSidebar: [
|
||||
{
|
||||
type: 'category',
|
||||
label: 'Java 基础',
|
||||
items: ['coding/java/intro', 'coding/java/advanced'],
|
||||
},
|
||||
{
|
||||
type: 'category',
|
||||
label: 'Java 框架',
|
||||
items: ['coding/java/spring-boot', 'coding/java/hibernate'],
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
export default sidebars
|
||||
```
|
||||
@@ -0,0 +1,398 @@
|
||||
> 具体可参考:https://docusaurus.io/zh-CN/docs/search
|
||||
|
||||
[Algolia](https://dashboard.algolia.com) 是一个强大的搜索引擎平台,专注于提供快速、可定制的搜索功能。它通常用于为网站、应用或文档提供实时搜索和自动完成功能。
|
||||
|
||||
## 1. 配置 algolia
|
||||
|
||||
先到 [官网](https://dashboard.algolia.com) 注册申请,大概两天后会收到邮件通知注册成功,再接着往下操作(不确定是否需要这步)
|
||||
|
||||
### 申请 Application
|
||||
|
||||
点击 `+ Create Application` 申请新的应用
|
||||
|
||||

|
||||
|
||||
申请表单填写步骤:
|
||||
|
||||
- 输入名称
|
||||
- `Select your Search plan` 选择 `Algolia` 即可,`DocSearch` 需要申请,但是允许查询次数比较多
|
||||
- 地区随便选择一个即可
|
||||
|
||||
### 申请 Index
|
||||
|
||||
点击菜单栏的 `Search` 或直接搜索栏搜索 Index 进入 Index 相关页面
|
||||
|
||||

|
||||
|
||||
进入页面后,点击 `Create Index` 创建 Index
|
||||
|
||||

|
||||
|
||||
接下来填写 Index 的名称即可
|
||||
|
||||

|
||||
|
||||
### 配置 Index(重要)
|
||||
|
||||
> 不要忽略这一步,不然会导致搜索不到内容
|
||||
|
||||
找到 Index 页面中的 `Configuration` 选项
|
||||
|
||||

|
||||
|
||||
下面需要修改3处地方
|
||||
|
||||
**Searchable attributes** 的值新增:
|
||||
|
||||
```
|
||||
title
|
||||
content
|
||||
keywords
|
||||
description
|
||||
lang
|
||||
language
|
||||
hierarchy.lvl0
|
||||
hierarchy.lvl1
|
||||
hierarchy.lvl2
|
||||
hierarchy.lvl3
|
||||
hierarchy.lvl4
|
||||
hierarchy.lvl5
|
||||
hierarchy.lvl6
|
||||
```
|
||||
|
||||

|
||||
|
||||
**Facts** 的值新增:
|
||||
|
||||
```
|
||||
category
|
||||
content
|
||||
docusaurus_tag
|
||||
lang
|
||||
language
|
||||
hierarchy.lvl0
|
||||
hierarchy.lvl1
|
||||
hierarchy.lvl2
|
||||
hierarchy.lvl3
|
||||
hierarchy.lvl4
|
||||
hierarchy.lvl5
|
||||
hierarchy.lvl6
|
||||
```
|
||||
|
||||

|
||||
|
||||
**Languages** 的值新增:
|
||||
|
||||
Index Languages 和 Query Languages 都需要添加
|
||||
|
||||
```
|
||||
Chinese
|
||||
English
|
||||
```
|
||||
|
||||

|
||||
|
||||
## 2. 修改 docusaurus.config.js
|
||||
|
||||
```json
|
||||
{
|
||||
"config": {
|
||||
"themeConfig": {
|
||||
"algolia": {
|
||||
"appId": "填写申请的appId",
|
||||
"apiKey": "填写申请的apiKey",
|
||||
"indexName": "填写申请的indexName"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
需要填写的信息可以在[该页面](https://dashboard.algolia.com/account/overview)中进行查找
|
||||
|
||||

|
||||
|
||||
进入该页面后即可查询到 `appId` 和 `apiKey`
|
||||
|
||||

|
||||
|
||||
- `appId`:就是申请的 Application ID
|
||||
- `apiKey`:就是 Search API Key
|
||||
- `IndexName`:就是申请的 Index 的名称
|
||||
|
||||
这样就会自动在 `navbar` 添加个搜索框
|
||||
|
||||
## 3. 爬虫
|
||||
|
||||
爬虫就是将自己网站的信息爬到 algolia 网站上,在这分为两种:
|
||||
|
||||
- algolia爬虫:使用 algolia 网站上的爬虫进行爬取(这个好像也需要申请)
|
||||
- 自定义爬虫:配置一个自定义爬虫,使用 Docker 或 GitHub Actions 来自动化执行爬虫任务
|
||||
|
||||
### algolia爬虫
|
||||
|
||||
还是进入 Index 页面,点击 `event data`
|
||||
|
||||

|
||||
|
||||
点击 `Crawler` 里面的 `Add your domain`
|
||||
|
||||

|
||||
|
||||
然后输入自己的网址进行验证,可选择多种方式
|
||||
|
||||

|
||||
|
||||
验证成功后,新建爬虫信息
|
||||
|
||||

|
||||
|
||||
填写相关信息
|
||||
|
||||

|
||||
|
||||
创建成功后,点击 Index 名称进入爬虫页面
|
||||
|
||||

|
||||
|
||||
默认创建好就进行爬虫了,但是配置信息需要改下,配置参考 [官方推荐](https://docsearch.algolia.com/docs/templates/#docusaurus-v3-template)
|
||||
|
||||

|
||||
|
||||
```js title="Editor"
|
||||
new Crawler({
|
||||
appId: 'YOUR_APP_ID',
|
||||
apiKey: 'YOUR_API_KEY',
|
||||
rateLimit: 8,
|
||||
maxDepth: 10,
|
||||
// 每天0点爬取一次
|
||||
schedule: 'every 1 day at 12:00 am',
|
||||
startUrls: ['https://YOUR_WEBSITE_URL/'],
|
||||
sitemaps: ['https://YOUR_WEBSITE_URL/sitemap.xml'],
|
||||
ignoreCanonicalTo: true,
|
||||
discoveryPatterns: ['https://YOUR_WEBSITE_URL/**'],
|
||||
actions: [
|
||||
{
|
||||
indexName: 'YOUR_INDEX_NAME',
|
||||
pathsToMatch: ['https://YOUR_WEBSITE_URL/**'],
|
||||
recordExtractor: ({ $, helpers }) => {
|
||||
// priority order: deepest active sub list header -> navbar active item -> 'Documentation'
|
||||
const lvl0
|
||||
= $(
|
||||
'.menu__link.menu__link--sublist.menu__link--active, .navbar__item.navbar__link--active'
|
||||
)
|
||||
.last()
|
||||
.text() || 'Documentation'
|
||||
|
||||
return helpers.docsearch({
|
||||
recordProps: {
|
||||
lvl0: {
|
||||
selectors: '',
|
||||
defaultValue: lvl0,
|
||||
},
|
||||
lvl1: ['header h1', 'article h1'],
|
||||
lvl2: 'article h2',
|
||||
lvl3: 'article h3',
|
||||
lvl4: 'article h4',
|
||||
lvl5: 'article h5, article td:first-child',
|
||||
lvl6: 'article h6',
|
||||
content: 'article p, article li, article td:last-child',
|
||||
},
|
||||
indexHeadings: true,
|
||||
aggregateContent: true,
|
||||
recordVersion: 'v3',
|
||||
})
|
||||
},
|
||||
},
|
||||
],
|
||||
initialIndexSettings: {
|
||||
YOUR_INDEX_NAME: {
|
||||
attributesForFaceting: [
|
||||
'type',
|
||||
'lang',
|
||||
'language',
|
||||
'version',
|
||||
'docusaurus_tag',
|
||||
],
|
||||
attributesToRetrieve: [
|
||||
'hierarchy',
|
||||
'content',
|
||||
'anchor',
|
||||
'url',
|
||||
'url_without_anchor',
|
||||
'type',
|
||||
],
|
||||
attributesToHighlight: ['hierarchy', 'content'],
|
||||
attributesToSnippet: ['content:10'],
|
||||
camelCaseAttributes: ['hierarchy', 'content'],
|
||||
searchableAttributes: [
|
||||
'unordered(hierarchy.lvl0)',
|
||||
'unordered(hierarchy.lvl1)',
|
||||
'unordered(hierarchy.lvl2)',
|
||||
'unordered(hierarchy.lvl3)',
|
||||
'unordered(hierarchy.lvl4)',
|
||||
'unordered(hierarchy.lvl5)',
|
||||
'unordered(hierarchy.lvl6)',
|
||||
'content',
|
||||
],
|
||||
distinct: true,
|
||||
attributeForDistinct: 'url',
|
||||
customRanking: [
|
||||
'desc(weight.pageRank)',
|
||||
'desc(weight.level)',
|
||||
'asc(weight.position)',
|
||||
],
|
||||
ranking: [
|
||||
'words',
|
||||
'filters',
|
||||
'typo',
|
||||
'attribute',
|
||||
'proximity',
|
||||
'exact',
|
||||
'custom',
|
||||
],
|
||||
highlightPreTag: '<span class="algolia-docsearch-suggestion--highlight">',
|
||||
highlightPostTag: '</span>',
|
||||
minWordSizefor1Typo: 3,
|
||||
minWordSizefor2Typos: 7,
|
||||
allowTyposOnNumericTokens: false,
|
||||
minProximity: 1,
|
||||
ignorePlurals: true,
|
||||
advancedSyntax: true,
|
||||
attributeCriteriaComputedByMinProximity: true,
|
||||
removeWordsIfNoResults: 'allOptional',
|
||||
separatorsToIndex: '_',
|
||||
},
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
> 注意:`schedule` 现在是每天0点自动爬取,表达式参考 https://www.algolia.com/doc/tools/crawler/apis/configuration/schedule?utm_medium=page_link&utm_source=dashboard
|
||||
|
||||
修改成功后重新爬虫
|
||||
|
||||

|
||||
|
||||
进入该页面即可查看爬虫后的全部信息
|
||||
|
||||

|
||||
|
||||
当爬虫结束并成功后,返回 Index 页面,如果出现下面页面的内容即 **代表成功**
|
||||
|
||||

|
||||
|
||||
成功后,进入网站进行搜索即可
|
||||
|
||||
### 自定义爬虫(Docker)
|
||||
|
||||
服务器上安装 `jq` 解析 `json` 文件
|
||||
|
||||
```bash
|
||||
sudo apt update && sudo apt install -y jq
|
||||
```
|
||||
|
||||
在项目根目录下新增 `.env` 和 `.docsearch.json` 文件
|
||||
|
||||
```bash title='.env'
|
||||
ALGOLIA_APP_ID=xxx
|
||||
ALGOLIA_API_KEY=xxx
|
||||
```
|
||||
|
||||
```json title='.docsearch.json'
|
||||
{
|
||||
// 需要替换
|
||||
"index_name": "xxx",
|
||||
// 需要替换。网站网址
|
||||
"start_urls": ["xxx"],
|
||||
// 需要替换。sitemap的网址,docusaurus 默认在根目录下生成 sitemap.xml
|
||||
"sitemap_urls": ["xxx"],
|
||||
"selectors": {
|
||||
"lvl0": {
|
||||
"selector": "(//ul[contains(@class,'menu__list')]//a[contains(@class, 'menu__link menu__link--sublist menu__link--active')]/text() | //nav[contains(@class, 'navbar')]//a[contains(@class, 'navbar__link--active')]/text())[last()]",
|
||||
"type": "xpath",
|
||||
"global": true,
|
||||
"default_value": "Documentation"
|
||||
},
|
||||
"lvl1": "header h1, article h1",
|
||||
"lvl2": "article h2",
|
||||
"lvl3": "article h3",
|
||||
"lvl4": "article h4",
|
||||
"lvl5": "article h5, article td:first-child",
|
||||
"lvl6": "article h6",
|
||||
"text": "article p, article li, article td:last-child"
|
||||
},
|
||||
"custom_settings": {
|
||||
"attributesForFaceting": [
|
||||
"type",
|
||||
"lang",
|
||||
"language",
|
||||
"version",
|
||||
"docusaurus_tag"
|
||||
],
|
||||
"attributesToRetrieve": [
|
||||
"hierarchy",
|
||||
"content",
|
||||
"anchor",
|
||||
"url",
|
||||
"url_without_anchor",
|
||||
"type"
|
||||
],
|
||||
"attributesToHighlight": ["hierarchy", "content"],
|
||||
"attributesToSnippet": ["content:10"],
|
||||
"camelCaseAttributes": ["hierarchy", "content"],
|
||||
"searchableAttributes": [
|
||||
"unordered(hierarchy.lvl0)",
|
||||
"unordered(hierarchy.lvl1)",
|
||||
"unordered(hierarchy.lvl2)",
|
||||
"unordered(hierarchy.lvl3)",
|
||||
"unordered(hierarchy.lvl4)",
|
||||
"unordered(hierarchy.lvl5)",
|
||||
"unordered(hierarchy.lvl6)",
|
||||
"content"
|
||||
],
|
||||
"distinct": true,
|
||||
"attributeForDistinct": "url",
|
||||
"customRanking": [
|
||||
"desc(weight.pageRank)",
|
||||
"desc(weight.level)",
|
||||
"asc(weight.position)"
|
||||
],
|
||||
"ranking": [
|
||||
"words",
|
||||
"filters",
|
||||
"typo",
|
||||
"attribute",
|
||||
"proximity",
|
||||
"exact",
|
||||
"custom"
|
||||
],
|
||||
"highlightPreTag": "<span class='algolia-docsearch-suggestion--highlight'>",
|
||||
"highlightPostTag": "</span>",
|
||||
"minWordSizefor1Typo": 3,
|
||||
"minWordSizefor2Typos": 7,
|
||||
"allowTyposOnNumericTokens": false,
|
||||
"minProximity": 1,
|
||||
"ignorePlurals": true,
|
||||
"advancedSyntax": true,
|
||||
"attributeCriteriaComputedByMinProximity": true,
|
||||
"removeWordsIfNoResults": "allOptional",
|
||||
"separatorsToIndex": "_",
|
||||
"synonyms": [
|
||||
["js", "javascript"],
|
||||
["ts", "typescript"]
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
然后运行命令
|
||||
|
||||
```bash
|
||||
docker run -it --env-file=.env -e "CONFIG=$(cat docsearch.json | jq -r tostring)" algolia/docsearch-scraper
|
||||
```
|
||||
|
||||
> 报错:algoliasearch.exceptions.RequestException: Method not allowed with this API key
|
||||
> 这个问题就是权限不够,需要使用 `Admin API Key`
|
||||
|
||||
如果出现下面页面的内容即 **代表成功**
|
||||

|
||||
@@ -0,0 +1,276 @@
|
||||
https://giscus.app/zh-CN
|
||||
|
||||
## 1. 准备一个 github 仓库
|
||||
|
||||
> 新建 或 已存在 的库都可以
|
||||
|
||||
修改配置:`/Settings/General`
|
||||
|
||||
保证仓库的 Danger Zone - visibility 是 public的
|
||||
|
||||

|
||||
|
||||
开启 Features - Discussions 功能
|
||||
|
||||

|
||||
|
||||
## 2. 配置 [giscus](https://github.com/apps/giscus)
|
||||
|
||||
在 github 中开启 giscus 功能,可根据需求选择指定的仓库或公共仓库
|
||||
|
||||

|
||||
|
||||
开启完毕后进入 [giscus](https://github.com/apps/giscus) 的官网,然后按照顺序配置:
|
||||
|
||||
1. 选择语言
|
||||
2. **仓库**:输入刚刚准备好的 github 仓库地址
|
||||
3. **页面 ↔️ discussion 映射关系** 选择 **Discussion 的标题包含页面的 pathname**
|
||||
4. **Discussion 分类** 选择第一个 **Announcements**
|
||||
5. 其他保持默认即可
|
||||
|
||||
然后下滑找到 **启用 giscus** 模块,里面的 `<script>` 信息需要用到,类似:
|
||||
|
||||
```html
|
||||
<script src="https://giscus.app/client.js"
|
||||
data-repo="xxxxx"
|
||||
data-repo-id="xxxx"
|
||||
data-category="xxxx"
|
||||
data-category-id="xxxxx"
|
||||
data-mapping="pathname"
|
||||
data-reactions-enabled="1"
|
||||
data-emit-metadata="0"
|
||||
data-input-position="bottom"
|
||||
data-theme="light"
|
||||
data-lang="zh-CN"
|
||||
crossorigin="anonymous"
|
||||
async>
|
||||
```
|
||||
|
||||
## 3. 在项目中启用
|
||||
|
||||
### 3.1 开启博客评论
|
||||
|
||||
```bash
|
||||
pnpm swizzle @docusaurus/theme-classic BlogPostPage
|
||||
```
|
||||
|
||||
- 选择 Eject (Unsafe) 回车
|
||||
- 选择 YES: I know what I am doing! 回车
|
||||
- 这时你的项目目录下src/theme/BlogPostPage生成了自定义主题的文件
|
||||
|
||||
添加依赖
|
||||
|
||||
```bash
|
||||
pnpm add @docusaurus/theme-common @docusaurus/plugin-content-blog
|
||||
```
|
||||
|
||||
下一步修改文件代码
|
||||
|
||||
下面三处标注是我们要修改添加代码的地方。 注意版本不同配置可能存在差异 根据标注自己找放评论的位置。
|
||||
|
||||
```js title="/src/theme/BlogPostPage/index.js"
|
||||
import { HtmlClassNameProvider, ThemeClassNames } from '@docusaurus/theme-common'
|
||||
|
||||
import { BlogPostProvider, useBlogPost } from '@docusaurus/theme-common/internal'
|
||||
import BlogLayout from '@theme/BlogLayout'
|
||||
import BlogPostItem from '@theme/BlogPostItem'
|
||||
import BlogPostPageMetadata from '@theme/BlogPostPage/Metadata'
|
||||
import BlogPostPaginator from '@theme/BlogPostPaginator'
|
||||
import TOC from '@theme/TOC'
|
||||
import clsx from 'clsx'
|
||||
// highlight-start
|
||||
import React, { useEffect, useRef } from 'react'
|
||||
// highlight-end
|
||||
|
||||
function BlogPostPageContent({ sidebar, children }) {
|
||||
const { metadata, toc } = useBlogPost()
|
||||
const { nextItem, prevItem, frontMatter } = metadata
|
||||
const {
|
||||
hide_table_of_contents: hideTableOfContents,
|
||||
toc_min_heading_level: tocMinHeadingLevel,
|
||||
toc_max_heading_level: tocMaxHeadingLevel,
|
||||
} = frontMatter
|
||||
|
||||
// highlight-start
|
||||
const commentElement = useRef(null)
|
||||
|
||||
useEffect(() => {
|
||||
// Update the document title using the browser API
|
||||
let s = document.createElement('script')
|
||||
s.src = 'https://giscus.app/client.js'
|
||||
s.setAttribute('data-repo', '[你的仓库]')
|
||||
s.setAttribute('data-repo-id', '[你的仓库 ID]=')
|
||||
s.setAttribute('data-category', '[你的分类名]')
|
||||
s.setAttribute('data-category-id', '[你的分类 ID]')
|
||||
s.setAttribute('data-mapping', 'pathname')
|
||||
s.setAttribute('data-reactions-enabled', '1')
|
||||
s.setAttribute('data-emit-metadata', '0')
|
||||
s.setAttribute('data-input-position', 'bottom')
|
||||
s.setAttribute('data-theme', document.documentElement.getAttribute('data-theme'))
|
||||
s.setAttribute('data-lang', 'zh-CN')
|
||||
s.setAttribute('crossorigin', 'anonymous')
|
||||
s.async = true
|
||||
commentElement.current.appendChild(s)
|
||||
}, [])
|
||||
// highlight-end
|
||||
|
||||
return (
|
||||
<BlogLayout
|
||||
sidebar={sidebar}
|
||||
toc={
|
||||
!hideTableOfContents && toc.length > 0
|
||||
? (
|
||||
<TOC
|
||||
toc={toc}
|
||||
minHeadingLevel={tocMinHeadingLevel}
|
||||
maxHeadingLevel={tocMaxHeadingLevel}
|
||||
/>
|
||||
)
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
<BlogPostItem>{children}</BlogPostItem>
|
||||
|
||||
{(nextItem || prevItem) && (
|
||||
<BlogPostPaginator nextItem={nextItem} prevItem={prevItem} />
|
||||
)}
|
||||
|
||||
// highlight-start
|
||||
<div style={{ marginTop: '20px' }} ref={commentElement}></div>
|
||||
// highlight-end
|
||||
|
||||
</BlogLayout>
|
||||
)
|
||||
}
|
||||
|
||||
export default function BlogPostPage(props) {
|
||||
const BlogPostContent = props.content
|
||||
return (
|
||||
<BlogPostProvider content={props.content} isBlogPostPage>
|
||||
<HtmlClassNameProvider
|
||||
className={clsx(
|
||||
ThemeClassNames.wrapper.blogPages,
|
||||
ThemeClassNames.page.blogPostPage,
|
||||
)}
|
||||
>
|
||||
<BlogPostPageMetadata />
|
||||
<BlogPostPageContent sidebar={props.sidebar}>
|
||||
<BlogPostContent />
|
||||
</BlogPostPageContent>
|
||||
</HtmlClassNameProvider>
|
||||
</BlogPostProvider>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
### 3.2 开启文档评论
|
||||
|
||||
```bash
|
||||
pnpm swizzle @docusaurus/theme-classic DocItem/Layout
|
||||
```
|
||||
|
||||
- 选择 Eject (Unsafe) 回车
|
||||
- 选择 YES: I know what I am doing! 回车
|
||||
- 这时你的项目目录下src/theme/BlogPostPage生成了自定义主题的文件
|
||||
|
||||
添加依赖
|
||||
|
||||
```bash
|
||||
pnpm add @docusaurus/plugin-content-docs
|
||||
```
|
||||
|
||||
下一步修改文件代码
|
||||
|
||||
下面三处标注是我们要修改添加代码的地方。 注意版本不同配置可能存在差异 根据标注自己找放评论的位置。
|
||||
|
||||
```js title="/src/theme/DocItem/Layout/index.js"
|
||||
import { useDoc } from '@docusaurus/plugin-content-docs/client'
|
||||
import { useWindowSize } from '@docusaurus/theme-common'
|
||||
import ContentVisibility from '@theme/ContentVisibility'
|
||||
import DocBreadcrumbs from '@theme/DocBreadcrumbs'
|
||||
import DocItemContent from '@theme/DocItem/Content'
|
||||
import DocItemFooter from '@theme/DocItem/Footer'
|
||||
import DocItemPaginator from '@theme/DocItem/Paginator'
|
||||
import DocItemTOCDesktop from '@theme/DocItem/TOC/Desktop'
|
||||
import DocItemTOCMobile from '@theme/DocItem/TOC/Mobile'
|
||||
import DocVersionBadge from '@theme/DocVersionBadge'
|
||||
import DocVersionBanner from '@theme/DocVersionBanner'
|
||||
import clsx from 'clsx'
|
||||
// highlight-start
|
||||
import React, { useEffect, useRef } from 'react'
|
||||
// highlight-end
|
||||
import styles from './styles.module.css'
|
||||
/**
|
||||
* Decide if the toc should be rendered, on mobile or desktop viewports
|
||||
*/
|
||||
function useDocTOC() {
|
||||
const { frontMatter, toc } = useDoc()
|
||||
const windowSize = useWindowSize()
|
||||
const hidden = frontMatter.hide_table_of_contents
|
||||
const canRender = !hidden && toc.length > 0
|
||||
const mobile = canRender ? <DocItemTOCMobile /> : undefined
|
||||
const desktop
|
||||
= canRender && (windowSize === 'desktop' || windowSize === 'ssr')
|
||||
? (
|
||||
<DocItemTOCDesktop />
|
||||
)
|
||||
: undefined
|
||||
return {
|
||||
hidden,
|
||||
mobile,
|
||||
desktop,
|
||||
}
|
||||
}
|
||||
export default function DocItemLayout({ children }) {
|
||||
const docTOC = useDocTOC()
|
||||
const { metadata } = useDoc()
|
||||
|
||||
// highlight-start
|
||||
const commentElement = useRef(null)
|
||||
|
||||
useEffect(() => {
|
||||
// Update the document title using the browser API
|
||||
let s = document.createElement('script')
|
||||
s.src = 'https://giscus.app/client.js'
|
||||
s.setAttribute('data-repo', '[你的仓库]')
|
||||
s.setAttribute('data-repo-id', '[你的仓库 ID]=')
|
||||
s.setAttribute('data-category', '[你的分类名]')
|
||||
s.setAttribute('data-category-id', '[你的分类 ID]')
|
||||
s.setAttribute('data-mapping', 'pathname')
|
||||
s.setAttribute('data-reactions-enabled', '1')
|
||||
s.setAttribute('data-emit-metadata', '0')
|
||||
s.setAttribute('data-input-position', 'bottom')
|
||||
s.setAttribute('data-theme', document.documentElement.getAttribute('data-theme'))
|
||||
s.setAttribute('data-lang', 'zh-CN')
|
||||
s.setAttribute('crossorigin', 'anonymous')
|
||||
s.async = true
|
||||
commentElement.current.appendChild(s)
|
||||
}, [])
|
||||
// highlight-end
|
||||
|
||||
return (
|
||||
<div className="row">
|
||||
<div className={clsx('col', !docTOC.hidden && styles.docItemCol)}>
|
||||
<ContentVisibility metadata={metadata} />
|
||||
<DocVersionBanner />
|
||||
<div className={styles.docItemContainer}>
|
||||
<article>
|
||||
<DocBreadcrumbs />
|
||||
<DocVersionBadge />
|
||||
{docTOC.mobile}
|
||||
<DocItemContent>{children}</DocItemContent>
|
||||
|
||||
// highlight-start
|
||||
<div style={{ marginTop: '20px' }} ref={commentElement}></div>
|
||||
// highlight-end
|
||||
|
||||
<DocItemFooter />
|
||||
</article>
|
||||
<DocItemPaginator />
|
||||
</div>
|
||||
</div>
|
||||
{docTOC.desktop && <div className="col col--3">{docTOC.desktop}</div>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
After Width: | Height: | Size: 4.6 KiB |
|
After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 8.1 KiB |
|
After Width: | Height: | Size: 83 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 76 KiB |
|
After Width: | Height: | Size: 73 KiB |
|
After Width: | Height: | Size: 75 KiB |
|
After Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 82 KiB |
|
After Width: | Height: | Size: 77 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 76 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 78 KiB |
|
After Width: | Height: | Size: 120 KiB |
|
After Width: | Height: | Size: 121 KiB |
|
After Width: | Height: | Size: 96 KiB |
|
After Width: | Height: | Size: 129 KiB |
|
After Width: | Height: | Size: 469 KiB |
@@ -0,0 +1,5 @@
|
||||
Git:https://git-scm.com/
|
||||
|
||||
Git 是一个免费、开源的分布式版本控制系统,旨在以高效、快速的方式处理从小型到超大型的各种项目。
|
||||
|
||||
Git 的速度非常快,并且拥有庞大的生态系统,包括各种图形界面(GUI)、代码托管服务以及命令行工具。
|
||||
@@ -0,0 +1,135 @@
|
||||
## 安装
|
||||
### windows
|
||||
https://git-scm.com/
|
||||
|
||||
### linux
|
||||
```bash
|
||||
sudo apt install git-all
|
||||
```
|
||||
> https://git-scm.com/book/zh/v2/%E8%B5%B7%E6%AD%A5-%E5%AE%89%E8%A3%85-Git
|
||||
|
||||
都可以使用 `git -v` 检验是否安装成功
|
||||
|
||||
|
||||
## 配置
|
||||
查看当前配置
|
||||
```bash
|
||||
git config --list
|
||||
```
|
||||
|
||||
设置邮箱和用户名
|
||||
```bash
|
||||
git config --global user.name "你的用户名"
|
||||
git config --global user.email "你的邮箱"
|
||||
```
|
||||
|
||||
设置代理
|
||||
```bash
|
||||
git config --global http.proxy http://127.0.0.1:7890
|
||||
git config --global https.proxy http://127.0.0.1:7890
|
||||
```
|
||||
|
||||
取消代理
|
||||
```bash
|
||||
git config --global --unset http.proxy
|
||||
git config --global --unset https.proxy
|
||||
```
|
||||
|
||||
|
||||
|
||||
## 概念
|
||||

|
||||
|
||||
Git 管理代码时,一般会经过这四个地方:
|
||||
- 工作区:放置代码的 目录/文件夹
|
||||
- 暂存区:就是相当于一个临时地方,将代码先放到这里
|
||||
- 本地仓库:电脑的正是仓库,就是相当于将代码正式放到了自己电脑的仓库中,保存代码的历史记录
|
||||
- 远程仓库:网络/云 上的仓库,方便和别人进行协作
|
||||
|
||||
可根据上面的图进行理解
|
||||
|
||||
## 基础操作
|
||||
```bash
|
||||
// 一般只有初始化仓库的时候才会用到
|
||||
git init
|
||||
|
||||
// 1.克隆远程仓库的代码
|
||||
git clone [url]
|
||||
|
||||
// 2.提交自己修改过的代码
|
||||
git add .
|
||||
git commit -m "注释"
|
||||
|
||||
// 3.拉取远程仓库的最新代码
|
||||
git pull
|
||||
|
||||
// 4.将自己的修改推送到远程仓库
|
||||
git push origin master
|
||||
```
|
||||
|
||||
## 命令速查表
|
||||

|
||||
|
||||
|
||||
|
||||
## 子模块
|
||||
|
||||
主仓库就像一个指向子模块的“快捷方式”,它记录了子模块的位置和版本。子模块是一个独立的仓库,存自己的代码和历史,主仓库只知道子模块的位置,不会存实际代码内容。
|
||||
|
||||
简单来说,它们是两个独立的仓库。推送代码时,应该先推送子模块的代码,再推送主仓库的代码,避免跟踪警告。如果你推送了子模块的修改,无论主仓库的代码有没有变化,都需要重新推送一次主仓库,以确保引用更新。
|
||||
|
||||
**添加子模块**
|
||||
|
||||
```bash
|
||||
git submodule add <url> <path>
|
||||
```
|
||||
|
||||
例如:
|
||||
|
||||
```bash
|
||||
git submodule add https://github.com/oneao/docusaurus code/docusaurus
|
||||
```
|
||||
|
||||
添加成功后会在主仓库根目录下生成 `.gitmodules` 文件,该文件内有子模块的信息
|
||||
|
||||
**初始化子模块并获取内容**
|
||||
|
||||
只使用
|
||||
|
||||
```bash
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
需要想修改代码并提交,需要切换到指定的分支
|
||||
```bash
|
||||
git branch
|
||||
|
||||
git checkout master
|
||||
```
|
||||
|
||||
**拉取子模块代码**
|
||||
|
||||
先拉取主仓库代码
|
||||
|
||||
```bash
|
||||
git pull
|
||||
```
|
||||
|
||||
再在主仓库位置更新子模块引用
|
||||
|
||||
```bash
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
然后进入子模块位置
|
||||
```bash
|
||||
git pull
|
||||
```
|
||||
|
||||
**从主仓库中移除子模块**
|
||||
|
||||
```bash
|
||||
git rm --cached code/docusaurus
|
||||
|
||||
// 删除子模块文件夹(如果不需要),提交更改。
|
||||
```
|
||||
@@ -0,0 +1,193 @@
|
||||
## push之前未pull
|
||||
|
||||
报错信息:
|
||||
|
||||
```bash
|
||||
D:\code\test\test1>git push origin master
|
||||
To http://192.168.1.189:8443/r/test.git
|
||||
! [rejected] master -> master (fetch first)
|
||||
error: failed to push some refs to 'http://192.168.1.189:8443/r/test.git'
|
||||
hint: Updates were rejected because the remote contains work that you do not
|
||||
hint: have locally. This is usually caused by another repository pushing to
|
||||
hint: the same ref. If you want to integrate the remote changes, use
|
||||
hint: 'git pull' before pushing again.
|
||||
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
|
||||
```
|
||||
|
||||
解决方法:
|
||||
|
||||
```bash
|
||||
# 先拉取
|
||||
git pull
|
||||
# 后推送
|
||||
git push origin master
|
||||
```
|
||||
|
||||
**注意:** 不要强推,可能覆盖他人修改,一般用不到。
|
||||
|
||||
```bash
|
||||
git push -f origin master
|
||||
```
|
||||
|
||||
## 合并冲突(修改同一文件)
|
||||
当 A 和 B 同时修改了同一文件的时候,本地文件和远程文件发生了冲突。Git 无法自动合并,需要你手动解决冲突。
|
||||
|
||||
例如:
|
||||
|
||||
```bash
|
||||
CONFLICT (content): Merge conflict in a.txt
|
||||
Automatic merge failed; fix conflicts and then commit the result.
|
||||
```
|
||||
|
||||
意思是:
|
||||
|
||||
- Git 在合并文件 `a.txt` 时,发现本地和远程对同一部分代码进行了修改;
|
||||
- 无法判断以哪一方为准,自动合并失败;
|
||||
- 需要你手动处理这个冲突。
|
||||
|
||||
解决方案:
|
||||
|
||||
1. 打开冲突的 `a.txt` 文件,查看里面的内容:
|
||||
|
||||
```
|
||||
<<<<<<< HEAD
|
||||
12 # 这里是 A 修改的
|
||||
=======
|
||||
1 # 这里是 B 修改的
|
||||
2
|
||||
>>>>>>> 6fe1e2d97eae79e0c5080ddea4bdef658841486d
|
||||
```
|
||||
|
||||
2. 手动修改内容,保留需要的部分。例如:
|
||||
|
||||
```
|
||||
12
|
||||
```
|
||||
|
||||
3. 添加修改后的文件:
|
||||
|
||||
```bash
|
||||
git add a.txt
|
||||
|
||||
git commit -m "解决 a.txt 冲突"
|
||||
|
||||
git push origin master
|
||||
```
|
||||
|
||||
## 修改文件但 git status 显示未修改
|
||||
|
||||
可能的原因:
|
||||
|
||||
- 你改的是换行符(LF/CRLF)但内容没变;
|
||||
- 编辑器保存规则设置导致未检测到真实修改;
|
||||
- 文件编码问题或隐藏字符。
|
||||
|
||||
解决方法:
|
||||
|
||||
- 用 `git diff` 检查是否真的修改了;
|
||||
- 也可以尝试先改点内容,再恢复,重新保存。
|
||||
|
||||
## 误删文件
|
||||
### 文件误删并已 add
|
||||
误删了一个文件(比如 `b.txt`),然后执行了:
|
||||
|
||||
```bash
|
||||
git add a.txt
|
||||
```
|
||||
|
||||
- 这时候 Git **把删除操作加入暂存区**,等待 commit。
|
||||
- 文件还没有被 commit,但已经从工作区和暂存区记录为“删除”。
|
||||
|
||||
|
||||
|
||||
**查看哪些文件被误删**
|
||||
|
||||
```bash
|
||||
git status
|
||||
```
|
||||
|
||||
示例输出
|
||||
|
||||
```bash
|
||||
Changes to be committed:
|
||||
(use "git restore --staged <file>..." to unstage)
|
||||
new file: a.txt
|
||||
|
||||
Changes not staged for commit:
|
||||
(use "git add/rm <file>..." to update what will be committed)
|
||||
(use "git restore <file>..." to discard changes in working directory)
|
||||
deleted: a.txt
|
||||
```
|
||||
|
||||
|
||||
|
||||
**恢复文件**
|
||||
|
||||
这会把文件从暂存区移除,但 **不会恢复工作区文件**。
|
||||
|
||||
```bash
|
||||
git restore --staged a.txt
|
||||
```
|
||||
|
||||
这会把文件从最后一次 commit 的版本恢复到工作区。
|
||||
|
||||
```bash
|
||||
git restore a.txt
|
||||
```
|
||||
|
||||
或者可以循环恢复多个误删文件:
|
||||
|
||||
```
|
||||
git restore --staged .
|
||||
git restore .
|
||||
```
|
||||
|
||||
> `git restore .` 会把所有误删且未 commit 的文件恢复。
|
||||
|
||||
### 文件已 commit,误删未 add
|
||||
|
||||
场景说明
|
||||
|
||||
- 文件 **已经被 Git commit**(也就是之前已经被保存到版本历史中)
|
||||
- 你在工作区 **误删了该文件**
|
||||
- **还没有执行 `git add`**
|
||||
|
||||
> 这时候 Git 知道文件原本存在,但工作区已经缺失。
|
||||
|
||||
|
||||
|
||||
**查看被误删的文件**
|
||||
|
||||
```bash
|
||||
git status
|
||||
```
|
||||
|
||||
示例输出:
|
||||
|
||||
```bash
|
||||
Changes not staged for commit:
|
||||
(use "git add/rm <file>..." to update what will be committed)
|
||||
deleted: a.txt
|
||||
```
|
||||
|
||||
> 🔹 `deleted: a.txt` 就是被误删的文件。
|
||||
|
||||
**恢复误删文件(未 add)**
|
||||
|
||||
```bash
|
||||
git restore a.txt
|
||||
```
|
||||
|
||||
> 这会从 **最近一次 commit** 恢复文件到工作区。
|
||||
|
||||
|
||||
|
||||
**检查文件是否恢复成功**
|
||||
|
||||
```
|
||||
git status
|
||||
```
|
||||
|
||||
- 文件会出现在工作区
|
||||
- `git status` 不再显示 `deleted`
|
||||
|
||||
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 945 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
@@ -0,0 +1,70 @@
|
||||
[nvm](https://nvm.uihtm.com/) 全英文也叫node.js version management,是一个nodejs的版本管理工具。nvm和n都是node.js版本管理工具,为了解决node.js各种版本存在不兼容现象可以通过它可以安装和切换不同版本的node.js。
|
||||
|
||||
前往 https://nvm.uihtm.com/doc/download-nvm.html 进行下载安装。
|
||||
|
||||
## Windows 安装
|
||||
|
||||
**配置路径**
|
||||
|
||||
```txt title="nvm/settings.txt"
|
||||
root: D:\devtool\nvm
|
||||
path: D:\devtool\nodejs
|
||||
```
|
||||
|
||||
**配置镜像源**
|
||||
|
||||
```txt title="nvm/settings.txt"
|
||||
node_mirror: http://npmmirror.com/mirrors/node/
|
||||
npm_mirror: http://registry.npmmirror.com/mirrors/npm/
|
||||
```
|
||||
|
||||
打开 cmd 输入 `nvm` 检查是否安装成功
|
||||
|
||||
## Linux 安装
|
||||
执行命令安装
|
||||
```bash
|
||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
|
||||
```
|
||||
|
||||
修改环境变量
|
||||
|
||||
``` bash
|
||||
sudo vim ~/.bashrc
|
||||
```
|
||||
|
||||
新增以下内容
|
||||
|
||||
```
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
||||
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
|
||||
|
||||
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
||||
|
||||
export NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node/
|
||||
export NVM_IOJS_ORG_MIRROR=https://registry.npmmirror.com/mirrors/npm/
|
||||
```
|
||||
|
||||
刷新使环境变量生效
|
||||
|
||||
```bash
|
||||
source ~/.bashrc
|
||||
```
|
||||
|
||||
## 常用命令
|
||||
|
||||
- `nvm ls-remote`:显示远程全部版本
|
||||
- `nvm ls-remote --lts`:显示远程稳定版本
|
||||
- `nvm list available`:查看所有可用的 Node.js 版本
|
||||
- `nvm install <version>`:安装指定版本的 Node.js,例如:`nvm install 8.12.0`
|
||||
- `nvm uninstall <version>`:卸载指定版本的 Node.js,适用于卸载失败时的恢复
|
||||
- `nvm use <version>`:切换到指定的 Node.js 版本,例如 `nvm use 18.16.0`
|
||||
- `nvm list`:查看已安装的 Node.js 版本
|
||||
- `nvm off`:禁用 Node.js 版本管理(不卸载任何东西)
|
||||
- `nvm on`:启用 Node.js 版本管理
|
||||
- `nvm ls`:显示所有已安装的 Node.js 版本
|
||||
- `nvm list available`:显示可以安装的所有 Node.js 版本
|
||||
- `nvm v`:显示当前安装的 nvm 版本
|
||||
- `nvm install stable`:安装最新的稳定版 Node.js
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"label": "包管理器",
|
||||
"position": 3,
|
||||
"link": {
|
||||
"type": "generated-index"
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 75 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 83 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 9.4 KiB |
@@ -0,0 +1,30 @@
|
||||
## 本地证书
|
||||
|
||||
### [mkcer](https://github.com/FiloSottile/mkcert/releases)
|
||||
|
||||
打开 cmd 执行命令
|
||||
|
||||
```bash
|
||||
mkcert-v1.4.4-windows-amd64.exe -install
|
||||
```
|
||||
|
||||
点击 是 即可
|
||||
|
||||

|
||||
|
||||
安装成功后会提示
|
||||
|
||||

|
||||
|
||||
生成证书
|
||||
```bash
|
||||
mkcert-v1.4.4-windows-amd64.exe localhost 127.0.0.1 ::1 192.168.1.131
|
||||
```
|
||||
成功提示
|
||||
|
||||

|
||||
|
||||
这样就成功啦,然后生成的证书在 **mkcert-v1.4.4-windows-amd64.exe** 的同级目录下
|
||||
|
||||
### openssl
|
||||
参考:https://xinyufeng.net/2024/08/16/%E5%9C%A8-Windows-%E4%B8%8A%E7%94%9F%E6%88%90%E6%9C%AC%E5%9C%B0-SSL-%E8%AF%81%E4%B9%A6%E5%B9%B6%E4%BD%BF%E7%94%A8-HTTPS-%E8%AE%BF%E9%97%AE%E6%9C%AC%E5%9C%B0-Nginx-%E6%9C%8D%E5%8A%A1%E5%99%A8/
|
||||
@@ -0,0 +1,94 @@
|
||||
## 安装
|
||||
|
||||
### windows
|
||||
|
||||
https://nginx.org/en/download.html
|
||||
直接下载解压即可
|
||||
|
||||
### linux
|
||||
|
||||
1. 下载(可根据Windows的下载地址查看所需要的版本)
|
||||
```bash
|
||||
wget https://nginx.org/download/nginx-1.28.1.tar.gz
|
||||
```
|
||||
2. 解压
|
||||
```bash
|
||||
sudo tar -zxvf nginx-1.28.1.tar.gz -C /usr/local
|
||||
```
|
||||
3. 进入解压目录下
|
||||
```bash
|
||||
cd /usr/local/nginx-1.28.1
|
||||
```
|
||||
4. 编译
|
||||
|
||||
```bash
|
||||
sudo ./configure --with-http_ssl_module
|
||||
|
||||
sudo make
|
||||
sudo make install
|
||||
```
|
||||
|
||||
> --with-http_ssl_module:开启https
|
||||
> --prefix=/usr/local/nginx:指定安装文件夹
|
||||
|
||||
> 报错 ./configure: error: the HTTP rewrite module requires the PCRE library. Nginx 编译时需要 PCRE 库,这是 Nginx 的 HTTP 重写模块(http_rewrite_module)所依赖的库。解决方法:
|
||||
>
|
||||
>```bash
|
||||
>sudo apt install libpcre3 libpcre3-dev
|
||||
>```
|
||||
|
||||
> 报错 ./configure: error: SSL modules require the OpenSSL library.
|
||||
>```bash
|
||||
>sudo apt install libssl-dev
|
||||
>```
|
||||
|
||||
5. 编译成功后查看nginx的安装位置
|
||||
```bash
|
||||
whereis nginx
|
||||
```
|
||||
6. 进入 `sbin` 目录运行 `nginx`
|
||||
|
||||
常用命令
|
||||
|
||||
```
|
||||
./nginx //启动
|
||||
./nginx -s stop //停止
|
||||
./nginx -s quit //安全退出
|
||||
./nginx -s reload //重载配置文件(修改了配置文件需要执行此命令 比较常用)
|
||||
ps aux|grep nginx //查看ngnix进程
|
||||
```
|
||||
|
||||
## 配置 https
|
||||
|
||||
参考配置
|
||||
|
||||
```
|
||||
#user nobody;
|
||||
worker_processes 1;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
// ...
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name xxx.xx;
|
||||
|
||||
ssl_certificate /usr/local/nginx/https/xxx.xx_bundle.crt;
|
||||
ssl_certificate_key /usr/local/nginx/https/xxx.xx.key;
|
||||
|
||||
ssl_session_cache shared:SSL:1m;
|
||||
ssl_session_timeout 5m;
|
||||
|
||||
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
location / {
|
||||
root html;
|
||||
index index.html index.htm;
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||