插件开发指南

5 步发布你的第一个灵核插件。

STEP 1 创建目录

建一个以插件 id 命名的目录,放入 plugin.json 和入口 index.html。

STEP 2 写 plugin.json

{
  "id": "com.example.hello",
  "name": "Hello",
  "version": "1.0.0",
  "description": "示例插件",
  "author": "你的名字",
  "main": "index.html",
  "features": [
    { "code": "hello", "cmds": ["你好", "hello"], "explain": "弹出问候" }
  ],
  "permissions": []
}

STEP 3 写 index.html

插件就是一个网页,通过 window.host.* 调用宿主能力。

<!doctype html>
<html><body>
  <h1>Hello</h1>
  <script>
    // 读剪贴板示例
    // const text = await window.host.clipboardRead();
  </script>
</body></html>

STEP 4 打包成 .kpkg

将整个目录压缩成 zip,改扩展名为 .kpkg。或者在插件中心「我的插件」点「打包」。

STEP 5 发布到市场

登录 开发者控制台,填写信息并上传 .kpkg 即可发布。

详细字段说明见 文档:插件 Manifest,权限模型见 文档:权限模型。