AmisRenderer: 注入 currentUser/currentProject/now 到 amis 数据域(§7-3 initvalue 动态 token)
转换器把老引擎 initvalue 动态 token 迁移成 amis 表达式(eip4-platform 同步提交):
{CURRENTUSER}→${currentUser}、{CURRENTTIME}→${now}、{CURRENTPROJECT}→${currentProject}
({CURRENTORG}→${orgId} 复用 F2-9 已注入)。本处把对应值注入 amis.embed 第三参数数据域,
使表单项 value 里的 ${...} 在初始化时求值。
- currentUser = profile.userId;orgId = profile.org(沿用 F2-9)。
- now = 本地 "YYYY-MM-DD HH:mm:ss"。
- currentProject 当前 profile 无此字段(会话级概念),注入空串使 ${currentProject} 求值为空
而非裸 token(优雅降级)。
验证:浏览器实证外部邮件收件箱搜索携 FOLDER=0(字面初值);动态 token 走与既有 orgId 注入
同一机制(F2-9 已验)。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -55,9 +55,23 @@ export function AmisRenderer({ schema }: AmisRendererProps) {
|
|||||||
return http.request({ url, method: m as never, data, responseType: responseType as never });
|
return http.request({ url, method: m as never, data, responseType: responseType as never });
|
||||||
};
|
};
|
||||||
|
|
||||||
// F2-9:注入当前用户 org 到 amis 数据域,供 select-tree source 中 ${orgId} 使用
|
// F2-9:注入当前用户 org 到 amis 数据域,供 select-tree source 中 ${orgId} 使用。
|
||||||
|
// §7-3:再注入 currentUser/currentProject/now,供转换器迁移的 initvalue 动态 token
|
||||||
|
// ({CURRENTUSER}/{CURRENTORG}/{CURRENTTIME}/{CURRENTPROJECT} → ${currentUser} 等)在表单初始化求值。
|
||||||
const profile = getProfile();
|
const profile = getProfile();
|
||||||
const amisProps = profile?.org ? { orgId: profile.org } : {};
|
const pad = (n: number) => String(n).padStart(2, '0');
|
||||||
|
const d = new Date();
|
||||||
|
const now = `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} `
|
||||||
|
+ `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
|
||||||
|
const amisProps: Record<string, unknown> = { now };
|
||||||
|
if (profile?.org) {
|
||||||
|
amisProps.orgId = profile.org;
|
||||||
|
}
|
||||||
|
if (profile?.userId) {
|
||||||
|
amisProps.currentUser = profile.userId;
|
||||||
|
}
|
||||||
|
// currentProject 当前 profile 无此字段(会话级概念),注入空串使 ${currentProject} 求值为空而非裸 token
|
||||||
|
amisProps.currentProject = '';
|
||||||
|
|
||||||
const instance = amis.embed(
|
const instance = amis.embed(
|
||||||
rootRef.current,
|
rootRef.current,
|
||||||
|
|||||||
Reference in New Issue
Block a user