feat: 模型 vision 能力检测,不支持时禁用图片上传
- model-bar.js: 新增 setVisionAvailable() 控制图片按钮状态 - model-bar.js: 导出 isVisionAvailable() 供其他组件查询 - input-area.js: 点击图片按钮时校验 vision 能力 - input-area.js: 发送消息时二次校验,防止绕过 - style.css: .icon-btn.disabled 灰显不可点击样式
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
import { state, KEYS } from '../state.js';
|
||||
import { fileToBase64, fileToText, detectLanguage, debounce, truncate, escapeHtml, formatSize } from '../utils.js';
|
||||
import { getSelectedModel, isThinkEnabled } from './model-bar.js';
|
||||
import { getSelectedModel, isThinkEnabled, isVisionAvailable } from './model-bar.js';
|
||||
import {
|
||||
renderMessages, appendAssistantPlaceholder, appendSystemMessage,
|
||||
updateLastAssistantMessage, clearMessages, safeMarkdown
|
||||
@@ -98,7 +98,13 @@ export function initInputArea() {
|
||||
chatInputEl.addEventListener('input', autoResizeTextarea);
|
||||
|
||||
// 图片上传
|
||||
document.querySelector('#btnAttachImg').addEventListener('click', () => fileInputEl.click());
|
||||
document.querySelector('#btnAttachImg').addEventListener('click', () => {
|
||||
if (!isVisionAvailable()) {
|
||||
showToast('当前模型不支持图片分析', 'warning');
|
||||
return;
|
||||
}
|
||||
fileInputEl.click();
|
||||
});
|
||||
fileInputEl.addEventListener('change', (e) => {
|
||||
handleImageSelect(e.target.files);
|
||||
e.target.value = '';
|
||||
@@ -290,6 +296,12 @@ export async function sendMessage() {
|
||||
return;
|
||||
}
|
||||
|
||||
// 有图片但模型不支持 vision → 阻止发送
|
||||
if (pendingImages.length > 0 && !isVisionAvailable()) {
|
||||
appendSystemMessage('⚠️ 当前模型不支持图片分析,请移除图片后重试');
|
||||
return;
|
||||
}
|
||||
|
||||
const currentSession = state.get(KEYS.CURRENT_SESSION);
|
||||
if (!currentSession) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user