Instructions for Using the View Capture Plugin
Environmental requirements
Minimum support: API 13
Installing the SDK
This package is a plugin package for view collection. Please ensure that the core SDK package @tingyun/sdk-core is installed before using it
Remote installation
Enter the project root directory and execute the following commands
ohpm install @tingyun/sdk-plugin-record
If you need to install a specific version of the plugin, you can manually specify the version (<version> is the specific version number)
ohpm install @tingyun/sdk-plugin-record@<version>
Installation of intranet repository
Users in the intranet environment are advised to upload the relevant har package to the enterprise intranet repository and complete the installation process through the intranet repository
Download the latest SDK from the Tingyun console Management - Download Center - App - Harmony, unzip the downloaded zip file, and upload tingyun-core_version.har and tingyun-plugin-record_version.har to the enterprise intranet repository
Enter the project root directory and execute the following command
ohpm install @tingyun/sdk-plugin-record
If you need to install a specific version of the plugin, you can manually specify the version (<version> is the specific version number)
ohpm install @tingyun/sdk-plugin-record@<version>
Initialize the plugin
Introduce the plugin during SDK initialization
import tingyun from '@tingyun/sdk-core'
import ViewRecordPlugin from '@tingyun/sdk-plugin-record'
tingyun.init({
// . ..
// Import the view collection plugin
plugins: [ViewRecordPlugin()],
record: {
// Whether to enable view collection upon first startup
enabled: true
}
})
Call API to open view collection
View collection still requires manual activation by the user even after the server and switch are turned on
import tingyun from '@tingyun/core';
// Start view acquisition
tingyun.startViewRecord();
Other APIs:
// Stop view capture
tingyun.pauseViewRecord();
// Restore view collection
tingyun.resumeViewRecord();
Note:
- startViewRecord can only be called once, and it must be called before pauseViewRecord and resumeViewRecord
- Before initializing the SDK, you can call the view collection API for pre-configuration. When the SDK starts, it will automatically use the state of the last API call as the initial state for view collection
Privacy control
Mask specified page
Configuration can be set through SDK initialization or issued by the platform, with the latter taking precedence
SDK initialization configuration
tingyun.init({
// . ..
viewRecord: {
pageBlacklist: ['page1', 'page2']
}
})
Mask specified component ID
Configuration can be set through SDK initialization or issued by the platform, with the latter taking precedence
Note: Component ID masking only supports components in the main window.
tingyun.init({
// . ..
viewRecord: {
viewIdBlacklist: ['view1', 'view2']
}
})
Mask specified area
The SDK provides APIs addViewRecordMaskArea and removeViewRecordMaskArea for adding and removing mask areas
Add mask area:
import tingyun from '@tingyun/core';
tingyun.addViewRecordMaskArea({
id: 'mask1',
rect: {
// Relative to the horizontal coordinate of the top left corner of the screen, unit: px
x: 0,
// Relative to the vertical coordinate of the top left corner of the screen, unit: px
y: 0,
// Width of the masked rectangular area, unit: px
width: 100,
// Mask rectangle height, unit: px
height: 100
}
})
Remove mask area:
import tingyun from '@tingyun/core';
tingyun.removeViewRecordMaskArea('mask1')
Disable screenshot for a specific window
By setting the privacy mode of the window to true using windowClass.setPrivacyMode(true), the SDK will refrain from capturing views from that specific window
Control through pause and resume API
You can pause view recording by calling tingyun.pauseViewRecord(), and resume recording by calling tingyun.resumeViewRecord()