PicGo-Core 使用教程
1. 项目的目录结构及介绍
PicGo-Core 是一个用于图片上传的工具,支持 CLI 和 API 调用。以下是其主要目录结构及其功能介绍:
PicGo-Core/
├── bin/
│ └── picgo
├── docs/
│ └── ...
├── src/
│ ├── commands/
│ ├── core/
│ ├── plugins/
│ └── utils/
├── test/
│ └── ...
├── .gitignore
├── LICENSE
├── package.json
├── README.md
└── tsconfig.json
- bin/: 包含可执行文件
picgo
,用于命令行调用。 - docs/: 包含项目文档。
- src/: 源代码目录,包含命令、核心逻辑、插件和工具函数。
- commands/: 命令行相关的代码。
- core/: 核心逻辑代码。
- plugins/: 插件相关的代码。
- utils/: 工具函数。
- test/: 测试代码。
- .gitignore: Git 忽略文件。
- LICENSE: 项目许可证。
- package.json: 项目依赖和脚本配置。
- README.md: 项目介绍文档。
- tsconfig.json: TypeScript 配置文件。
2. 项目的启动文件介绍
PicGo-Core 的启动文件位于 bin/
目录下,名为 picgo
。这个文件是一个可执行脚本,用于启动 PicGo-Core 的命令行接口。
#!/usr/bin/env node
require('../dist/index.js')
该脚本使用 Node.js 环境运行,加载 dist/index.js
文件,这是编译后的 TypeScript 代码入口。
3. 项目的配置文件介绍
PicGo-Core 的配置文件默认位于用户目录下的 .picgo/config.json
。以下是一个典型的配置文件示例:
{
"picBed": {
"current": "github",
"github": {
"repo": "Anonymous772066235/Typora_Images",
"branch": "main",
"token": "***",
"path": "img/",
"customUrl": "https://github.com/Anonymous772066235/Typora_Images/raw/main"
},
"uploader": "github",
"transformer": "path"
},
"picgoPlugins": {
"picgo-plugin-github-plus": true
}
}
- picBed: 图片上传配置。
- current: 当前使用的上传方式。
- github: GitHub 上传配置。
- repo: 仓库名。
- branch: 分支名。
- token: GitHub 访问令牌。
- path: 仓库内文件路径。
- customUrl: 自定义图片 URL。
- uploader: 上传器类型。
- transformer: 转换器类型。
- picgoPlugins: 插件配置。
通过修改这个配置文件,可以自定义图片上传的方式和目标。