* 支持资源包资源多语言显示与管理员字段覆盖 资源包导入的专家、技能、规则和连接器按当前语言显示名称与描述,并允许管理员修改白名单字段,后续资源包更新不会覆盖已修改内容。 后端: - 新增 admin_overrides 字段与迁移,规则补充 description - 导入更新时保留管理员覆盖的字段及 i18n 值 - 连接器支持覆盖 URL、代理、标签、授权方式及 OAuth 参数 前端: - 资源名称和描述按当前界面语言展示 - 资源包专家、技能、规则开放名称和描述编辑 - 资源包连接器开放连接配置与标签编辑 * 限制技能内容编辑框高度
React + TypeScript + Vite + shadcn/ui
MonkeyAI 管理端使用 React、TypeScript、Vite 和 Tailwind CSS 3.4。降级前的完整回退基线为提交 5789bb73。
Chrome 86 兼容
tailwind.config.cjs维护主题、状态变体及工具类,postcss.config.cjs将 CSS 生成到 Chrome 86 可识别的选择器与逻辑属性。生产 JS/CSS 构建目标均为 Chrome 86。- 主题使用 RGB 通道,支持透明度修饰和深浅色切换;不再依赖原生 CSS 级联层、OKLCH、颜色混合或 CSS 属性注册。旧版视口高度使用
vh。 src/lib/browser-compat.ts在应用启动前安装数组.at()、Object.hasOwn()和:has()兼容支持,platform-compat.ts补齐 AbortSignal 超时/取消原因以及安全随机 UUID。已有原生实现保持不变。- 图表与表单仅有的容器宽度断点使用
ResizeObserver,按内容宽度判断,表单通过上下文跟随最近分组;不改写样式表。图表和示意图保留传统比例占位回退,避免不支持aspect-ratio时区域高度塌陷;日期按钮显式设置单元格高度。滚动条同时提供物理定位,兼容旧版不支持的行内逻辑定位。 - Base UI 1.7.0 的构造点击事件带有版本限定的 pnpm 补丁:Chrome 86 虽有 PointerEvent 构造器,但构造的 click 不会激活复选框。补丁按窗口检测实际行为,必要时使用 MouseEvent,现代浏览器保留 PointerEvent,同时保留修饰键和原组件的确认、校验及禁用逻辑。该共享路径也用于 Checkbox;更新 Base UI 时需复核补丁与浏览器测试。
- 不支持磁盘暂存的浏览器,大目录导入仍应使用现成 ZIP;复制等安全上下文功能继续遵循浏览器的 HTTPS/权限限制。
安装后重启 Vite 开发服务器,使新的 PostCSS 配置生效:
pnpm install --frozen-lockfile
pnpm dev --force
验证命令:
pnpm test
pnpm lint
pnpm build
CHROME_BIN=/path/to/chrome86 pnpm test:browser
# 使用另一个已安装的 Chromium 验证现代浏览器
CHROME_BIN=/path/to/current-chrome pnpm test:browser
# 可选:验证正在运行的开发服务器,API 使用隔离测试数据
CHROME_BIN=/path/to/chrome86 ADMIN_DEV_URL=http://localhost:5173 pnpm test:browser
依赖补丁变更后需停止旧开发服务器,执行 pnpm install --frozen-lockfile 再运行 pnpm dev --force,避免 Vite 的旧预构建仍使用未修复代码。
浏览器检查使用真实可执行文件,不通过修改 User-Agent 模拟旧浏览器。覆盖首页、普通 HTTP 下 UUID、深浅主题、48px 表格行、下拉菜单、日期面板、动态 :has()、饼图有效高度、内容宽度断点、移动布局,以及 Switch 的鼠标、空格键、确认/取消和保存期间禁用。回归中使用 Chromium 86.0.4240.0 与 141.0.7390.37;不据此声明其他浏览器已完成全量验证。浏览器测试不会访问真实业务接口。
成员与分组虚拟滚动
左侧分组树只展开顶层分组,将可见层级整理成扁平行并虚拟渲染;成员索引、排序及跨组去重人数只在数据或语言变化时重新计算。展开状态和批量选择独立于行组件保存,滚动卸载不会丢失;同一成员在不同分组中使用独立的来源键。
右侧成员卡片使用 TanStack Virtual 和 ResizeObserver 测量实际高度,保留多分组徽章换行。两侧移动端都有固定高度的滚动区域;焦点、菜单和拖拽涉及的行会临时保留,避免操作过程中失去节点。现有成员与分组接口仍返回完整数据,虚拟滚动限制的是挂载数量。
独立浏览器回归使用一万名模拟成员,覆盖首尾滚动、卡片高度、展开和勾选状态、菜单与拖拽节点、批量状态操作、移动来源、搜索重置及移动布局:
CHROME_BIN=/path/to/chrome86 pnpm test:browser:members
CHROME_BIN=/path/to/current-chrome pnpm test:browser:members
费用设置的成员额度卡片复用相同的虚拟滚动,按实际行高测量;过滤、姓名/积分排序和重置选择器的成员选项按数据变化缓存。搜索或切换排序回到顶部,账户详情打开时保留来源行,关闭刷新后继续使用当前搜索和排序。
CHROME_BIN=/path/to/chrome86 pnpm test:browser:quotas
CHROME_BIN=/path/to/current-chrome pnpm test:browser:quotas
客户端登录授权
/client-login 登录后必须明确确认当前账号、实际返回地址和附加权限,空权限列表也不会自动完成。确认提交始终携带 X-CSRF-Token 和 approved_scopes 数组。后台仅允许登记的应用回调,或桌面端固定路径的本机回环动态端口(localhost、127.0.0.1、[::1]);前端还会核对最终返回地址与确认页展示的地址一致,拒绝外部网站、脚本 URL 和其他未登记目标。
CHROME_BIN=/path/to/chrome86 pnpm test:browser:auth
CHROME_BIN=/path/to/current-chrome pnpm test:browser:auth
Adding components
To add components to your app, run the following command:
npx shadcn@latest add button
This will place the ui components in the src/components directory. 当前 shadcn 新模板可能包含 Tailwind 4 专用样式,生成后需检查并迁移到现有 Tailwind 3 配置,不能直接覆盖公共组件。新增状态、动态选择器或工具类后,应运行上面的 Chrome 86 浏览器检查。
Using components
To use the components in your app, import them as follows:
import { Button } from "@/components/ui/button"
GroupSelect
src/components/group-select.tsx provides a controlled group/user tree selector.
It does not fetch data or apply membership permissions; callers supply options,
localized text, and disabled states. MemberGroupSelect wraps it for member creation.
import { useState } from "react"
import { GroupSelect, type GroupSelectionValue } from "@/components/group-select"
function AssigneeSelect() {
const [value, setValue] = useState<GroupSelectionValue>({
groupIds: [],
userIds: [],
})
return (
<GroupSelect
options={[
{ id: "team", name: "团队", disabled: true },
{ id: "engineering", parentId: "team", name: "研发" },
]}
users={[
{ id: "alice", name: "Alice", groupIds: ["engineering"] },
]}
value={value}
onValueChange={setValue}
label="负责人"
placeholder="选择负责人"
emptyText="暂无可选项"
locale="zh-CN"
defaultExpanded
collapsible
multiple={false}
selectionMode="users"
searchable
searchPlaceholder="搜索名称、邮箱或拼音"
noResultsText="没有匹配的分组或用户"
/>
)
}
| Prop | Default | Behavior |
|---|---|---|
defaultExpanded |
true |
Initial expansion of all folders, including leaves; later prop changes do not reset expansion. |
collapsible |
true |
Enables clicking folder icons to expand/collapse independently of selection. |
multiple |
true |
Allows multiple selections. When false, selecting an item replaces both ID lists and closes the popover. |
searchable |
false |
Shows a fixed search field above the scrollable tree. Searches names, user emails, and Chinese pinyin (full spelling or initials), retaining ancestor paths and matched groups' subtrees. |
searchPlaceholder |
label |
Localized search placeholder and accessible label. |
noResultsText |
emptyText |
Localized message for no search matches. |
selectionMode |
"groups" |
"groups" shows/selects folders only; "users" shows users with folders as containers; "both" allows selecting both. |
options |
Required | Flat { id, parentId?, name, disabled? } group data. Missing parents appear at the top level. |
users |
[] |
{ id, name, groupIds, disabled? } records. Users with no matching group appear at the top level; users in multiple groups share one selection. |
value / onValueChange |
Required | Controlled { groupIds, userIds } value. |
cascadeGroups |
false |
Authorization inheritance for multi-selection: selecting a group covers descendants and their users, removes redundant explicit grants, and shows inherited/partial checkbox states. Without it, selections are independent. |
Use defaultExpanded={true} with collapsible={false} for an always expanded tree.
With both false, folders remain closed. Reset the controlled value when changing
selection modes; in single mode, supply at most one selected ID across both lists.
Pass id to associate an external FieldLabel; otherwise an ID is generated.
The trigger displays selected names without ancestor paths.
Searching temporarily expands matching paths without modifying selections or saved
folder expansion. Clearing the query restores folder expansion; closing the
popover clears the query. Authorization inheritance always uses the complete tree,
even when search hides some nodes. Supply email on user options to enable email
matching; email addresses are not displayed in the tree. Pinyin supports joined or
spaced spelling (zhangsan / zhang san) and initials (zs), using the library's
contextual pronunciation for Chinese names. Search indexes are memoized so typing
does not repeat transliteration.