初始化导入 hjsq H5 项目代码
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<template>
|
||||
<div class="activityWeb">
|
||||
<div class="main">
|
||||
<iframe v-if="activityUrl" class="iframe" :src="activityUrl" frameborder="0"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, onMounted } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { showToast } from 'vant';
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
/**
|
||||
* 活动链接:仅接受 http(s) 外链;非法链接直接返回上一页,避免空白 iframe
|
||||
*/
|
||||
const activityUrl = computed(() => {
|
||||
console.log(route.query);
|
||||
const raw = route.query.url;
|
||||
const url = typeof raw === 'string' ? raw : Array.isArray(raw) ? raw[0] : '';
|
||||
if (!url || !/^https?:\/\//i.test(url?.trim())) {
|
||||
return '';
|
||||
}
|
||||
return url?.trim();
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
if (!activityUrl.value) {
|
||||
showToast('活动链接无效');
|
||||
router.back();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.activityWeb {
|
||||
height: 100%;
|
||||
|
||||
.main {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
.iframe {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user