fix: 修复前端导航和页面跳转问题
- 添加统一的导航菜单到所有页面 - 修复页面路由映射和高亮状态 - 创建 navigation.js 统一管理页面跳转 - 添加 test_navigation.py 路由测试工具 - 支持仪表板、预警管理、智能对话、HTTP对话页面间无缝切换 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -21,5 +21,6 @@
|
|||||||
"[markdown]": {
|
"[markdown]": {
|
||||||
"files.encoding": "utf8"
|
"files.encoding": "utf8"
|
||||||
},
|
},
|
||||||
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/Scripts/python.exe"
|
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/Scripts/python.exe",
|
||||||
|
"Codegeex.RepoIndex": true
|
||||||
}
|
}
|
||||||
|
|||||||
94
convert_encoding.bat
Normal file
94
convert_encoding.bat
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
@echo off
|
||||||
|
setlocal enabledelayedexpansion
|
||||||
|
chcp 65001 >nul 2>&1
|
||||||
|
echo ========================================
|
||||||
|
echo 代码文件编码批量转换工具
|
||||||
|
echo ========================================
|
||||||
|
echo.
|
||||||
|
|
||||||
|
:: 设置要扫描的文件扩展名
|
||||||
|
set "extensions=*.py *.java *.js *.ts *.html *.css *.xml *.json *.md *.txt *.bat *.cmd *.ps1 *.sh *.yml *.yaml *.ini *.cfg *.conf *.properties"
|
||||||
|
|
||||||
|
:: 设置目标目录(默认为当前目录)
|
||||||
|
set "target_dir=%cd%"
|
||||||
|
if not "%~1"=="" set "target_dir=%~1"
|
||||||
|
|
||||||
|
echo 目标目录: %target_dir%
|
||||||
|
echo.
|
||||||
|
|
||||||
|
:: 检查目录是否存在
|
||||||
|
if not exist "%target_dir%" (
|
||||||
|
echo 错误:指定的目录不存在
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
:: 创建临时目录
|
||||||
|
set "temp_dir=%temp%\encoding_convert_%random%"
|
||||||
|
mkdir "%temp_dir%"
|
||||||
|
|
||||||
|
:: 统计变量
|
||||||
|
set "total_files=0"
|
||||||
|
set "converted_files=0"
|
||||||
|
set "skipped_files=0"
|
||||||
|
|
||||||
|
echo 开始扫描文件...
|
||||||
|
echo.
|
||||||
|
|
||||||
|
:: 遍历所有指定扩展名的文件
|
||||||
|
for %%e in (%extensions%) do (
|
||||||
|
for /r "%target_dir%" %%f in (%%e) do (
|
||||||
|
set /a total_files+=1
|
||||||
|
call :process_file "%%f"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ========================================
|
||||||
|
echo 转换完成
|
||||||
|
echo ========================================
|
||||||
|
echo 总文件数: %total_files%
|
||||||
|
echo 已转换: %converted_files%
|
||||||
|
echo 已跳过: %skipped_files%
|
||||||
|
echo.
|
||||||
|
|
||||||
|
:: 清理临时目录
|
||||||
|
rd /s /q "%temp_dir%" 2>nul
|
||||||
|
|
||||||
|
pause
|
||||||
|
exit /b
|
||||||
|
|
||||||
|
:process_file
|
||||||
|
set "file=%~1"
|
||||||
|
set "is_utf8=0"
|
||||||
|
|
||||||
|
:: 检查文件是否已经是UTF-8编码
|
||||||
|
powershell -Command "try { $content = [System.IO.File]::ReadAllText('%file%', [System.Text.Encoding]::UTF8); $content | Out-Null; exit 0 } catch { exit 1 }" >nul 2>&1
|
||||||
|
if %errorlevel% equ 0 set "is_utf8=1"
|
||||||
|
|
||||||
|
if %is_utf8% equ 1 (
|
||||||
|
echo [跳过] %file% (已经是UTF-8)
|
||||||
|
set /a skipped_files+=1
|
||||||
|
) else (
|
||||||
|
echo [转换] %file%
|
||||||
|
|
||||||
|
:: 尝试检测并转换编码
|
||||||
|
powershell -Command ^
|
||||||
|
"$path = '%file%'; ^
|
||||||
|
try { ^
|
||||||
|
$bytes = [System.IO.File]::ReadAllBytes($path); ^
|
||||||
|
$encoding = [System.Text.Encoding]::GetEncoding('GB2312'); ^
|
||||||
|
$content = $encoding.GetString($bytes); ^
|
||||||
|
[System.IO.File]::WriteAllText($path, $content, [System.Text.Encoding]::UTF8); ^
|
||||||
|
exit 0 ^
|
||||||
|
} catch { ^
|
||||||
|
exit 1 ^
|
||||||
|
}"
|
||||||
|
|
||||||
|
if %errorlevel% equ 0 (
|
||||||
|
set /a converted_files+=1
|
||||||
|
) else (
|
||||||
|
echo [警告] 无法转换 %file%
|
||||||
|
)
|
||||||
|
)
|
||||||
|
goto :eof
|
||||||
168
fix_git_push.bat
168
fix_git_push.bat
@@ -1,117 +1,154 @@
|
|||||||
@echo off
|
@echo off
|
||||||
chcp 65001 >nul
|
setlocal enabledelayedexpansion
|
||||||
|
chcp 65001 >nul 2>&1
|
||||||
echo ========================================
|
echo ========================================
|
||||||
echo Git推送问题诊断和修复工具
|
echo Git推送问题诊断和修复工具
|
||||||
echo ========================================
|
echo ========================================
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
:: 1. 检查Git状态
|
:: 1. 检查Git状态
|
||||||
echo [1] 检查Git状态...
|
echo [1] 检查Git状态...
|
||||||
git status
|
git status >nul 2>&1
|
||||||
if %errorlevel% neq 0 (
|
if %errorlevel% neq 0 (
|
||||||
echo ? Git未初始化
|
echo ? Git未初始化或不可用
|
||||||
|
echo 请确保:
|
||||||
|
echo 1. 已安装Git
|
||||||
|
echo 2. 当前目录是Git仓库
|
||||||
pause
|
pause
|
||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
|
echo ? Git状态正常
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
:: 2. 检查远程仓库配置
|
:: 2. 检查远程仓库配置
|
||||||
echo [2] 检查远程仓库配置...
|
echo [2] 检查远程仓库配置...
|
||||||
|
git remote -v >nul 2>&1
|
||||||
|
if %errorlevel% neq 0 (
|
||||||
|
echo ? 未配置远程仓库
|
||||||
|
echo 请先运行: git remote add origin ^<仓库地址^>
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
echo ? 远程仓库配置正常
|
||||||
git remote -v
|
git remote -v
|
||||||
if %errorlevel% neq 0 (
|
echo.
|
||||||
echo ? 未配置远程仓库
|
|
||||||
echo 请先运行: git remote add origin <仓库地址>
|
:: 3. 检查当前分支
|
||||||
|
echo [3] 检查当前分支...
|
||||||
|
for /f "tokens=*" %%b in ('git branch --show-current 2^>nul') do set current_branch=%%b
|
||||||
|
if "!current_branch!"=="" (
|
||||||
|
echo ? 无法获取当前分支信息
|
||||||
pause
|
pause
|
||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
|
echo 当前分支: !current_branch!
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
:: 3. 检查当前分支
|
:: 4. 检查是否有未提交的更改
|
||||||
echo [3] 检查当前分支...
|
echo [4] 检查未提交的更改...
|
||||||
git branch --show-current
|
git status --porcelain >nul 2>&1
|
||||||
echo.
|
|
||||||
|
|
||||||
:: 4. 检查是否有未提交的更改
|
|
||||||
echo [4] 检查未提交的更改...
|
|
||||||
git status --porcelain
|
|
||||||
if %errorlevel% equ 0 (
|
if %errorlevel% equ 0 (
|
||||||
echo ?? 有未提交的更改
|
git status --porcelain | findstr /r "." >nul
|
||||||
set /p commit="是否先提交更改? (y/n): "
|
if !errorlevel! equ 0 (
|
||||||
if /i "%commit%"=="y" (
|
echo ?? 有未提交的更改
|
||||||
git add .
|
set /p commit="是否先提交更改? (y/n): "
|
||||||
set /p msg="请输入提交信息: "
|
if /i "!commit!"=="y" (
|
||||||
if "%msg%"=="" set msg=自动提交
|
git add .
|
||||||
git commit -m "%msg%"
|
set /p msg="请输入提交信息: "
|
||||||
|
if "!msg!"=="" set msg=自动提交
|
||||||
|
git commit -m "!msg!"
|
||||||
|
if !errorlevel! neq 0 (
|
||||||
|
echo ? 提交失败
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
echo ? 暂存区状态正常
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
:: 5. 尝试获取远程分支信息
|
:: 5. 尝试获取远程分支信息
|
||||||
echo [5] 获取远程分支信息...
|
echo [5] 获取远程分支信息...
|
||||||
git fetch origin
|
git fetch origin >nul 2>&1
|
||||||
if %errorlevel% neq 0 (
|
if %errorlevel% neq 0 (
|
||||||
echo ? 无法连接到远程仓库
|
echo ? 无法连接到远程仓库
|
||||||
echo.
|
echo.
|
||||||
echo 可能的原因:
|
echo 可能的原因:
|
||||||
echo 1. 网络连接问题
|
echo 1. 网络连接问题
|
||||||
echo 2. 远程仓库地址错误
|
echo 2. 远程仓库地址错误
|
||||||
echo 3. 需要认证(请检查是否已配置SSH密钥或Token)
|
echo 3. 需要认证(请检查是否已配置SSH密钥或Token)
|
||||||
echo.
|
echo.
|
||||||
echo 远程仓库地址:
|
echo 远程仓库地址:
|
||||||
git config --get remote.origin.url
|
git config --get remote.origin.url
|
||||||
|
echo.
|
||||||
|
echo 解决建议:
|
||||||
|
echo 1. 检查网络连接
|
||||||
|
echo 2. 验证远程仓库地址
|
||||||
|
echo 3. 配置SSH密钥或访问令牌
|
||||||
pause
|
pause
|
||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
echo ? 远程仓库连接成功
|
echo ? 远程仓库连接成功
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
:: 6. 检查分支跟踪关系
|
:: 6. 检查分支跟踪关系
|
||||||
echo [6] 检查分支跟踪关系...
|
echo [6] 检查分支跟踪关系...
|
||||||
git branch -vv
|
git branch -vv
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
:: 7. 尝试推送到远程
|
:: 7. 尝试推送到远程
|
||||||
echo [7] 尝试推送...
|
echo [7] 尝试推送...
|
||||||
set current_branch=
|
echo 当前分支: !current_branch!
|
||||||
for /f "tokens=*" %%b in ('git branch --show-current') do set current_branch=%%b
|
|
||||||
|
|
||||||
echo 当前分支: %current_branch%
|
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
:: 检查远程是否存在该分支
|
:: 检查远程是否存在该分支
|
||||||
git ls-remote --heads origin %current_branch% >nul 2>&1
|
git ls-remote --heads origin !current_branch! >nul 2>&1
|
||||||
if %errorlevel% equ 0 (
|
if %errorlevel% equ 0 (
|
||||||
echo 远程分支 %current_branch% 已存在
|
echo 远程分支 !current_branch! 已存在
|
||||||
echo.
|
echo.
|
||||||
echo 尝试使用当前分支名称推送...
|
echo 尝试使用当前分支名称推送...
|
||||||
git push origin %current_branch%
|
git push origin !current_branch!
|
||||||
|
if !errorlevel! neq 0 (
|
||||||
|
echo.
|
||||||
|
echo ? 推送失败,尝试拉取最新更改...
|
||||||
|
git pull origin !current_branch! --rebase
|
||||||
|
if !errorlevel! equ 0 (
|
||||||
|
echo ? 重新尝试推送...
|
||||||
|
git push origin !current_branch!
|
||||||
|
) else (
|
||||||
|
echo ? 拉取失败,请检查冲突
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
)
|
||||||
) else (
|
) else (
|
||||||
echo 远程分支 %current_branch% 不存在
|
echo 远程分支 !current_branch! 不存在
|
||||||
echo.
|
echo.
|
||||||
echo 尝试设置上游并推送...
|
echo 尝试设置上游并推送...
|
||||||
git push -u origin %current_branch%
|
git push -u origin !current_branch!
|
||||||
)
|
)
|
||||||
|
|
||||||
if %errorlevel% equ 0 (
|
if %errorlevel% equ 0 (
|
||||||
echo.
|
echo.
|
||||||
echo ? 推送成功!
|
echo ? 推送成功!
|
||||||
) else (
|
) else (
|
||||||
echo.
|
echo.
|
||||||
echo ? 推送失败
|
echo ? 推送失败
|
||||||
echo.
|
echo.
|
||||||
echo ? 常见问题和解决方案:
|
echo ? 常见问题和解决方案:
|
||||||
echo.
|
echo.
|
||||||
echo 1. 如果是认证问题:
|
echo 1. 如果是认证问题:
|
||||||
echo - 检查SSH密钥: ssh -T git@github.com (GitHub) 或 ssh -T git@gitee.com (Gitee)
|
echo - 检查SSH密钥: ssh -T git@github.com (GitHub) 或 ssh -T git@gitee.com (Gitee)
|
||||||
echo - 或使用HTTPS + Token方式
|
echo - 或使用HTTPS + Token方式
|
||||||
echo.
|
echo.
|
||||||
echo 2. 如果是分支冲突:
|
echo 2. 如果是分支冲突:
|
||||||
echo - 运行: git pull origin %current_branch% --rebase
|
echo - 运行: git pull origin !current_branch! --rebase
|
||||||
echo - 解决冲突后: git push origin %current_branch%
|
echo - 解决冲突后: git push origin !current_branch!
|
||||||
echo.
|
echo.
|
||||||
echo 3. 如果远程分支名称不同:
|
echo 3. 如果远程分支名称不同:
|
||||||
echo - 检查远程分支: git branch -r
|
echo - 检查远程分支: git branch -r
|
||||||
echo - 可能需要推送主分支: git push origin main 或 git push origin master
|
echo - 可能需要推送主分支: git push origin main 或 git push origin master
|
||||||
echo.
|
echo.
|
||||||
pause
|
pause
|
||||||
exit /b 1
|
exit /b 1
|
||||||
@@ -119,7 +156,6 @@ if %errorlevel% equ 0 (
|
|||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ========================================
|
echo ========================================
|
||||||
echo ? 诊断完成!
|
echo ? 诊断完成!
|
||||||
echo ========================================
|
echo ========================================
|
||||||
pause
|
pause
|
||||||
|
|
||||||
|
|||||||
@@ -1,80 +1,66 @@
|
|||||||
# 核心依赖
|
# 核心依赖
|
||||||
sqlalchemy>=2.0.32
|
sqlalchemy==2.0.32
|
||||||
requests>=2.32.3
|
requests==2.32.3
|
||||||
numpy>=1.26.4
|
numpy==1.26.4
|
||||||
scikit-learn>=1.4.2
|
scikit-learn==1.4.2
|
||||||
|
|
||||||
# 数据库驱动
|
# 数据库驱动
|
||||||
pymysql>=1.1.1
|
pymysql==1.1.1
|
||||||
cryptography>=43.0.1
|
cryptography==43.0.1
|
||||||
flask>=3.0.3
|
flask==3.0.3
|
||||||
flask-cors>=5.0.0
|
flask-cors==5.0.0
|
||||||
websockets>=15.0.1
|
websockets==15.0.1
|
||||||
|
|
||||||
# 中文处理
|
# 中文处理
|
||||||
jieba>=0.42.1
|
jieba==0.42.1
|
||||||
|
|
||||||
# 系统监控
|
# 系统监控
|
||||||
psutil>=5.9.8
|
psutil==5.9.8
|
||||||
|
|
||||||
# 数据处理
|
# 数据处理
|
||||||
pandas>=2.2.2
|
pandas==2.2.2
|
||||||
openpyxl>=3.1.5
|
openpyxl==3.1.5
|
||||||
|
|
||||||
# 向量化(可选,如果不需要可以注释掉以节省空间)
|
|
||||||
# sentence-transformers>=2.7.1
|
|
||||||
# transformers>=4.43.2
|
|
||||||
# torch>=2.4.1
|
|
||||||
|
|
||||||
# 日志和配置
|
# 日志和配置
|
||||||
python-dotenv>=1.0.1
|
python-dotenv==1.0.1
|
||||||
structlog>=24.4.0
|
structlog==24.4.0
|
||||||
|
|
||||||
# 时间处理
|
# 时间处理
|
||||||
python-dateutil>=2.9.0
|
python-dateutil==2.9.0
|
||||||
|
|
||||||
# JSON处理
|
# JSON处理
|
||||||
ujson>=5.10.0
|
ujson==5.10.0
|
||||||
|
|
||||||
# 异步支持
|
# 异步支持
|
||||||
aiohttp>=3.10.10
|
aiohttp==3.10.10
|
||||||
# asyncio是Python内置模块,不需要安装
|
# asyncio是Python内置模块,不需要安装
|
||||||
|
|
||||||
# Redis缓存
|
# Redis缓存
|
||||||
redis>=5.2.0
|
|
||||||
redis-py-cluster>=2.1.3
|
|
||||||
|
|
||||||
# 测试框架
|
# 测试框架
|
||||||
pytest>=8.3.3
|
pytest==8.3.3
|
||||||
pytest-asyncio>=0.24.0
|
pytest-asyncio==0.24.0
|
||||||
pytest-cov>=6.0.0
|
pytest-cov==6.0.0
|
||||||
|
|
||||||
# 代码质量
|
# 代码质量
|
||||||
black>=24.8.0
|
black==24.8.0
|
||||||
flake8>=7.1.1
|
flake8==7.1.1
|
||||||
mypy>=1.11.1
|
mypy==1.11.1
|
||||||
isort>=5.13.2
|
isort==5.13.2
|
||||||
|
|
||||||
# 安全
|
# 安全
|
||||||
bcrypt>=4.2.1
|
bcrypt==4.2.1
|
||||||
pyjwt>=2.9.0
|
pyjwt==2.9.0
|
||||||
|
|
||||||
# 文件处理
|
# 文件处理
|
||||||
python-magic>=0.4.27
|
python-magic==0.4.27
|
||||||
pillow>=11.0.0
|
pillow==11.0.0
|
||||||
|
|
||||||
# 网络工具
|
# 网络工具
|
||||||
urllib3>=2.2.3
|
urllib3==2.2.3
|
||||||
httpx>=0.27.2
|
httpx==0.27.2
|
||||||
|
|
||||||
# 数据验证
|
# 数据验证
|
||||||
pydantic>=2.9.2
|
pydantic==2.9.2
|
||||||
marshmallow>=3.21.4
|
marshmallow==3.23.3
|
||||||
|
|
||||||
# 任务队列(可选)
|
|
||||||
# celery>=5.4.0
|
|
||||||
# kombu>=5.4.1
|
|
||||||
|
|
||||||
# 文档生成(可选)
|
|
||||||
# sphinx>=7.5.0
|
|
||||||
# sphinx-rtd-theme>=2.0.0
|
|
||||||
@@ -3,56 +3,56 @@ chcp 65001 >nul
|
|||||||
setlocal enabledelayedexpansion
|
setlocal enabledelayedexpansion
|
||||||
|
|
||||||
echo ========================================
|
echo ========================================
|
||||||
echo 简单Git推送工具
|
echo 简单Git推送工具
|
||||||
echo ========================================
|
echo ========================================
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
:: 1. 显示Git状态
|
:: 1. 显示Git状态
|
||||||
echo [1] Git状态:
|
echo [1] Git状态:
|
||||||
git status --short
|
git status --short
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
:: 2. 显示远程仓库
|
:: 2. 显示远程仓库
|
||||||
echo [2] 远程仓库:
|
echo [2] 远程仓库:
|
||||||
git remote -v
|
git remote -v
|
||||||
if %errorlevel% neq 0 (
|
if %errorlevel% neq 0 (
|
||||||
echo 错误: 未配置远程仓库
|
echo 错误: 未配置远程仓库
|
||||||
pause
|
pause
|
||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
:: 3. 显示当前分支
|
:: 3. 显示当前分支
|
||||||
echo [3] 当前分支:
|
echo [3] 当前分支:
|
||||||
for /f "tokens=*" %%b in ('git branch --show-current 2^>nul') do set branch=%%b
|
for /f "tokens=*" %%b in ('git branch --show-current 2^>nul') do set branch=%%b
|
||||||
if "!branch!"=="" (
|
if "!branch!"=="" (
|
||||||
echo 警告: 无法获取分支名称,尝试使用main
|
echo 警告: 无法获取分支名称,尝试使用main
|
||||||
set branch=main
|
set branch=main
|
||||||
)
|
)
|
||||||
echo 分支: !branch!
|
echo 分支: !branch!
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
:: 4. 检查是否有未提交的更改
|
:: 4. 检查是否有未提交的更改
|
||||||
echo [4] 检查未提交的更改...
|
echo [4] 检查未提交的更改...
|
||||||
git diff --quiet
|
git diff --quiet
|
||||||
set has_uncommitted=%errorlevel%
|
set has_uncommitted=%errorlevel%
|
||||||
git diff --cached --quiet
|
git diff --cached --quiet
|
||||||
set has_staged=%errorlevel%
|
set has_staged=%errorlevel%
|
||||||
|
|
||||||
if %has_uncommitted% neq 0 (
|
if %has_uncommitted% neq 0 (
|
||||||
echo 有未暂存的更改
|
echo 有未暂存的更改
|
||||||
)
|
)
|
||||||
if %has_staged% neq 0 (
|
if %has_staged% neq 0 (
|
||||||
echo 有已暂存的更改
|
echo 有已暂存的更改
|
||||||
)
|
)
|
||||||
if %has_uncommitted% equ 0 if %has_staged% equ 0 (
|
if %has_uncommitted% equ 0 if %has_staged% equ 0 (
|
||||||
echo 所有更改已提交
|
echo 所有更改已提交
|
||||||
)
|
)
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
:: 5. 尝试推送
|
:: 5. 尝试推送
|
||||||
echo [5] 开始推送...
|
echo [5] 开始推送...
|
||||||
echo 命令: git push origin !branch!
|
echo 命令: git push origin !branch!
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
git push origin !branch! 2>&1 | findstr /v "^$"
|
git push origin !branch! 2>&1 | findstr /v "^$"
|
||||||
@@ -61,44 +61,44 @@ set push_error=!errorlevel!
|
|||||||
if !push_error! equ 0 (
|
if !push_error! equ 0 (
|
||||||
echo.
|
echo.
|
||||||
echo ========================================
|
echo ========================================
|
||||||
echo 推送成功!
|
echo 推送成功!
|
||||||
echo ========================================
|
echo ========================================
|
||||||
) else (
|
) else (
|
||||||
echo.
|
echo.
|
||||||
echo ========================================
|
echo ========================================
|
||||||
echo 推送失败!错误码: !push_error!
|
echo 推送失败!错误码: !push_error!
|
||||||
echo ========================================
|
echo ========================================
|
||||||
echo.
|
echo.
|
||||||
echo 尝试设置上游并推送...
|
echo 尝试设置上游并推送...
|
||||||
git push -u origin !branch! 2>&1 | findstr /v "^$"
|
git push -u origin !branch! 2>&1 | findstr /v "^$"
|
||||||
set push_u_error=!errorlevel!
|
set push_u_error=!errorlevel!
|
||||||
|
|
||||||
if !push_u_error! equ 0 (
|
if !push_u_error! equ 0 (
|
||||||
echo.
|
echo.
|
||||||
echo ========================================
|
echo ========================================
|
||||||
echo 推送成功(已设置上游)!
|
echo 推送成功(已设置上游)!
|
||||||
echo ========================================
|
echo ========================================
|
||||||
) else (
|
) else (
|
||||||
echo.
|
echo.
|
||||||
echo ========================================
|
echo ========================================
|
||||||
echo 推送仍然失败
|
echo 推送仍然失败
|
||||||
echo ========================================
|
echo ========================================
|
||||||
echo.
|
echo.
|
||||||
echo 常见问题和解决方案:
|
echo 常见问题和解决方案:
|
||||||
echo.
|
echo.
|
||||||
echo 1. 认证问题:
|
echo 1. 认证问题:
|
||||||
echo - 检查SSH密钥: ssh -T git@github.com (GitHub)
|
echo - 检查SSH密钥: ssh -T git@github.com (GitHub)
|
||||||
echo - 检查SSH密钥: ssh -T git@gitee.com (Gitee)
|
echo - 检查SSH密钥: ssh -T git@gitee.com (Gitee)
|
||||||
echo - 或使用HTTPS + Personal Access Token
|
echo - 或使用HTTPS + Personal Access Token
|
||||||
echo.
|
echo.
|
||||||
echo 2. 远程仓库地址:
|
echo 2. 远程仓库地址:
|
||||||
git config --get remote.origin.url
|
git config --get remote.origin.url
|
||||||
echo.
|
echo.
|
||||||
echo 3. 分支冲突:
|
echo 3. 分支冲突:
|
||||||
echo - 先拉取: git pull origin !branch! --rebase
|
echo - 先拉取: git pull origin !branch! --rebase
|
||||||
echo - 解决冲突后推送: git push origin !branch!
|
echo - 解决冲突后推送: git push origin !branch!
|
||||||
echo.
|
echo.
|
||||||
echo 4. 检查网络连接和远程仓库权限
|
echo 4. 检查网络连接和远程仓库权限
|
||||||
echo.
|
echo.
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
142
src/web/static/js/navigation.js
Normal file
142
src/web/static/js/navigation.js
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
/**
|
||||||
|
* 通用导航管理脚本
|
||||||
|
* 用于处理页面间导航和活动状态
|
||||||
|
*/
|
||||||
|
|
||||||
|
class NavigationManager {
|
||||||
|
constructor() {
|
||||||
|
this.currentPage = this.getCurrentPage();
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
// 设置当前页面的活动状态
|
||||||
|
this.setActiveNavigation();
|
||||||
|
|
||||||
|
// 添加导航点击事件监听
|
||||||
|
this.addNavigationListeners();
|
||||||
|
|
||||||
|
// 添加页面加载完成后的处理
|
||||||
|
this.addPageLoadHandlers();
|
||||||
|
}
|
||||||
|
|
||||||
|
getCurrentPage() {
|
||||||
|
const path = window.location.pathname;
|
||||||
|
if (path === '/' || path === '/dashboard') return 'dashboard';
|
||||||
|
if (path === '/alerts') return 'alerts';
|
||||||
|
if (path === '/chat') return 'chat';
|
||||||
|
if (path === '/chat-http') return 'chat-http';
|
||||||
|
return 'dashboard';
|
||||||
|
}
|
||||||
|
|
||||||
|
setActiveNavigation() {
|
||||||
|
// 清除所有活动状态
|
||||||
|
document.querySelectorAll('.nav-link').forEach(link => {
|
||||||
|
link.classList.remove('active');
|
||||||
|
});
|
||||||
|
|
||||||
|
// 设置当前页面的活动状态
|
||||||
|
const activeSelectors = {
|
||||||
|
'dashboard': 'a.nav-link[href="/dashboard"]',
|
||||||
|
'alerts': 'a.nav-link[href="/alerts"]',
|
||||||
|
'chat': 'a.nav-link[href="/chat"]',
|
||||||
|
'chat-http': 'a.nav-link[href="/chat-http"]'
|
||||||
|
};
|
||||||
|
|
||||||
|
const selector = activeSelectors[this.currentPage];
|
||||||
|
if (selector) {
|
||||||
|
document.querySelectorAll(selector).forEach(link => {
|
||||||
|
link.classList.add('active');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addNavigationListeners() {
|
||||||
|
// 对导航链接添加点击处理
|
||||||
|
document.querySelectorAll('a.nav-link[href^="/"]').forEach(link => {
|
||||||
|
link.addEventListener('click', (e) => {
|
||||||
|
const href = link.getAttribute('href');
|
||||||
|
|
||||||
|
// 如果是当前页面,阻止默认行为
|
||||||
|
if (href === window.location.pathname) {
|
||||||
|
e.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 显示加载状态
|
||||||
|
this.showLoadingState();
|
||||||
|
|
||||||
|
// 正常跳转
|
||||||
|
// 注意:这里不阻止默认行为,让浏览器正常跳转
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 对 dashboard.html 的侧边栏导航特殊处理
|
||||||
|
document.querySelectorAll('.sidebar a.nav-link[href^="/"]').forEach(link => {
|
||||||
|
link.addEventListener('click', (e) => {
|
||||||
|
this.showLoadingState();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
showLoadingState() {
|
||||||
|
// 显示加载提示
|
||||||
|
const loadingHtml = `
|
||||||
|
<div id="navigation-loading" class="position-fixed top-0 start-0 w-100 h-100 d-flex justify-content-center align-items-center"
|
||||||
|
style="background: rgba(255,255,255,0.9); z-index: 9999;">
|
||||||
|
<div class="text-center">
|
||||||
|
<div class="spinner-border text-primary" role="status">
|
||||||
|
<span class="visually-hidden">加载中...</span>
|
||||||
|
</div>
|
||||||
|
<p class="mt-2 mb-0">页面跳转中...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
document.body.insertAdjacentHTML('beforeend', loadingHtml);
|
||||||
|
}
|
||||||
|
|
||||||
|
addPageLoadHandlers() {
|
||||||
|
// 页面加载完成后移除加载状态
|
||||||
|
window.addEventListener('load', () => {
|
||||||
|
const loading = document.getElementById('navigation-loading');
|
||||||
|
if (loading) {
|
||||||
|
loading.remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 处理浏览器前进后退
|
||||||
|
window.addEventListener('popstate', () => {
|
||||||
|
this.currentPage = this.getCurrentPage();
|
||||||
|
this.setActiveNavigation();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 手动导航到指定页面
|
||||||
|
navigateTo(page) {
|
||||||
|
const urls = {
|
||||||
|
'dashboard': '/dashboard',
|
||||||
|
'alerts': '/alerts',
|
||||||
|
'chat': '/chat',
|
||||||
|
'chat-http': '/chat-http'
|
||||||
|
};
|
||||||
|
|
||||||
|
const url = urls[page];
|
||||||
|
if (url && url !== window.location.pathname) {
|
||||||
|
this.showLoadingState();
|
||||||
|
window.location.href = url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 页面加载完成后初始化导航管理器
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
window.navigationManager = new NavigationManager();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 导航函数,可以在控制台或页面中使用
|
||||||
|
window.navigateTo = (page) => {
|
||||||
|
if (window.navigationManager) {
|
||||||
|
window.navigationManager.navigateTo(page);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -179,6 +179,50 @@
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<!-- 导航栏 -->
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<a class="navbar-brand" href="/dashboard">
|
||||||
|
<i class="fas fa-shield-alt me-2"></i>
|
||||||
|
TSP助手预警管理
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
|
<ul class="navbar-nav me-auto">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="/dashboard">
|
||||||
|
<i class="fas fa-tachometer-alt me-1"></i>仪表板
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="/alerts">
|
||||||
|
<i class="fas fa-bell me-1"></i>预警管理
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link active" href="/chat">
|
||||||
|
<i class="fas fa-comments me-1"></i>智能对话
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="/chat-http">
|
||||||
|
<i class="fas fa-comment-dots me-1"></i>对话(HTTP)
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div class="navbar-nav ms-auto">
|
||||||
|
<span class="navbar-text">
|
||||||
|
<i class="fas fa-circle text-success"></i> WebSocket连接
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<!-- 侧边栏 -->
|
<!-- 侧边栏 -->
|
||||||
@@ -327,6 +371,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script src="{{ url_for('static', filename='js/navigation.js') }}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/chat.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/chat.js') }}"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -179,6 +179,50 @@
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<!-- 导航栏 -->
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<a class="navbar-brand" href="/dashboard">
|
||||||
|
<i class="fas fa-shield-alt me-2"></i>
|
||||||
|
TSP助手预警管理
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
|
<ul class="navbar-nav me-auto">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="/dashboard">
|
||||||
|
<i class="fas fa-tachometer-alt me-1"></i>仪表板
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="/alerts">
|
||||||
|
<i class="fas fa-bell me-1"></i>预警管理
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="/chat">
|
||||||
|
<i class="fas fa-comments me-1"></i>智能对话
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link active" href="/chat-http">
|
||||||
|
<i class="fas fa-comment-dots me-1"></i>对话(HTTP)
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div class="navbar-nav ms-auto">
|
||||||
|
<span class="navbar-text">
|
||||||
|
<i class="fas fa-circle text-info"></i> HTTP轮询
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<!-- 侧边栏 -->
|
<!-- 侧边栏 -->
|
||||||
@@ -327,6 +371,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script src="{{ url_for('static', filename='js/navigation.js') }}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/chat_http.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/chat_http.js') }}"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -387,11 +387,11 @@
|
|||||||
控制面板
|
控制面板
|
||||||
</h5>
|
</h5>
|
||||||
<nav class="nav flex-column">
|
<nav class="nav flex-column">
|
||||||
<a class="nav-link active" href="#dashboard" data-tab="dashboard" data-i18n="sidebar-dashboard">
|
<a class="nav-link active" href="/dashboard" data-i18n="sidebar-dashboard">
|
||||||
<i class="fas fa-home"></i>
|
<i class="fas fa-home"></i>
|
||||||
仪表板
|
仪表板
|
||||||
</a>
|
</a>
|
||||||
<a class="nav-link" href="#chat" data-tab="chat" data-i18n="sidebar-conversations">
|
<a class="nav-link" href="/chat" data-i18n="sidebar-conversations">
|
||||||
<i class="fas fa-comments"></i>
|
<i class="fas fa-comments"></i>
|
||||||
智能对话
|
智能对话
|
||||||
</a>
|
</a>
|
||||||
@@ -399,7 +399,7 @@
|
|||||||
<i class="fas fa-brain"></i>
|
<i class="fas fa-brain"></i>
|
||||||
Agent管理
|
Agent管理
|
||||||
</a>
|
</a>
|
||||||
<a class="nav-link" href="#alerts" data-tab="alerts" data-i18n="sidebar-alerts">
|
<a class="nav-link" href="/alerts" data-i18n="sidebar-alerts">
|
||||||
<i class="fas fa-exclamation-triangle"></i>
|
<i class="fas fa-exclamation-triangle"></i>
|
||||||
预警管理
|
预警管理
|
||||||
</a>
|
</a>
|
||||||
@@ -415,9 +415,9 @@
|
|||||||
<i class="fas fa-sync"></i>
|
<i class="fas fa-sync"></i>
|
||||||
飞书同步
|
飞书同步
|
||||||
</a>
|
</a>
|
||||||
<a class="nav-link" href="#conversation-history" data-tab="conversation-history" data-i18n="sidebar-conversation-history">
|
<a class="nav-link" href="/chat-http" data-i18n="sidebar-conversation-history">
|
||||||
<i class="fas fa-history"></i>
|
<i class="fas fa-comment-dots"></i>
|
||||||
对话历史
|
HTTP对话
|
||||||
</a>
|
</a>
|
||||||
<a class="nav-link" href="#token-monitor" data-tab="token-monitor" data-i18n="sidebar-token-monitor">
|
<a class="nav-link" href="#token-monitor" data-tab="token-monitor" data-i18n="sidebar-token-monitor">
|
||||||
<i class="fas fa-coins"></i>
|
<i class="fas fa-coins"></i>
|
||||||
@@ -2472,6 +2472,7 @@
|
|||||||
<!-- 脚本 -->
|
<!-- 脚本 -->
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@3.9.1/dist/chart.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/chart.js@3.9.1/dist/chart.min.js"></script>
|
||||||
|
<script src="{{ url_for('static', filename='js/navigation.js') }}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/dashboard.js') }}?v=1.0.9"></script>
|
<script src="{{ url_for('static', filename='js/dashboard.js') }}?v=1.0.9"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -12,14 +12,43 @@
|
|||||||
<!-- 导航栏 -->
|
<!-- 导航栏 -->
|
||||||
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<a class="navbar-brand" href="#">
|
<a class="navbar-brand" href="/dashboard">
|
||||||
<i class="fas fa-shield-alt me-2"></i>
|
<i class="fas fa-shield-alt me-2"></i>
|
||||||
TSP助手预警管理
|
TSP助手预警管理
|
||||||
</a>
|
</a>
|
||||||
<div class="navbar-nav ms-auto">
|
|
||||||
<span class="navbar-text" id="monitor-status">
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
|
||||||
<i class="fas fa-circle text-warning"></i> 监控状态检查中...
|
<span class="navbar-toggler-icon"></span>
|
||||||
</span>
|
</button>
|
||||||
|
|
||||||
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
|
<ul class="navbar-nav me-auto">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="/dashboard">
|
||||||
|
<i class="fas fa-tachometer-alt me-1"></i>仪表板
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link active" href="/alerts">
|
||||||
|
<i class="fas fa-bell me-1"></i>预警管理
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="/chat">
|
||||||
|
<i class="fas fa-comments me-1"></i>智能对话
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="/chat-http">
|
||||||
|
<i class="fas fa-comment-dots me-1"></i>对话(HTTP)
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div class="navbar-nav ms-auto">
|
||||||
|
<span class="navbar-text" id="monitor-status">
|
||||||
|
<i class="fas fa-circle text-warning"></i> 监控状态检查中...
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -650,6 +679,7 @@
|
|||||||
<!-- 脚本 -->
|
<!-- 脚本 -->
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||||
|
<script src="{{ url_for('static', filename='js/navigation.js') }}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/app.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/app.js') }}"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -3,69 +3,69 @@ chcp 65001 >nul
|
|||||||
setlocal enabledelayedexpansion
|
setlocal enabledelayedexpansion
|
||||||
|
|
||||||
echo ========================================
|
echo ========================================
|
||||||
echo Git推送测试脚本
|
echo Git推送测试脚本
|
||||||
echo ========================================
|
echo ========================================
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
:: 检查Git状态
|
:: 检查Git状态
|
||||||
echo [1] 检查Git状态...
|
echo [1] 检查Git状态...
|
||||||
git status --porcelain >nul 2>&1
|
git status --porcelain >nul 2>&1
|
||||||
if %errorlevel% neq 0 (
|
if %errorlevel% neq 0 (
|
||||||
echo Git未初始化
|
echo Git未初始化
|
||||||
pause
|
pause
|
||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
echo Git状态正常
|
echo Git状态正常
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
:: 获取当前分支
|
:: 获取当前分支
|
||||||
echo [2] 获取当前分支...
|
echo [2] 获取当前分支...
|
||||||
set current_branch=
|
set current_branch=
|
||||||
for /f "tokens=*" %%b in ('git branch --show-current 2^>nul') do set current_branch=%%b
|
for /f "tokens=*" %%b in ('git branch --show-current 2^>nul') do set current_branch=%%b
|
||||||
|
|
||||||
if "!current_branch!"=="" (
|
if "!current_branch!"=="" (
|
||||||
echo 无法获取当前分支,使用默认分支main
|
echo 无法获取当前分支,使用默认分支main
|
||||||
set current_branch=main
|
set current_branch=main
|
||||||
) else (
|
) else (
|
||||||
echo 当前分支: !current_branch!
|
echo 当前分支: !current_branch!
|
||||||
)
|
)
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
:: 检查远程仓库
|
:: 检查远程仓库
|
||||||
echo [3] 检查远程仓库...
|
echo [3] 检查远程仓库...
|
||||||
git remote -v
|
git remote -v
|
||||||
if %errorlevel% neq 0 (
|
if %errorlevel% neq 0 (
|
||||||
echo 未配置远程仓库
|
echo 未配置远程仓库
|
||||||
pause
|
pause
|
||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
:: 尝试推送
|
:: 尝试推送
|
||||||
echo [4] 尝试推送到远程...
|
echo [4] 尝试推送到远程...
|
||||||
echo 分支: !current_branch!
|
echo 分支: !current_branch!
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
git push origin !current_branch! 2>&1
|
git push origin !current_branch! 2>&1
|
||||||
if %errorlevel% equ 0 (
|
if %errorlevel% equ 0 (
|
||||||
echo.
|
echo.
|
||||||
echo 推送成功!
|
echo 推送成功!
|
||||||
) else (
|
) else (
|
||||||
echo.
|
echo.
|
||||||
echo 推送失败
|
echo 推送失败
|
||||||
echo.
|
echo.
|
||||||
echo 可能的原因:
|
echo 可能的原因:
|
||||||
echo 1. 远程分支不存在,尝试设置上游...
|
echo 1. 远程分支不存在,尝试设置上游...
|
||||||
git push -u origin !current_branch! 2>&1
|
git push -u origin !current_branch! 2>&1
|
||||||
if %errorlevel% equ 0 (
|
if %errorlevel% equ 0 (
|
||||||
echo 推送成功(已设置上游)!
|
echo 推送成功(已设置上游)!
|
||||||
) else (
|
) else (
|
||||||
echo 推送仍然失败
|
echo 推送仍然失败
|
||||||
echo.
|
echo.
|
||||||
echo 请检查:
|
echo 请检查:
|
||||||
echo - 网络连接
|
echo - 网络连接
|
||||||
echo - 认证配置(SSH密钥或Token)
|
echo - 认证配置(SSH密钥或Token)
|
||||||
echo - 远程仓库地址
|
echo - 远程仓库地址
|
||||||
pause
|
pause
|
||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
@@ -73,7 +73,7 @@ if %errorlevel% equ 0 (
|
|||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ========================================
|
echo ========================================
|
||||||
echo 测试完成
|
echo 测试完成
|
||||||
echo ========================================
|
echo ========================================
|
||||||
pause
|
pause
|
||||||
|
|
||||||
|
|||||||
121
test_navigation.py
Normal file
121
test_navigation.py
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
前端导航测试脚本
|
||||||
|
测试所有页面路由是否正常工作
|
||||||
|
"""
|
||||||
|
|
||||||
|
import requests
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
|
def test_page_routes(base_url="http://localhost:5000"):
|
||||||
|
"""测试所有页面路由"""
|
||||||
|
|
||||||
|
# 测试的路由列表
|
||||||
|
routes = [
|
||||||
|
("/", "仪表板"),
|
||||||
|
("/dashboard", "仪表板"),
|
||||||
|
("/alerts", "预警管理"),
|
||||||
|
("/chat", "智能对话"),
|
||||||
|
("/chat-http", "HTTP对话")
|
||||||
|
]
|
||||||
|
|
||||||
|
print("🔍 开始测试前端路由...")
|
||||||
|
print(f"📍 基础URL: {base_url}")
|
||||||
|
print("-" * 60)
|
||||||
|
|
||||||
|
results = []
|
||||||
|
|
||||||
|
for route, name in routes:
|
||||||
|
try:
|
||||||
|
url = f"{base_url}{route}"
|
||||||
|
print(f"🧪 测试路由: {route} ({name})")
|
||||||
|
|
||||||
|
# 发送请求
|
||||||
|
response = requests.get(url, timeout=10)
|
||||||
|
|
||||||
|
# 检查响应状态
|
||||||
|
if response.status_code == 200:
|
||||||
|
print(f" ✅ 状态码: {response.status_code}")
|
||||||
|
|
||||||
|
# 检查响应内容是否包含HTML
|
||||||
|
content_type = response.headers.get('Content-Type', '')
|
||||||
|
if 'text/html' in content_type:
|
||||||
|
print(f" ✅ 内容类型: {content_type}")
|
||||||
|
|
||||||
|
# 检查是否包含导航栏
|
||||||
|
if 'navbar' in response.text:
|
||||||
|
print(f" ✅ 导航栏: 存在")
|
||||||
|
else:
|
||||||
|
print(f" ⚠️ 导航栏: 缺失")
|
||||||
|
|
||||||
|
# 检查页面大小
|
||||||
|
size_kb = len(response.content) / 1024
|
||||||
|
print(f" ✅ 页面大小: {size_kb:.1f} KB")
|
||||||
|
|
||||||
|
results.append((route, name, "成功", response.status_code))
|
||||||
|
else:
|
||||||
|
print(f" ❌ 内容类型错误: {content_type}")
|
||||||
|
results.append((route, name, "内容类型错误", response.status_code))
|
||||||
|
else:
|
||||||
|
print(f" ❌ 状态码错误: {response.status_code}")
|
||||||
|
results.append((route, name, "状态码错误", response.status_code))
|
||||||
|
|
||||||
|
except requests.exceptions.ConnectionError:
|
||||||
|
print(f" ❌ 连接失败: 服务器未启动")
|
||||||
|
results.append((route, name, "连接失败", 0))
|
||||||
|
break
|
||||||
|
except requests.exceptions.Timeout:
|
||||||
|
print(f" ❌ 请求超时")
|
||||||
|
results.append((route, name, "请求超时", 0))
|
||||||
|
except Exception as e:
|
||||||
|
print(f" ❌ 未知错误: {str(e)}")
|
||||||
|
results.append((route, name, f"错误: {str(e)}", 0))
|
||||||
|
|
||||||
|
print()
|
||||||
|
|
||||||
|
# 打印测试总结
|
||||||
|
print("=" * 60)
|
||||||
|
print("📊 测试总结:")
|
||||||
|
|
||||||
|
success_count = 0
|
||||||
|
total_count = len(results)
|
||||||
|
|
||||||
|
for route, name, status, code in results:
|
||||||
|
status_icon = "✅" if status == "成功" else "❌"
|
||||||
|
print(f" {status_icon} {route} ({name}): {status}")
|
||||||
|
if status == "成功":
|
||||||
|
success_count += 1
|
||||||
|
|
||||||
|
print()
|
||||||
|
print(f"📈 成功率: {success_count}/{total_count} ({success_count/total_count*100:.1f}%)")
|
||||||
|
|
||||||
|
if success_count == total_count:
|
||||||
|
print("🎉 所有路由测试通过!")
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
print("⚠️ 部分路由存在问题")
|
||||||
|
return False
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print("TSP助手前端路由测试工具")
|
||||||
|
print("=" * 60)
|
||||||
|
|
||||||
|
# 检查服务器是否运行
|
||||||
|
base_url = "http://localhost:5000"
|
||||||
|
|
||||||
|
# 如果提供了命令行参数,使用自定义URL
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
base_url = sys.argv[1]
|
||||||
|
|
||||||
|
success = test_page_routes(base_url)
|
||||||
|
|
||||||
|
if not success:
|
||||||
|
print("\n💡 解决建议:")
|
||||||
|
print("1. 确保Flask服务器已启动: python src/web/app.py")
|
||||||
|
print("2. 检查端口是否正确: 默认5000")
|
||||||
|
print("3. 检查防火墙设置")
|
||||||
|
print("4. 查看服务器日志了解详细错误信息")
|
||||||
|
|
||||||
|
sys.exit(0 if success else 1)
|
||||||
Reference in New Issue
Block a user