Skip to content

pixso.ui ​

pixso.ui 对象包含了用来操作用户界面并与用户界面进行信息交流的接口。

bounds ​

  • Readonly:true
  • Type: Rect
typescript
interface Rect {
  readonly x: number;
  readonly y: number;
  readonly width: number;
  readonly height: number;
}

当前 UI 模态框在浏览器坐标系中的边界信息。

mode ​

  • Type: "NORMAL" | "SIMPLIFIED"
  • Tip: 跨线程通信

当前 UI 模态框的显示模式,默认为 NORMAL,SIMPLIFIED 模式会隐藏插件图标和标题。可通过调用 pixso.showUI时在options参数中设置。

visible ​

  • Type: boolean
  • Tip: 跨线程通信

当前 UI 模态框是否显示。

show ​

  • Type: show(): void
  • Tip: 跨线程通信

控制 UI 模态框显示。在通过 pixso.showUI(..., { visible: false }) 创建模态框后,或调用了 pixso.ui.hide() 隐藏模态框之后,可使用pixso.ui.show() 显示模态框。

hide ​

  • Type: hide(): void
  • Tip: 跨线程通信

隐藏 UI 模态框显示。隐藏之后, UI 模态框仍将继续运行代码并能够发送和接收消息,但是,它不会呈现给用户。

resize ​

  • Type: resize(width: number, height: number): void
  • Tip: 跨线程通信

创建 UI 模态框之后,通过此 API 可以更改 UI 模态框的尺寸。

reposition ​

  • Type: reposition(x: number, y: number): void
  • Tip: 跨线程通信

创建 UI 模态框之后,通过此 API 可以更改 UI 模态框的定位。

close ​

  • Type: close(): void
  • Tip: 跨线程通信

销毁 UI 模态框以及其中的 iframe,一旦执行之后,iframe 中的代码将不再执行,也不能继续传递或接受消息。

postMessage ​

  • Type: postMessage(pluginMessage: any, options?: UIPostMessageOptions): void
  • Tip: 跨线程通信
参数 ​

pluginMessage

这个 API 几乎可以传递任何数据类型或普通对象,只要它是可序列化的对象。

这类似于说如果有必要应该可以通过网络发送对象。您可以发送对象、数组、数字、字符串、布尔值、null、未定义、日期对象和 Uint8Array 对象。但是,不会发送对象的函数和原型链。

onMessage ​

  • Type: onmessage: MessageEventHandler | undefined;
typescript
type MessageEventHandler = (
  pluginMessage: any,
  props: OnMessageProperties
) => void;

注册 UI 模态框的消息事件的执行函数。

on ​

  • Type:
typescript
on(type: "message", callback: MessageEventHandler): void;
on(type: "minimize", callback: () => void): void;

注册 UI 模态框的消息事件的执行函数。

once ​

  • Type:
typescript
once(type: "message", callback: MessageEventHandler): void;
once(type: "minimize", callback: () => void): void;

注册 UI 模态框的消息事件的执行函数,但只会执行一次。

off ​

  • Type:
typescript
off(type: "message", callback: MessageEventHandler): void;
off(type: "minimize", callback: () => void): void;

移除 pixso.ui.on 或 pixso.ui.once 注册的事件执行函数。

enableMinimize ​

  • Type: boolean
  • Tip: 跨线程通信

当前 UI 模态框是否显示最小化按钮,默认为 false。可通过调用 pixso.showUI时在options参数中设置。

minimizeTip ​

  • Type: string
  • Tip: 跨线程通信

UI 模态框最小化按钮的悬浮提示文本。

setMinimizeIcon ​

  • type: setCloseIcon(icon: string | Uint8Array): void
  • Tip: 跨线程通信

修改 UI 模态框最小化按钮的图标。

closeTip ​

  • Type: string
  • Tip: 跨线程通信

UI 模态框关闭按钮的悬浮提示文本。

setCloseIcon ​

  • type: setCloseIcon(icon: string | Uint8Array): void
  • Tip: 跨线程通信

修改 UI 模态框关闭按钮的图标。

enableResize ​

  • Type: boolean
  • Tip: 跨线程通信

当前 UI 模态框是否可调整大小。

minWidth ​

  • Type: number
  • Tip: 跨线程通信

当前 UI 模态框的最小宽度。

minHeight ​

  • Type: number
  • Tip: 跨线程通信

当前 UI 模态框的最小高度。