AppApi
API Functions
setConfig
Set configuration
Params:
| Param Name | Description |
|---|---|
key | string |
value | string |
Signature:
setConfig: (key: string | AppApiConstants, value: string | number | boolean) => Promise<any>getConfig
Get configuration
Params:
| Param Name | Description |
|---|---|
key | - |
defaultValue | - |
Returns: Promise<string | number | boolean>
Signature:
getConfig: <T extends string | number | boolean>(key: string | AppApiConstants, defaultValue: T) => Promise<T>getVersion
Get version information
Params:
| Param Name | Description |
|---|---|
type | string - Optional. Specify the type of version to get.
|
Returns: Promise<string>
Signature:
getVersion: (type?: 'app' | 'electron' | 'chrome' | 'node' | 'v8') => Promise<string>getRuntimeInfo
Get App's runtime info (e.g. app name, os/electron/node version, etc.)
Signature:
getRuntimeInfo: () => Promise<AppRuntimeInfo>getPreloadPath
Get Preload JS path @see Using Preload Scripts
Returns: Promise<string>
Signature:
getPreloadPath: () => Promise<string>getAppPath
Get application installation path
Returns: Promise<string>
Signature:
getAppPath: () => Promise<string>openAddWidgetWindow
Open the app's add/search widget window @deprecated Use showAppWindow('/widget/add', options) instead, which is more flexible and supports custom routes.
Signature:
openAddWidgetWindow: () => Promise<void>showAppWindow
Show a new window with specified route and options support routes: /user/profile /auth/register
Params:
| Param Name | Description |
|---|---|
route | - |
options | - |
Signature:
showAppWindow: (route: string | AppRoutes, options?: BrowserWindowOptions) => Promise<void>openSettingWindow
Open the app's setting window @deprecated Use showAppWindow('/setting/common', options) instead, which is more flexible and supports custom routes.
Signature:
openSettingWindow: () => Promise<void>openCheckUpdateWindow
Open the app's update window @deprecated Use showAppWindow('/widget/info', options) instead, which is more flexible and supports custom routes.
Signature:
openCheckUpdateWindow: () => Promise<void>openWidgetManagerWindow
open the app's widget manager window @deprecated Use showAppWindow('/widget/search', options) instead, which is more flexible and supports custom routes.
Signature:
openWidgetManagerWindow: () => Promise<void>openWidgetPackageManagerWindow
@deprecated Use showAppWindow('/widget/package', options) instead, which is more flexible and supports custom routes.
Signature:
openWidgetPackageManagerWindow: () => Promise<void>openRuntimeInfoWindow
Open the app's runtime info window @deprecated Use showAppWindow('/setting/info', options) instead, which is more flexible and supports custom routes.
Signature:
openRuntimeInfoWindow: () => Promise<void>getIconFile
Get the app's icon file path
Returns: Promise<string>
Signature:
getIconFile: () => Promise<string>isWindowsStore
Check if the app is running as Windows Store app (appx)
Returns: Promise<boolean>
Signature:
isWindowsStore: () => Promise<boolean>getLanguageCode
Get app's language, if user has not set, return navigator.language
Signature:
getLanguageCode: () => Promise<string>setLanguageCode
Set app's language
Params:
| Param Name | Description |
|---|---|
code | - |
Signature:
setLanguageCode: (code: LanguageCode) => Promise<void>setProxy
Set app's global proxy settings, set empty string to disable proxy @example
AppApi.setProxy({
proxyRules:'socks5://127.0.0.1:7890'
})Params:
| Param Name | Description |
|---|---|
config | - |
Signature:
setProxy: (config: ProxyConfig) => Promise<void>getProxy
Signature:
getProxy: () => Promise<ProxyConfig>setThemeCSS
Set app's global theme CSS
Params:
| Param Name | Description |
|---|---|
css | - |
Signature:
setThemeCSS: (css: string) => Promise<void>getThemeCSS
Get the app's global theme CSS
Returns: Promise<string> If the theme CSS is not set, return empty string
Signature:
getThemeCSS: () => Promise<string>setDevMode
enable/disable developer mode
Signature:
setDevMode: (enable: boolean) => Promise<void>getDevMode
get developer mode is enabled
Signature:
getDevMode: () => Promise<boolean>getGridCellSize
Get the app's desktop grid system cell size
Signature:
getGridCellSize: () => Promise<number>setGridCellSize
Set the app's desktop grid system cell size
Params:
| Param Name | Description |
|---|---|
size | - |
Signature:
setGridCellSize: (size: number) => Promise<void>exit
exit application
Signature:
exit: () => Promise<void>API Events
| Event Name | Value | Description |
|---|---|---|
CONFIG_CHANGED | 'event::cn.widgetjs.core.app.config.changed' | Triggered when application settings change |
MOVING_GRID_WINDOW | 'event::cn.widgetjs.core.app.moving.grid.window' | Triggered when the desktop widget grid window moves |
STOP_MOVING_GRID_WINDOW | 'event::cn.widgetjs.core.app.moving.grid.window.stop' | Triggered when the desktop widget grid window stops moving |
PROXY_CHANGED | 'event::cn.widgetjs.core.app.proxy.changed' | Application proxy changed |
LANGUAGE_CHANGED | 'event::cn.widgetjs.core.app.language.changed' | Application language changed |
API Constants
| Constant Name | Value | Description |
|---|---|---|
CONFIG_GRID_CELL_SIZE | 'cn.widgetjs.config.grid.size' | Desktop widget grid size |
CONFIG_WIDGET_THEME_CSS | 'cn.widgetjs.config.widget.theme.css' | Application theme CSS settings |
CONFIG_PROXY | 'cn.widgetjs.config.app.proxy' | Application global proxy settings |
CONFIG_DEV_MODE | 'cn.widgetjs.config.app.dev.mode' | - |
CONFIG_LANGUAGE | 'cn.widgetjs.config.app.language' | Application language settings |