Skip to content

Complete Examples

This page provides multiple complete script extension examples to help you quickly understand and use the script integration feature.

Example 1: Device Manager

A comprehensive device management script integrating task execution, UI extensions, and settings panel.

manifest.json

json
{
  "id": "com.example.devicemanager",
  "name": "Device Manager",
  "version": "1.0.0",
  "author": "Example Team",
  "description": "External device management panel integration",
  "icon": "icon.png",
  
  "events": {
    "app/run": {
      "action": "$.nodejs.run",
      "args": ["server2.js", "arg1", "arg2"]
    }
  },
  
  "scripts": [
    {
      "id": "open_panel",
      "name": "Open Management Panel",
      "command": {
        "action": "$.shell.open",
        "args": ["DevicePanel.exe", "$.deviceId"]
      }
    },
    {
      "id": "sync_device",
      "name": "Sync Device Info",
      "command": {
        "action": "$.http.post",
        "args": [
          "https://api.example.com/sync",
          { "deviceId": "$.deviceId" }
        ]
      }
    }
  ],
  
  "views": {
    "header/slots": [
      {
        "name": "Web Console",
        "icon": "console.png",
        "command": {
          "action": "$.webview.open",
          "args": [
            "https://console.example.com/",
            { "width": 1200, "height": 800 }
          ]
        }
      }
    ]
  },
  
  "settings": [
    {
      "key": "api_url",
      "name": "API Server",
      "type": "text",
      "value": "https://api.example.com",
      "require": true
    },
    {
      "key": "api_key",
      "name": "API Key",
      "type": "text",
      "value": "",
      "placeholder": "Enter your API key",
      "require": true
    },
    {
      "key": "sync_interval",
      "name": "Sync Interval (seconds)",
      "type": "number",
      "value": 60
    },
    {
      "key": "auto_sync",
      "name": "Auto Sync",
      "type": "checkbox",
      "value": true
    }
  ]
}

Script Structure

com.example.devicemanager/
├── manifest.json           # Configuration manifest
├── icon.png                # Script icon
├── console.png             # Console button icon
├── DevicePanel.exe         # External program
└── settings.json           # Auto-generated config file

Cooperation: try.catch@foxmail.com