Browse Source

add news

master
sunfree 9 months ago
parent
commit
6aa00c365b
  1. 79
      src/components/blogs/HomePage.vue

79
src/components/blogs/HomePage.vue

@ -3,7 +3,7 @@
<!-- 头部导航菜单 --> <!-- 头部导航菜单 -->
<div class="headerMenu" v-if="show_menu"> <div class="headerMenu" v-if="show_menu">
<a-menu v-model:selectedKeys="current" mode="horizontal" :items="items" style="border-bottom: none;" <a-menu v-model:selectedKeys="current" mode="horizontal" :items="items" style="border-bottom: none;"
@click="menuClick" @select="menuSelect"/>
@click="menuClick" @select="menuSelect" />
<a-input-search v-model:value="value" placeholder="search" style="width: 200px" @search="onSearch" /> <a-input-search v-model:value="value" placeholder="search" style="width: 200px" @search="onSearch" />
</div> </div>
<div class="author" v-if="show_author"></div> <div class="author" v-if="show_author"></div>
@ -121,12 +121,12 @@
</Simplebar> </Simplebar>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { h, reactive, ref,nextTick } from 'vue';
import { h, reactive, ref, nextTick } from 'vue';
import { MenuProps } from 'ant-design-vue/es/menu'; import { MenuProps } from 'ant-design-vue/es/menu';
import { HomeOutlined, HighlightOutlined, ProfileOutlined, CameraOutlined, UsergroupDeleteOutlined, DownCircleOutlined } from '@ant-design/icons-vue'; import { HomeOutlined, HighlightOutlined, ProfileOutlined, CameraOutlined, UsergroupDeleteOutlined, DownCircleOutlined } from '@ant-design/icons-vue';
import { MusicLined, EmailLined, QQLined, WechatLined, GravatarLined, GitHubLined } from "@/assets" import { MusicLined, EmailLined, QQLined, WechatLined, GravatarLined, GitHubLined } from "@/assets"
import Typed from 'typed.js'; import Typed from 'typed.js';
import { onMounted,watch } from 'vue';
import { onMounted, watch } from 'vue';
import type { CSSProperties } from 'vue'; import type { CSSProperties } from 'vue';
import { CaretRightOutlined } from '@ant-design/icons-vue'; import { CaretRightOutlined } from '@ant-design/icons-vue';
import 'APlayer/dist/APlayer.min.css'; import 'APlayer/dist/APlayer.min.css';
@ -143,7 +143,7 @@ const activeKey = ref(['']);
const text = `A dog is a type of domesticated animal.Known for its loyalty and faithfulness,it can be found as a welcome guest in many households across the world.`; const text = `A dog is a type of domesticated animal.Known for its loyalty and faithfulness,it can be found as a welcome guest in many households across the world.`;
const customStyle = const customStyle =
'background: #F5F5F5;border-radius: 4px;margin-bottom: 12px;border: 0;overflow: hidden'; 'background: #F5F5F5;border-radius: 4px;margin-bottom: 12px;border: 0;overflow: hidden';
const scrollbar=ref<Element | null>(null);
const scrollbar = ref<Element | null>(null);
onMounted(() => { onMounted(() => {
// home // home
new Typed('.author', { new Typed('.author', {
@ -316,8 +316,8 @@ onMounted(() => {
const show_menu = ref(false); const show_menu = ref(false);
const show_carousel = ref(true); const show_carousel = ref(true);
const show_author = ref(true) const show_author = ref(true)
const mainCss=reactive({
marginTop:"0px"
const mainCss = reactive({
marginTop: "0px"
}) })
const items = ref<MenuProps['items']>([ const items = ref<MenuProps['items']>([
@ -385,23 +385,21 @@ const handleScroll = () => {
}; };
const menuClick = ({ item }: { item: any }) => { const menuClick = ({ item }: { item: any }) => {
handleScrollEnabled.value=false
if (scrollbar.value) {
}
if (item.url=="/" || item.url=="/home") {
handleScrollEnabled.value=true
show_carousel.value=true
}else{
show_menu.value=true
show_carousel.value=false
scrollbar.value!.scrollTop=0
mainCss.marginTop="48px"
// localStorage.setItem('show_menu', 'true');
// localStorage.setItem('show_carousel', 'false');
// localStorage.setItem('scrollPosition', '0');
// localStorage.setItem('mainCss_marginTop', '48px');
}
router.push(item.url)
// handleScrollEnabled.value = false;
// if (scrollbar.value) {
// scrollbar.value.scrollTop = 0;
// }
// if (item.url === '/' || item.url === '/home') {
// handleScrollEnabled.value = true;
// show_carousel.value = true;
// } else {
// show_menu.value = true;
// show_carousel.value = false;
// mainCss.marginTop = '48px';
// }
router.push(item.url);
} }
const current = ref<string[]>(['mail']); const current = ref<string[]>(['mail']);
@ -411,13 +409,14 @@ const downScroll = () => {
if (scrollbar.value) { if (scrollbar.value) {
const scrollTop = scrollbar.value.scrollTop; const scrollTop = scrollbar.value.scrollTop;
const viewportHeight = scrollbar.value.clientHeight; const viewportHeight = scrollbar.value.clientHeight;
const scrollDistance = viewportHeight - scrollTop -48;
const scrollDistance = viewportHeight - scrollTop - 48;
setTimeout(() => { setTimeout(() => {
scrollbar.value!.scrollBy({ top: scrollDistance, behavior: 'smooth' }); scrollbar.value!.scrollBy({ top: scrollDistance, behavior: 'smooth' });
}, 300); }, 300);
} }
}; };
// //
// const articles=reactive({ // const articles=reactive({
// img:"", // img:"",
@ -437,6 +436,35 @@ const img = ref("https://os.alipayobjects.com/rmsportal/QBnOOoLaAfKPirc.png")
const gravatarClick = () => { const gravatarClick = () => {
window.open("https://www.baidu.com") window.open("https://www.baidu.com")
} }
const updateCarouselVisibility = (routeName) => {
handleScrollEnabled.value = false;
if (scrollbar.value) {
scrollbar.value.scrollTop = 0;
}
if (routeName === 'home') {
handleScrollEnabled.value = true;
show_carousel.value = true;
} else {
show_menu.value = true;
show_carousel.value = false;
mainCss.marginTop = '48px';
}
};
//
watch(
() => route.name,
(newRouteName) => {
updateCarouselVisibility(newRouteName);
},
{ immediate: true }
);
router.beforeEach((to, from, next) => {
updateCarouselVisibility(to.name);
next();
});
</script> </script>
<style scoped> <style scoped>
.headerMenu { .headerMenu {
@ -488,10 +516,11 @@ const gravatarClick = () => {
} }
} }
.carousel img{
.carousel img {
height: 100vh; height: 100vh;
width: 100vw; width: 100vw;
} }
.anchorDown { .anchorDown {
position: absolute; position: absolute;
bottom: 100px; bottom: 100px;

Loading…
Cancel
Save