elements 通常是从 getLassoElements/getElements 等接口拿到的既有元素(带 uuid),转换前后 uuid 保持不变。该接口依赖这些元素当前仍在原生缓存中,缓存中找不到的元素会被直接跳过,不会单独报错,详见 Element 缓存与释放。
- 参数对象字段:
返回
APIResponse<boolean>:result === true表示元素转化贴纸成功
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
元素(Element)转换为贴纸。
elements 通常是从 getLassoElements/getElements 等接口拿到的既有元素(带 uuid),转换前后 uuid 保持不变。该接口依赖这些元素当前仍在原生缓存中,缓存中找不到的元素会被直接跳过,不会单独报错,详见 Element 缓存与释放。
static convertElement2Sticker(
params: {
machineType: number;
elements: Object[];
stickerPath: string;
}
): Promise<APIResponse<boolean>>;
| 字段 | 类型 | 说明 |
|---|---|---|
machineType | number | 机器类型:0 A5, 1 A6, 2 A6X, 3 A5X, 4 Nomad, 5 Manta |
elements | Element[] | 元素数据 |
stickerPath | string | 输出路径(贴纸保存位置) |
APIResponse<boolean>:
result === true 表示元素转化贴纸成功import { PluginCommAPI, type Element } from 'sn-plugin-lib';
/**
* 将套索选中的元素转换为贴纸的示例。
*/
export async function exampleConvertElement2Sticker() {
const lassoRes = await PluginCommAPI.getLassoElements();
if (!lassoRes.success) {
throw new Error(lassoRes.error?.message ?? 'getLassoElements 调用失败');
}
const params = {
machineType: 3,
elements: (lassoRes.result ?? []) as Element[],
stickerPath: '/storage/emulated/0/Note/stickers/out.png',
};
const res = await PluginCommAPI.convertElement2Sticker(params as any);
if (!res.success) {
throw new Error(res.error?.message ?? 'convertElement2Sticker 调用失败');
}
return res.result;
}