### Start Recording Example
Source: https://doc.quickapp.cn/features/system/record.html
Example of how to start recording with specified parameters.
```javascript
record.start({
duration: 10000,
sampleRate: 8000,
numberOfChannels: 1,
encodeBitRate: 16000,
//frameSize:1024,
//format: 'pcm',
format: 'aac',
success: function(data) {
console.log(`handling success: ${data.uri}`)
},
fail: function(data, code) {
console.log(`handling fail, code = ${code}, errorMsg=${data}`)
}
})
```
--------------------------------
### Get Provider Example
Source: https://doc.quickapp.cn/features/service/push.html
Example of how to get the service provider's code.
```javascript
console.log(push.getProvider())
```
--------------------------------
### Less Pre-compilation Setup
Source: https://doc.quickapp.cn/tutorial/framework/page-style-and-layout.html
Instructions and example for setting up and using Less for CSS pre-compilation in Quick App.
```bash
npm i less less-loader
```
```vue
less示例!
```
--------------------------------
### Scss Pre-compilation Setup
Source: https://doc.quickapp.cn/tutorial/framework/page-style-and-layout.html
Instructions and example for setting up and using Sass (Scss) for CSS pre-compilation in Quick App.
```bash
npm i node-sass sass-loader
```
```vue
less示例!
```
--------------------------------
### onframerecorded Callback Example
Source: https://doc.quickapp.cn/features/system/record.html
Example of how to handle the onframerecorded callback to get audio data frames.
```javascript
record.onframerecorded = function (res){
//获取音频数据:res.frameBuffer
//是否是最后一帧:res.isLastFrame
}
```
--------------------------------
### Fetch API Example
Source: https://doc.quickapp.cn/ide/simulator-devtools.html
This code snippet demonstrates how to use the fetch API to make a GET request.
```javascript
fetch.fetch({
url: 'https://www.example.com',
responseType: 'text',
method: 'GET',
success: function(response) {
console.log('---回调success---: ', response)
},
fail: function(data, code) {
console.log('---回调fail---: ', data, code)
},
complete: function(a, b, c) {
console.log(`---回调complete---: `, a, b, c)
}
})
```
--------------------------------
### Get Clipboard Content Example
Source: https://doc.quickapp.cn/features/system/clipboard.html
Example of how to get the content from the clipboard.
```javascript
clipboard.get({
success: function(data) {
console.log(`handling success: ${data.text}`)
},
fail: function(data, code) {
console.log(`handling fail, code = ${code}`)
}
})
```
--------------------------------
### Get Image Info Example
Source: https://doc.quickapp.cn/features/system/image.html
Example of how to get image information.
```javascript
image.getImageInfo({
uri: 'internal://tmp/abc.jpg',
success: function(data) {
console.log(`handling success: size = ${data.size}`)
},
fail: function(data, code) {
console.log(`handling fail, code = ${code}`)
}
})
```
--------------------------------
### Get NFC Adapter Example
Source: https://doc.quickapp.cn/features/system/nfc.html
Example of how to get the NFC adapter instance.
```javascript
import nfc from '@system.nfc'
nfcadapter = nfc.getNFCAdapter()
```
--------------------------------
### Download Example
Source: https://doc.quickapp.cn/features/system/request.html
An example demonstrating how to use the `request.download()` method to initiate a file download.
```javascript
request.download({
url: 'http://www.example.com',
success: function(data) {
console.log(`handling success${data.token}`)
},
fail: function(data, code) {
console.log(`handling fail, code = ${code}`)
}
})
```
--------------------------------
### Get EXIF Attributes Example
Source: https://doc.quickapp.cn/features/system/image.html
Example of how to get EXIF attributes from an image.
```javascript
image.getExifAttributes({
uri: 'internal://cache/123.png',
success: function(data) {
console.log(`handling success: ${JSON.stringify(data.attributes)}`)
},
fail: function(data, code) {
console.log(`handling fail, code = ${code}`)
}
})
```
--------------------------------
### menuBar Configuration Example
Source: https://doc.quickapp.cn/framework/manifest.html
Example of how to configure menuBar globally and for specific pages in manifest.json.
```json
{
"display": {
"menuBarData": {
// 全局配置
"menuBar":true,
"menuBarStyle":"dark",
"shareTitle":"分享标题",
"shareDescription":"分享描述",
"shareIcon":"分享url"
},
"pages": {
"Hello": {
// 页面配置,默认使用页面menuBarData配置,页面无配置使用全局menuBarData配置
"menuBarData": {
"menuBar" true,
"menuBarStyle":"dark",
"shareTitle":"子页面分享标题",
"shareDescription":"分页面享描述",
"shareIcon":"页面分享url",
"shareCurrentPage":true,
"shareUrl":"https://www.quickapp.cn/",
"shareParams":"{key:1,id:2})"
}
}
}
}
```
--------------------------------
### 注销蓝牙模块
Source: https://doc.quickapp.cn/tutorial/features/using-bluetooth.html
注销蓝牙模块
```javascript
console.log(`handling fail, code = ${code}`)
},
complete: function () {
console.log("complete")
}
})
}
};
```
--------------------------------
### Import Module
Source: https://doc.quickapp.cn/features/system/configuration.html
Demonstrates how to import the configuration module.
```javascript
import configuration from '@system.configuration' or const configuration = require('@system.configuration')
```
--------------------------------
### getLength() Example
Source: https://doc.quickapp.cn/features/system/router.html
Example of how to get the length of the router.
```javascript
var length = router.getLength()
console.log(`page's length = ${length}`)
```
--------------------------------
### getState() Example
Source: https://doc.quickapp.cn/features/system/router.html
Example of how to get the current page state.
```javascript
var page = router.getState()
console.log(`page index = ${page.index}`)
console.log(`page name = ${page.name}`)
console.log(`page path = ${page.path}`)
```
--------------------------------
### onConfigurationChanged Example
Source: https://doc.quickapp.cn/framework/script.html
Example of how to handle configuration changes, such as locale, theme mode, orientation, and screen size.
```javascript
onConfigurationChanged(evt) {
console.log(`触发生命周期onConfigurationChanged, 配置类型:${evt.type}`)
}
```
--------------------------------
### NfcA.getMaxTransceiveLength() Example
Source: https://doc.quickapp.cn/features/system/nfca.html
Example of how to get the maximum transceive length.
```javascript
nfca.getMaxTransceiveLength({
success: function(data) {
console.log(`handling success, length = ` + data.length)
},
fail: function(data, code) {
console.log(`handling fail, code = ${code}`)
},
complete: function() {
console.log(`handling complete`)
}
})
```
--------------------------------
### file.mkdir Example
Source: https://doc.quickapp.cn/features/system/file.html
Example of creating a directory.
```javascript
file.mkdir({
uri: 'internal://files/dir/',
success: function(data) {
console.log(`handling success`)
},
fail: function(data, code) {
console.log(`handling fail, code = ${code}`)
}
})
```
--------------------------------
### getVideoThumbnail Method Example
Source: https://doc.quickapp.cn/features/system/video.html
Example of getting a video thumbnail.
```javascript
Video.getVideoThumbnail({
uri: 'internal://temp/xxx.mp4',
success: function(data) {
console.log(`handling success,uri = ${data.uri}`)
},
fail: function(data, code) {
console.log(`handling fail, code = ${code}`)
}
})
```
--------------------------------
### Example
Source: https://doc.quickapp.cn/widgets/web.html
Example of using system.onmessage and system.postMessage within a web page to communicate with the quick app.
```javascript
system.onmessage = function(data) {
console.log('message received: ' + data)
}
system.postMessage('hello')
```
--------------------------------
### MifareUltralight.getMaxTransceiveLength() Example
Source: https://doc.quickapp.cn/features/system/nfcmifareultralight.html
Example of how to get the maximum transceive length using MifareUltralight.getMaxTransceiveLength().
```javascript
mifareultralight.getMaxTransceiveLength({
success: function(data) {
console.log(`handling success, length = ` + data.length)
},
fail: function(data, code) {
console.log(`handling fail, code = ${code}`)
},
complete: function() {
console.log(`handling complete`)
}
})
```
--------------------------------
### Example
Source: https://doc.quickapp.cn/widgets/web.html
Example of using the web component.
```html
```
--------------------------------
### IsoDep.getMaxTransceiveLength() Example
Source: https://doc.quickapp.cn/features/system/nfcisodep.html
Example of how to get the maximum transceive length using IsoDep.getMaxTransceiveLength().
```javascript
isodep.getMaxTransceiveLength({
success: function(data) {
console.log(`handling success, length = ` + data.length)
},
fail: function(data, code) {
console.log(`handling fail, code = ${code}`)
},
complete: function() {
console.log(`handling complete`)
}
})
```
--------------------------------
### 创建项目
Source: https://doc.quickapp.cn/ide/cli.html
使用 `hap init ` 命令创建一个项目模板。
```bash
hap init
```
--------------------------------
### NfcA.getSak() Example
Source: https://doc.quickapp.cn/features/system/nfca.html
Example of how to get SAK information from the NFC tag.
```javascript
nfca.getSak({
success: function(data) {
console.log(`handling success, result = ` + data.sak)
},
fail: function(data, code) {
console.log(`handling fail, code = ${code}`)
},
complete: function() {
console.log(`handling complete`)
}
})
```
--------------------------------
### 注销蓝牙模块
Source: https://doc.quickapp.cn/tutorial/features/using-bluetooth.html
在不需要使用蓝牙时,需要注销蓝牙模块,以释放系统资源
```javascript
//取消不需要的状态监听
bluetooth.onadapterstatechange = null
bluetooth.onbleconnectionstatechange = null
bluetooth.onblecharacteristicvaluechange = null
bluetooth.ondevicefound = null
//注销蓝牙模块
bluetooth.closeAdapter({
//是否关闭系统蓝牙开关,默认false,此操作会直接关闭系统蓝牙,为了不影响用户其他蓝牙设备的体验,不建议设置为true
operateAdapter: false,
success: function () {
console.log("success");
},
fail: function (data, code) {
console.log(`handling fail, code = ${code}`);
},
complete: function () {
console.log("complete");
}
});
```
--------------------------------
### NfcA.getAtqa() Example
Source: https://doc.quickapp.cn/features/system/nfca.html
Example of how to get ATQA information from the NFC tag.
```javascript
nfca.getAtqa({
data: arrayBuffer,
success: function(data) {
console.log(`handling success, result = ` + new Int8Array(data.atqa))
},
fail: function(data, code) {
console.log(`handling fail, code = ${code}`)
},
complete: function() {
console.log(`handling complete`)
}
})
```
--------------------------------
### 应用图标配置
Source: https://doc.quickapp.cn/tutorial/overview/project-structure.html
Example of configuring the application's icon in manifest.json.
```json
{
"icon": "/assets/images/logo.png"
}
```
--------------------------------
### Download File Example
Source: https://doc.quickapp.cn/features/system/downloadtask.html
Demonstrates how to use the downloadtask.downloadFile method to initiate a download, and how to handle success, failure, and progress updates, as well as aborting the task.
```javascript
const retDownloadTask = downloadtask.downloadFile({
url: 'http://www.example.com',
success: function(res){
console.log("Download success.resp = " + JSON.stringify(res))
},
fail: function(data, code) {
console.log(`handling fail, errMsg = ${data}`)
console.log(`handling fail, errCode = ${code}`)
}
})
// 中断下载任务
retDownloadTask.abort()
// 监听响应头事件
retDownloadTask.onHeadersReceived(header => {
console.log(
`listening for response header event, header = ${JSON.stringify(header)}`
)
})
// 监听下载进度事件
retDownloadTask.onProgressUpdate(res => {
console.log(
`listening download progress update event, progressUpdate data = ${JSON.stringify(res)}`
)
})
// 取消全部监听 HTTP Response Header 事件
retDownloadTask.offHeadersReceived()
// 取消全部监听下载进度事件
retDownloadTask.offProgressUpdate()
```
--------------------------------
### Get Current Locale
Source: https://doc.quickapp.cn/features/system/configuration.html
Example of how to get the current application's locale.
```javascript
const locale = configuration.getLocale()
console.log(locale.language)
```
--------------------------------
### maven
Source: https://doc.quickapp.cn/features/service/accountsdk.html
maven集成方式
```xml
com.quickapp.union
account-sdk-java
1.0-SNAPSHOT
```
--------------------------------
### getPages() Example
Source: https://doc.quickapp.cn/features/system/router.html
Example of how to get the list of pages in the current page stack.
```javascript
var stacks = router.getPages()
console.log('栈底页面名称为:', stacks[0].name) // 如 list、detail 等
console.log('栈底页面路径为:', stacks[0].path) // 如 /list、/detail、/home/preview
```
--------------------------------
### pickFile Example
Source: https://doc.quickapp.cn/features/system/media.html
Example of how to use the pickFile API.
```javascript
media.pickFile({
success: function(data) {
console.log(`handling success: ${data.uri}`)
},
fail: function(data, code) {
console.log(`handling fail, code = ${code}`)
}
})
```
--------------------------------
### getSupportedCoordTypes() Example
Source: https://doc.quickapp.cn/features/system/geolocation.html
Example of how to get supported coordinate types using geolocation.getSupportedCoordTypes().
```javascript
var types = geolocation.getSupportedCoordTypes()
```
--------------------------------
### showContextMenu Example
Source: https://doc.quickapp.cn/features/system/prompt.html
Example of how to display a context menu with a list of items and custom styling using prompt.showContextMenu.
```javascript
prompt.showContextMenu({
itemList: ['item1', 'item2'],
itemColor: '#ff33ff',
success: function(data) {
console.log('handling success')
},
cancel: function() {
console.log('handling cancel')
},
fail: function(data, code) {
console.log(`handling fail, code = ${code}`)
}
})
```
--------------------------------
### IsoDep.getHistoricalBytes() Example
Source: https://doc.quickapp.cn/features/system/nfcisodep.html
Example of how to get historical bytes from an NFC tag using IsoDep.getHistoricalBytes().
```javascript
isodep.getHistoricalBytes({
success: function(data) {
console.log(`handling success, length = ` + new Int8Array(data.histBytes))
},
fail: function(data, code) {
console.log(`handling fail, code = ${code}`)
},
complete: function() {
console.log(`handling complete`)
}
})
```
--------------------------------
### NfcV.getMaxTransceiveLength() Example
Source: https://doc.quickapp.cn/features/system/nfcv.html
Example of how to use the NfcV.getMaxTransceiveLength() method to get the maximum transceive length.
```javascript
nfcv.getMaxTransceiveLength({
success: function(data) {
console.log(`handling success, length = ` + data.length)
},
fail: function(data, code) {
console.log(`handling fail, code = ${code}`)
},
complete: function() {
console.log(`handling complete`)
}
})
```
--------------------------------
### showDialog Example
Source: https://doc.quickapp.cn/features/system/prompt.html
Example of how to display a dialog box with custom buttons and callbacks using prompt.showDialog.
```javascript
prompt.showDialog({
title: 'title',
message: 'message',
buttons: [
{
text: 'btn',
color: '#33dd44'
}
],
success: function(data) {
console.log('handling callback')
},
cancel: function() {
console.log('handling cancel')
},
fail: function(data, code) {
console.log(`handling fail, code = ${code}`)
}
})
```
--------------------------------
### app.ux example
Source: https://doc.quickapp.cn/framework/source-file.html
Example of app.ux, including manifest configuration, public script introduction, and error handling.
```html
```
--------------------------------
### Getting Canvas Context
Source: https://doc.quickapp.cn/widgets/canvas.html
This example shows how to get the 2D rendering context for a canvas element.
```javascript
var canvas = this.$element('canvasid');
var ctx = canvas.getContext('2d');
```
--------------------------------
### 项目根目录结构
Source: https://doc.quickapp.cn/tutorial/overview/project-structure.html
This snippet shows the typical directory structure of a Quick App project, including source files, assets, pages, and configuration files.
```bash
└── src
│ ├── assets # 公用的资源(Images/Styles/字体...)
│ │ ├──images # 存储 png/jpg/svg 等公共图片资源
│ │ └──styles # 存放 less/css/sass 等公共样式资源
│ ├── helper # 项目自定义辅助各类工具
│ ├── pages # 统一存放项目页面级代码
│ ├── app.ux # 应用程序代码的入口文件
│ └── manifest.json # 配置应用基本信息
└── package.json # 定义项目需要的各种模块及配置信息
```
--------------------------------
### MifareClassic.getMaxTransceiveLength() Example
Source: https://doc.quickapp.cn/features/system/nfcmifareclassic.html
Example of how to get the maximum transceive length for an NFC tag using MifareClassic.getMaxTransceiveLength().
```javascript
mifareclassic.getMaxTransceiveLength({
success: function(data) {
console.log(`handling success, length = ` + data.length)
},
fail: function(data, code) {
console.log(`handling fail, code = ${code}`)
},
complete: function() {
console.log(`handling complete`)
}
})
```
--------------------------------
### Example
Source: https://doc.quickapp.cn/widgets/web.html
Example of handling the back press event to navigate within the webview or the app.
```javascript
onBackPress () {
this.$element('web').canBack({
callback: function (e) {
if (e) {
// Load the previous URL in the history list
this.$element('web').back()
} else {
router.back()
}
}.bind(this)
})
// Prevent default behavior and wait for asynchronous operation
return true
}
```
--------------------------------
### getLocation Example
Source: https://doc.quickapp.cn/features/system/geolocation.html
Example of how to use the getLocation interface to get the current geographical location.
```javascript
geolocation.getLocation({
success: function(data) {
console.log(
`handling success: longitude = ${data.longitude}, latitude = ${
data.latitude
}`
)
},
fail: function(data, code) {
console.log(`handling fail, code = ${code}, errorMsg=${data}`)
}
})
```
--------------------------------
### Get Current Theme Mode
Source: https://doc.quickapp.cn/features/system/configuration.html
Example of how to get the current application's theme mode.
```javascript
const themeMode = configuration.getThemeMode()
console.log(`Theme mode is ${themeMode} now~`)
```
--------------------------------
### Full Screen Custom Component Example
Source: https://doc.quickapp.cn/widgets/video.html
Example demonstrating how to enable custom components in full-screen video playback using a div wrapper with enablevideofullscreencontainer set to true.
```html
```
--------------------------------
### 应用名称配置
Source: https://doc.quickapp.cn/tutorial/overview/project-structure.html
Example of configuring the application's name in manifest.json.
```json
{
"name": "发票小助手"
}
```
--------------------------------
### Get Current Screen Brightness
Source: https://doc.quickapp.cn/features/system/brightness.html
Example of how to get the current screen brightness value.
```javascript
brightness.getValue({
success: function(data) {
console.log(`handling success, value = ${data.value}`)
},
fail: function(data, code) {
console.log(`handling fail, code = ${code}`)
}
})
```
--------------------------------
### 示例代码
Source: https://doc.quickapp.cn/tutorial/features/using-bluetooth.html
示例代码如下
```html