目录

Developing the web-view Component

web-view is a container that directly integrates the web page content into the UI of the atomic service, so that a user can browse a web page without leaving the service, thereby providing seamless browsing experience for the user.

Preparations

  1. Configure the business domain names.
  2. Install the JS SDK. For details, see JS SDK.

JS SDK

How to Obtain

Inherit the JS SDK to your project using npm.

How to Install

Open the cmd window in the target path and run the following npm command to obtain the corresponding JS file:

npm install @atomicservice/ascf-web-sdk

How to Use

es6

import has from '@atomicservice/ascf-web-sdk';

has.ascfweb.getEnv((res) => {
   console.log('success: ', res);
});

umd

<script src="../dist/ascf-web-sdk.umd.js"></script>
<script>
  has.ascfweb.getEnv((res) => {
    console.log('success: ', res);
  });
</script>

A success message displayed in the command output indicates that the SDK has been successfully installed and you can use the web-view component.

Copy the ascf-web-sdk.umd.js file in the npm installation package to the static resource directory of the project, and change the value of script src in the preceding example to the corresponding path.

UserAgent

When web-view is used to access the server, ASCF/Application ID is added to the system UserAgent to determine whether UserAgent is running on ASCF.

Example

******: original UserAgent content.

****** ASCF/1234567890123456

Determine whether an HTML5 page is opened in ASCF through UserAgent.

Example

const isAscfWebview = window.navigator.userAgent.includes('ASCF');  // true

When isAscfWebview is true, the HTML5 page is successfully opened in ASCF.