<template>
	<view class="page-container">
		<web-view :src="url" class="webview"></web-view>
	</view>
</template>

<script setup lang="uts">
	import { ref, onMounted } from 'vue'

	const url = ref<string>('')

	onMounted(() => {
		const pages = getCurrentPages()
		const currentPage = pages[pages.length - 1]
		const options = currentPage.options
		let targetUrl: string = ''
		if (options != null) {
			const urlParam = options['url']
			if (urlParam != null) {
				const urlStr: string = urlParam.toString()
				const decodedUrl: string | null = decodeURIComponent(urlStr)
				if (decodedUrl != null) {
					targetUrl = decodedUrl
				}
			}
		}
		url.value = targetUrl
	})
</script>

<style lang="scss">
	.page-container {
		flex: 1;
		width: 100%;
		height: 100%;
	}
	.webview {
		width: 100%;
		height: 100%;
	}
</style>
