registerFlow の step handler において、ctx パラメータは FlowRuntimeContext のインスタンスです。委譲チェーンを通じて、モデルレベルおよびエンジンレベルのすべてのプロパティとメソッドにアクセスできます。
registerFlow
ctx
FlowRuntimeContext
委譲チェーンは以下の通りです:
FlowRuntimeContext(現在の flow のランタイムコンテキスト) → FlowModelContext(model.context、モデルレベル) → FlowEngineContext(engine.context、グローバルレベル)
プラグイン開発で最もよく使う ctx のプロパティです:
ctx.model
FlowModel
ctx.api
APIClient
@nocobase/sdk
ctx.viewer
FlowViewer
dialog()
drawer()
ctx.message
MessageInstance
ctx.message.success('OK')
ctx.notification
NotificationInstance
ctx.modal
HookAPI
ctx.t(key, options?)
(string, object?) => string
ctx.router
Router
ctx.route
RouteOptions
ctx.location
Location
ctx.ref
React.RefObject
ctx.flowKey
string
ctx.mode
'runtime' | 'settings'
ctx.token
ctx.role
ctx.auth
object
{ roleName, locale, token, user }
ctx.themeToken
ctx.dataSourceManager
DataSourceManager
ctx.engine
FlowEngine
ctx.app
Application
ctx.i18n
i18n
ctx.request(options)
axios
ctx.makeResource(ResourceClass)
MultiRecordResource
SingleRecordResource
ctx.initResource(className)
ctx.viewer.dialog(options)
options.content
(view) => JSX
view.close()
ctx.viewer.drawer(options)
ctx.openView(uid, options)
ctx.exit()
ctx.exitAll()
ctx.getStepParams(stepKey)
ctx.setStepParams(stepKey, params)
ctx.getStepResults(stepKey)
ctx.runAction(actionName, params?)
ctx.getAction(name)
ctx.getActions()
ctx.getEvents()
ctx.aclCheck(params)
ctx.acl
ctx.resolveJsonTemplate(template)
{{ ctx.xxx }}
ctx.getVar(path)
ctx.xxx.yyy
ctx.runjs(code, variables?, options?)
ctx.requireAsync(url)
ctx.importAsync(url)
ctx.loadCSS(href)
ctx.onRefReady(ref, callback, timeout)
ctx.defineProperty(key, options)
ctx.defineMethod(name, fn, info?)
MyModel.registerFlow({ key: 'clickFlow', on: 'click', steps: { showMessage: { async handler(ctx) { ctx.message.success(ctx.t('操作が成功しました')); }, }, }, });