<script lang="ts" setup>
    const page = reactive({
        title: '',
        link: '',
    })

    onLoad(({ title, link }) => {
        page.title = title ? decodeURI(title) : ''
        page.link = decodeURIComponent(link)

        if (!link) {
            Message.toast('页面打开失败，参数错误')
            uni.navigateBack()
            return
        }

        // 设置标题栏为文件名
        if (page.title && page.title !== 'undefined') {
            uni.setNavigationBarTitle({
                title: page.title,
            })
        }

        // #ifdef APP-PLUS
        const webview = plus.webview.currentWebview()
        webview.setStyle({ scalable: true })
        // #endif
    })
</script>

<template>
    <view class="wrap" v-if="page.link">
        <web-view :src="page.link" :update-title="!page.title" />
    </view>
</template>
