Browse Source

add new

master
sunfree 8 months ago
parent
commit
c9971963cf
  1. 69
      src/components/blogs/HomePage.vue
  2. 51
      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"> <Simplebar @scroll="handleScroll">
<div class="header"> <div class="header">
<!-- 头部导航菜单 --> <!-- 头部导航菜单 -->
<NavigateMenu />
<NavigateMenu :updateCarouselVisibility="updateCarouselVisibility"/>
<!-- 作者名字 --> <!-- 作者名字 -->
<div class="author" v-if="show_author">{{ author }}</div> <div class="author" v-if="show_author">{{ author }}</div>
<!-- 轮播 --> <!-- 轮播 -->
@ -17,7 +17,6 @@
</div> </div>
</div> </div>
<!-- 主要内容区域 --> <!-- 主要内容区域 -->
<div class="mainContainer" :style="mainCss"> <div class="mainContainer" :style="mainCss">
<div class="leftBar"> <div class="leftBar">
@ -119,7 +118,7 @@
</Simplebar> </Simplebar>
</template> </template>
<script lang="ts" setup> <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 { DownCircleOutlined } from '@ant-design/icons-vue';
import Typed from 'typed.js'; import Typed from 'typed.js';
import { onMounted, watch } from 'vue'; import { onMounted, watch } from 'vue';
@ -137,8 +136,12 @@ import StatisticCount from "./StatisticCount.vue"
import NavigateMenu from './header/NavigateMenu.vue'; import NavigateMenu from './header/NavigateMenu.vue';
import { homePageStore } from '@/stores'; import { homePageStore } from '@/stores';
import CarouselImg from './header/CarouselImg.vue'; 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 author = ref("SunFree.")
const { idShow } = homePageStore() const { idShow } = homePageStore()
const route=useRoute()
const router=useRouter()
const { show_menu, show_carousel, show_author, show_anchornDown } = toRefs(idShow) const { show_menu, show_carousel, show_author, show_anchornDown } = toRefs(idShow)
const mainCss = reactive({ const mainCss = reactive({
@ -172,20 +175,12 @@ const mainCss = reactive({
// title: '', // title: '',
// children: [ // 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 }) => { // const jumpMenu = ({ key }: { key: string }) => {
// router.push(`/${key}`) // 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 articleTitle = ref<string>('');
// const onSearch = (searchValue: string) => { // const onSearch = (searchValue: string) => {
@ -387,7 +382,7 @@ const downScroll = () => {
// ]) // ])
// //
const heat = ref(null); const heat = ref(null);
const current = ref<string[]>(['home']);
function generateDates(numDays: number) { function generateDates(numDays: number) {
const dates = []; const dates = [];
const currentDate = new Date(); const currentDate = new Date();

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

@ -7,15 +7,22 @@
</template> </template>
<script setup lang='ts'> <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 router from '@/router';
import { useRouter } from 'vue-router';
const route=useRouter()
import { homePageStore } from '@/stores'; 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 { idShow } = homePageStore()
const { show_menu } = toRefs(idShow) 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 current = ref<string[]>(['home']);
const items = ref<MenuProps['items']>([ const items = ref<MenuProps['items']>([
{ {
@ -66,41 +73,13 @@ const items = ref<MenuProps['items']>([
title: '关于sunfree', 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 }) => { const jumpMenu = ({ key }: { key: string }) => {
router.push(`/${key}`) 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( watch(
() => route.name, () => route.name,
(newRouteName) => { (newRouteName) => {
updateCarouselVisibility(newRouteName);
props.updateCarouselVisibility(newRouteName);
if (newRouteName) { if (newRouteName) {
// //
const menuItem = items.value?.find((item: any) => { const menuItem = items.value?.find((item: any) => {
@ -126,10 +105,6 @@ watch(
}, },
{ immediate: true } { immediate: true }
); );
const scrollbar = ref<Element | null>(null);
onMounted(()=>{
scrollbar.value = document.querySelector('.simplebar-content-wrapper');
})
</script> </script>
<style scoped> <style scoped>

5
src/router/blog.ts

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

Loading…
Cancel
Save