Compare commits
2 Commits
c61d3c68f2
...
dd7802c6f7
| Author | SHA1 | Date | |
|---|---|---|---|
| dd7802c6f7 | |||
| 074531f705 |
@@ -13,7 +13,11 @@ export interface BannerItem {
|
|||||||
translation?: { title?: string; body?: string; imageUrl?: string };
|
translation?: { title?: string; body?: string; imageUrl?: string };
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps<{ banners: BannerItem[] }>();
|
const props = defineProps<{
|
||||||
|
banners: BannerItem[];
|
||||||
|
/** 未配置跳转链接时的默认路由 */
|
||||||
|
fallbackTo?: string;
|
||||||
|
}>();
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const active = ref(0);
|
const active = ref(0);
|
||||||
@@ -51,14 +55,12 @@ function prev() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onBannerClick(banner: BannerItem) {
|
function onBannerClick(banner: BannerItem) {
|
||||||
if (banner.linkType === 'ROUTE' && banner.linkTarget) {
|
if (banner.id) {
|
||||||
router.push(banner.linkTarget);
|
void router.push(`/announcements/${banner.id}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (banner.linkType === 'URL' && banner.linkTarget) {
|
if (props.fallbackTo) {
|
||||||
let url = banner.linkTarget.trim();
|
void router.push(props.fallbackTo);
|
||||||
if (!/^https?:\/\//i.test(url)) url = `https://${url}`;
|
|
||||||
window.open(url, '_blank');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ const FALLBACK_BANNER_URL = '/uploads/banners/welcome.svg';
|
|||||||
|
|
||||||
export const DEFAULT_BANNER: BannerItem = {
|
export const DEFAULT_BANNER: BannerItem = {
|
||||||
id: 'default',
|
id: 'default',
|
||||||
linkType: 'ROUTE',
|
|
||||||
linkTarget: '/bet',
|
|
||||||
translation: {
|
translation: {
|
||||||
title: '',
|
title: '',
|
||||||
imageUrl: defaultBannerImg,
|
imageUrl: defaultBannerImg,
|
||||||
|
|||||||
@@ -107,13 +107,12 @@ onActivated(() => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="inbox-hub" :class="{ 'inbox-hub--tabs': inboxEnabled }">
|
<div class="inbox-hub" :class="{ 'inbox-hub--tabs': inboxEnabled }">
|
||||||
<header v-if="!inboxEnabled" class="page-header">
|
<header class="page-header">
|
||||||
<button type="button" class="back-btn" :aria-label="t('messages.back')" @click="goBack">‹</button>
|
<button type="button" class="back-btn" :aria-label="t('messages.back')" @click="goBack">‹</button>
|
||||||
<h1>{{ t(hubTitleKey) }}</h1>
|
<h1>{{ t(hubTitleKey) }}</h1>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div v-if="inboxEnabled" class="hub-top-bar">
|
<div v-if="inboxEnabled" class="hub-top-bar">
|
||||||
<button type="button" class="hub-back-btn" :aria-label="t('messages.back')" @click="goBack">‹</button>
|
|
||||||
<nav class="hub-tabs" role="tablist">
|
<nav class="hub-tabs" role="tablist">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
@@ -217,26 +216,11 @@ onActivated(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.hub-top-bar {
|
.hub-top-bar {
|
||||||
display: flex;
|
|
||||||
align-items: stretch;
|
|
||||||
gap: 6px;
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
border-bottom: 1px solid var(--border);
|
border-bottom: 1px solid var(--border);
|
||||||
}
|
}
|
||||||
|
|
||||||
.hub-back-btn {
|
|
||||||
flex-shrink: 0;
|
|
||||||
align-self: center;
|
|
||||||
width: 32px;
|
|
||||||
height: 32px;
|
|
||||||
border: 1px solid var(--border);
|
|
||||||
border-radius: 8px;
|
|
||||||
background: var(--bg-card);
|
|
||||||
color: var(--primary);
|
|
||||||
font-size: 20px;
|
|
||||||
line-height: 1;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hub-tabs {
|
.hub-tabs {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user