version 1

This commit is contained in:
2025-07-15 14:11:39 +08:00
parent 81d4874926
commit dc94cc41c2
16 changed files with 1872 additions and 445 deletions

View File

@ -0,0 +1,38 @@
# ui_fragments/tab_data_processing.py
import streamlit as st
import callbacks
from project_model import Project # 引入 Project 以便進行型別註記
@st.fragment
def render_tab(project: Project):
"""
負責顯示「1. 資料處理 & AI 加註」Tab 的所有 UI 元件和邏輯。
"""
# 根據 project.data 的狀態來決定顯示哪個 UI
if project.data:
# --- 狀態一:專案「已同步」---
st.session_state.operation_status = {
"success": True,
"message": "✅ 專案資料已就緒。"
}
with st.container(border=True):
col1, col2 = st.columns([3, 1])
with col1:
st.subheader("專案資料與 AI 加註")
with col2:
st.button("🔄 從 Notion 同步更新", on_click=callbacks.callback_sync_notion)
with st.expander("預覽專案資料", expanded=False):
st.json(project.data)
st.divider()
st.subheader("AI 自動加註")
# ... (AI 加註的按鈕和邏輯) ...
st.button("執行 AI 翻譯與音標加註並寫回 Notion", on_click=callbacks.callback_add_zh_ipa)
else:
# --- 狀態二:專案「僅初始化」---
st.info(" 這個專案的框架已建立,請執行第一步來同步核心資料。")
st.button("🚀 步驟一:從 Notion 抓取專案資料", on_click=callbacks.callback_sync_notion, type="primary")
st.divider()
st.info("✍️ **人工檢查點**\n\n1. 請確保 `Notion` 中的內容是您想要的最終版本。\n2. 修改完成後,記得點擊上方的同步按鈕。")