Browse Source

add new

master
sunfree 8 months ago
parent
commit
c9971963cf
  1. 69
      src/components/blogs/HomePage.vue
  2. 53
      src/components/blogs/header/NavigateMenu.vue
  3. 5
      src/router/blog.ts

69
src/components/blogs/HomePage.vue

@ -2,7 +2,7 @@
<Simplebar @scroll="handleScroll">
<div class="header">
<!-- 头部导航菜单 -->
<NavigateMenu />
<NavigateMenu :updateCarouselVisibility="updateCarouselVisibility"/>
<!-- 作者名字 -->
<div class="author" v-if="show_author">{{ author }}</div>
<!-- 轮播 -->
@ -17,7 +17,6 @@
</div>
</div>
<!-- 主要内容区域 -->
<div class="mainContainer" :style="mainCss">
<div class="leftBar">
@ -119,7 +118,7 @@
</Simplebar>
</template>
<script lang="ts" setup>
import { reactive, ref, nextTick, toRefs } from 'vue';
import { reactive, ref, nextTick, toRefs,h } from 'vue';
import { DownCircleOutlined } from '@ant-design/icons-vue';
import Typed from 'typed.js';
import { onMounted, watch } from 'vue';
@ -137,8 +136,12 @@ import StatisticCount from "./StatisticCount.vue"
import NavigateMenu from './header/NavigateMenu.vue';
import { homePageStore } from '@/stores';
import CarouselImg from './header/CarouselImg.vue';
import { HomeOutlined, HighlightOutlined, ProfileOutlined, CameraOutlined, UsergroupDeleteOutlined } from '@ant-design/icons-vue';
import type { MenuProps } from 'ant-design-vue';
const author = ref("SunFree.")
const { idShow } = homePageStore()
const route=useRoute()
const router=useRouter()
const { show_menu, show_carousel, show_author, show_anchornDown } = toRefs(idShow)
const mainCss = reactive({
@ -172,20 +175,12 @@ const mainCss = reactive({
// title: '',
// children: [
// {
// label: '1',
// key: 'album1',
// },
// {
// label: '2',
// key: 'album2',
// },
// {
// label: '3',
// key: 'album3',
// label: '',
// key: 'personself',
// },
// {
// label: '4',
// key: 'album4',
// label: '',
// key: 'otherimg',
// },
// ],
// },
@ -206,27 +201,27 @@ const mainCss = reactive({
// const jumpMenu = ({ key }: { key: string }) => {
// router.push(`/${key}`)
// };
// const updateCarouselVisibility = (routeName: any) => {
// handleScrollEnabled.value = false;
// if (scrollbar.value) {
// scrollbar.value.scrollTop = 0;
// }
// if (routeName === 'home') {
// handleScrollEnabled.value = true;
// show_carousel.value = true;
// show_menu.value = false
// } else {
// show_menu.value = true;
// show_author.value = false;
// show_carousel.value = false;
// show_anchornDown.value = false;
// mainCss.marginTop = '48px';
// }
// };
// router.beforeEach((to, _, next) => {
// updateCarouselVisibility(to.name);
// next();
// });
const updateCarouselVisibility = (routeName: any) => {
handleScrollEnabled.value = false;
if (scrollbar.value) {
scrollbar.value.scrollTop = 0;
}
if (routeName === 'home') {
handleScrollEnabled.value = true;
show_carousel.value = true;
show_menu.value = false
} else {
show_menu.value = true;
show_author.value = false;
show_carousel.value = false;
show_anchornDown.value = false;
mainCss.marginTop = '48px';
}
};
router.beforeEach((to, _, next) => {
updateCarouselVisibility(to.name);
next();
});
//
// const articleTitle = ref<string>('');
// const onSearch = (searchValue: string) => {
@ -387,7 +382,7 @@ const downScroll = () => {
// ])
//
const heat = ref(null);
const current = ref<string[]>(['home']);
function generateDates(numDays: number) {
const dates = [];
const currentDate = new Date();

53
src/components/blogs/header/NavigateMenu.vue

@ -7,17 +7,24 @@
</template>
<script setup lang='ts'>
import { ref, h, toRefs,watch,onMounted } from 'vue';
import { HomeOutlined, HighlightOutlined, ProfileOutlined, CameraOutlined, UsergroupDeleteOutlined } from '@ant-design/icons-vue';
import type { MenuProps } from 'ant-design-vue';
import { ref, toRefs,watch,h } from 'vue';
import router from '@/router';
import { useRouter } from 'vue-router';
const route=useRouter()
import { homePageStore } from '@/stores';
import { useRoute } from 'vue-router';
import { HomeOutlined, HighlightOutlined, ProfileOutlined, CameraOutlined, UsergroupDeleteOutlined } from '@ant-design/icons-vue';
import type { MenuProps } from 'ant-design-vue';
const props = defineProps(["items", "updateCarouselVisibility"])
const { idShow } = homePageStore()
const { show_menu } = toRefs(idShow)
const searchValue = ref("")
const articleTitle = ref<string>('');
const route = useRoute()
const onSearch = (searchValue: string) => {
console.log('use value', searchValue);
console.log('or use this.value', articleTitle.value);
};
const current = ref<string[]>(['home']);
const items = ref<MenuProps['items']>([
const items = ref<MenuProps['items']>([
{
key: 'home',
icon: () => h(HomeOutlined),
@ -66,41 +73,13 @@ const items = ref<MenuProps['items']>([
title: '关于sunfree',
},
]);
const searchValue = ref("")
const articleTitle = ref<string>('');
const onSearch = (searchValue: string) => {
console.log('use value', searchValue);
console.log('or use this.value', articleTitle.value);
};
const jumpMenu = ({ key }: { key: string }) => {
router.push(`/${key}`)
};
const updateCarouselVisibility = (routeName: any) => {
handleScrollEnabled.value = false;
if (scrollbar.value) {
scrollbar.value.scrollTop = 0;
}
if (routeName === 'home') {
handleScrollEnabled.value = true;
show_carousel.value = true;
show_menu.value = false
} else {
show_menu.value = true;
show_author.value = false;
show_carousel.value = false;
show_anchornDown.value = false;
mainCss.marginTop = '48px';
}
};
router.beforeEach((to, _, next) => {
updateCarouselVisibility(to.name);
next();
});
watch(
() => route.name,
(newRouteName) => {
updateCarouselVisibility(newRouteName);
props.updateCarouselVisibility(newRouteName);
if (newRouteName) {
//
const menuItem = items.value?.find((item: any) => {
@ -126,10 +105,6 @@ watch(
},
{ immediate: true }
);
const scrollbar = ref<Element | null>(null);
onMounted(()=>{
scrollbar.value = document.querySelector('.simplebar-content-wrapper');
})
</script>
<style scoped>

5
src/router/blog.ts

@ -37,6 +37,11 @@ const blogRoute:Array<RouteRecordRaw>=[
name:"personself",
component:()=>import("@/views/blog/imagemanage/PersonSelfView.vue")
},
{
path:"chart",
name:"chart",
component:()=>import("@/views/blog/AmountChartView.vue")
},
{
path:"otherimg",
name:"otherimg",

Loading…
Cancel
Save