You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Jelastic清单中配置可选邮箱设置并将取值返回给用户

Jelastic清单动态参数最简实现方案

核心思路

  • 所有动态计算后的参数直接存入Jelastic环境持久化属性(props),全局可访问,无需子清单透传
  • 采用「留空则使用默认值/自动生成值」的交互替代toggle,减少用户操作步骤

邮箱需求实现代码

1. 表单配置

settings:
  fields:
    - name: customEmail
      caption: 自定义邮箱(留空则默认使用Jelastic登录邮箱)
      type: string
      required: false

2. 安装阶段计算并持久化参数

onInstall:
  # 计算最终使用的邮箱并存储到全局属性
  - script: |
      let finalEmail = "${settings.customEmail}".trim() || "${user.email}";
      return {
        result: 0,
        props: {
          "service.email": finalEmail
        }
      };
  # 安装子服务直接读取全局属性,不需要后续服务透传参数
  - install:
      jps: my-service-manifest.yml
      settings:
        username: ${props.service.email}
  # 其他串联安装的服务无需处理邮箱参数,不影响原有清单逻辑
  - install:
      jps: other-service-manifest.yml
      settings:
        otherParam: 其他配置参数

3. 成功提示直接读取全局属性

success:
  text: |
    **服务用户名(邮箱)**: ${props.service.email}
    **对应密码**: ${props.service.password}

同类参数(自动生成密钥/密码)实现示例

适用于需要用户可选手动输入、默认自动生成的所有场景:

表单配置

settings:
  fields:
    - name: customApiKey
      caption: 自定义API密钥(留空则自动生成20位随机密钥)
      type: string
      required: false

计算逻辑

onInstall:
  - script: |
      let finalApiKey = "${settings.customApiKey}".trim() || "${fn.password(20)}";
      return {
        result: 0,
        props: {
          "service.apiKey": finalApiKey
        }
      };

后续任意位置都可以通过${props.service.apiKey}读取该值。


方案优势

  • 无需改造子清单透传无关参数,不破坏原有服务的配置逻辑
  • 统一的参数处理逻辑可复用,所有可选动态参数都可以用这套模式实现
  • 持久化存储的参数在环境全生命周期可用,升级、扩容操作后依然可读取

内容的提问来源于stack exchange,提问作者Laurent Michel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.25 11:06:04