新增: AI工具授权目录总开关(信任所有目录)

- path_auth判定加bypass旁路:开启时白名单外目录免逐次询问直接放行
- 黑名单凭据目录保护不随开关放行(安全硬边界保留)
- 设置页授权目录面板加开关(默认关,读取失败按关处理)
- 对话区开启时常驻放行提示横幅防静默裸奔,中英i18n齐
This commit is contained in:
lxy
2026-09-29 14:59:02 +08:00
parent 0168617503
commit 8a1675b58c
8 changed files with 114 additions and 5 deletions
+16
View File
@@ -29,6 +29,10 @@
@provider-switched="(name: string) => showToast(t('aiChat.providerSwitched', { model: name }), 'info')"
/>
<!-- 「信任所有目录」放行横幅:开关开启期间常驻提示(设置-安全-AI 工具授权目录),
提醒当前 AI 可直接访问任意非受保护目录;黑名单目录仍被拒绝 -->
<div v-if="pathAuthBypass" class="ai-auth-bypass-banner">{{ $t('aiChat.pathAuthBypassBanner') }}</div>
<!-- 第四批抽离至 ai/MessageList.vue(消息列表 + 流式 Markdown 分块渲染 + 工具卡转发 +
折叠归档段 + 滚动跟随/回底部,零行为变更,store/useMarkdown 单例共享) -->
<MessageList
@@ -161,6 +165,8 @@ const router = useRouter()
// 关(false,兜底回退):挂 DirAuthDialog 独立弹窗老链路(useAiEvents AiDirAuthRequired case 走 pendingDirAuths)。
const appSettings = useAppSettingsStore()
const unifiedApproval = appSettings.useSetting<boolean>('df-ai-unified-approval', true)
// 「信任所有目录」总开关(与设置页 AllowedDirsPanel 同一 KV):开启时对话区顶部常驻放行横幅
const pathAuthBypass = appSettings.useSetting<boolean>('df-ai-path-auth-bypass', false)
// ── 空状态示例问题随 MessageList 子组件迁移(examplePrompts 数组在子组件内);
// 父仅保留 sendExamplePrompt 转发(子 emit 'send-example-prompt' → 父委托 ChatInput.sendExamplePrompt)。──
@@ -683,6 +689,16 @@ async function initContextEventListeners(): Promise<void> {
TopBar.vue scoped 自持 + .ai-btn-icon* 抽 components.css 全局共享,
原 AiChat scoped 不渗透子组件根,删此重复块零视觉变更) */
/* ── 「信任所有目录」放行横幅(开关开启期间常驻,warning 色系对齐 .ai-toast-warning) ── */
.ai-auth-bypass-banner {
padding: 5px 14px;
background: var(--df-warning-bg);
color: var(--df-warning);
border-bottom: 0.5px solid color-mix(in srgb, var(--df-warning) 40%, transparent);
font-size: 12px;
user-select: none;
}
/* ═══ Input ═══ */
.ai-input-area {
padding: 10px 14px;