Commit 1e3069f5 authored by IronHammer Std's avatar IronHammer Std
Browse files

更新了readme

parent f28254f9
# React + TypeScript + Vite
# INTERN PROJECT FRONTEND
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
## 前端编辑方式
Currently, two official plugins are available:
### 修改方式
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh 使用 npm run dev 即可实时跟随修改。
## Expanding the ESLint configuration 主要逻辑在 App.tsx 当中。
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules: 如果需要修改逻辑,直接改正 App.tsx 的各个部分即可。
```js ### 打包方式
export default tseslint.config({
extends: [ 调用 npm run build 即可打包。
// Remove ...tseslint.configs.recommended and replace with this
...tseslint.configs.recommendedTypeChecked, 打包后的文件在dist文件夹。
// Alternatively, use this for stricter rules
...tseslint.configs.strictTypeChecked, 如果打包之后的html打开不显示,可以:
// Optionally, add this for stylistic rules - 把生成后的index.html打开
...tseslint.configs.stylisticTypeChecked, - 把js和css移至与html同目录下面
], - 把html当中引用js和css的路径修正
languageOptions: { - 去掉crossorigin字样
// other options... - 把script段从head移到body,并去掉type = "module"
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'], ## 后端对接
tsconfigRootDir: import.meta.dirname,
}, 在app.tsx当中硬编码了使用8080端口。可以在其中修改到实际使用的端口上面。
},
}) 后端对接部分与接口文档一致。具体内容如下:
设后端正确配置后,在8080端口上打开了后端服务(http://localhost:8080)。
### 获取评论:
URL:
- 部分获取: http://localhost:8080/comment/get?page={待请求的页码,从1开始计数}&size={每页大小}
- 获取全部: http://localhost:8080/comment/get?size=-1
方法:GET
header:无需
body: 无需
后端返回的response:
```json
{
"code": 0, // 0表示成功,其他表示失败
"msg": "success", // 返回信息
"data":
{
"total": int, //评论的总数,无论请求参数是什么
"comments":
[
{
"id": int, // 评论ID
"name": "string", // 评论者名字
"content": "string", // 评论内容
}
]
}
}
```
### 添加评论:
URL: http://localhost:8080/comment/add
方法:POST
header:
```json
{"Content-Type": "application/json"}
```
body:
```json
{
"name": "string", // 评论者名字
"content": "string" // 评论内容
}
``` ```
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules: 后端返回的response:
```json
```js {
// eslint.config.js "code": 0, // 0表示成功,其他表示失败
import reactX from 'eslint-plugin-react-x' "msg": "success", // 返回信息
import reactDom from 'eslint-plugin-react-dom' "data":
{
export default tseslint.config({ "id": int, // 评论ID
plugins: { "name": "string", // 评论者名字
// Add the react-x and react-dom plugins "content": "string" // 评论内容
'react-x': reactX, }
'react-dom': reactDom, }
},
rules: {
// other rules...
// Enable its recommended typescript rules
...reactX.configs['recommended-typescript'].rules,
...reactDom.configs.recommended.rules,
},
})
``` ```
### 删除评论:
URL: http://localhost:8080/comment/delete?id={待删除的评论id}
方法:POST
header:无需
body: 无需
后端返回的response:
```json
{
"code": 0, // 0表示成功,其他表示失败
"msg": "success", // 返回信息
"data": null
}
```
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment