The content of this page has been automatically translated by AI. If you encounter any problems while reading, you can view the corresponding content in Chinese.

Development and Debugging

Last updated: 2025-04-28 10:52:07

H5 Panel Scaffolding

We can use the following command to initialize an H5 panel project:
npx --package caz@1.0.0 caz tencentyun/iotexplorer-h5-panel-template my-h5-panel
If you have used tools like vue-cli to initialize a project, then this command is similar to it. This command will pull iotexplorer-h5-panel-template as a template, and then perform some feature selections, such as version number, choice of framework, etc. As shown below, finally, it will initialize an H5 panel project.


After the project creation is completed, developers can refer to README.md in the project directory. After installing dependencies, run the project through the following command:
npm run dev -- --productId=your_productId
Among them, your_productId is the productId of the corresponding product of the H5 panel.

H5 Panel Demo

IoT Explorer provides an H5 panel Demo for developers' reference. The H5 panel Demo is open to developers in an open-source way, making it easy for developers to refer to when developing H5 panels.
The H5 panel Demo project is written using the React framework. For details, see iotexplorer-h5-panel-demo.
We also provide a scaffolding tool that supports the creation of H5 panel demos with React or Vue frameworks. For details, see iotexplorer-H5-panel-template.

Starting Debugging

During the development and debugging of the H5 panel, execute the following commands.
1. Install dependencies (execute once after downloading the Demo).
npm install
2. Real-time compilation H5 panel (needs to keep running during the development process).
npm run dev
When this command is executed, the JS file of the H5 panel can be accessed via http://127.0.0.1:9000/index.js, and the CSS file can be accessed via http://127.0.0.1:9000/index.css. After the H5 panel source code file is changed, the JS file and CSS file will be automatically recompiled. Refresh the H5 panel page to load the updated JS file and CSS file.

Compilation and Building

After the H5 panel development is completed, execute the following commands to build the JS file and CSS file of the H5 panel.
npm run release
After the build is complete, the JS file and CSS file will be output to dist/index.js and dist/index.css respectively. Developers need to upload these files to the interactive development configuration item of the product in the IoT Explorer Console. For operations, see Upload H5 Panel.

Debugging the H5 Panel

Use the official account webpage debug feature of a browser or WeChat Developer Tools to access the specified URL, accessible in H5 panel development mode, to debug the H5 panel.
In development mode, the H5 panel framework will load the JS file and CSS file from the following two URLs respectively. You need to configure a proxy so that the browser or WeChat Developer Tools can load the JS file and CSS file of the H5 panel through these two URLs, thereby debugging the H5 panel.
JS file URL: https://developing.script/developing.js
CSS file URL: https://developing.style/developing.css
Note:
Development mode requires your Tencent Cloud login status. You must use a Tencent Cloud account with permission to operate on the product to log in and enter the H5 panel development mode of the corresponding product.

Local Debugging

Local debugging will register a Tencent Lianlian user associated with your Tencent Cloud account as a Debug User, and create a family and a device for debugging, so you no need to pay attention to the logic of creating a family, device binding, etc., just focus on the development of the H5 panel.
Access the following URL to perform local debugging of the H5 panel. Replace ABCDEFG with the actual product ID.
https://iot.cloud.tencent.com/h5panel/developing?productId=ABCDEFG
The following describes the detailed directions by taking the local debugging of the H5 panel Demo with WeChat Developer Tools as an example.

Step 1: Download a Demo Project

1. Pull the source code of the Demo project.
git clone https://github.com/tencentyun/iotexplorer-h5-panel-demo.git
2. Install dependencies.
cd iotexplorer-h5-panel-demo
npm install

Step 2: Install and Configure whistle

If you are not familiar with whistle, you can also try an easier proxy-free mode to skip step 2.
1. Install whistle, execute the following command:
npm install -g whistle
2. Start up whistle, execute the following command:
w2 start
After whistle starts successfully, the command line has the following output:
[i] whistle@2.5.7 started
[i] 1. use your device to visit the following URL list, gets the IP of the URL you can access:
http://127.0.0.1:8899/
... (output omitted)
3. Open http://127.0.0.1:8899/ through a browser and enter the user interface of whistle.
4. Select Rules > Default and enter the rule configuration page. Fill in the following proxy rules in the input box.
developing.script/developing.js http://127.0.0.1:9000/index.js
developing.style/developing.css http://127.0.0.1:9000/index.css
Click Save to save the changed content.
whistle - Configure proxy rules


5. 1. Click
HTTPS
in the menu bar to enter the HTTPS configuration interface. Check "Capture TUNNEL CONNECTs".
6. 1. Click Download RootCA to download the root certificate locally.
Note:
No need to pay attention to the QR code information in this step. Click Download RootCA and check "Capture TUNNEL CONNECTs".



7. Install the root certificate. For specific steps, please see Installing Root Certificate.

Step 3: Start Up Real-Time Compilation of the Demo Project

In the Demo project directory, execute the following command:
npm run dev

After successful compilation, the command line has the following output:
i 「wds」: Project is running at https://localhost:9000/
... (intermediate output omitted)
i 「wdm」: Compiled successfully.


Step 4: Configure WeChat Developer Tool

1. Open WeChat Developer Tools and select Settings > Proxy > Proxy Settings from the menu bar.
2. Select manually set proxy, fill in the proxy address with 127.0.0.1, and fill in the port with 8899.
WeChat Developer Tools - Proxy Settings



Step 5: Open the H5 Panel in WeChat Developer Tool

1. Open WeChat Developer Tools, click the official account webpage on the new project page, and enter the Official Account Debugging Page.
WeChat Developer Tools - WeChat Official Account Debugging


2. Verify whether the H5 panel JS files can be accessed. Enter https://developing.script/developing.js in the address bar and press Enter. If the JS file code can be loaded and displayed in the emulator, it indicates that the H5 panel JS files can be accessed.
3. Enter the local debugging URL in the address bar and press Enter. The emulator will jump to the login page of the Tencent Cloud console.
4. Select Model > "Windows (480×800 | Dpr:2)" from the emulator menu.
Note:
If the emulator simulates a mobile environment, WeChat or QQ login cannot be carried out normally. Here, change to the Windows model first. After logging in, it can be changed back to the original model setting.

WeChat Developer Tools - Device Settings


5. Log in to the Tencent Cloud console on the emulator page. Once logged in successfully, the emulator will navigate to the H5 panel, where H5 panel debugging can be performed.

Agentless Mode

The way to enable the proxy-free mode is also simple. Just add a parameter after the link in the development panel: &sw=true. Suppose we want to develop a device with productId ABCDEFG and deviceName dev1. Then, the proxy-free mode can be enabled via the following link.
- https://iot.cloud.tencent.com/h5panel/developing?productId=ABCDEFG&deviceName=dev1
+ https://iot.cloud.tencent.com/h5panel/developing?productId=ABCDEFG&deviceName=dev1&sw=true
By adding sw=true, a service-worker will be enabled on the page. Through the interception and forwarding of requests by the service-worker, requests for developing.script and developing.style will be proxied to the localhost development server. This approach is also effective for subsequent real device debugging and testing on actual devices.

Overview of Agentless Mode Principle

As previously mentioned, in development mode, the H5 panel framework will load JS files and CSS files from the following two URLs respectively:
JS file URL: https://developing.script/developing.js
- CSS file URL: https://developing.style/developing.css
The files packaged by the development server are accessed via localhost. Therefore, we need to perform a proxy between the two. The above-mentioned whistle plays such a role. If we don't use whistle, we can also use the browser's built-in service-worker. By listening to the fetch event and then intercepting and modifying requests, we can complete such work. This is the proxy-free mode. That is to say, the so-called proxy-free mode is not actually agentless. It merely avoids installing tools like whistle and achieves request proxying through the browser's own capabilities (service-worker).

Real Device Debugging

Through actual device debugging, you can perform H5 panel debugging on the specified device. Replace ABCDEFG with the actual product ID and abcdefg with the actual device name. If you need to debug the virtual device provided by IoT Explorer, replace abcdefg with ~virtualDev.
https://iot.cloud.tencent.com/h5panel/developing?productId=ABCDEFG&deviceName=abcdefg
Note:
When debugging the specified device, this device will be automatically bound to the family of your Debug User, and the original binding relationship of this device will be removed at the same time.
Released products do not support real device debugging, because there are risks of unbinding relationships of devices in use by real users.

Real Device Debugging

For released products, real device debugging is not open, and it is very difficult to debug the H5 panel in the mini program. To address this issue, the platform provides a real device debugging solution. Real device debugging allows debugging of the H5 panel while maintaining the device's existing binding relationship. Before starting, you need to use the Tencent Lianlian Mini Program to bind the device to be debugged. Specific steps are as follows.
1. Open Tencent Lianlian Mini Program, select Mine > About Us to enter the About Us page.
2. Long-press the Tencent Lianlian Logo and select Enter Development Mode in the pop-up menu. Page prompt indicates successful entry into development mode.


3. Return to the homepage of Tencent Lianlian Mini Program. In the device list, long-press the device that needs to be debugged and select "Generate H5 Panel Debugging Address" in the pop-up menu. Then, this debugging address will be copied to the clipboard.


4. Use browser to access this debugging address to perform H5 panel real device debugging.

Uploading the H5 Panel

After the H5 panel development is completed, upload the JS file and CSS file of the H5 panel in the console. Specific operations are as follows:
1. Log in to Tencent Cloud and enter the IoT Explorer Console, select a project and products, and enter the product detail page.
2. Select Interactive Development > Panel Configuration, click Configure to enter the panel configuration page.



3. Select H5 Custom Dashboard from the dashboard type.



4. In the Upload JS form, click Upload and select the JS files of the H5 panel. After upload completion, the page displays the file names, sizes, and MD5 info of the JS files.



5. If necessary, upload a CSS file. In the "Upload CSS" form, click Upload and select the CSS file of the H5 panel. After upload completion, the page displays the file name, size, and MD5 info of the CSS file.
6. Click Save. The page prompt indicates that the saving is successful. The uploaded JS files and CSS files are saved to take effect.
Note:
If the panel contains small images, they can be inlined into the code through build tools. If the image is relatively large, it is recommended to upload it to COS and then refer to it through a link.

H5 Panel Access Allowlist

During the development phase, you need to set an access allowlist to use Tencent Lianlian to debug the H5 custom panel. For more information on how to set the access allowlist, see Quick Start.