backup: 完成 HR_position_ 表格前綴重命名與欄位對照表整理
變更內容: - 所有資料表加上 HR_position_ 前綴 - 整理完整欄位顯示名稱與 ID 對照表 - 模組化 JS 檔案 (admin.js, ai.js, csv.js 等) - 專案結構優化 (docs/, scripts/, tests/ 等) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
90
scripts/fix_gemini_model.py
Normal file
90
scripts/fix_gemini_model.py
Normal file
@@ -0,0 +1,90 @@
|
||||
"""
|
||||
修正 Gemini 模型名稱和關閉按鈕
|
||||
"""
|
||||
|
||||
# 1. 修正 llm_config.py 中的 Gemini 模型
|
||||
with open('llm_config.py', 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
# 備份
|
||||
with open('llm_config.py.backup', 'w', encoding='utf-8') as f:
|
||||
f.write(content)
|
||||
|
||||
# 替換模型名稱:gemini-pro -> gemini-2.0-flash-exp
|
||||
old_model = 'gemini-pro'
|
||||
new_model = 'gemini-2.0-flash-exp' # 使用最新的 Gemini 2.0 Flash
|
||||
|
||||
content = content.replace(
|
||||
f'models/{old_model}:generateContent',
|
||||
f'models/{new_model}:generateContent'
|
||||
)
|
||||
|
||||
if 'gemini-2.0-flash-exp' in content:
|
||||
print(f"SUCCESS: Updated Gemini model to {new_model}")
|
||||
else:
|
||||
print("ERROR: Could not update model")
|
||||
|
||||
with open('llm_config.py', 'w', encoding='utf-8') as f:
|
||||
f.write(content)
|
||||
|
||||
|
||||
# 2. 修正 index.html 中的關閉按鈕
|
||||
with open('index.html', 'r', encoding='utf-8') as f:
|
||||
html_content = f.read()
|
||||
|
||||
# 備份
|
||||
with open('index.html.backup3', 'w', encoding='utf-8') as f:
|
||||
f.write(html_content)
|
||||
|
||||
# 找到並修正關閉按鈕
|
||||
# 問題:onclick 使用了複雜的選擇器,可能失效
|
||||
# 解決:使用更簡單可靠的方式
|
||||
|
||||
old_close_button = '''<button onclick="this.closest('[style*=\\'position: fixed\\']').remove()"'''
|
||||
new_close_button = '''<button onclick="closeErrorModal(this)"'''
|
||||
|
||||
if old_close_button in html_content:
|
||||
html_content = html_content.replace(old_close_button, new_close_button)
|
||||
print("SUCCESS: Updated close button onclick")
|
||||
else:
|
||||
print("INFO: Close button pattern not found (might be already fixed)")
|
||||
|
||||
# 添加 closeErrorModal 函數(如果不存在)
|
||||
if 'function closeErrorModal' not in html_content:
|
||||
close_modal_function = '''
|
||||
// 關閉錯誤訊息對話框
|
||||
function closeErrorModal(button) {
|
||||
const modal = button.closest('[style*="position: fixed"]');
|
||||
if (modal) {
|
||||
modal.style.opacity = '0';
|
||||
setTimeout(() => modal.remove(), 300);
|
||||
}
|
||||
}
|
||||
'''
|
||||
|
||||
# 在 showCopyableError 函數後添加
|
||||
if 'function showCopyableError' in html_content:
|
||||
html_content = html_content.replace(
|
||||
' // 複製錯誤訊息到剪貼板',
|
||||
close_modal_function + '\n // 複製錯誤訊息到剪貼板'
|
||||
)
|
||||
print("SUCCESS: Added closeErrorModal function")
|
||||
|
||||
# 同時修正底部的確定按鈕
|
||||
old_confirm_button = '''<button onclick="this.closest('[style*=\\'position: fixed\\']').remove()"'''
|
||||
if old_confirm_button in html_content:
|
||||
html_content = html_content.replace(old_confirm_button, new_close_button)
|
||||
print("SUCCESS: Updated confirm button onclick")
|
||||
|
||||
with open('index.html', 'w', encoding='utf-8') as f:
|
||||
f.write(html_content)
|
||||
|
||||
print("\nAll fixes applied!")
|
||||
print("\nChanges made:")
|
||||
print(f"1. Gemini model: {old_model} -> {new_model}")
|
||||
print("2. Close button: Fixed onclick handler")
|
||||
print("3. Added closeErrorModal function")
|
||||
print("\nNext steps:")
|
||||
print("1. Restart Flask server")
|
||||
print("2. Reload browser page (Ctrl+F5)")
|
||||
print("3. Test AI generation")
|
||||
Reference in New Issue
Block a user