<template>
|
<div class="home">
|
<img alt="Vue logo" src="../assets/logo.png">
|
<HelloWorld msg="Welcome to Your Vue.js App"/>
|
<div id = "mt"></div>
|
</div>
|
</template>
|
|
<script>
|
// @ is an alias to /src
|
import HelloWorld from '@/components/HelloWorld.vue'
|
import { Launcher } from 'live-cat'
|
|
export default {
|
name: 'Home',
|
components: {
|
HelloWorld
|
},
|
mounted()
|
{
|
},
|
async created()
|
{
|
|
this.get3d()
|
|
alert(123)
|
|
},
|
methods:
|
{
|
async get3d()
|
{
|
let virtualEl = null
|
let answerList = []
|
//useEffect(()=>{
|
//bootstrap()
|
//},[])
|
const appKey = "cGSdMdd6iarelspq";
|
const address = "https://app.3dcat.live";
|
const bootstrap = async () => {
|
try {
|
const launch = new Launcher({
|
baseOptions: {
|
address,
|
appKey,
|
startType: 1, // 1:普通链接 | 3:投屏链接
|
optionalParam: 'resolution=${375}x${656} platform=mobile'
|
},
|
|
});
|
//alert(12)
|
alert(launch.taskId)
|
const player = document.querySelector('#mt');
|
//const player = document.querySelector("body");
|
document.querySelector("body").style.width = "100vw";
|
document.querySelector("body").style.height = "100vh";
|
await launch.automata(player);
|
} catch (error) {
|
//alert(233)
|
//alert(error)
|
console.error(error);
|
}
|
}
|
window.addEventListener("DOMContentLoaded", () => {
|
if (
|
navigator.userAgent.includes("miniProgram") ||
|
navigator.userAgent.includes("MicroMessenger")
|
) {
|
//微信浏览器/微信小程序环境
|
document.addEventListener("WeixinJSBridgeReady", bootstrap, false);
|
} else {
|
bootstrap();
|
}
|
});
|
},
|
}
|
}
|
</script>
|
<style>
|
#mt
|
{
|
border:1px solid red;
|
width:375px;
|
height:656px;
|
position:relative;
|
}
|
</style>
|