From 2fa83d53a4b99852dd01f8d1365b4c1597f5474e Mon Sep 17 00:00:00 2001 From: Connor <963408438@qq.com> Date: Mon, 12 Jan 2026 17:44:12 +0800 Subject: [PATCH] =?UTF-8?q?README=20=E6=96=87=E4=BB=B6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 38 +++++++++++++++++++++++++++++-------- configs/config.example.yaml | 14 +++++++------- pkg/utils/random.go | 28 --------------------------- 3 files changed, 37 insertions(+), 43 deletions(-) delete mode 100644 pkg/utils/random.go diff --git a/README.md b/README.md index 0129466..dc3071f 100644 --- a/README.md +++ b/README.md @@ -164,32 +164,54 @@ ffmpeg -version ### ⚙️ 配置文件 -编辑 `configs/config.yaml`: +复制并编辑配置文件: + +```bash +cp configs/config.example.yaml configs/config.yaml +vim configs/config.yaml +``` + +配置文件格式(`configs/config.yaml`): ```yaml app: - name: "Huobao Drama" - mode: "development" # development / production + name: "Huobao Drama API" + version: "1.0.0" + debug: true # 开发环境设为true,生产环境设为false + +server: port: 5678 + host: "0.0.0.0" + cors_origins: + - "http://localhost:3012" + read_timeout: 600 + write_timeout: 600 database: type: "sqlite" path: "./data/drama_generator.db" + max_idle: 10 + max_open: 100 storage: type: "local" local_path: "./data/storage" base_url: "http://localhost:5678/static" -logging: - level: "info" - output: "stdout" +ai: + default_text_provider: "openai" + default_image_provider: "openai" + default_video_provider: "doubao" ``` **重要配置项:** -- `ai.doubao.api_key`: 豆包AI的API密钥(**必需**) +- `app.debug`: 调试模式开关(开发环境建议设为true) +- `server.port`: 服务运行端口 +- `server.cors_origins`: 允许跨域访问的前端地址 +- `database.path`: SQLite数据库文件路径 - `storage.local_path`: 本地文件存储路径 -- `app.port`: 服务运行端口 +- `storage.base_url`: 静态资源访问URL +- `ai.default_*_provider`: AI服务提供商配置(在Web界面中配置具体的API Key) ### 📥 安装依赖 diff --git a/configs/config.example.yaml b/configs/config.example.yaml index ae972ac..ae25c33 100644 --- a/configs/config.example.yaml +++ b/configs/config.example.yaml @@ -1,26 +1,26 @@ app: - name: "Drama Generator" + name: "Huobao Drama API" version: "1.0.0" - debug: false + debug: true server: - port: 8080 + port: 5678 host: "0.0.0.0" cors_origins: - - "http://localhost:8080" + - "http://localhost:3012" read_timeout: 600 write_timeout: 600 database: type: "sqlite" - path: "/data/drama.db" + path: "./data/drama_generator.db" max_idle: 10 max_open: 100 storage: type: "local" - local_path: "/data/storage" - base_url: "http://localhost:8080/static" + local_path: "./data/storage" + base_url: "http://localhost:5678/static" ai: default_text_provider: "openai" diff --git a/pkg/utils/random.go b/pkg/utils/random.go deleted file mode 100644 index c6d4110..0000000 --- a/pkg/utils/random.go +++ /dev/null @@ -1,28 +0,0 @@ -package utils - -import ( - "math/rand" - "time" -) - -func init() { - rand.Seed(time.Now().UnixNano()) -} - -func GenerateVerificationCode(length int) string { - digits := "0123456789" - code := make([]byte, length) - for i := range code { - code[i] = digits[rand.Intn(len(digits))] - } - return string(code) -} - -func GenerateRandomString(length int) string { - chars := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" - result := make([]byte, length) - for i := range result { - result[i] = chars[rand.Intn(len(chars))] - } - return string(result) -}