feat: align homepage banner navigation and default banner logic with main

This commit is contained in:
2026-06-18 17:30:57 +08:00
parent 3eace49899
commit 6b8dde5924
2 changed files with 9 additions and 9 deletions

View File

@@ -13,7 +13,11 @@ export interface BannerItem {
translation?: { title?: string; body?: string; imageUrl?: string };
}
const props = defineProps<{ banners: BannerItem[] }>();
const props = defineProps<{
banners: BannerItem[];
/** 未配置跳转链接时的默认路由 */
fallbackTo?: string;
}>();
const router = useRouter();
const active = ref(0);
@@ -51,14 +55,12 @@ function prev() {
}
function onBannerClick(banner: BannerItem) {
if (banner.linkType === 'ROUTE' && banner.linkTarget) {
router.push(banner.linkTarget);
if (banner.id) {
void router.push(`/announcements/${banner.id}`);
return;
}
if (banner.linkType === 'URL' && banner.linkTarget) {
let url = banner.linkTarget.trim();
if (!/^https?:\/\//i.test(url)) url = `https://${url}`;
window.open(url, '_blank');
if (props.fallbackTo) {
void router.push(props.fallbackTo);
}
}

View File

@@ -7,8 +7,6 @@ const FALLBACK_BANNER_URL = '/uploads/banners/welcome.svg';
export const DEFAULT_BANNER: BannerItem = {
id: 'default',
linkType: 'ROUTE',
linkTarget: '/bet',
translation: {
title: '',
imageUrl: defaultBannerImg,