oak-frontend-base 更新日志
6.0.4 未发布(区间:6.0.3..HEAD)
- 增加 Desktop web runtime、离线 locale 与桌面外观支持,并把 web platform 与具体 renderer 分开表达;浏览器、Tauri、Electron 不再依赖同一个模糊环境分支。
- 导出 OakComponent template types 并恢复组件类型推导,配合 oak-cli 生成传统 render 的注入声明;平台 render props 的实验性扩展已回退,业务合同仍以组件定义推导为准。
- console route access 会等待权限上下文就绪再判定,避免初始化阶段把“尚未加载”误判成无权;旧 pull-to-refresh 实现也已替换并恢复正确 web platform 语义。
- Web 初始化入口保留旧 positional signature,同时支持 options object:
namespaceConfigs、renderError、renderLoading、renderProvider、oakTheme、iconLibraries、antdConfigProviderProps、antdMobileConfigProviderProps都进入标准初始化流程。 - 标准 web app tree 和初始化错误 tree 都会挂载
RouteAccessProvider、NamespaceConfigProvider、AntDConfigProvider、AntD MobileConfigProvider、StyleProvider和 Oak theme shell,应用侧可以通过useNamespaceConfig(...)读取 CLI 生成的 namespace 配置。 - 新增
RouteAccessBoundary与resolveRouteAccess(...),route.access支持public、deny、root、login、ref、relation、operation、anyOf、allOf和数组简写;operation会调用features.cache.checkOperation(...),并可通过$context.entity/$context.entityId引用当前 console 上下文。 - namespace 配置支持
access.unconfiguredAccess和features.console.contextEntities。当前 console context 不在 namespace 允许范围内时,relationaccess 和依赖$context.*的operationaccess 会返回contextMismatch。 oak-frontend-base/config导出CreatePageConfig、CreateComponentConfig、CreateNamespaceConfig,内置组件的小程序 JSON 从index.json迁移到index.config.ts,配合 oak-cli 生成虚拟页面 / 组件 JSON。- OakIcon 图标库能力扩展:
OakIcon支持旧内置名、显式oak:*、自定义 font 图标库和 web-only React 图标库。registerOakIconLibraries(...)会注册编译期、初始化 options 和 namespace config 中的图标库,font 图标支持运行时注入styleText,React 图标支持同步icons/resolveIcon(...)和异步loadIcon(...)。 - 新增 Oak theme runtime:
OakTheme、OakThemeProvider、mergeOakTheme、oakThemeToCssVars、oakCssVarsToCssText和oakTokenVars成为共享 token / CSS 变量契约;features.theme可以持久化theme-mode、主色和oakTheme,并兼容迁移旧的ogb:feature-theme-state;Web 初始化会把 Oak token 同步成 AntDConfigProvider.theme.token默认值,应用显式传入的 AntD token 优先级更高。 - 新增
components/theme/setting主题设置组件,支持浅色、深色、跟随系统和主色切换,读取初始化主题和运行时features.theme合并后的有效OakTheme。 cache.callSSEEndpoint(name, props, options)对齐 connector-backed SSE endpoint,默认透传当前前端上下文,ignoreContext: true时不传上下文;DebugConnector.callSSEEndpoint()仍明确不可用。- 前端 socket / subscriber 会从
socketPoint.get()读取scope,并在 socket.ioauth.oakSocketScope中透传给后端,保持多 scope 场景下的连接身份一致。 FrontendRuntimeContext增加 locale 序列化语义,前端运行现场可以携带当前语言信息。- 小程序 route map 改为构建期注入的运行时模块,支持 canonical Oak route 到 WeChat 产物路径的双向映射、namespace route、subpackage route mapping 和 tabBar 判断;显式 route map 存在时,缺失路由不再回退猜测。
- 小程序 navigator 统一使用
setNamespacePath(...)/getNamespacePath()语义,旧setNamespace(...)/getNamespace()/namespace仍兼容但开发态会警告;switchTab会丢弃 query / state 并输出 warning。 - 小程序 polyfill 改用
oak-domain的 URL / fetch 标准导出,补充DOMException、getRandomValues等运行能力;socket.io 小程序端改为 ESM repack,减少体积并修复导出。 - 新增轻量 / 专项 ECharts 小程序 canvas 组件:
ec-canvas-basic、line、bar、pie、gauge、map等,避免所有页面都引入完整 chart runtime。 pageHeader成为唯一维护的页面头部实现,pageHeader2被移除;web 端返回按钮判断会优先读取 namespace menu,再回退到contextMenuFactory.menus,支持相对 menu path 和 namespace-prefixed path 匹配。ListPro使用 runningTree loading 作为默认 loading / reload 状态,继续渲染 Oak 自有 Pagination,并断言不接受tablePagination;列表行操作按钮修复“执行后仍显示无权限动作”的问题,并增加紧凑操作按钮配置。- Pagination 组件重写布局和文案,补充中英文 locale、右对齐样式、
showSizeChanger、showQuickJumper、自定义showTotal和函数式分页选项。 - 新增
searchPanel共享筛选面板组件,补齐 web / pc / 小程序入口,用于列表页的命名过滤器 UI;近期同步修复了 PC 端折叠控制、FilterPanel 展开按钮栅格布局和展开后收起按钮裁剪问题。 runningTree增加静态 selection / fresh value / composed operations 缓存和失效逻辑,selectOption可从组件配置透传到节点;修复 zombie 虚拟节点复用、createNode行为和带点字面量 key 被unset误删导致的缓存异常。- Web 错误边界和初始化错误页重构,支持自定义初始化错误 UI;Loading 默认仍走 NProgress,传入
renderLoading时由应用完全接管 route lazy fallback;网络异常、断网和 server proxy 错误文案统一由getErrorPageCopy(...)/ locale 解析。 - 依赖和构建同步升级 React 19、AntD 6、AntD Mobile、React Native、peer dependencies、TypeScript 参数兼容和
optimizeDeps.include,并在package.json.oak.runtime.server标记前端包不参与 server runtime。
主要 diff 文件:
src/platforms/web/initialize/*、src/platforms/web/RouteAccessBoundary.tsx、src/platforms/web/NamespaceConfigProvider.tsx、src/features/routeAccess.ts、src/config/index.ts、src/theme.ts、src/features/theme.ts、src/features/cache.ts、src/features/socket/*、src/features/mpRouteMap.ts、src/features/navigator.mp.ts、src/features/runningTree.ts、src/types/Icon.ts、src/utils/iconLibrary.ts、src/components/icon/*、src/components/pageHeader/*、src/components/listPro/*、src/components/pagination/*、src/components/searchPanel/*、src/components/filterPanel/*、src/utils/errorPage.ts、src/miniprogram_npm/ec-canvas-*、test/routeAccess.test.ts、test/mpRouteMap.test.ts、test/cacheSSEEndpoint.test.ts、test/iconLibrary.test.ts6.0.3(tag:6.0.3,区间:6.0.1..6.0.3)
升级注意
Web 初始化:新项目应使用 options object 传递
namespaceConfigs、oakTheme、renderLoading、AntD provider props 等配置。不要在应用侧重复包一层全局 RouteAccess / NamespaceConfig / AntD provider,除非确实要隔离一个子树。route access:
operation.target.checkerTypes 是前端合法性探测的 checker 范围字段;依赖 console 上下文的规则应声明 $context.entity / $context.entityId,并确认 namespace 的 features.console.contextEntities 范围。小程序路由:历史小程序代码如果直接拼生成产物路径,或把 namespace 路由和业务 canonical route 混用,需要回到 Oak navigator 或当前 route map 能识别的静态调用方式。显式 route map 存在时缺失路由不会自动猜测,
switchTab 也不会保留 query / state。组件迁移:
pageHeader2 已移除,改用 pageHeader。ListPro 不接受 tablePagination,共享分页样式应改 Oak 自有 components/pagination。OakIcon:菜单、页面和 namespace 配置中的图标应继续写字符串,推荐显式使用
oak:* 或 <library>:*。Web React 图标库只在 web 运行时可用,小程序侧需要使用 font 图标库;使用 fontUrl 的库仍需要配套 icons glyph 映射。主题:Oak 自有组件主题应走
oakTheme / features.theme / --oak-* CSS 变量;AntD / AntD Mobile 的 provider props 只用于三方 UI 库配置。