feat: 重构项目结构并添加平台同步基础架构
- 重构项目目录结构,将功能模块移至 modules/ 目录 - 创建平台同步基础架构,包括发布器基类和 GitHub 发布器 - 新增 UI 状态管理模块 (modules/ui/state.py) 统一管理会话状态 - 更新依赖配置,添加平台同步所需依赖 (httpx, pyperclip) - 整理文档结构,将所有文档分类移至 docs/ 目录 - 添加 .cursorrules 文件定义项目开发规范 - 清理根目录重复文件,保持项目结构整洁
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
"""
|
||||
UI-level modules for GEO Streamlit app.
|
||||
|
||||
Each top-level Tab in `geo_tool.py` should have a corresponding
|
||||
`tab_*.py` module here, exposing a `render_*` function that is
|
||||
invoked from the main app.
|
||||
"""
|
||||
|
||||
from . import tab_keywords, tab_autowrite
|
||||
@@ -0,0 +1,53 @@
|
||||
import streamlit as st
|
||||
|
||||
|
||||
def ss_init(key, default):
|
||||
"""
|
||||
统一的 session_state 初始化函数。
|
||||
|
||||
- 仅当 key 不存在时才写入默认值
|
||||
- 避免在多个模块中重复实现
|
||||
"""
|
||||
if key not in st.session_state:
|
||||
st.session_state[key] = default
|
||||
|
||||
|
||||
def init_session_state():
|
||||
"""
|
||||
初始化 GEO 应用中跨 Tab 使用的核心 session_state 字段。
|
||||
|
||||
说明:
|
||||
- 这里只负责**跨 Tab 共享**或在多处使用的 key
|
||||
- 各 Tab 内部的临时/局部状态仍然由 Tab 自己按需调用 ss_init
|
||||
"""
|
||||
# 配置相关
|
||||
# ss_init("cfg", {}) # 移除:由主程序 geo_tool.py 负责初始化,避免空字典覆盖默认配置
|
||||
ss_init("cfg_applied", False)
|
||||
ss_init("cfg_valid", False)
|
||||
ss_init("cfg_errors", [])
|
||||
|
||||
# 关键词模块
|
||||
ss_init("keywords", [])
|
||||
ss_init("kw_last_num", 40)
|
||||
ss_init("kw_generation_mode", "AI生成")
|
||||
ss_init("wordbanks", None)
|
||||
|
||||
# 内容创作模块
|
||||
ss_init("generated_contents", [])
|
||||
ss_init("zip_bytes", None)
|
||||
ss_init("zip_filename", "")
|
||||
ss_init("content_scores", {})
|
||||
ss_init("selected_content_idx", 0)
|
||||
|
||||
# 文章优化模块
|
||||
ss_init("optimized_article", "")
|
||||
ss_init("opt_changes", "")
|
||||
ss_init("opt_platform", "通用优化")
|
||||
|
||||
# 多模型验证
|
||||
ss_init("verify_combined", None)
|
||||
ss_init("verify_last_queries", "")
|
||||
|
||||
# 其他跨模块使用的标志位
|
||||
ss_init("cancel_generation", False)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,168 @@
|
||||
import streamlit as st
|
||||
|
||||
|
||||
def inject_global_theme():
|
||||
"""注入全局 CSS 主题,保持与原 geo_tool.py 中完全一致的视觉风格。"""
|
||||
st.markdown(
|
||||
"""
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Noto+Sans+SC:wght@400;500;600&display=swap');
|
||||
|
||||
::root {
|
||||
--bg: #FFFFFF;
|
||||
--panel: #F7FAFC;
|
||||
--text: #1A202C;
|
||||
--muted: #4A5568;
|
||||
--border: #E2E8F0;
|
||||
--primary: #2563EB;
|
||||
--shadow: 0 1px 2px rgba(16,24,40,.04), 0 6px 16px rgba(16,24,40,.06);
|
||||
--radius: 12px;
|
||||
}
|
||||
|
||||
html, body, .stApp {
|
||||
font-family: "Inter", "Noto Sans SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
|
||||
background: var(--bg) !important;
|
||||
color: var(--text) !important;
|
||||
}
|
||||
|
||||
.block-container { padding-top: 1.6rem !important; padding-bottom: 3.5rem !important; }
|
||||
|
||||
/* Sidebar */
|
||||
section[data-testid="stSidebar"] { background: var(--panel) !important; border-right: 1px solid var(--border) !important; }
|
||||
|
||||
/* 侧边栏分组卡片 */
|
||||
section[data-testid="stSidebar"] .stForm,
|
||||
section[data-testid="stSidebar"] div[data-testid="stVerticalBlockBorderWrapper"] {
|
||||
background: #FFFFFF !important;
|
||||
border-radius: 8px !important;
|
||||
padding: 1rem !important;
|
||||
margin-bottom: 1rem !important;
|
||||
border: 1px solid var(--border) !important;
|
||||
box-shadow: 0 1px 2px rgba(16,24,40,.02), 0 2px 8px rgba(16,24,40,.04) !important;
|
||||
}
|
||||
|
||||
/* 标题层级 */
|
||||
h1, h2, h3, h4, h5, h6 { font-family: "Inter", "Noto Sans SC", sans-serif !important; color: var(--text) !important; }
|
||||
h1 { font-size: 2.15rem !important; font-weight: 600 !important; letter-spacing: -0.4px !important; margin-bottom: 1.0rem !important; }
|
||||
h2 { font-size: 1.25rem !important; font-weight: 600 !important; color: var(--text) !important; margin: 1.8rem 0 0.75rem 0 !important; }
|
||||
|
||||
/* 按钮 - 保留圆角 */
|
||||
button[kind="primary"],
|
||||
div[data-testid="stButton"] button[kind="primary"],
|
||||
div[data-testid="stFormSubmitButton"] button[kind="primary"] {
|
||||
# background-color: var(--primary) !important;
|
||||
# color: white !important;
|
||||
border-radius: var(--radius) !important;
|
||||
# border: none !important;
|
||||
}
|
||||
|
||||
button[kind="secondary"],
|
||||
div[data-testid="stButton"] button[kind="secondary"] {
|
||||
background: #FFFFFF !important;
|
||||
border: 1px solid var(--border) !important;
|
||||
# color: var(--text) !important;
|
||||
border-radius: var(--radius) !important;
|
||||
}
|
||||
|
||||
button:focus, button:focus-visible {
|
||||
box-shadow: 0 0 0 3px rgba(37,99,235,0.12) !important;
|
||||
outline: none !important;
|
||||
}
|
||||
|
||||
/* 输入 */
|
||||
.stTextInput input, .stTextArea textarea, .stSelectbox div[data-baseweb="select"] {
|
||||
border-radius: 10px !important;
|
||||
}
|
||||
.stTextInput input, .stTextArea textarea {
|
||||
border: 1px solid var(--border) !important;
|
||||
padding: 0.75rem !important;
|
||||
}
|
||||
.stTextInput input:focus, .stTextArea textarea:focus {
|
||||
border-color: var(--primary) !important;
|
||||
box-shadow: 0 0 0 3px rgba(37,99,235,0.12) !important;
|
||||
}
|
||||
|
||||
/* Tabs - 移除圆角和边框(核心修复) */
|
||||
.stTabs [role="tab"] {
|
||||
border-radius: 0 !important;
|
||||
border: none !important;
|
||||
background: transparent !important;
|
||||
padding: 12px 16px !important;
|
||||
color: var(--muted) !important;
|
||||
font-weight: 500 !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
/* 防止 focus 框干扰 */
|
||||
.stTabs [role="tab"]:focus,
|
||||
.stTabs [role="tab"]:focus-visible {
|
||||
outline: none !important;
|
||||
box-shadow: none !important;
|
||||
border: none !important;
|
||||
}
|
||||
|
||||
/* Tabs 产品化 */
|
||||
.stTabs [data-baseweb="tab-list"] { gap: 8px; }
|
||||
.stTabs [data-baseweb="tab"]{
|
||||
padding: 10px 14px;
|
||||
border-radius: 10px;
|
||||
background: transparent;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
.stTabs [aria-selected="true"]{
|
||||
background: rgba(37,99,235,.08);
|
||||
border: 1px solid rgba(37,99,235,.20);
|
||||
}
|
||||
|
||||
/* 卡片容器 */
|
||||
div[data-testid="stVerticalBlockBorderWrapper"] {
|
||||
border-radius: var(--radius) !important;
|
||||
box-shadow: var(--shadow) !important;
|
||||
padding: 1.5rem !important;
|
||||
background: #FFFFFF !important;
|
||||
margin-bottom: 1rem !important;
|
||||
border: 1px solid var(--border) !important;
|
||||
}
|
||||
|
||||
/* Metric/KPI 卡片 */
|
||||
div[data-testid="stMetricContainer"] {
|
||||
min-height: 130px !important;
|
||||
padding: 1rem !important;
|
||||
border-radius: var(--radius) !important;
|
||||
background: #FFFFFF !important;
|
||||
border: 1px solid var(--border) !important;
|
||||
box-shadow: var(--shadow) !important;
|
||||
}
|
||||
|
||||
div[data-testid="stMetricValue"] {
|
||||
min-height: 3rem !important;
|
||||
height: 3rem !important;
|
||||
display: flex !important;
|
||||
align-items: center !important;
|
||||
font-size: 1.5rem !important;
|
||||
}
|
||||
|
||||
/* Expander */
|
||||
.streamlit-expanderHeader {
|
||||
font-weight: 500 !important;
|
||||
color: var(--text) !important;
|
||||
padding: 0.75rem 0 !important;
|
||||
}
|
||||
|
||||
/* 分隔线 */
|
||||
hr {
|
||||
border: none;
|
||||
border-top: 1px solid var(--border) !important;
|
||||
margin: 1.5rem 0 !important;
|
||||
}
|
||||
</style>
|
||||
""",
|
||||
unsafe_allow_html=True,
|
||||
)
|
||||
|
||||
# 保留原有按钮圆角覆盖,避免视觉回退
|
||||
st.markdown(
|
||||
"<style>button{border-radius:0px !important;}</style>",
|
||||
unsafe_allow_html=True,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user