primevue-mirror/pages/index.vue

112 lines
3.8 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-10 08:38:49 +00:00
<AppNews v-if="$appState.newsActive" />
2023-10-10 09:26:51 +00:00
<AppTopBar :showConfigurator="false" showDarkSwitch @darkswitch-click="onThemeToggle"/>
2023-10-10 08:38:49 +00:00
<HeroSection />
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 />
<DesignerSection />
<TemplateSection />
<FeaturesSection />
<FooterSection />
</div>
2022-02-23 11:42:11 +00:00
</template>
2022-09-06 13:53:29 +00:00
<script>
2023-10-10 05:41:15 +00:00
definePageMeta({
2023-10-10 08:38:49 +00:00
layout: "custom",
2023-10-10 05:41:15 +00:00
});
import EventBus from '@/layouts/AppEventBus';
2023-10-10 08:38:49 +00:00
import AppNews from '@/layouts/AppNews';
import HeroSection from './landing/HeroSection';
import AppTopBar from '@/layouts/AppTopBar.vue';
2022-09-06 13:53:29 +00:00
import BlockSection from './landing/BlockSection';
import DesignerSection from './landing/DesignerSection';
import FeaturesSection from './landing/FeaturesSection';
import FooterSection from './landing/FooterSection';
2022-12-08 12:26:57 +00:00
import TemplateSection from './landing/TemplateSection';
import ThemeSection from './landing/ThemeSection';
import UsersSection from './landing/UsersSection';
2023-05-25 13:28:03 +00:00
2022-02-23 11:42:11 +00:00
export default {
2022-09-14 14:26:41 +00:00
props: {
theme: {
type: String,
default: null
}
},
data() {
return {
tableTheme: 'lara-light-blue'
};
},
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
2022-09-14 14:26:41 +00:00
this.replaceTableTheme(this.$appState.darkTheme ? 'lara-dark-blue' : 'lara-light-blue');
},
methods: {
onThemeToggle() {
2023-10-10 09:26:51 +00:00
const newTheme = this.$appState.darkTheme ? 'lara-light-teal' : 'lara-dark-teal';
const newTableTheme = this.$appState.darkTheme ? this.tableTheme.replace('dark', 'light') : this.tableTheme.replace('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 08:38:49 +00:00
return ['landing', { 'layout-dark': this.$appState?.darkTheme, 'layout-light': !this.$appState?.darkTheme, 'landing-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,
DesignerSection,
TemplateSection,
UsersSection,
FeaturesSection,
2022-12-27 08:12:25 +00:00
FooterSection
2022-09-14 14:26:41 +00:00
}
};
</script>