<template>
|
<web-view :src="src" @message="viewMessage" :allow="allow"/>
|
</template>
|
|
<script setup>
|
|
const allow = "accelerometer;ambient-light-sensor;autoplay;battery;camera;clipboard-read;clipboard-write;cross-origin-isolated;display-capture;document-domain;encrypted-media;execution-while-not-rendered;execution-while-out-of-viewport;fullscreen;gamepad;geolocation;gyroscope;hid;idle-detection;local-fonts;magnetometer;microphone;midi;payment;picture-in-picture;publickey-credentials-get;screen-wake-lock;serial;speaker-selection;storage-access;sync-xhr;usb;web-share;xr-spatial-tracking"
|
const src = defineModel("src");
|
const emit = defineEmits(["webMessage"]);
|
function viewMessage(event) {
|
messageFun({
|
data: {
|
data: {
|
arg: event.detail.data[0],
|
},
|
type: "WEB_INVOKE_APPSERVICE",
|
},
|
});
|
}
|
|
// WEB_INVOKE_APPSERVICE
|
function messageFun(e) {
|
if (e.data.type === "WEB_INVOKE_APPSERVICE") {
|
if (e.data.data.arg.type === "tokenExpired") {
|
return uni.reLaunch({
|
url: "/pages/login/index",
|
});
|
}
|
emit("webMessage", e.data.data.arg);
|
}
|
}
|
|
onShow(() => {
|
if (window && window.addEventListener)
|
window.addEventListener("message", messageFun);
|
});
|
onHide(() => {
|
if (window && window.removeEventListener)
|
window.removeEventListener("message", messageFun);
|
});
|
</script>
|
|
<style scoped lang="scss"></style>
|