Browse Source

add neew

master
panda 8 months ago
parent
commit
00866a5ba1
  1. 22
      src/components/blogs/header/NavigateMenu.vue
  2. 19
      src/stores/index.ts
  3. 17
      src/views/blog/HomePageView.vue

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

@ -2,7 +2,7 @@
<div class="menu" v-if="show_menu">
<a-menu v-model:selectedKeys="current" mode="horizontal" :items="items" style="border-bottom: none;"
@click="jumpMenu" />
<a-input-search v-model:value="searchValue" placeholder="search" style="width: 200px" @search="onSearch" />
<a-input-search v-model:value="searchValue" placeholder="search" style="width: 200px" @search="onSearch" :disabled="isDisabled"/>
</div>
</template>
@ -16,14 +16,15 @@ import { HomeOutlined, HighlightOutlined, ProfileOutlined, CameraOutlined, Userg
import type { MenuProps } from 'ant-design-vue';
import { get } from '@/tools/request';
const props = defineProps(["items", "updateCarouselVisibility"])
const { idShow,fetchHomePageList } = homePageStore()
const { idShow,fetchHomePageList,setEmpty } = homePageStore()
const { show_menu } = toRefs(idShow)
const store = useContentStore();
const searchValue = ref("")
const articleTitle = ref<string>('');
const route = useRoute()
const onSearch =async (searchValue: string) => {
await fetchHomePageList(searchValue);
const isDisabled=ref(false)
const onSearch =(searchValue: string) => {
fetchHomePageList(searchValue)
};
const current = ref<string[]>(['home']);
const items = ref<MenuProps['items']>([
@ -111,7 +112,20 @@ watch(
},
{ immediate: true }
);
watch(searchValue, (newValue) => {
if (newValue === "") {
fetchHomePageList("");
}
});
router.beforeEach((to, _, next) => {
if (to.name !== 'home') {
isDisabled.value=true;
} else {
isDisabled.value=false;
}
next();
});
</script>
<style scoped>

19
src/stores/index.ts

@ -12,12 +12,24 @@ export const homePageStore = defineStore("homePage", () => {
show_author: true,
show_anchornDown: true
})
const isEmpty=ref(false)
const homepagelist = ref<homePageInterface[]>([]);
const fetchHomePageList = async (query: string="") => {
const response = await get(`/statistics/homepage?title=${query}`);
homepagelist.value = response.data.data;
// const response = await get(`/statistics/searchtitle?title=${query}`);
// homepagelist.value = response.data.data;
get(`/statistics/searchtitle?title=${query}`).then(res => {
homepagelist.value = res.data.data;
if (res.data.data.length === 0) {
isEmpty.value=true
}else{
isEmpty.value=false
}
})
};
return { idShow, homepagelist,fetchHomePageList }
return { idShow, homepagelist,isEmpty,fetchHomePageList }
})
export const blogStore = defineStore("blog", () => {
@ -43,7 +55,6 @@ export const useContentStore = defineStore('content', () => {
return { content, titles, setContent, setTitles, getTitle, showCatalogue };
});
export const diaryStore = defineStore("diary", () => {
const delControl = reactive({
open: false,

17
src/views/blog/HomePageView.vue

@ -94,12 +94,20 @@
</a-badge-ribbon>
</div>
</div>
<div class="loadbutton">
<a-button v-if="showLoadMoreButton" @click="loadMore" class="ripple-button" :loading="loading" type="primary">
<a-button v-if="showLoadMoreButton" @click="loadMore" class="ripple-button" :loading="loading"
type="primary">
{{ loading ? '加载中...' : '加载更多' }}
</a-button>
</div>
<div class="is-null" v-if="homepageStore.isEmpty">
<a-card hoverable>
<a-empty />
</a-card>
</div>
</div>
</template>
<script setup lang='ts'>
@ -164,7 +172,7 @@ watch(() => homepageStore.homepagelist, () => {
// homepagelist
currentIndex = 0;
showNextBatch();
});
},);
</script>
<style scoped>
@ -263,9 +271,4 @@ watch(() => homepageStore.homepagelist, () => {
justify-content: right;
margin-bottom: 24px;
}
</style>
Loading…
Cancel
Save