Files
DailyHot/src/views/Home.vue
imsyy 72da75ddd7 feat: 同步最新接口
- 支持自动添加新加入的接口 #12
2023-12-05 17:24:07 +08:00

80 lines
1.9 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="home">
<!-- <n-alert type="info" :show-icon="false" style="margin-bottom: 20px">
站点未完工
</n-alert> -->
<n-grid
v-if="store.newsArr[0] && store.newsArr.filter((item) => item.show)[0]"
cols="1 560:2 800:3 1100:4 1500:5"
:x-gap="24"
:y-gap="24"
>
<n-grid-item
class="news-card"
v-for="(item, index) in store.newsArr.filter((item) => item.show)"
:key="item"
:style="{ animationDelay: index / 10 + 0.2 + 's' }"
>
<HotList :hotData="item" />
</n-grid-item>
</n-grid>
<div class="error" v-else>
<n-divider dashed class="tip"> 此处暂无内容 </n-divider>
<n-space justify="center">
<n-button size="large" secondary strong @click="reset">
出错了点此重置
</n-button>
</n-space>
</div>
</div>
</template>
<script setup>
import { mainStore } from "@/store";
import HotList from "@/components/HotList.vue";
const store = mainStore();
// 重置
const reset = () => {
$dialog.warning({
title: "重置站点",
content:
"确认重置站点?你的自定义数据将会恢复为默认状态!(当设置页面能正常进入并显示时请不要执行此操作!)",
positiveText: "重置",
negativeText: "取消",
onPositiveClick: () => {
if ($timeInterval) clearInterval($timeInterval);
localStorage.clear();
location.reload();
},
});
};
</script>
<style lang="scss" scoped>
.home {
.news-card {
opacity: 0;
transform: translateY(20px);
animation-timing-function: cubic-bezier(0.42, 0, 0.58, 1);
animation: cardShow 0.3s forwards ease-in-out;
}
.tip {
font-size: 22px;
}
}
// 出现动画
@keyframes cardShow {
0% {
opacity: 0;
transform: translateY(20px);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
</style>