fix:修复日记显示不全的问题

This commit is contained in:
2025-11-11 23:33:19 +08:00
parent 5ec0781a53
commit f62613205c
2 changed files with 19 additions and 8 deletions

View File

@@ -5,8 +5,11 @@
:is-dark="appStore.isDark" :is-dark="appStore.isDark"
class="journal-calendar card-item"/> class="journal-calendar card-item"/>
<journal-card v-if="journalStore.currentJournal.id !== 0" <div v-if="journalStore.dateJournalList.length > 0"
:item="journalStore.currentJournal"/> class="journal-list">
<journal-card v-for="(item, index) in journalStore.dateJournalList"
:key="index" :item="item"/>
</div>
<el-empty v-else description="今日暂无日记" /> <el-empty v-else description="今日暂无日记" />
</div> </div>
@@ -35,6 +38,7 @@ const dailyInfo = reactive({
}) })
const updateInfo = () => { const updateInfo = () => {
journalStore.dateJournalList = []
getCalendarMoveDate() getCalendarMoveDate()
getCalendarAttrDates() getCalendarAttrDates()
} }
@@ -42,7 +46,7 @@ const updateInfo = () => {
const getCalendarMoveDate = () => { const getCalendarMoveDate = () => {
const recordLength = journalStore.journalList.length const recordLength = journalStore.journalList.length
if (recordLength > 0) { if (recordLength > 0) {
journalStore.currentJournal = getJournalDay(formatDate(new Date())) journalStore.dateJournalList = getJournalDay(formatDate(new Date()))
} }
} }
@@ -54,7 +58,7 @@ const getCalendarAttrDates = () => {
dates: new Date() dates: new Date()
}) })
const dateList = journalStore.journalList.map((item) => item.date) const dateList = journalStore.journalList.map((item) => formatDate(item.date))
dailyInfo.attrs.push({ dailyInfo.attrs.push({
dot: 'red', dot: 'red',
dates: [...new Set(dateList)] dates: [...new Set(dateList)]
@@ -66,12 +70,11 @@ const getCalendarAttrDates = () => {
* @param day 日期 * @param day 日期
*/ */
const dateClick = (day: CalendarDay) => { const dateClick = (day: CalendarDay) => {
journalStore.currentJournal = getJournalDay(formatDate(day.date)) journalStore.dateJournalList = getJournalDay(formatDate(day.date))
} }
const getJournalDay = (date: string): IJournal => { const getJournalDay = (date: string): IJournal[] => {
return journalStore.journalList.find((item) => formatDate(item.date) === date) return journalStore.journalList.filter((item) => formatDate(item.date) === date) || []
|| journalStore.getEmptyJournal()
} }
/** /**
@@ -96,5 +99,12 @@ const changeMonthClick = async (value) => {
.journal-calendar { .journal-calendar {
width: 100%; width: 100%;
} }
.journal-list {
width: 100%;
display: flex;
flex-direction: column;
gap: 1vh;
}
} }
</style> </style>

View File

@@ -25,6 +25,7 @@ export const useJournalStore = defineStore('journal', {
imageUrl: '', imageUrl: '',
videoUrl: '' videoUrl: ''
} as IJournal, } as IJournal,
dateJournalList: [] as IJournal[],
journalImagePath: ImagePathEnum.JOURNAL, journalImagePath: ImagePathEnum.JOURNAL,
journalVideoPath: ImagePathEnum.JOURNAL, journalVideoPath: ImagePathEnum.JOURNAL,
journalDialog: { journalDialog: {