完善后台的图标库引用逻辑和在线图标库的引用
This commit is contained in:
@@ -57,9 +57,9 @@ npm install
|
||||
go mod download
|
||||
```
|
||||
|
||||
#### 3. 生成Ent代码(必须)
|
||||
#### 3. 生成 Ent 代码(仅修改 Schema 后)
|
||||
|
||||
**重要:** 在运行项目之前,必须先生成Ent代码,否则Go代码无法编译。
|
||||
生成后的 Ent 源码已提交到仓库,普通运行和构建不需要重复生成。只有修改 `internal/ent/schema` 后才运行:
|
||||
|
||||
```bash
|
||||
# 进入ent目录
|
||||
@@ -72,21 +72,11 @@ go generate ./...
|
||||
cd ../..
|
||||
```
|
||||
|
||||
**如果遇到版本兼容性错误**(如 `invalid array length` 或 `Deprecated undefined`),使用:
|
||||
```bash
|
||||
cd internal/ent
|
||||
# 使用与go.mod一致的版本(当前是v0.13.1)
|
||||
go run -mod=mod entgo.io/ent/cmd/ent@v0.13.1 generate ./schema
|
||||
cd ../..
|
||||
```
|
||||
|
||||
**重要**:版本号必须与 `go.mod` 中的 `entgo.io/ent` 版本一致。
|
||||
|
||||
**说明:**
|
||||
- `go generate` 是Go的内置命令,用于运行代码生成工具
|
||||
- `./...` 表示当前目录及所有子目录
|
||||
- 这会根据 `schema/` 目录中的定义生成Ent ORM代码
|
||||
- 如果Go版本较新(如go1.25+),可能需要使用 `go run` 方式
|
||||
- 生成器使用 `go.mod` 中固定的 Ent 版本,不会使用 `@latest`
|
||||
|
||||
#### 4. 运行项目
|
||||
|
||||
@@ -132,26 +122,14 @@ chcp 65001
|
||||
|
||||
#### 5. 构建部署
|
||||
|
||||
**构建Go后端(Linux):**
|
||||
**构建 Linux 单文件程序:**
|
||||
```bash
|
||||
# 生成Ent代码(必须)
|
||||
cd internal/ent
|
||||
go generate ./...
|
||||
cd ../..
|
||||
|
||||
# 构建Linux二进制文件
|
||||
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o home-vue-go main.go
|
||||
make build-linux
|
||||
```
|
||||
|
||||
**构建Go后端(Windows):**
|
||||
```bash
|
||||
# 生成Ent代码(必须)
|
||||
cd internal\ent
|
||||
go generate ./...
|
||||
cd ..\..
|
||||
|
||||
# 构建Windows二进制文件
|
||||
go build -o home-vue-go.exe main.go
|
||||
**构建 Windows 单文件程序:**
|
||||
```powershell
|
||||
make build-windows
|
||||
```
|
||||
|
||||
**构建前端:**
|
||||
@@ -166,7 +144,7 @@ npm run build
|
||||
|
||||
**说明:**
|
||||
- `go build` 编译Go程序为二进制文件
|
||||
- `CGO_ENABLED=1` 启用CGO(SQLite需要)
|
||||
- SQLite 使用纯 Go 驱动,构建不需要 CGO 或 GCC
|
||||
- `GOOS=linux GOARCH=amd64` 指定目标平台和架构
|
||||
- `-o` 指定输出文件名
|
||||
|
||||
@@ -257,10 +235,10 @@ cd internal/ent && go generate ./... && cd ../..
|
||||
go run main.go
|
||||
|
||||
# 构建后端(当前平台)
|
||||
go build -o home-vue-go main.go
|
||||
CGO_ENABLED=0 go build -o home-vue-go .
|
||||
|
||||
# 构建后端(Linux)
|
||||
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o home-vue-go main.go
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o home-vue-go .
|
||||
|
||||
# 查看Go版本
|
||||
go version
|
||||
|
||||
Reference in New Issue
Block a user