跳转至

脚本预编译与帮助(CompileController)

iScript 脚本编辑器后端支持:对脚本内容做预编译校验、返回 iScript 帮助文档 HTML,供设计器脚本编辑器使用。

  • 接口类型:REST 资源
  • 基址${myapps.context-path.designer:}/api/designtime(类级 @RequestMapping
  • Tag:脚本编辑器模块

公共说明

  • 鉴权:是(需 designerToken)。控制器继承自 AbstractDesignTimeController(基类为 @RestController)。鉴权机制详见 index.md「鉴权说明」。
  • 响应:统一 Resource(见 ../index.md「统一响应结构」)。成功 errcode=0;异常 errcode=500
  • HTTP 方法:受 CommonSecurityFilter 限制,仅允许 GET/POST/HEAD/OPTIONS

1. 脚本预编译

对提交的 iScript 内容执行预编译,返回编译结果字符串。

  • 接口类型:REST 资源
  • 请求方式POST
  • 请求路径/applications/iscript/compile(完整:{designer-context}/api/designtime/applications/iscript/compile
  • 鉴权:是(需 designerToken)
  • Tag:脚本编辑器模块

请求参数

参数名 位置 类型 必填 说明
content body string(JSON) 脚本内容数据包体

请求体

JSON 对象,包含 iscriptString(待编译的 iScript 源码)。

{ "iscriptString": "<iScript 源码>" }

请求示例

POST /api/designtime/applications/iscript/compile HTTP/1.1
Content-Type: application/json

{ "iscriptString": "var x = 1;" }

响应

结构:统一 Resource(见 ../index.md「统一响应结构」)。 dataString,编译结果。

成功示例

{ "errcode": 0, "errmsg": "ok", "data": "<编译结果>", "errors": null }
失败示例
{ "errcode": 500, "errmsg": "<异常信息>", "data": null, "errors": null }


2. 获取 iScript 帮助文档

按当前请求语言返回 iScript 帮助文档 HTML 片段。

  • 接口类型:REST 资源
  • 请求方式GET
  • 请求路径/applications/iscript/getIscriptHelp(完整:{designer-context}/api/designtime/applications/iscript/getIscriptHelp
  • 鉴权:是(需 designerToken)
  • Tag:脚本编辑器模块

请求参数

参数名 位置 类型 必填 说明
staticPath query string 静态资源路径(用于在 HTML 中拼接资源引用)

说明:staticPath 形参未标注 @RequestParam,由 Spring MVC 按请求参数绑定,故可缺省。语言由 CookieUtil.getMultiLanguage(request) 从请求/会话/Cookie 中解析。

请求示例

GET /api/designtime/applications/iscript/getIscriptHelp?staticPath= HTTP/1.1

响应

结构:统一 Resource(见 ../index.md「统一响应结构」)。 dataString,帮助文档 HTML 片段。

成功示例

{ "errcode": 0, "errmsg": "ok", "data": "<iScript 帮助 HTML>", "errors": null }
失败示例(XML 解析异常):
{ "errcode": 500, "errmsg": "<异常信息>", "data": null, "errors": null }