API
We provide some common capabilities for easy use in development. Named $he3
, you can access it through window.$he3
.
The following is a list of APIs. Please refer to the demonstration code below for specific calling methods.
message
triggers global message promptscopyText
copies a piece of textsubscribeThemeChange
subscribes to theme changesdownloadByUrl
downloads a file via URLlang
current languagetheme
current themeshellOpenExternal
opens a URL with a system default protocol. The main scenario is to open a URL address through a browser.isDev
whether the current environment is a development environmentisMacOS
whether the current device is MacisWindows
whether the current device is WindowsisLinux
whether the current device is LinuxgetSearchValue
gets the content entered in the search input (only needs to be rendered in the search box)getLastClipboard
gets the current contents of the clipboardonUseClipboardValue
callback function triggered after using the clipboard, notifying the user
Global message prompts
$he3.message.success('Success');
$he3.message.error('Fail');
$he3.message.info('Tip');
$he3.message.warning('Warning');
Get current clipboard content
$he3.getLastClipboard().then((data) => {
console.log(data);
});
Copy text
$he3.copyText('copy text');
Get current theme
Gets the current theme, returns dark or light
console.log($he3.theme)
Subscribe theme changes
subscribeThemeChange
accepts a callback function. When the theme changes, it will trigger the callback function, which will return the current theme, dark or light.
Developers don't need to pay attention to whether the current theme follows the system theme or the user-defined theme. Just subscribe to this event, and then make corresponding processing according to the theme change. We will keep the global themes consistent.
$he3.subscribeThemeChange((data) => {
console.log(data);
});
Get current language
The following is a list of languages we currently support:
- en English
- zh Simplified Chinese
- zh-tw Traditional Chinese
- es Spanish
- ja Japanese
- ko Korean
- de German
- fr French
- it Italian
- ru Russian
- pt Portuguese
console.log($he3.lang);
Download file by URL
$he3.downloadByUrl('https://www.baidu.com/img/bd_logo1.png');