Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

案例支持代码执行前后注入脚本 #264

Open
Aarebecca opened this issue Dec 2, 2023 · 0 comments
Open

案例支持代码执行前后注入脚本 #264

Aarebecca opened this issue Dec 2, 2023 · 0 comments

Comments

@Aarebecca
Copy link

诉求

  1. 支持注入位置在脚本执行前/后
  2. 注入的脚本能够访问案例代码中定义的变量,例如
const circle = new Circle({ ... })

后执行脚本应当能够访问到 circle 变量

  1. 注入位置考虑可以是在 meta.json 中配置
{
  "demos": [
    {
      "filename": "案例代码文件",
      "title": {
        "zh": "标题",
        "en": "Title"
      },
      "screenshot": "截图",
      "pre-exec": "预执行脚本文件",
      "post-exec": "后执行脚本文件"
    }
  ]
}

用途

将一些用户不需要感知的逻辑从案例代码中隐藏,例如

  • G 中的 stats/GUI 监控逻辑
  • G6 中 resize 部分逻辑
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant