Files
yu-zhi-ran/platform/check.py
T
lt 277b13eaae feat: 完成布局优化 - 操作列固定、批量按钮自适应、分类标签带数量
优化内容:
1. 表格布局:
   - 使用 calc(100vw - 160px) 确保表格不超出视口
   - 操作列 fixed='right' 固定在右侧,宽度 300px
   - 按钮 3 个后自动换行 (max-width: 200px)
   - 恢复合理列宽,不再过度压缩

2. 批量操作区域:
   - 容器改为 inline-block,宽度自适应按钮内容
   - 背景宽度与按钮总宽度匹配

3. 分类标签:
   - 显示数量 (如 '待处理 (20)')
   - 点击切换筛选,去掉误导的 'X' 图标

4. 删除功能:
   - 操作列增加删除按钮
   - 删除前弹出确认对话框

5. 系统日志:
   - 修复后端日志路径 (parents[4])
   - 404 时显示友好提示

6. 其他:
   - 左侧菜单宽度 160px
   - 所有功能保留 (登录、用户管理、批量操作等)
2026-04-27 11:32:17 +08:00

91 lines
2.7 KiB
Python
Raw 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.
#!/usr/bin/env python3
"""部署前检查脚本"""
import sys
from pathlib import Path
import importlib.util
def check_file(path, desc):
if Path(path).exists():
print(f"{desc}: {path}")
return True
else:
print(f"❌ 缺失: {desc}{path}")
return False
def check_module(module, desc):
if importlib.util.find_spec(module):
print(f"✅ Python模块: {module}")
return True
else:
print(f"❌ 缺失Python模块: {module}(需运行 pip install -r requirements.txt")
return False
def main():
print("========================================")
print("宇之然内容创作平台 - 部署前检查")
print("========================================\n")
all_ok = True
# 1. 项目结构检查
print("【1】项目结构")
base = Path(__file__).parent
paths = [
(base / "backend" / "app" / "main.py", "后端入口"),
(base / "frontend" / "index.html", "前端主文件"),
(base / "data", "数据目录"),
(base / "logs", "日志目录"),
(base / ".." / "automation" / "data" / "sustainability_topics.json", "选题JSON"),
(base / ".." / "scripts" / "creator.py", "创作脚本"),
(base / ".." / "scripts" / "publisher.py", "发布脚本"),
]
for p, desc in paths:
all_ok &= check_file(p, desc)
print()
# 2. Python依赖检查
print("【2】Python依赖")
modules = ["fastapi", "uvicorn", "sqlalchemy", "pydantic"]
for m in modules:
all_ok &= check_module(m, "模块")
print()
# 3. 配置检查
print("【3】配置与环境")
backend_dir = base / "backend"
venv_ok = (backend_dir / "venv").exists()
if venv_ok:
print("✅ 虚拟环境存在")
else:
print("⚠️ 虚拟环境不存在(可选,建议创建)")
print()
# 4. 端口检查(从环境变量或脚本参数获取端口)
import os
import sys
port = int(os.environ.get('YZR_PORT', sys.argv[1] if len(sys.argv) > 1 else '8001'))
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.bind(("0.0.0.0", port))
print(f"✅ 端口 {port} 可用")
except OSError as e:
print(f"❌ 端口 {port} 被占用: {e}")
all_ok = False
finally:
s.close()
print()
print("========================================")
if all_ok:
print("✅ 检查通过,可以运行 ./run.sh 启动服务")
else:
print("❌ 存在问题,请根据上述提示修复")
print("========================================")
return 0 if all_ok else 1
if __name__ == "__main__":
sys.exit(main())