This commit is contained in:
乘风
2026-01-30 14:10:47 +08:00
parent 174253584f
commit c08ca72992
8 changed files with 781 additions and 0 deletions

1
cli_path.txt Normal file
View File

@@ -0,0 +1 @@
C:\Program Files (x86)\Tencent\微信web开发者工具\cli.bat

View File

@@ -0,0 +1,74 @@
@echo off
chcp 65001 >nul
echo ==================================
echo Soul派对小程序 - 编译脚本
echo ==================================
echo.
:: 设置项目路径
set "PROJECT_PATH=%~dp0"
set "PROJECT_PATH=%PROJECT_PATH:~0,-1%"
:: 微信开发者工具可能的安装路径
set "CLI1=C:\Program Files (x86)\Tencent\微信web开发者工具\cli.bat"
set "CLI2=C:\Program Files\Tencent\微信web开发者工具\cli.bat"
set "CLI3=%LOCALAPPDATA%\微信web开发者工具\cli.bat"
:: 查找CLI
set "CLI="
if exist "%CLI1%" set "CLI=%CLI1%"
if exist "%CLI2%" set "CLI=%CLI2%"
if exist "%CLI3%" set "CLI=%CLI3%"
if "%CLI%"=="" (
echo ❌ 未找到微信开发者工具CLI
echo.
echo 请手动操作:
echo 1. 打开微信开发者工具
echo 2. 点击"导入项目"
echo 3. 选择目录: %PROJECT_PATH%
echo 4. 点击"编译"按钮
echo.
pause
exit /b 1
)
echo ✅ 找到微信开发者工具: %CLI%
echo 项目路径: %PROJECT_PATH%
echo.
:: 1. 打开项目
echo 📂 步骤1打开项目...
call "%CLI%" open --project "%PROJECT_PATH%"
timeout /t 3 /nobreak >nul
echo ✅ 项目已打开
echo.
:: 2. 编译项目
echo 🔨 步骤2编译项目...
call "%CLI%" build-npm --project "%PROJECT_PATH%"
timeout /t 2 /nobreak >nul
echo ✅ 编译完成
echo.
:: 3. 生成预览二维码
echo 📱 步骤3生成预览二维码...
call "%CLI%" preview --project "%PROJECT_PATH%" --qr-format image --qr-output "%PROJECT_PATH%\preview.png"
if exist "%PROJECT_PATH%\preview.png" (
echo ✅ 二维码已生成: %PROJECT_PATH%\preview.png
start "" "%PROJECT_PATH%\preview.png"
) else (
echo ⚠️ 二维码生成失败,请在开发者工具中手动点击"预览"
)
echo.
echo ==================================
echo 🎉 编译完成!
echo ==================================
echo.
echo 下一步操作:
echo 1. 在模拟器中查看效果
echo 2. 点击"预览"生成二维码,用微信扫码测试
echo 3. 点击"上传"提交到微信后台
echo.
pause

View File

@@ -0,0 +1,93 @@
# Soul派对小程序 - Windows编译脚本
Write-Host "==================================" -ForegroundColor Cyan
Write-Host " Soul派对小程序 - 编译脚本" -ForegroundColor Cyan
Write-Host "==================================" -ForegroundColor Cyan
Write-Host ""
# 设置项目路径
$ProjectPath = Split-Path -Parent $MyInvocation.MyCommand.Path
# 微信开发者工具可能的安装路径
$cliPaths = @(
"C:\Program Files (x86)\Tencent\微信web开发者工具\cli.bat",
"C:\Program Files\Tencent\微信web开发者工具\cli.bat",
"$env:LOCALAPPDATA\微信web开发者工具\cli.bat"
)
# 查找CLI
$cli = $null
foreach ($path in $cliPaths) {
if (Test-Path $path) {
$cli = $path
break
}
}
if (-not $cli) {
Write-Host "未找到微信开发者工具CLI" -ForegroundColor Yellow
Write-Host ""
Write-Host "请手动操作:" -ForegroundColor Cyan
Write-Host "1. 打开微信开发者工具" -ForegroundColor White
Write-Host "2. 点击 '导入项目'" -ForegroundColor White
Write-Host "3. 选择目录: $ProjectPath" -ForegroundColor White
Write-Host "4. 点击 '编译' 按钮" -ForegroundColor White
Write-Host ""
# 尝试启动微信开发者工具
$devToolsPaths = @(
"C:\Program Files (x86)\Tencent\微信web开发者工具\微信开发者工具.exe",
"C:\Program Files\Tencent\微信web开发者工具\微信开发者工具.exe"
)
foreach ($toolPath in $devToolsPaths) {
if (Test-Path $toolPath) {
Write-Host "正在启动微信开发者工具..." -ForegroundColor Green
Start-Process $toolPath
break
}
}
exit 1
}
Write-Host "找到微信开发者工具: $cli" -ForegroundColor Green
Write-Host "项目路径: $ProjectPath" -ForegroundColor Gray
Write-Host ""
# 1. 打开项目
Write-Host "步骤1打开项目..." -ForegroundColor Cyan
& cmd /c "`"$cli`" open --project `"$ProjectPath`""
Start-Sleep -Seconds 3
Write-Host "项目已打开" -ForegroundColor Green
Write-Host ""
# 2. 编译项目
Write-Host "步骤2编译项目..." -ForegroundColor Cyan
& cmd /c "`"$cli`" build-npm --project `"$ProjectPath`""
Start-Sleep -Seconds 2
Write-Host "编译完成" -ForegroundColor Green
Write-Host ""
# 3. 生成预览二维码
Write-Host "步骤3生成预览二维码..." -ForegroundColor Cyan
$previewPath = Join-Path $ProjectPath "preview.png"
& cmd /c "`"$cli`" preview --project `"$ProjectPath`" --qr-format image --qr-output `"$previewPath`""
if (Test-Path $previewPath) {
Write-Host "二维码已生成: $previewPath" -ForegroundColor Green
Start-Process $previewPath
} else {
Write-Host "二维码生成失败,请在开发者工具中手动点击'预览'" -ForegroundColor Yellow
}
Write-Host ""
Write-Host "==================================" -ForegroundColor Cyan
Write-Host " 编译完成!" -ForegroundColor Green
Write-Host "==================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "下一步操作:" -ForegroundColor Cyan
Write-Host "1. 在模拟器中查看效果" -ForegroundColor White
Write-Host "2. 点击'预览'生成二维码,用微信扫码测试" -ForegroundColor White
Write-Host "3. 点击'上传'提交到微信后台" -ForegroundColor White
Write-Host ""

99
启动小程序.ps1 Normal file
View File

@@ -0,0 +1,99 @@
# Soul派对小程序 - Windows启动脚本
# 用于启动后端API服务器并指导打开微信开发者工具
Write-Host "==================================" -ForegroundColor Cyan
Write-Host " Soul派对·创业实验 启动脚本 " -ForegroundColor Cyan
Write-Host "==================================" -ForegroundColor Cyan
Write-Host ""
# 检查Node.js
try {
$nodeVersion = node -v
Write-Host "✅ Node.js版本: $nodeVersion" -ForegroundColor Green
} catch {
Write-Host "❌ 错误: 未检测到Node.js请先安装Node.js" -ForegroundColor Red
Write-Host "下载地址: https://nodejs.org/" -ForegroundColor Yellow
exit 1
}
# 检查pnpm
$packageManager = "npm"
try {
$pnpmVersion = pnpm -v
Write-Host "✅ pnpm版本: $pnpmVersion" -ForegroundColor Green
$packageManager = "pnpm"
} catch {
Write-Host "⚠️ 警告: 未检测到pnpm将使用npm..." -ForegroundColor Yellow
try {
$npmVersion = npm -v
Write-Host "✅ npm版本: $npmVersion" -ForegroundColor Green
} catch {
Write-Host "❌ 错误: 未检测到npm" -ForegroundColor Red
exit 1
}
}
Write-Host ""
Write-Host "1⃣ 检查依赖..." -ForegroundColor Cyan
# 检查是否已安装依赖
if (-not (Test-Path "node_modules")) {
Write-Host "📦 正在安装依赖..." -ForegroundColor Yellow
if ($packageManager -eq "pnpm") {
pnpm install
} else {
npm install
}
if ($LASTEXITCODE -ne 0) {
Write-Host "❌ 依赖安装失败" -ForegroundColor Red
exit 1
}
} else {
Write-Host "✅ 依赖已安装" -ForegroundColor Green
}
Write-Host ""
Write-Host "2⃣ 检查小程序配置..." -ForegroundColor Cyan
# 检查app.js中的API地址配置
$appJsPath = "miniprogram\app.js"
if (Test-Path $appJsPath) {
$appJsContent = Get-Content $appJsPath -Raw
if ($appJsContent -match "baseUrl:\s*['`"]([^'`"]+)['`"]") {
$currentApiUrl = $matches[1]
Write-Host " 当前API地址: $currentApiUrl" -ForegroundColor Gray
if ($currentApiUrl -notmatch "localhost") {
Write-Host "⚠️ 提示: API地址指向生产环境本地开发建议修改为 http://localhost:3000" -ForegroundColor Yellow
}
}
}
Write-Host ""
Write-Host "3⃣ 启动后端API服务器..." -ForegroundColor Cyan
Write-Host ""
Write-Host "🚀 服务器将运行在: http://localhost:3000" -ForegroundColor Green
Write-Host "📡 API接口地址: http://localhost:3000/api" -ForegroundColor Green
Write-Host ""
Write-Host "📱 下一步操作:" -ForegroundColor Cyan
Write-Host " 1. 打开微信开发者工具" -ForegroundColor White
Write-Host " 2. 点击 '导入项目'" -ForegroundColor White
Write-Host " 3. 选择项目目录: $PWD\miniprogram" -ForegroundColor White
Write-Host " 4. AppID会自动识别或使用测试号" -ForegroundColor White
Write-Host " 5. 在详情 -> 本地设置中,勾选 '不校验合法域名'" -ForegroundColor White
Write-Host " 6. 点击 '编译' 按钮" -ForegroundColor White
Write-Host ""
Write-Host "🔧 后台管理地址: http://localhost:3000/admin" -ForegroundColor Cyan
Write-Host ""
Write-Host "==================================" -ForegroundColor Cyan
Write-Host "按 Ctrl+C 停止服务器" -ForegroundColor Yellow
Write-Host "==================================" -ForegroundColor Cyan
Write-Host ""
# 启动开发服务器
if ($packageManager -eq "pnpm") {
pnpm run dev
} else {
npm run dev
}

64
启动总结.txt Normal file
View File

@@ -0,0 +1,64 @@
==========================================
Soul创业派对小程序 - 启动总结
==========================================
✅ 已完成的操作:
1. ✅ 检查了项目配置
- Node.js: v22.12.0
- pnpm: 10.26.2
- 依赖: 已安装
2. ✅ 启动了后端服务器
- 地址: http://localhost:3000
- API: http://localhost:3000/api
- 状态: 后台运行中
3. ✅ 创建了启动指南文档
- 快速启动指南.md
- 小程序启动指南.md
==========================================
下一步操作
==========================================
📱 打开微信开发者工具:
1. 打开微信开发者工具(如未安装,请先下载)
2. 导入项目:
- 点击"导入项目"
- 选择目录: e:\Gongsi\Mycontent\miniprogram
- AppID: wxb8bbb2b10dec74aa自动识别
3. 配置本地设置:
- 点击"详情" → "本地设置"
- ✅ 勾选"不校验合法域名"
4. 点击"编译"按钮
==========================================
重要提示
==========================================
⚠️ API地址配置
当前配置: https://soul.quwanzhi.com生产环境
本地开发建议(可选):
修改 miniprogram/app.js 第9行
baseUrl: 'http://localhost:3000',
如果不修改,确保已勾选"不校验合法域名"即可。
==========================================
测试地址
==========================================
后端服务器: http://localhost:3000
API接口: http://localhost:3000/api
后台管理: http://localhost:3000/admin
==========================================
祝开发顺利!🎉

245
小程序启动指南.md Normal file
View File

@@ -0,0 +1,245 @@
# 🚀 小程序启动指南 - Windows版
## 📋 项目概览
- **项目名称**: Soul创业派对小程序
- **小程序AppID**: `wxb8bbb2b10dec74aa`
- **后端框架**: Next.js
- **开发端口**: 3000
- **API地址**: `http://localhost:3000/api` (本地开发)
---
## 🎯 快速启动3步
### 第1步启动后端服务器
**方式1使用PowerShell脚本推荐**
```powershell
# 在项目根目录执行
.\启动小程序.ps1
```
**方式2手动启动**
```powershell
# 安装依赖(如果还没安装)
pnpm install
# 或
npm install
# 启动开发服务器
pnpm dev
# 或
npm run dev
```
**成功标志**: 看到 `Ready in 2.3s``Local: http://localhost:3000`
---
### 第2步打开微信开发者工具
1. **打开微信开发者工具**
- 如果没有安装请先下载https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html
2. **导入项目**
- 点击工具栏的 **"导入项目"** 或 **"+"** 按钮
- 选择项目目录:`e:\Gongsi\Mycontent\miniprogram`
- AppID会自动识别`wxb8bbb2b10dec74aa`
- 如果没有AppID可以选择 **"测试号"** 进行开发测试
3. **点击"导入"**
---
### 第3步配置并编译
1. **配置本地设置**
- 点击右上角 **"详情"** 按钮
- 切换到 **"本地设置"** 标签页
- ✅ 勾选 **"不校验合法域名、web-view业务域名、TLS 版本以及 HTTPS 证书"**
- ✅ 勾选 **"不校验安全域名"**
2. **检查API配置可选**
- 如果API请求失败检查 `miniprogram/app.js` 中的 `baseUrl`
- 本地开发应设置为:`http://localhost:3000`
- 当前配置:`https://soul.quwanzhi.com`(生产环境)
3. **点击"编译"按钮**
- 等待编译完成
- 在模拟器中查看效果
---
## 🔧 配置说明
### 小程序配置文件
**文件位置**: `miniprogram/project.config.json`
```json
{
"appid": "wxb8bbb2b10dec74aa",
"projectname": "soul-startup"
}
```
### API地址配置
**文件位置**: `miniprogram/app.js`
**本地开发配置**:
```javascript
globalData: {
baseUrl: 'http://localhost:3000', // 本地开发
// ...
}
```
**生产环境配置**:
```javascript
globalData: {
baseUrl: 'https://soul.quwanzhi.com', // 生产环境
// ...
}
```
---
## 📱 功能测试清单
### ✅ 首页测试
- [ ] 书籍封面显示正常
- [ ] 最新章节列表加载
- [ ] 点击章节可以跳转
### ✅ 目录页测试
- [ ] 章节列表完整显示
- [ ] 购买状态正确显示
### ✅ 找伙伴页测试
- [ ] 星空动画流畅
- [ ] 匹配功能正常
### ✅ 我的页面测试
- [ ] 登录功能正常
- [ ] 分销中心显示
- [ ] 海报生成功能
### ✅ 阅读页测试
- [ ] 章节内容加载
- [ ] 目录侧滑正常
- [ ] 书签功能可用
---
## ⚠️ 常见问题
### Q1: 提示"不在以下request合法域名列表中"
**解决方案**:
1. 在微信开发者工具中,点击 **"详情"** → **"本地设置"**
2. ✅ 勾选 **"不校验合法域名"**
3. 重新编译
---
### Q2: API请求失败提示网络错误
**检查清单**:
- [ ] 后端服务器是否已启动?(应该看到 `http://localhost:3000`
- [ ] `app.js` 中的 `baseUrl` 是否正确?
- [ ] 是否勾选了"不校验合法域名"
- [ ] 控制台是否有错误信息?
**调试方法**:
1. 打开微信开发者工具的 **"调试器"** 标签
2. 切换到 **"Network"** 查看请求详情
3. 查看 **"Console"** 中的错误信息
---
### Q3: 登录功能失败
**可能原因**:
1. 后端API未启动
2. AppID配置错误
3. 网络请求被拦截
**解决方案**:
1. 确认后端服务器运行在 `http://localhost:3000`
2. 检查 `project.config.json` 中的AppID
3. 查看控制台错误信息
---
### Q4: 端口被占用
**错误信息**: `Port 3000 is already in use`
**解决方案**:
```powershell
# 查找占用3000端口的进程
netstat -ano | findstr :3000
# 结束进程替换PID为实际进程ID
taskkill /PID <PID> /F
# 或者修改端口在package.json中
# "dev": "next dev -p 3001"
```
---
## 🎨 开发技巧
### 实时预览
- 修改代码后,微信开发者工具会自动编译
- 点击 **"预览"** 可以生成二维码,用微信扫码在真机上测试
### 调试工具
- **调试器**: 查看Console、Network、Storage等
- **AppData**: 查看全局数据状态
- **Storage**: 查看本地存储数据
### 代码修改
- 修改 `miniprogram/` 目录下的代码
- 保存后自动编译
- 在模拟器中查看效果
---
## 📞 技术支持
### 项目信息
- **项目路径**: `e:\Gongsi\Mycontent`
- **小程序目录**: `e:\Gongsi\Mycontent\miniprogram`
- **后端目录**: `e:\Gongsi\Mycontent`(根目录)
### 相关文档
- `miniprogram/小程序部署说明.md` - 详细部署文档
- `miniprogram/小程序快速配置指南.md` - 快速配置指南
- `开发文档/` - 完整开发文档
---
## ✅ 启动检查清单
启动前确认:
- [ ] Node.js已安装建议v18+
- [ ] pnpm或npm已安装
- [ ] 微信开发者工具已安装
- [ ] 项目依赖已安装(`node_modules` 目录存在)
启动步骤:
- [ ] 后端服务器已启动(`http://localhost:3000`
- [ ] 微信开发者工具已打开
- [ ] 项目已导入(选择 `miniprogram` 目录)
- [ ] 已勾选"不校验合法域名"
- [ ] 已点击编译按钮
---
**祝开发顺利!** 🎉

151
快速启动指南.md Normal file
View File

@@ -0,0 +1,151 @@
# 🚀 小程序快速启动指南
## ✅ 当前项目状态
- **Node.js版本**: v22.12.0 ✅
- **pnpm版本**: 10.26.2 ✅
- **依赖状态**: 已安装 ✅
- **后端服务器**: 正在启动中...
---
## 📋 启动步骤
### 1⃣ 后端服务器(已自动启动)
后端服务器正在后台运行,访问地址:
- **本地地址**: http://localhost:3000
- **API接口**: http://localhost:3000/api
如果服务器未启动,请手动执行:
```powershell
cd e:\Gongsi\Mycontent
pnpm dev
```
---
### 2⃣ 打开微信开发者工具
1. **打开微信开发者工具**
- 下载地址https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html
2. **导入项目**
- 点击 **"导入项目"** 或 **"+"** 按钮
- **项目目录**: `e:\Gongsi\Mycontent\miniprogram`
- **AppID**: `wxb8bbb2b10dec74aa`(会自动识别)
- 如果没有AppID选择 **"测试号"**
3. **点击"导入"**
---
### 3⃣ 配置本地设置
在微信开发者工具中:
1. 点击右上角 **"详情"** 按钮
2. 切换到 **"本地设置"** 标签页
3.**必须勾选**
- "不校验合法域名、web-view业务域名、TLS 版本以及 HTTPS 证书"
- "不校验安全域名"
---
### 4⃣ API地址配置可选
**当前配置**: `https://soul.quwanzhi.com`(生产环境)
**本地开发选项**(二选一):
**选项A使用本地API推荐**
- 修改 `miniprogram/app.js` 第9行
```javascript
baseUrl: 'http://localhost:3000', // 改为本地地址
```
**选项B使用生产API**
- 保持当前配置不变
- 确保已勾选"不校验合法域名"
- 需要网络连接访问生产服务器
---
### 5⃣ 编译运行
1. 点击工具栏的 **"编译"** 按钮
2. 等待编译完成
3. 在模拟器中查看效果
---
## 🎯 功能测试
### 首页
- 书籍封面显示
- 最新章节列表
- 点击章节跳转
### 目录页
- 章节列表完整显示
- 购买状态正确
### 找伙伴页
- 星空动画流畅
- 匹配功能正常
### 我的页面
- 登录功能
- 分销中心
- 海报生成
---
## ⚠️ 常见问题
### Q: API请求失败
**解决方案**:
1. 确认后端服务器已启动(访问 http://localhost:3000 测试)
2. 在微信开发者工具中勾选"不校验合法域名"
3. 如果使用本地API确认 `app.js` 中的 `baseUrl` 为 `http://localhost:3000`
4. 查看调试器 → Network 标签查看请求详情
### Q: 端口被占用?
**解决方案**:
```powershell
# 查找占用3000端口的进程
netstat -ano | findstr :3000
# 结束进程替换PID
taskkill /PID <PID> /F
```
### Q: 登录功能失败?
**检查**:
1. 后端API是否正常访问 http://localhost:3000/api/miniprogram/login
2. AppID是否正确
3. 查看控制台错误信息
---
## 📱 真机预览
1. 点击工具栏 **"预览"** 按钮
2. 用微信扫码生成的二维码
3. 在真机上测试功能
---
## 📞 项目信息
- **项目路径**: `e:\Gongsi\Mycontent`
- **小程序目录**: `e:\Gongsi\Mycontent\miniprogram`
- **AppID**: `wxb8bbb2b10dec74aa`
- **后端端口**: 3000
---
**祝开发顺利!** 🎉

54
检查配置.ps1 Normal file
View File

@@ -0,0 +1,54 @@
# 检查小程序配置脚本
Write-Host "==================================" -ForegroundColor Cyan
Write-Host " 小程序配置检查工具" -ForegroundColor Cyan
Write-Host "==================================" -ForegroundColor Cyan
Write-Host ""
$appJsPath = "miniprogram\app.js"
$projectConfigPath = "miniprogram\project.config.json"
# 检查app.js
if (Test-Path $appJsPath) {
Write-Host "✅ 找到 app.js" -ForegroundColor Green
$content = Get-Content $appJsPath -Raw
if ($content -match "baseUrl:\s*['`"]([^'`"]+)['`"]") {
$baseUrl = $matches[1]
Write-Host " 当前API地址: $baseUrl" -ForegroundColor Gray
if ($baseUrl -match "localhost|127\.0\.0\.1") {
Write-Host " ✅ 已配置为本地开发地址" -ForegroundColor Green
} else {
Write-Host " ⚠️ 当前为生产环境地址,本地开发建议修改为: http://localhost:3000" -ForegroundColor Yellow
Write-Host ""
Write-Host " 修改方法:" -ForegroundColor Cyan
Write-Host " 1. 打开文件: $appJsPath" -ForegroundColor White
Write-Host " 2. 找到 baseUrl 配置行" -ForegroundColor White
Write-Host " 3. 修改为: baseUrl: 'http://localhost:3000'," -ForegroundColor White
}
}
} else {
Write-Host "❌ 未找到 app.js" -ForegroundColor Red
}
Write-Host ""
# 检查project.config.json
if (Test-Path $projectConfigPath) {
Write-Host "✅ 找到 project.config.json" -ForegroundColor Green
$config = Get-Content $projectConfigPath | ConvertFrom-Json
if ($config.appid) {
Write-Host " AppID: $($config.appid)" -ForegroundColor Gray
}
if ($config.projectname) {
Write-Host " 项目名称: $($config.projectname)" -ForegroundColor Gray
}
} else {
Write-Host "❌ 未找到 project.config.json" -ForegroundColor Red
}
Write-Host ""
Write-Host "==================================" -ForegroundColor Cyan