未完成内容,不代表最终质量
JS 接口参考

UI

功能简介

实现插件设置页的 UI 渲染。

权限声明

使用此接口需要向 manifest 的 permissions 中加入 ui 权限。

相关类型

  • PluginUIButton{ primary: boolean; text: string; callback_fun_id: string }
  • PluginUIDropdown{ options: string[]; callback_fun_id: string }
  • PluginUIInput{ text: string; callback_fun_id: string }
  • PluginUINodeContent – 联合类型(Text / Button / Dropdown / Input / HtmlDocument)
  • PluginUINode{ node_id: string; visibility: boolean; disabled: boolean; content: PluginUINodeContent }

接口

updatePluginSettingsUI

updatePluginSettingsUI(ui: PluginUINode[]): void

刷新插件设置页面,仅影响已打开的设置页。

openPageWithNodes

openPageWithNodes(ui: PluginUINode[]): void

以节点数组形式打开新页面。 (未实现)

openPageWithUrl

openPageWithUrl(url: string): void

用内置浏览器打开远端网页。 (自 v1.1.0 版本起可用)

示例

import AstroBox from "astrobox-plugin-sdk";

const ui = [
  {
    node_id: "btn1",
    visibility: true,
    disabled: false,
    content: {
      type: "Button",
      value: { primary: true, text: "同步", callback_fun_id: "syncFun" },
    },
  },
];

AstroBox.ui.updatePluginSettingsUI(ui)

大纲