feat(router): 添加分享页面并优化广告页面逻辑
- 在路由中添加 share 页面,用于展示分享内容 - 在 AD 页面中增加 hasShare 状态,用于判断是否处于分享页面 - 根据 hasShare 状态动态调整 AD 页面样式 - 新增 Share 组件,用于渲染分享页面
This commit is contained in:
@@ -164,6 +164,12 @@ const router = createRouter({
|
|||||||
name: 'design',
|
name: 'design',
|
||||||
meta: {},
|
meta: {},
|
||||||
component: Design
|
component: Design
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/share/:code',
|
||||||
|
name: 'share',
|
||||||
|
meta: {},
|
||||||
|
component: () => import('@/views/Share/Index.vue')
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ const router = useRouter();
|
|||||||
const { banners } = fetchBanners();
|
const { banners } = fetchBanners();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const bannerInfo = computed(() => {
|
const bannerInfo = computed(() => {
|
||||||
console.log(banners.value);
|
// console.log(banners.value);
|
||||||
|
|
||||||
return banners.value?.find((item: any) => item.code === route.params.code);
|
return banners.value?.find((item: any) => item.code === route.params.code);
|
||||||
});
|
});
|
||||||
|
// 当前是否处于分享页面
|
||||||
|
const hasShare = defineModel<boolean>('hasShare', { default: false });
|
||||||
function handleButtonClick() {
|
function handleButtonClick() {
|
||||||
if (!bannerInfo.value?.url) {
|
if (!bannerInfo.value?.url) {
|
||||||
router.push({ name: 'intelligentGeneration' });
|
router.push({ name: 'intelligentGeneration' });
|
||||||
@@ -23,7 +23,7 @@ function handleButtonClick() {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<section class="banner-container">
|
<section class="banner-container" :style="{ background: hasShare ? 'white' : undefined }">
|
||||||
<section class="msg-info">
|
<section class="msg-info">
|
||||||
<h3>{{ bannerInfo?.title }}</h3>
|
<h3>{{ bannerInfo?.title }}</h3>
|
||||||
<el-space spacer="|">
|
<el-space spacer="|">
|
||||||
@@ -61,6 +61,7 @@ function handleButtonClick() {
|
|||||||
>
|
>
|
||||||
<!-- 立即进入 -->
|
<!-- 立即进入 -->
|
||||||
<el-button
|
<el-button
|
||||||
|
v-if="hasShare"
|
||||||
style="width: 95%; height: 50px; border-radius: 15px"
|
style="width: 95%; height: 50px; border-radius: 15px"
|
||||||
color="#70b937"
|
color="#70b937"
|
||||||
@click="handleButtonClick"
|
@click="handleButtonClick"
|
||||||
@@ -77,7 +78,6 @@ function handleButtonClick() {
|
|||||||
.banner-container {
|
.banner-container {
|
||||||
padding: $gap * 2;
|
padding: $gap * 2;
|
||||||
margin-bottom: $gap * 6;
|
margin-bottom: $gap * 6;
|
||||||
|
|
||||||
.msg-info {
|
.msg-info {
|
||||||
font-family: PingFangSC-Medium;
|
font-family: PingFangSC-Medium;
|
||||||
h2 {
|
h2 {
|
||||||
|
|||||||
11
src/views/Share/Index.vue
Normal file
11
src/views/Share/Index.vue
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { defineAsyncComponent } from 'vue';
|
||||||
|
|
||||||
|
const shareComponent = defineAsyncComponent(() => import('@/views/AD/Index.vue'));
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<share-component :has-share="true" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped></style>
|
||||||
Reference in New Issue
Block a user