Skip to content

Configuration Description ​

A micro app contains two main configuration files: app.config.js and components.config.js.

App Config (app.config.js) ​

Defines the micro app's basic info, permissions, data nodes, etc.

Basic Config ​

ParameterTypeRequiredDescription
appJsonVersionstring✅Config file version, currently 1.1 is the latest
authorstring✅Author identifier, used to generate the component tag name prefix. Must not contain special characters
microAppIdstring✅Unique app identifier, format is author-appname
versionstring✅Version number, following semantic versioning
entrystring✅Entry file path, such as 'main.js'
iconstring✅App icon file name (located in the public directory)
debugbooleanDebug mode. The backend can view API requests and data node debug data via command line; the frontend can view other debug data via the console. Default: false.

App Info (appInfo) ​

Basic app info. To support multiple languages, parameters support i18n, such as $t:APP_NAME.

Parameters: ​

ParameterTypeRequiredDescription
appNamestring✅App name
descriptionstring-App description
networkDescriptionstring-Network request description
appJsonVersion:'1.1' vs old version (1.0) format update notes
js
// 1.1 without i18n support:
appInfo: {
  appName: 'Hello World',
  description: 'Micro App Hello World',
  networkDescription: 'No need to link to any third-party websites',
}

// 1.1 with i18n support:
appInfo: {
  appName: '$t:APP_NAME',
  description: '$t:APP_DESCRIPTION',
  networkDescription: '$t:NETWORK_DESCRIPTION',
}

// i18n file: locales/en-US.json
export default {
  // App basic info
  APP_NAME: 'Hello World',
  APP_DESCRIPTION: 'Micro App Hello World',

  // Network configuration
  NETWORK_DESCRIPTION: 'No need to link to any third-party websites'

  // ...
}

// i18n file: locales/zh-CN.json
export default {
  // App basic info
  APP_NAME: 'Hello World',
  APP_DESCRIPTION: 'Sun-Panel Demo Micro App',

  // Network configuration
  NETWORK_DESCRIPTION: 'No need to link to any third-party websites'

  // ...
}
js
// 1.0 old format (will gradually stop being supported after the Sun-Panel official release, please update your base template as soon as possible):
appInfo: {
  'zh-CN': {
    appName: 'Weather',
    description: 'View weather data worldwide',
    networkDescription: 'Download necessary config data on first run'
  },
  'en-US': {
    appName: 'Weather',
    description: 'View weather data worldwide',
    networkDescription: 'Download necessary config data on first run'
  }
}

Permission Config (permissions) ​

Declare the permissions required by the app, such as network requests, data nodes, etc. See Permission Declaration.

Network Domain Whitelist (networkDomains) ​

When declaring the network permission, you must configure the whitelist of allowed domains. See Permission Declaration.

Data Node Config (dataNodes) ​

Configure the app's persistent data storage nodes. See Data Nodes.

Complete Example ​

./config/app.config.js file content:

js
export default {
  // Basic info
  appJsonVersion: '1.1',
  author: 'hslr',
  microAppId: 'hslr-weather',
  version: '1.0.0',
  entry: 'main.js',
  icon: 'logo.png',
  debug: false,

  // i18n translation config
  i18n: translations,

  // App info
  appInfo: {
    appName: 'Weather',
    description: 'View weather data worldwide',
    networkDescription: 'Connect to third-party weather API',
  },

  // Permission config
  permissions: [
    'network',     // network permission
    'dataNode'     // data node permission
  ],

  // Network domain whitelist
  networkDomains: [
    'api.example.com'
  ],

  // Data node config
  dataNodes: {
    // Node name
    config: {
      scope: 'app',
      isPublic: true
    }
  }
};
js
export default {
  // Basic info
  author: 'hslr',
  microAppId: 'hslr-weather',
  version: '1.0.0',
  entry: 'main.js',
  icon: 'logo.png',
  debug: false,

  // i18n info
  appInfo: {
    'zh-CN': {
      appName: 'Weather',
      description: 'View weather data worldwide',
      networkDescription: 'Download necessary config data on first run'
    },
    'en-US': {
      appName: 'Weather',
      description: 'View weather data worldwide',
      networkDescription: 'Download necessary config data on first run'
    }
  },

  // Permission config
  permissions: [
    'network',     // network permission
    'dataNode'     // data node permission
  ],

  // Network domain whitelist
  networkDomains: [
    'api.example.com'
  ],

  // Data node config
  dataNodes: {
    // Node name
    config: {
      scope: 'app',
      isPublic: true
    }
  }
}

Component Config (components.config.js) ​

Defines the basic info of the micro app's page components and widget components.

Complete Example ​

Version notes

appJsonVersion:1.1 adds the widgetName, widgetDescription, and sort fields, with i18n support.

javascript
import HelloWorldConfig from '../src/components/widgetConfig.js';
import HelloWorldWidget from '../src/components/widget.js';

export default {
  // Page registration
  pages: {
    'hello-world-config': {
      component: HelloWorldConfig,
      background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
      backgroundDark: 'linear-gradient(135deg, #1a1a2e 0%, #16213e 100%)',
      headerTextColor: '#ffffff',
      headerTextColorDark: '#e0e0e0',
    }
  },

  // Widget registration
  widgets: {
    'hello-world-widget': {
      component: HelloWorldWidget,
      configComponentName: 'hello-world-config',
      // Fields added in appJsonVersion:1.1
      widgetName: 'Demo Widget',
      widgetDescription: 'Demo Widget Description',
      sort: 10, // Sort weight, smaller numbers come first
      size: ['1x1', '1x2', '2x1', '2x2', '2x4', '1xfull'],
      background: '',
    },
  },
};

Page Component Types ​

The micro app's page components are divided into two types:

TypeIdentifierDescription
Widget Config ComponentconfigOpens as a guided page when adding a widget, or via the widget's right-click menu "Widget Config"
Main Page ComponentmainOpens from a unified entry at the same micro app list location (unified entry not yet implemented), or anywhere within the micro app using this.api.window.open("main page name")

You can specify the page type via the type field, defaulting to config.

Page Config Parameters ​

ParameterTypeRequiredDescription
componentclass✅Page component class
backgroundstring-Background style (CSS background property), default: #ffffff (white)
backgroundDarkstring-Background style in dark mode, follows background when empty
headerTextColorstring-Header text color, default: #000000 (black)
headerTextColorDarkstring-Header text color in dark mode, follows headerTextColor when empty
widthnumber | string-Window width, in px when a number, default: 800
heightnumber | string-Window height, in px when a number, default: 600
showFullscreenBtnboolean-Whether to show the fullscreen button, default: false
resizeboolean-Whether to allow resizing the window, default: false
moveboolean-Whether to allow moving the window, default: false
typestring-Page type, values: main (main page), config (widget config page), default: config

Widget Config Parameters ​

ParameterTypeRequiredDescription
componentclass✅Widget component class
configComponentNamestring-Corresponding config page name (when configured, opens the page config component window when adding a component or via the widget's right-click menu)
widgetNamestring-Widget display name (added in 1.1, supports $t: syntax)
widgetDescriptionstring-Widget description (added in 1.1, supports $t: syntax)
sortnumber-Sort weight, smaller numbers come first (added in 1.1)
sizestring[]✅Supported grid sizes
backgroundstring-Default background color

Supported Grid Sizes ​

size

SizeDescription (row x column)Use Case
1x11 grid × 1 gridMini component
1x21 grid × 2 gridsVertical narrow card
2x12 grids × 1 gridHorizontal narrow card
2x22 grids × 2 gridsStandard card
2x42 grids × 4 gridsLarge card
4x44 grids × 4 gridsLarge card
1xfull1 grid × full screen widthFull-width display

Naming Conventions ​

  • microAppId: Use author-feature format, such as hslr-weather
  • Page name: Use lowercase letters and hyphens, such as weather-config
  • Widget name: Use lowercase letters and hyphens, such as weather-widget

Released under the MIT License.