<script setup> import { ref } from 'vue' import AccountWorkPiece from "../../components/AccountWorkPiece.vue"; import router from "../../router/index.js"; // 示例:草稿数据 const drafts = ref([ ]) function createNewDraft() { router.push('/editor') } </script> <template> <div class="container"> <!-- 顶部按钮居中 --> <div class="top-bar"> <button class="create-btn" @click="createNewDraft">新建博客</button> </div> <!-- 下面循环渲染草稿展示条 --> <div class="draft-list"> <AccountWorkPiece v-for="(item, index) in drafts" :key="index" :cover="item.cover" :title="item.title" :createdTime="item.createdTime" :lastModifiedTime="item.lastModifiedTime" :isDraft="true" /> </div> </div> </template> <style scoped> .container { width: 100%; height: auto; overflow-y: auto; display: flex; flex-direction: column; align-items: center; color: #f5f6f7; animation: fadeIn 0.3s ease-in-out; } .theme-light .container { background-color: #ffffff; color: #333333; } .top-bar { display: flex; justify-content: center; margin: 20px 0; } .create-btn { padding: 8px 16px; background-color: #3b6ea8; color: #f5f6f7; border: none; border-radius: 4px; cursor: pointer; } .create-btn:hover { background-color: #2f5687; } .theme-light .create-btn { background-color: #ffc107; color: #333333; } .theme-light .create-btn:hover { background-color: #e0a806; } .draft-list { display: flex; flex-direction: column; gap: 10px; width: 80%; max-width: 800px; } @keyframes fadeIn { 0% { opacity: 0; } 100% { opacity: 1; } } </style>