Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
mlaj
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2025-08-26 12:00:00 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6f38771890f5157c9d6a089b19fb1bfb20b7faa0
6f387718
1 parent
3ba77978
feat(日历): 禁用未来日期并添加样式
添加日期格式化函数中对未来日期的禁用逻辑,并设置对应的禁用样式
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
src/views/checkin/IndexCheckInPage.vue
src/views/checkin/IndexCheckInPage.vue
View file @
6f38771
...
...
@@ -429,6 +429,11 @@ const openImagePreview = (index, post) => {
const onChange = (index) => {
startPosition.value = index;
}
/**
* 日历日期格式化函数
* @param {Object} day - 日期对象
* @returns {Object} 格式化后的日期对象
*/
const formatter = (day) => {
const year = day.date.getFullYear();
const month = day.date.getMonth() + 1;
...
...
@@ -436,6 +441,13 @@ const formatter = (day) => {
let checkin_days = myCheckinDates.value;
// 禁用未来日期
if (dayjs(day.date).isAfter(new Date(), 'day')) {
day.type = 'disabled';
day.className = 'calendar-disabled';
return day;
}
// 检查当前日期是否在签到日期列表中
if (checkin_days && checkin_days.length > 0) {
// 格式化当前日期为YYYY-MM-DD格式,与checkin_days中的格式匹配
...
...
@@ -840,4 +852,15 @@ const formatData = (data) => {
:deep(.van-calendar__footer) {
display: none;
}
/* 禁用未来日期的样式 */
:deep(.calendar-disabled) {
color: #c8c9cc !important;
background-color: #f7f8fa !important;
cursor: not-allowed !important;
}
:deep(.calendar-disabled .van-calendar__day-text) {
color: #c8c9cc !important;
}
</style>
...
...
Please
register
or
login
to post a comment