Skip to content

feat: 资源管理器支持按模式排除文件/目录(issue #18) - #21

Open
wuxiangru915 wants to merge 4 commits into
omdsh-dev:mainfrom
wuxiangru915:feat/explorer-exclude
Open

feat: 资源管理器支持按模式排除文件/目录(issue #18)#21
wuxiangru915 wants to merge 4 commits into
omdsh-dev:mainfrom
wuxiangru915:feat/explorer-exclude

Conversation

@wuxiangru915

Copy link
Copy Markdown

概述

解决 issue #18:资源管理器像常见 IDE 一样按模式隐藏不需要的文件/目录(Unity 用户过滤 .meta、隐藏 node_modulesbuild 等系统生成内容)。

设计要点

  • 零依赖纯函数 src/exclude-patterns.ts:条目名称匹配(目录/文件一视同仁),单个 * 通配、大小写不敏感、空白模式忽略;compileExcludePatterns 预编译正则(渲染路径每行复用,不重复编译)。
  • 纯显示层过滤:不碰 host 半、fs.tree 路由与 listDirectory 不动,其他消费者(git/editor)不受影响;explorerExclude 缺省 [] = 行为不变。
  • 声明式设置扩展settings.toggles(布尔)之外新增 settings.texts 文本行——多行输入、失焦提交、自动 trim/去空/去重;explorer tab 在设置页齿轮弹窗中维护排除模式,修改后 ExplorerView 订阅 prefs 即时生效。
  • 全链路同步:SidebarPrefs(prefs-shared)+ PrefsSchema(config)+ parsePrefs 防御解析 + 设置持久化。

改动清单

  • src/exclude-patterns.ts(新):匹配逻辑
  • src/prefs-shared.ts / src/config.ts / src/client/prefs.tsexplorerExclude 字段
  • src/client/service.tsSidebarSettingText + settings.texts
  • src/client/SideCardSection.tsx / .module.css:文本行 UI(TextSettingRow)
  • src/client/builtins/tabs.tsx / ExplorerView.tsx:声明 + 过滤渲染
  • src/client/locales.ts:zh/en 文案
  • 测试:匹配逻辑 12 例、prefs 解析、设置行渲染、ExplorerView 过滤(含动态订阅)、builtins/schema 适配
  • 文档:docs/plans/2026-08-14-explorer-exclude-design.md、README(zh/en)、AGENTS.md

验证

  • pnpm typecheck ✓ pnpm build ✓ NODE_ENV=test pnpm test:423/424 通过(唯一失败为预先存在的 node-pty 预编译环境问题,与本改动无关)
  • 附带 chore: 显式声明 unrun 依赖——tsdown 的 optional peer,全新 pnpm installpnpm build 会因缺它失败(本机 Node 22 + pnpm 11 实测),显式声明后构建稳定。

已知限制(README 已记录)

  • 排除是显示层过滤:超大目录(单层 >1000 项)的截断计数在过滤后可能偏少
  • 非目标:全量 glob(**?{} 等)后续可加

- 新增 exclude-patterns 纯函数(单 * 通配、大小写不敏感、零依赖,预编译 matcher)
- SidebarPrefs 新增 explorerExclude 字符串数组(缺省 [] = 不过滤,行为不变)
- 声明式设置新增 texts 文本行(多行输入、失焦提交、去空/去重),explorer tab 声明排除模式
- ExplorerView 订阅 prefs,按模式过滤渲染,设置页修改即时生效
- 双语文案 + 单测(匹配逻辑 12、prefs 解析、设置行、组件渲染、schema 默认值)
PR omdsh-dev#21 的 settings.texts(多行文本行,如 explorerExclude 排除模式)
与 main 侧 v0.11/v0.12 的声明式设置演进(toggles 支持
switch/text/number、pluginToggles、render 自定义面板)合并:

- SideCardSection: 保留新版开关/文本/数字行 + 自定义面板,texts 多行
  textarea 作为追加行接入 FeatureSettingsRows/SettingsBody,齿轮条件
  计入 texts
- service.ts / prefs.ts: texts 与 pluginToggles/render 并存;
  stringArrayOf 与 pluginSettingsMapOf 并存
- 测试/文档/锁文件同步合并(unrun 显式依赖保留)

验证:pnpm typecheck ✓ pnpm build ✓ NODE_ENV=test pnpm test 509 全过
(41 文件,含 explorer-exclude 与 side-card-section 新规格)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant