primevue-mirror/pages/index.vue

118 lines
4.3 KiB
Vue
Raw Normal View History

2022-02-23 11:42:11 +00:00
<template>
2022-12-20 17:28:51 +00:00
<div :class="landingClass">
2023-10-17 11:34:50 +00:00
<AppNews />
2023-10-14 19:53:46 +00:00
<AppTopBar :showConfigurator="false" :showMenuButton="false" @darkswitch-click="onDarkModeToggle" />
2023-10-10 08:38:49 +00:00
<HeroSection />
<FeaturesSection />
2023-03-24 12:54:11 +00:00
<UsersSection />
2022-12-20 17:28:51 +00:00
<ThemeSection :theme="tableTheme" @table-theme-change="onTableThemeChange" />
<BlockSection />
<TemplateSection />
<FooterSection />
</div>
2022-02-23 11:42:11 +00:00
</template>
2022-09-06 13:53:29 +00:00
<script>
import BlockSection from '@/components/landing/BlockSection.vue';
import FeaturesSection from '@/components/landing/FeaturesSection.vue';
import FooterSection from '@/components/landing/FooterSection.vue';
import HeroSection from '@/components/landing/HeroSection.vue';
import TemplateSection from '@/components/landing/TemplateSection.vue';
import ThemeSection from '@/components/landing/ThemeSection.vue';
import UsersSection from '@/components/landing/UsersSection.vue';
import EventBus from '@/layouts/AppEventBus';
2023-10-10 08:38:49 +00:00
import AppNews from '@/layouts/AppNews';
import AppTopBar from '@/layouts/AppTopBar.vue';
2023-05-25 13:28:03 +00:00
2022-02-23 11:42:11 +00:00
export default {
2023-10-24 13:01:43 +00:00
setup() {
definePageMeta({
layout: 'custom'
});
},
2022-09-14 14:26:41 +00:00
props: {
theme: {
type: String,
default: null
}
},
data() {
return {
2024-01-18 03:51:37 +00:00
tableTheme: 'aura-light-green'
2022-09-14 14:26:41 +00:00
};
},
themeChangeListener: null,
mounted() {
let afId = this.$route.query['af_id'];
2022-12-09 20:47:50 +00:00
2022-09-14 14:26:41 +00:00
if (afId) {
let today = new Date();
let expire = new Date();
2022-12-09 20:47:50 +00:00
2022-09-14 14:26:41 +00:00
expire.setTime(today.getTime() + 3600000 * 24 * 7);
document.cookie = 'primeaffiliateid=' + afId + ';expires=' + expire.toUTCString() + ';path=/; domain:primefaces.org';
}
2022-02-23 21:19:22 +00:00
2023-12-30 22:26:14 +00:00
const preferredColorScheme = localStorage.getItem(this.$appState.colorSchemeKey);
const prefersDarkColorScheme = window.matchMedia('(prefers-color-scheme: dark)').matches;
if ((preferredColorScheme === null && prefersDarkColorScheme) || preferredColorScheme === 'dark') {
2024-01-18 03:51:37 +00:00
this.replaceTableTheme('aura-dark-green');
2023-12-30 22:26:14 +00:00
} else {
2024-01-18 03:51:37 +00:00
this.replaceTableTheme('aura-light-green');
2023-12-30 22:26:14 +00:00
}
2022-09-14 14:26:41 +00:00
},
methods: {
2023-10-14 19:53:46 +00:00
onDarkModeToggle() {
2024-01-18 03:51:37 +00:00
const newTheme = this.$appState.darkTheme ? 'aura-light-green' : 'aura-dark-green';
const newTableTheme = this.$appState.darkTheme ? this.tableTheme.replace('dark', 'light') : this.tableTheme.replace('light', 'dark');
2023-12-30 22:26:14 +00:00
localStorage.setItem(this.$appState.colorSchemeKey, this.$appState.darkTheme ? 'light' : 'dark');
EventBus.emit('theme-change', { theme: newTheme, dark: !this.$appState.darkTheme });
this.replaceTableTheme(newTableTheme);
},
2022-09-14 14:26:41 +00:00
onTableThemeChange(value) {
this.replaceTableTheme(value);
},
replaceTableTheme(newTheme) {
const elementId = 'home-table-link';
const linkElement = document.getElementById(elementId);
const tableThemeTokens = linkElement?.getAttribute('href').split('/') || null;
const currentTableTheme = tableThemeTokens ? tableThemeTokens[tableThemeTokens.length - 2] : null;
2022-02-23 11:42:11 +00:00
2022-09-14 14:26:41 +00:00
if (currentTableTheme !== newTheme && tableThemeTokens) {
const newThemeUrl = linkElement.getAttribute('href').replace(currentTableTheme, newTheme);
2022-02-23 19:52:21 +00:00
2022-09-14 14:26:41 +00:00
const cloneLinkElement = linkElement.cloneNode(true);
2022-12-09 20:47:50 +00:00
2022-09-14 14:26:41 +00:00
cloneLinkElement.setAttribute('id', elementId + '-clone');
cloneLinkElement.setAttribute('href', newThemeUrl);
cloneLinkElement.addEventListener('load', () => {
linkElement.remove();
cloneLinkElement.setAttribute('id', elementId);
});
linkElement.parentNode?.insertBefore(cloneLinkElement, linkElement.nextSibling);
this.tableTheme = newTheme;
}
}
},
computed: {
landingClass() {
2023-10-10 16:58:35 +00:00
return ['landing', { 'layout-dark': this.$appState?.darkTheme, 'layout-light': !this.$appState?.darkTheme, 'layout-news-active': this.$appState?.newsActive }];
2022-09-14 14:26:41 +00:00
}
},
components: {
2023-10-10 08:38:49 +00:00
AppNews,
AppTopBar,
HeroSection,
2022-09-14 14:26:41 +00:00
ThemeSection,
BlockSection,
TemplateSection,
UsersSection,
FeaturesSection,
2022-12-27 08:12:25 +00:00
FooterSection
2022-09-14 14:26:41 +00:00
}
};
</script>