MCPcopy Create free account
hub / github.com/Feather-2/Burner-X / updateProcessButtonState

Function updateProcessButtonState

js/ui/ui-processing.js:125–211  ·  view source on GitHub ↗
(pdfFiles, isProcessing)

Source from the content-addressed store, hash-verified

123 }
124
125 function updateProcessButtonState(pdfFiles, isProcessing) {
126 if (!processBtn) return;
127 const getActiveFiles = typeof global.getActiveFiles === 'function' ? global.getActiveFiles : null;
128 const effectiveFiles = getActiveFiles ? getActiveFiles() : pdfFiles;
129 let ocrConfigAvailable = true; // 重命名:更清晰地表示 OCR 配置是否可用
130 let translationKeysAvailable = true;
131 const hasPdfFiles = effectiveFiles.some(file => file.name.toLowerCase().endsWith('.pdf'));
132
133 // 检查 OCR 引擎与所需配置
134 let ocrEngine = 'mistral';
135 let ocrConfigValid = true;
136 let ocrConfigMessage = '';
137 try {
138 if (window.ocrSettingsManager && typeof window.ocrSettingsManager.getCurrentConfig === 'function') {
139 ocrEngine = window.ocrSettingsManager.getCurrentConfig().engine || (localStorage.getItem('ocrEngine') || 'mistral');
140 // 使用 validateConfig 检查配置是否完整
141 const validation = window.ocrSettingsManager.validateConfig();
142 ocrConfigValid = validation.valid;
143 ocrConfigMessage = validation.message;
144 } else {
145 ocrEngine = localStorage.getItem('ocrEngine') || 'mistral';
146 }
147 } catch {}
148
149 if (hasPdfFiles) {
150 if (ocrEngine === 'none') {
151 // 选择了"不需要 OCR"但有 PDF 文件,标记为无效
152 ocrConfigAvailable = false;
153 } else if (!ocrConfigValid) {
154 // 当前选择的 OCR 引擎配置不完整
155 ocrConfigAvailable = false;
156 } else {
157 // OCR 配置有效
158 ocrConfigAvailable = true;
159 }
160 }
161
162 // 检查翻译 Keys(如果需要翻译)- 直接使用 app.js 的逻辑
163 const settings = typeof global.loadSettings === 'function' ? global.loadSettings() : {};
164 const selectedTranslationModelName = settings.selectedTranslationModel || 'none';
165 let translationModelDisplayName = selectedTranslationModelName;
166 let currentTranslationModelForProvider = null;
167 let translationModelConfigForProcess = null;
168
169 if (selectedTranslationModelName !== 'none') {
170 if (selectedTranslationModelName === 'custom') {
171 const selectedCustomSourceId = settings.selectedCustomSourceSiteId;
172 if (!selectedCustomSourceId) {
173 translationKeysAvailable = false;
174 } else {
175 const allSourceSites = typeof global.loadAllCustomSourceSites === 'function' ? global.loadAllCustomSourceSites() : {};
176 const siteConfig = allSourceSites[selectedCustomSourceId];
177 if (!siteConfig) {
178 translationKeysAvailable = false;
179 } else {
180 currentTranslationModelForProvider = `custom_source_${selectedCustomSourceId}`;
181 translationModelConfigForProcess = siteConfig;
182 translationModelDisplayName = siteConfig.displayName || siteConfig.name || selectedCustomSourceId;

Callers 8

app.jsFile · 0.85
handleClearFilesFunction · 0.85
handleRemoveFileFunction · 0.85
addFilesToListFunction · 0.85
handleFormatFilterChangeFunction · 0.85
handleFormatFilterClickFunction · 0.85
handleProcessClickFunction · 0.85
_retryRecordInternalFunction · 0.85

Calls 6

hasAvailableKeysMethod · 0.95
getActiveFilesFunction · 0.85
updateValidationAlertFunction · 0.85
getCurrentConfigMethod · 0.80
validateConfigMethod · 0.45
loadSettingsMethod · 0.45

Tested by

no test coverage detected