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

更新了readme

parent f28254f9
# React + TypeScript + Vite
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
## Expanding the ESLint configuration
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
```js
export default tseslint.config({
extends: [
// Remove ...tseslint.configs.recommended and replace with this
...tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
...tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
...tseslint.configs.stylisticTypeChecked,
],
languageOptions: {
// other options...
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
},
})
# INTERN PROJECT FRONTEND
## 前端编辑方式
### 修改方式
使用 npm run dev 即可实时跟随修改。
主要逻辑在 App.tsx 当中。
如果需要修改逻辑,直接改正 App.tsx 的各个部分即可。
### 打包方式
调用 npm run build 即可打包。
打包后的文件在dist文件夹。
如果打包之后的html打开不显示,可以:
- 把生成后的index.html打开
- 把js和css移至与html同目录下面
- 把html当中引用js和css的路径修正
- 去掉crossorigin字样
- 把script段从head移到body,并去掉type = "module"
## 后端对接
在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:
```js
// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'
export default tseslint.config({
plugins: {
// Add the react-x and react-dom plugins
'react-x': reactX,
'react-dom': reactDom,
},
rules: {
// other rules...
// Enable its recommended typescript rules
...reactX.configs['recommended-typescript'].rules,
...reactDom.configs.recommended.rules,
},
})
后端返回的response:
```json
{
"code": 0, // 0表示成功,其他表示失败
"msg": "success", // 返回信息
"data":
{
"id": int, // 评论ID
"name": "string", // 评论者名字
"content": "string" // 评论内容
}
}
```
### 删除评论:
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