feat: 增加端映射设置
This commit is contained in:
parent
3af47d48cf
commit
fb66af9154
14
README.md
14
README.md
|
|
@ -8,13 +8,6 @@
|
|||
### 1. 克隆并安装后端
|
||||
|
||||
```bash
|
||||
cd Nano-Claw
|
||||
|
||||
# 创建虚拟环境
|
||||
python -m venv .venv
|
||||
source .venv/bin/activate # Windows: .venv\Scripts\activate
|
||||
|
||||
# 安装依赖
|
||||
pip install -e .
|
||||
```
|
||||
|
||||
|
|
@ -23,6 +16,10 @@ pip install -e .
|
|||
创建并编辑 `config.yml`,填入你的信息:
|
||||
|
||||
```yaml
|
||||
# Port
|
||||
backend_port: 3000
|
||||
frontend_port: 4000
|
||||
|
||||
# GLM API
|
||||
api_key: your-api-key-here
|
||||
api_url: https://open.bigmodel.cn/api/paas/v4/chat/completions
|
||||
|
|
@ -45,7 +42,7 @@ mysql -u root -p -e "CREATE DATABASE glm_chat CHARACTER SET utf8mb4 COLLATE utf8
|
|||
### 4. 启动后端
|
||||
|
||||
```bash
|
||||
flask --app backend run --port 5000
|
||||
python -m backend.run
|
||||
```
|
||||
|
||||
### 5. 启动前端
|
||||
|
|
@ -56,7 +53,6 @@ npm install
|
|||
npm run dev
|
||||
```
|
||||
|
||||
打开 http://localhost:3000 即可使用。
|
||||
|
||||
## 项目结构
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
from backend import create_app
|
||||
from backend import create_app, load_config
|
||||
|
||||
app = create_app()
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(debug=True, port=5000)
|
||||
cfg = load_config()
|
||||
app.run(debug=True, port=cfg.get("backend_port"))
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^5.2.0",
|
||||
"js-yaml": "^4.1.1",
|
||||
"vite": "^6.0.0"
|
||||
}
|
||||
},
|
||||
|
|
@ -982,6 +983,13 @@
|
|||
"integrity": "sha512-YXgQ7JjaO18NeK2K9VTbDHaFy62WrObMa6XERNfNOkAhD1F1oDSf3ZJ7K6GqabZ0BvSDHajp8qfS5Sa2I9n8uQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/argparse": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/argparse/-/argparse-2.0.1.tgz",
|
||||
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
|
||||
"dev": true,
|
||||
"license": "Python-2.0"
|
||||
},
|
||||
"node_modules/csstype": {
|
||||
"version": "3.2.3",
|
||||
"resolved": "https://registry.npmmirror.com/csstype/-/csstype-3.2.3.tgz",
|
||||
|
|
@ -1090,6 +1098,19 @@
|
|||
"node": ">=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/js-yaml": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmmirror.com/js-yaml/-/js-yaml-4.1.1.tgz",
|
||||
"integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"argparse": "^2.0.1"
|
||||
},
|
||||
"bin": {
|
||||
"js-yaml": "bin/js-yaml.js"
|
||||
}
|
||||
},
|
||||
"node_modules/magic-string": {
|
||||
"version": "0.30.21",
|
||||
"resolved": "https://registry.npmmirror.com/magic-string/-/magic-string-0.30.21.tgz",
|
||||
|
|
|
|||
|
|
@ -9,12 +9,13 @@
|
|||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"vue": "^3.4.0",
|
||||
"highlight.js": "^11.10.0",
|
||||
"marked": "^15.0.0",
|
||||
"highlight.js": "^11.10.0"
|
||||
"vue": "^3.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^5.2.0",
|
||||
"js-yaml": "^4.1.1",
|
||||
"vite": "^6.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,24 @@
|
|||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import fs from 'fs'
|
||||
import yaml from 'js-yaml'
|
||||
import { fileURLToPath } from 'url'
|
||||
import { dirname, resolve } from 'path'
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url)
|
||||
const __dirname = dirname(__filename)
|
||||
|
||||
const config = yaml.load(
|
||||
fs.readFileSync(resolve(__dirname, '..', 'config.yml'), 'utf-8')
|
||||
)
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
server: {
|
||||
port: 3000,
|
||||
port: config.frontend_port,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:5000',
|
||||
target: `http://localhost:${config.backend_port}`,
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue