Files
one-api-workers/public/js/main.js
T
dreamhunter2333andClaude Sonnet 4.5 50b40a18a8 fix: 修复频道多选下拉框选择无效的问题
- 将点击事件从 div 移到 checkbox 的 onchange 事件
- 新增 handleChannelCheckboxChange 函数,正确处理 checkbox 状态
- 避免手动切换 checkbox 导致状态被切换两次的问题
- 现在点击 checkbox 可以正确更新选中状态

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-17 18:48:42 +08:00

66 lines
2.9 KiB
JavaScript

// ===== Main Entry Point =====
import { toggleModal, switchTab, toggleTheme, showNotification, copyToClipboard } from './utils.js';
import { toggleAuthModal, authenticate, initAuth } from './auth.js';
import { updateRequestTemplate, testAPI } from './api-test.js';
import { loadChannels, showChannelList, showChannelForm, editChannel, saveChannel, toggleChannelEditMode, deleteChannel, addMapperRow, removeMapperRow } from './channels.js';
import { loadTokens, showTokenList, showTokenForm, editToken, saveToken, generateTokenKey, toggleTokenEditMode, deleteToken, setQuotaValue, toggleChannelDropdown, toggleChannelSelection, filterChannels, handleChannelCheckboxChange } from './tokens.js';
import { loadPricing, savePricing, addPricingModel, removePricingRow, togglePricingEditMode } from './pricing.js';
import { initDatabase } from './database.js';
// Expose functions to global scope for onclick handlers
window.toggleModal = toggleModal;
window.switchTab = switchTab;
window.toggleTheme = toggleTheme;
window.copyToClipboard = copyToClipboard;
window.toggleAuthModal = toggleAuthModal;
window.authenticate = authenticate;
window.updateRequestTemplate = updateRequestTemplate;
window.testAPI = testAPI;
window.loadChannels = loadChannels;
window.showChannelList = showChannelList;
window.showChannelForm = showChannelForm;
window.editChannel = editChannel;
window.saveChannel = saveChannel;
window.toggleChannelEditMode = toggleChannelEditMode;
window.deleteChannel = deleteChannel;
window.addMapperRow = addMapperRow;
window.removeMapperRow = removeMapperRow;
window.loadTokens = loadTokens;
window.showTokenList = showTokenList;
window.showTokenForm = showTokenForm;
window.editToken = editToken;
window.saveToken = saveToken;
window.generateTokenKey = generateTokenKey;
window.setQuotaValue = setQuotaValue;
window.toggleTokenEditMode = toggleTokenEditMode;
window.deleteToken = deleteToken;
window.toggleChannelDropdown = toggleChannelDropdown;
window.toggleChannelSelection = toggleChannelSelection;
window.handleChannelCheckboxChange = handleChannelCheckboxChange;
window.filterChannels = filterChannels;
window.loadPricing = loadPricing;
window.savePricing = savePricing;
window.addPricingModel = addPricingModel;
window.removePricingRow = removePricingRow;
window.togglePricingEditMode = togglePricingEditMode;
window.initDatabase = initDatabase;
// Initialize on DOMContentLoaded
document.addEventListener('DOMContentLoaded', () => {
// Initialize theme
const isDark = localStorage.getItem('theme') === 'dark';
if (isDark) {
document.documentElement.classList.add('dark');
document.getElementById('themeIcon').textContent = '☀️';
} else {
document.documentElement.classList.remove('dark');
document.getElementById('themeIcon').textContent = '🌙';
}
// Initialize authentication
initAuth();
// Initialize API test template
updateRequestTemplate();
});