- Changed beta notice to service notice on home page translations for English, Spanish, and French. - Updated privacy information to reflect transparency and continuous maintenance. - Added new public guides content with detailed sections for various topics. - Implemented routing for guide list and individual guide articles. - Created new components for displaying guides and articles.
540 lines
13 KiB
Vue
540 lines
13 KiB
Vue
<template>
|
|
<header class="app-header">
|
|
<div class="app-header__inner">
|
|
<div class="brand">
|
|
<div class="logo"><img src="/images/logos/logo.png" alt="YourPart" /></div>
|
|
<div class="brand-copy">
|
|
<strong>YourPart</strong>
|
|
<span>{{ $t('appShell.header.tagline') }}</span>
|
|
</div>
|
|
</div>
|
|
<div class="header-ad" v-if="showHeaderAd">
|
|
<ins
|
|
v-if="isMobileAd"
|
|
key="header-ad-mobile"
|
|
class="adsbygoogle"
|
|
style="display:inline-block;width:320px;height:50px"
|
|
data-ad-client="ca-pub-1104166651501135"
|
|
:data-ad-slot="activeAdSlotId"
|
|
></ins>
|
|
<ins
|
|
v-else
|
|
key="header-ad-desktop"
|
|
class="adsbygoogle"
|
|
style="display:inline-block;width:728px;height:90px"
|
|
data-ad-client="ca-pub-1104166651501135"
|
|
:data-ad-slot="activeAdSlotId"
|
|
></ins>
|
|
</div>
|
|
<div class="header-meta">
|
|
<div class="header-meta__context">
|
|
<label class="header-lang">
|
|
<span class="header-lang__label">{{ $t('appShell.header.language') }}</span>
|
|
<select
|
|
class="header-lang__select"
|
|
:aria-label="$t('appShell.header.language')"
|
|
:value="language"
|
|
@change="onUiLanguageChange($event.target.value)"
|
|
>
|
|
<option v-for="opt in uiLocaleOptions" :key="opt.value" :value="opt.value">
|
|
{{ opt.nativeLabel }}
|
|
</option>
|
|
</select>
|
|
</label>
|
|
</div>
|
|
<div class="connection-status" v-if="isLoggedIn">
|
|
<div class="status-indicator" :class="backendStatusClass">
|
|
<span class="status-dot"></span>
|
|
<span class="status-text">{{ $t('appShell.header.backend') }}</span>
|
|
</div>
|
|
<div class="status-indicator" :class="daemonStatusClass">
|
|
<span class="status-dot"></span>
|
|
<span class="status-text">{{ $t('appShell.header.daemon') }}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
</template>
|
|
|
|
<script>
|
|
import { mapGetters } from 'vuex';
|
|
import apiClient from '@/utils/axios.js';
|
|
import { SUPPORTED_UI_LOCALES } from '@/i18n/supportedLocales.js';
|
|
|
|
const ADSENSE_SCRIPT_ID = 'google-adsense-script';
|
|
const ADSENSE_CLIENT_ID = 'ca-pub-1104166651501135';
|
|
|
|
export default {
|
|
name: 'AppHeader',
|
|
data() {
|
|
return {
|
|
adInitialized: false,
|
|
viewportWidth: typeof window !== 'undefined' ? window.innerWidth : 1280,
|
|
/** Endonyme: jede Sprache bezeichnet sich in ihrer eigenen Sprache. */
|
|
uiLocaleOptions: [
|
|
{ value: 'de', nativeLabel: 'Deutsch' },
|
|
{ value: 'en', nativeLabel: 'English' },
|
|
{ value: 'ceb', nativeLabel: 'Binisaya' },
|
|
{ value: 'es', nativeLabel: 'Español' },
|
|
{ value: 'fr', nativeLabel: 'Français' },
|
|
],
|
|
};
|
|
},
|
|
computed: {
|
|
...mapGetters(['isLoggedIn', 'user', 'language', 'connectionStatus', 'daemonConnectionStatus']),
|
|
backendStatusClass() {
|
|
return {
|
|
'status-connected': this.connectionStatus === 'connected',
|
|
'status-connecting': this.connectionStatus === 'connecting',
|
|
'status-disconnected': this.connectionStatus === 'disconnected',
|
|
'status-error': this.connectionStatus === 'error'
|
|
};
|
|
},
|
|
daemonStatusClass() {
|
|
return {
|
|
'status-connected': this.daemonConnectionStatus === 'connected',
|
|
'status-connecting': this.daemonConnectionStatus === 'connecting',
|
|
'status-disconnected': this.daemonConnectionStatus === 'disconnected',
|
|
'status-error': this.daemonConnectionStatus === 'error'
|
|
};
|
|
},
|
|
showHeaderAd() {
|
|
if (!this.activeAdSlotId) {
|
|
return false;
|
|
}
|
|
const path = this.$route?.path || '';
|
|
// Anzeigen bevorzugt auf Bereichen mit dauerhaftem, inhaltlich starkem Content.
|
|
return (
|
|
path === '/' ||
|
|
path.startsWith('/blogs') ||
|
|
path.startsWith('/ratgeber') ||
|
|
path.startsWith('/vokabeltrainer') ||
|
|
path.startsWith('/bisaya-lernen') ||
|
|
path.startsWith('/deutsch-fuer-bisaya') ||
|
|
path === '/falukant' ||
|
|
path === '/minigames'
|
|
);
|
|
},
|
|
desktopAdSlotId() {
|
|
const slot = String(
|
|
import.meta.env.VITE_ADSENSE_HEADER_SLOT_DESKTOP
|
|
|| import.meta.env.VITE_ADSENSE_HEADER_SLOT
|
|
|| ''
|
|
).trim();
|
|
return /^\d{6,}$/.test(slot) ? slot : '';
|
|
},
|
|
mobileAdSlotId() {
|
|
const slot = String(
|
|
import.meta.env.VITE_ADSENSE_HEADER_SLOT_MOBILE
|
|
|| import.meta.env.VITE_ADSENSE_HEADER_SLOT
|
|
|| ''
|
|
).trim();
|
|
return /^\d{6,}$/.test(slot) ? slot : '';
|
|
},
|
|
isMobileAd() {
|
|
return this.viewportWidth < 960;
|
|
},
|
|
activeAdSlotId() {
|
|
return this.isMobileAd ? this.mobileAdSlotId : this.desktopAdSlotId;
|
|
}
|
|
},
|
|
watch: {
|
|
showHeaderAd: {
|
|
immediate: true,
|
|
handler(next) {
|
|
if (next) {
|
|
this.$nextTick(() => this.initHeaderAd());
|
|
}
|
|
}
|
|
},
|
|
isMobileAd(next, prev) {
|
|
if (next !== prev) {
|
|
this.adInitialized = false;
|
|
if (this.showHeaderAd) {
|
|
this.$nextTick(() => this.initHeaderAd());
|
|
}
|
|
}
|
|
}
|
|
},
|
|
mounted() {
|
|
if (typeof window !== 'undefined') {
|
|
window.addEventListener('resize', this.handleResize, { passive: true });
|
|
}
|
|
},
|
|
beforeUnmount() {
|
|
if (typeof window !== 'undefined') {
|
|
window.removeEventListener('resize', this.handleResize);
|
|
}
|
|
},
|
|
methods: {
|
|
handleResize() {
|
|
this.viewportWidth = window.innerWidth;
|
|
},
|
|
initHeaderAd() {
|
|
if (!this.showHeaderAd) return;
|
|
if (this.adInitialized) return;
|
|
if (typeof window === 'undefined') return;
|
|
this.ensureAdSenseScript()
|
|
.then(() => {
|
|
try {
|
|
(window.adsbygoogle = window.adsbygoogle || []).push({});
|
|
this.adInitialized = true;
|
|
} catch (err) {
|
|
console.warn('AppHeader: adsense slot init failed', err);
|
|
}
|
|
})
|
|
.catch((err) => {
|
|
console.warn('AppHeader: adsense script could not be loaded', err);
|
|
});
|
|
},
|
|
ensureAdSenseScript() {
|
|
if (typeof window === 'undefined') {
|
|
return Promise.resolve();
|
|
}
|
|
if (window.adsbygoogle) {
|
|
return Promise.resolve();
|
|
}
|
|
const existing = document.getElementById(ADSENSE_SCRIPT_ID);
|
|
if (existing) {
|
|
return new Promise((resolve, reject) => {
|
|
existing.addEventListener('load', resolve, { once: true });
|
|
existing.addEventListener('error', reject, { once: true });
|
|
});
|
|
}
|
|
return new Promise((resolve, reject) => {
|
|
const script = document.createElement('script');
|
|
script.id = ADSENSE_SCRIPT_ID;
|
|
script.async = true;
|
|
script.crossOrigin = 'anonymous';
|
|
script.src = `https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${ADSENSE_CLIENT_ID}`;
|
|
script.addEventListener('load', resolve, { once: true });
|
|
script.addEventListener('error', reject, { once: true });
|
|
document.head.appendChild(script);
|
|
});
|
|
},
|
|
async onUiLanguageChange(code) {
|
|
if (!SUPPORTED_UI_LOCALES.includes(code)) {
|
|
return;
|
|
}
|
|
await this.$store.dispatch('setLanguage', code);
|
|
this.applyI18nLocale(code);
|
|
if (!this.isLoggedIn || !this.user?.id) {
|
|
return;
|
|
}
|
|
try {
|
|
const { data } = await apiClient.post('/api/settings/filter', {
|
|
userid: this.user.id,
|
|
type: 'personal',
|
|
});
|
|
const langRow = data.find((s) => s.name === 'language');
|
|
if (!langRow?.options?.length) {
|
|
return;
|
|
}
|
|
const opt = langRow.options.find((o) => o.value === code);
|
|
if (!opt) {
|
|
return;
|
|
}
|
|
await apiClient.post('/api/settings/update', {
|
|
userid: this.user.id,
|
|
settingId: langRow.id,
|
|
value: opt.id,
|
|
});
|
|
} catch (err) {
|
|
console.warn('AppHeader: profile language could not be synced', err);
|
|
}
|
|
},
|
|
/** UI sofort auf neue Sprache umstellen, ohne Seiten-Reload (nur reaktives i18n). */
|
|
applyI18nLocale(code) {
|
|
const g = this.$i18n;
|
|
if (!g) {
|
|
return;
|
|
}
|
|
const loc = g.locale;
|
|
if (loc && typeof loc === 'object' && 'value' in loc) {
|
|
loc.value = code;
|
|
} else {
|
|
g.locale = code;
|
|
}
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style scoped>
|
|
.app-header {
|
|
position: relative;
|
|
flex: 0 0 auto;
|
|
padding: 6px 14px;
|
|
background:
|
|
linear-gradient(180deg, rgba(255, 249, 240, 0.96) 0%, rgba(246, 236, 220, 0.98) 100%);
|
|
color: #2b1f14;
|
|
border-bottom: 1px solid rgba(93, 64, 55, 0.12);
|
|
box-shadow: 0 5px 14px rgba(93, 64, 55, 0.06);
|
|
}
|
|
|
|
.app-header__inner {
|
|
max-width: var(--shell-max-width);
|
|
margin: 0 auto;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: flex-start;
|
|
gap: 16px;
|
|
}
|
|
|
|
.brand {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
min-width: 0;
|
|
}
|
|
|
|
.logo {
|
|
width: 40px;
|
|
height: 40px;
|
|
padding: 5px;
|
|
border-radius: 12px;
|
|
background:
|
|
linear-gradient(180deg, rgba(248, 162, 43, 0.18) 0%, rgba(255, 255, 255, 0.76) 100%);
|
|
border: 1px solid rgba(248, 162, 43, 0.22);
|
|
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
|
|
}
|
|
|
|
.logo > img {
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: contain;
|
|
}
|
|
|
|
.brand-copy {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0;
|
|
min-width: 0;
|
|
}
|
|
|
|
.brand-copy strong {
|
|
font-size: 1rem;
|
|
line-height: 1.1;
|
|
color: #3a2a1b;
|
|
}
|
|
|
|
.brand-copy span {
|
|
font-size: 0.74rem;
|
|
color: rgba(95, 75, 57, 0.78);
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
|
|
.header-meta {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
margin-left: auto;
|
|
}
|
|
|
|
.header-ad {
|
|
flex: 1 1 728px;
|
|
min-width: 320px;
|
|
max-width: 728px;
|
|
min-height: 90px;
|
|
max-height: 90px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.header-ad .adsbygoogle {
|
|
width: 100%;
|
|
max-width: 100%;
|
|
overflow: hidden !important;
|
|
}
|
|
|
|
.header-ad :deep(iframe),
|
|
.header-ad :deep([id^="aswift_"]) {
|
|
max-width: 100% !important;
|
|
}
|
|
|
|
.header-meta__context {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
}
|
|
|
|
.header-lang {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
margin: 0;
|
|
font-size: 0.72rem;
|
|
color: rgba(95, 75, 57, 0.85);
|
|
}
|
|
|
|
.header-lang__label {
|
|
font-weight: 600;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.header-lang__select {
|
|
min-width: 7.5rem;
|
|
max-width: 11rem;
|
|
padding: 4px 8px;
|
|
border-radius: 8px;
|
|
border: 1px solid rgba(93, 64, 55, 0.18);
|
|
background: rgba(255, 255, 255, 0.85);
|
|
color: #3a2a1b;
|
|
font-size: 0.72rem;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.header-lang__select:focus {
|
|
outline: 2px solid rgba(248, 162, 43, 0.45);
|
|
outline-offset: 1px;
|
|
}
|
|
|
|
.connection-status {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
|
|
.status-indicator {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
min-height: 28px;
|
|
padding: 0 10px;
|
|
border-radius: 999px;
|
|
font-size: 0.72rem;
|
|
font-weight: 700;
|
|
border: 1px solid rgba(93, 64, 55, 0.1);
|
|
background: rgba(255, 255, 255, 0.62);
|
|
}
|
|
|
|
.status-dot {
|
|
width: 8px;
|
|
height: 8px;
|
|
border-radius: 50%;
|
|
animation: pulse 2s infinite;
|
|
}
|
|
|
|
.status-connected .status-dot {
|
|
background-color: #4caf50;
|
|
}
|
|
|
|
.status-connecting .status-dot {
|
|
background-color: #ff9800;
|
|
}
|
|
|
|
.status-disconnected .status-dot {
|
|
background-color: #f44336;
|
|
}
|
|
|
|
.status-error .status-dot {
|
|
background-color: #f44336;
|
|
}
|
|
|
|
.status-connected {
|
|
background-color: rgba(76, 175, 80, 0.12);
|
|
color: #245b2c;
|
|
}
|
|
|
|
.status-connecting {
|
|
background-color: rgba(255, 152, 0, 0.12);
|
|
color: #8b5e0d;
|
|
}
|
|
|
|
.status-disconnected {
|
|
background-color: rgba(244, 67, 54, 0.12);
|
|
color: #8f2c27;
|
|
}
|
|
|
|
.status-error {
|
|
background-color: rgba(244, 67, 54, 0.12);
|
|
color: #8f2c27;
|
|
}
|
|
|
|
@keyframes pulse {
|
|
0% { opacity: 1; }
|
|
50% { opacity: 0.5; }
|
|
100% { opacity: 1; }
|
|
}
|
|
|
|
@media (max-width: 960px) {
|
|
.app-header {
|
|
padding: 6px 10px;
|
|
}
|
|
|
|
.app-header__inner {
|
|
gap: 10px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.header-ad {
|
|
order: 3;
|
|
width: 100%;
|
|
max-width: 320px;
|
|
flex: 1 1 100%;
|
|
min-height: 50px;
|
|
max-height: 50px;
|
|
}
|
|
|
|
.header-ad .adsbygoogle {
|
|
width: 320px !important;
|
|
min-width: 320px !important;
|
|
max-width: 320px !important;
|
|
height: 50px !important;
|
|
min-height: 50px !important;
|
|
max-height: 50px !important;
|
|
}
|
|
|
|
.header-ad :deep(iframe),
|
|
.header-ad :deep([id^="aswift_"]) {
|
|
width: 320px !important;
|
|
height: 50px !important;
|
|
max-height: 50px !important;
|
|
}
|
|
|
|
.header-meta {
|
|
width: 100%;
|
|
justify-content: space-between;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.header-meta__context {
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.brand-copy span {
|
|
font-size: 0.76rem;
|
|
white-space: normal;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 640px) {
|
|
.app-header__inner {
|
|
align-items: flex-start;
|
|
}
|
|
|
|
.brand {
|
|
width: 100%;
|
|
}
|
|
|
|
.header-meta {
|
|
gap: 8px;
|
|
}
|
|
|
|
.connection-status {
|
|
width: 100%;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.status-indicator {
|
|
min-height: 32px;
|
|
}
|
|
}
|
|
</style>
|