Files
wk-backend/README.md
2026-04-03 14:24:29 +08:00

110 lines
2.9 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 刷课平台后端
### 功能实现
- 登录
- 获取课程列表
- 获取网课记录
- 学习接口
### 拉取代码
```shell
git clone --recurse-submodules https://gitea.kmux.cn/cqcst/wk-backend
```
更新已有仓库时,建议带上 submodule 一起同步:
```shell
git pull --recurse-submodules
task fe:sync
```
如果前端仓库 `wk-frontend` 有新提交,需要把主仓库里的 submodule 指针更新到最新:
```shell
task fe:update
git status
```
### 代码构建
**推荐使用 [Taskfile](https://taskfile.dev/) 进行项目构建**
可通过环境变量配置本地代理 / 跳过 SSL 校验,但只有在设置页手动开启调试后才会生效:
```shell
CKWK_DEBUG_PROXY=http://127.0.0.1:9000
CKWK_DEBUG_SKIP_SSL_VERIFY=true
```
也可以通过环境变量让后端启动时默认开启调试:
```shell
CKWK_DEBUG_ENABLED=true
```
调试日志 WS 在后端调试已开启时可用,连接地址:
```shell
ws://127.0.0.1:8080/api/debug/logs/ws
```
调试日志快照和下载接口:
```shell
GET /api/debug/logs
GET /api/debug/logs/download
```
服务端会保留最近 1000 条内存日志,并持续推送新的入站 HTTP、出站请求和应用日志。
- 支持命令
```
* fe:sync: 同步前端 submodule 🔁
* fe:update: 拉取前端 submodule 最新提交 ⬆️
* build: 构建前端 + 后端 📦
* dev: 同时启动前后端(开发模式)🔥
* rebuild: 清理并重建 🔁
* release: 构建多平台二进制 🌍
* upx: 压缩二进制文件 (智能跳过 macOS 和 Windows ARM)
* be:build: 构建后端二进制 🔨
* be:run: 启动后端服务 🧠
* dev:be: 只启动后端(配合前端 dev
* fe:build: 构建前端 🏗️
* fe:clean: 清理前端构建产物 🧹
* fe:dev: 启动前端开发服务器 🚀
* fe:install: 安装前端依赖 📦
```
### 项目结构
- 目录
**前端项目地址: [wk-frontend](https://gitea.kmux.cn/cqcst/wk-frontend)**
```
.
├── Taskfile.yml # taskfile 命令定义
├── bin # 输出目录
├── cmd # 启动入口
├── go.mod
├── go.sum
├── internal
│   ├── ckwk # 网课接口
│   ├── conf # 项目配置
│   ├── dto # 请求响应实体
│   ├── handler # 控制层
│   ├── middleware # 中间件
│   ├── router # 路由定义
│   └── schedule # 定时任务
├── pkg
│   ├── common # 通用工具
│   ├── log # 日志
│   └── request # 请求库
└── web
├── frontend # 存放前端项目
└── web.go # 构建时读取前端输出目录
```