Files
Your Name 90d2a230a3 Fix: 解决Win10中文乱码和编译路径问题
- 将批处理脚本改为英文输出
- 添加UTF-8编码支持(chcp 65001)
- 添加go.mod存在性检查
- 创建详细的Windows使用说明文档
2026-04-25 22:51:05 +08:00

174 lines
2.8 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.
# Windows 10 使用说明
## 解决中文乱码问题
已将脚本中的中文改为英文,避免乱码问题。
## 在 Win10 上编译和运行
### 方法一:从网络位置编译(推荐)
1. **打开PowerShell或CMD**
2. **切换到项目目录**
```cmd
cd \\192.168.6.193\Share\Projects\network-topology-discovery
```
3. **编译程序**
```cmd
build.bat
```
4. **运行程序**
```cmd
start.bat
```
5. **访问Web界面**
打开浏览器访问:`http://localhost:8080`
### 方法二:复制到本地编译(更快)
如果网络位置编译慢,可以:
1. **复制整个项目到本地**
```cmd
xcopy \\192.168.6.193\Share\Projects\network-topology-discovery C:\Projects\network-topology-discovery /E /I
```
2. **切换到本地目录**
```cmd
cd C:\Projects\network-topology-discovery
```
3. **编译和运行**
```cmd
build.bat
start.bat
```
### 方法三:手动命令行编译
如果批处理脚本有问题,可以手动执行:
```cmd
# 切换到项目目录
cd \\192.168.6.193\Share\Projects\network-topology-discovery
# 编译
set GOOS=windows
set GOARCH=amd64
go build -o network-topology.exe -ldflags="-s -w" ./cmd
# 运行
network-topology.exe
```
## 常见问题
### 1. 提示 "go.mod file not found"
**原因**:没有在项目根目录运行脚本
**解决**
```cmd
# 先切换到正确的目录
cd \\192.168.6.193\Share\Projects\network-topology-discovery
# 确认go.mod存在
dir go.mod
# 然后再运行
build.bat
```
### 2. 编译后找不到 network-topology.exe
**原因**:编译失败或输出到错误目录
**解决**
```cmd
# 手动编译并指定输出路径
go build -o network-topology.exe ./cmd
# 检查文件是否存在
dir network-topology.exe
```
### 3. 运行时提示 "web目录不存在"
**原因**:web文件夹不在正确位置
**解决**
确保目录结构如下:
```
network-topology-discovery/
├── network-topology.exe
├── web/
│ ├── index.html
│ ├── css/
│ └── js/
└── config.json
```
### 4. 端口8080被占用
**解决**
编辑 `config.json`,修改端口:
```json
{
"web": {
"port": 8081
}
}
```
## 环境要求
确保已安装:
- ✅ Go 1.22 或更高版本
- ✅ Windows 10/11
- ✅ 网络连接(访问网络设备)
检查Go版本:
```cmd
go version
```
## 快速测试
编译完成后,可以快速测试:
```cmd
# 1. 编译
build.bat
# 2. 启动
start.bat
# 3. 打开浏览器
# 访问: http://localhost:8080
# 4. 测试添加设备
# 点击"添加设备",输入你的设备IP和SSH凭据
```
## 更新项目
如果从Git仓库更新:
```cmd
# 拉取最新代码
git pull
# 重新编译
build.bat
# 运行
start.bat
```
---
如有其他问题,请查看 README.md 或提交Issue。