插件模块 #
此模块用于使用容器的插件功能。
基础用法
<template>
<div class="es-sdk-root-css">
<s-title-view class="es-sdk-content-title-css" :text="$options.name" />
<div class="es-sdk-content-divider-css" />
<div class="es-sdk-content-column-css">
<s-text-view :text="'安装状态:' + installStatus" />
<s-text-button text="安装广告插件" @onButtonClicked="onButtonClicked" />
</div>
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import { useESPlugin } from '@extscreen/es3-core'
import type { ESPluginInfo, ESPluginListener } from '@extscreen/es3-core'
export default defineComponent({
name: '插件',
setup() {
const installStatus = ref('')
const plugin = useESPlugin()
const pluginInfo: ESPluginInfo = {
pkg: 'eskit.plugin.ad.huan',
}
const listener: ESPluginListener = {
onPluginInstallSuccess(pkg: string, status: number, msg: string) {
installStatus.value =
`onPluginInstallSuccess ` +
` pkg:${pkg} status:${status} msg:${msg}`
},
onPluginInstallProgress(
pkg: string,
status: number,
current: number,
total: number
) {
installStatus.value =
`onESPluginInstallProgress ` +
` pkg:${pkg} status:${status} current:${current} total:${total}`
},
onPluginInstallError(pkg: string, status: number, msg: string) {
installStatus.value =
`onPluginInstallError ` +
` pkg:${pkg} msg:${msg} status:${status}`
},
}
function onESCreate() {
plugin.addListener(pluginInfo, listener)
}
function onESDestroy() {
plugin.removeListener(listener)
}
function onButtonClicked() {
plugin.installPlugin(pluginInfo)
}
return {
installStatus,
onButtonClicked,
onESCreate,
onESDestroy,
}
},
})
</script>
<style></style>
qt.plugin 用法 alpha
<template>
<div class="es-sdk-root-css">
<s-title-view class="es-sdk-content-title-css" :text="$options.name" />
<div class="es-sdk-content-divider-css" />
<div class="es-sdk-content-column-css">
<s-text-view :text="'安装状态:' + installStatus" />
<s-text-button text="安装广告插件" @onButtonClicked="onButtonClicked" />
</div>
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import type { ESPluginInfo, ESPluginListener } from '@extscreen/es3-core'
export default defineComponent({
name: '插件',
setup() {
const installStatus = ref('')
const pluginInfo: ESPluginInfo = {
pkg: 'eskit.plugin.ad.huan',
}
const listener: ESPluginListener = {
onPluginInstallSuccess(pkg: string, status: number, msg: string) {
installStatus.value =
`onPluginInstallSuccess ` +
` pkg:${pkg} status:${status} msg:${msg}`
},
onPluginInstallProgress(
pkg: string,
status: number,
current: number,
total: number
) {
installStatus.value =
`onESPluginInstallProgress ` +
` pkg:${pkg} status:${status} current:${current} total:${total}`
},
onPluginInstallError(pkg: string, status: number, msg: string) {
installStatus.value =
`onPluginInstallError ` +
` pkg:${pkg} msg:${msg} status:${status}`
},
}
function onESCreate() {
qt.plugin.addListener(pluginInfo, listener)
}
function onESDestroy() {
qt.plugin.removeListener(listener)
}
function onButtonClicked() {
qt.plugin.installPlugin(pluginInfo)
}
return {
installStatus,
onButtonClicked,
onESCreate,
onESDestroy,
}
},
})
</script>
<style></style>
API #
DataStructure #
ESPluginInfo #
Name | Description | Type | Default |
---|---|---|---|
pkg | 插件的包名 | string | - |
Exposes #
Name | Description | Type |
---|---|---|
installPlugin | 该方法安装插件 | Function |
addListener | 该方法添加安装插件监听 | Function |
removeListener | 该方法删除安装插件监听 | Function |