Titter 项目教程
titter Decentralized Twitter prototype built with Polygon, GraphQL, Next.js, Ceramic, Arweave, and Bundlr 项目地址: https://gitcode.com/gh_mirrors/ti/titter
1. 项目目录结构及介绍
titter/
├── public/
│ ├── index.html
│ └── favicon.ico
├── src/
│ ├── assets/
│ ├── components/
│ ├── pages/
│ ├── App.js
│ ├── index.js
│ └── routes.js
├── .env
├── .gitignore
├── package.json
├── README.md
└── yarn.lock
目录结构介绍
- public/: 存放静态文件,如
index.html
和 favicon.ico
。 - src/: 项目的源代码目录。
- assets/: 存放图片、样式等资源文件。
- components/: 存放 React 组件。
- pages/: 存放页面组件。
- App.js: 应用的主组件。
- index.js: 应用的入口文件。
- routes.js: 路由配置文件。
- .env: 环境变量配置文件。
- .gitignore: Git 忽略文件配置。
- package.json: 项目依赖和脚本配置。
- README.md: 项目说明文档。
- yarn.lock: Yarn 包管理器生成的锁定文件。
2. 项目启动文件介绍
src/index.js
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(<App />, document.getElementById('root'));
文件介绍
- ReactDOM.render: 将
App
组件渲染到 index.html
中的 root
元素。 - App: 应用的主组件,包含了整个应用的逻辑和结构。
3. 项目配置文件介绍
.env
REACT_APP_API_URL=https://api.example.com
文件介绍
- REACT_APP_API_URL: 定义了应用的 API 地址,可以在代码中通过
process.env.REACT_APP_API_URL
访问。
package.json
{
"name": "titter",
"version": "1.0.0",
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"dependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3"
}
}
文件介绍
- scripts: 定义了项目的脚本命令。
- start: 启动开发服务器。
- build: 构建生产环境代码。
- test: 运行测试。
- eject: 弹出配置文件(不可逆操作)。
- dependencies: 项目依赖的包。
- react: React 库。
- react-dom: React DOM 库。
- react-scripts: Create React App 提供的脚本工具。
titter Decentralized Twitter prototype built with Polygon, GraphQL, Next.js, Ceramic, Arweave, and Bundlr 项目地址: https://gitcode.com/gh_mirrors/ti/titter