Skip to content

运行环境模块

数据结构

ESRuntimeDeviceInfo

运行环境信息

参数描述类型非空
deviceId设备IDstring
deviceType设备类型string

接口

getRuntimeDeviceInfo

该方法获取运行环境信息。

完整方法声明:function getRuntimeDeviceInfo(): ESRuntimeDeviceInfo | null

  • 参数:

  • 返回值:
属性描述类型默认值
运行环境信息ESRuntimeDeviceInfo | null

getRuntimeDeviceId

该方法获取运行环境唯一标识符。

完整方法声明:function getRuntimeDeviceId(): string | null

  • 参数:

  • 返回值:
属性描述类型默认值
运行环境唯一标识符string | null

getRuntimeDeviceType

该方法获取运行环境类型。

完整方法声明:function getRuntimeDeviceType(): string | null

  • 参数:

  • 返回值:
属性描述类型默认值
运行环境类型string | null

基础用法

  • 代码示例:
    点击查看源码
    vue
    <template>
    	<div class='es-sdk-root-css'>
    		<s-title-view class='es-sdk-content-title-css' :text='this.$options.name' />
    		<div class='es-sdk-content-divider-css' />
    		<div class='es-sdk-content-column-css'>
    			<s-text-view text='运行容器信息'></s-text-view>
    			<s-text-view :text="'设备信息:' + deviceInfo"></s-text-view>
    			<s-text-view :text="'设备类型:' + deviceType"></s-text-view>
    			<s-text-view :text="'设备ID:' + deviceId"></s-text-view>
    		</div>
    	</div>
    </template>
    
    <script lang='ts'>
    import {defineComponent} from '@vue/runtime-core';
    import {ref} from 'vue';
    import {useESRuntime} from '@extscreen/es3-core';
    
    export default defineComponent({
    	name: '运行时模块',
    	setup() {
    
    		const deviceType = ref('');
    		const deviceId = ref('');
    		const deviceInfo = ref('');
    		const runtimeDevice = useESRuntime();
    		runtimeDevice.init().then();
    
    		function onESCreate(params) {
    			deviceInfo.value = JSON.stringify(runtimeDevice.getRuntimeDeviceInfo());
    			deviceId.value = runtimeDevice.getRuntimeDeviceId();
    			deviceType.value = runtimeDevice.getRuntimeDeviceType();
    		}
    
    		return {
    			onESCreate,
    			deviceType,
    			deviceId,
    			deviceInfo,
    		};
    	},
    });
    
    </script>
    <style>
    </style>