|
|
|
@ -2,7 +2,7 @@
|
|
|
|
|
<div class="welcome-container">
|
|
|
|
|
<!-- 上部分:欢迎文字 -->
|
|
|
|
|
<div class="welcome-header">
|
|
|
|
|
欢迎来到珞珈岛,珈人
|
|
|
|
|
欢迎来到珞珈岛,{{ userStore.userInfo?.username ? userStore.userInfo.username : '珈人' }}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- 中间部分:月份、日期、星期 -->
|
|
|
|
@ -33,6 +33,7 @@
|
|
|
|
|
|
|
|
|
|
<script setup lang="js" name="WelcomeCalendar">
|
|
|
|
|
import { ref } from 'vue';
|
|
|
|
|
import { useUserStore } from '@/stores/user';
|
|
|
|
|
|
|
|
|
|
const today = new Date();
|
|
|
|
|
|
|
|
|
@ -40,10 +41,31 @@ const today = new Date();
|
|
|
|
|
const currentMonthText = ref(['一', '月']); // 默认值
|
|
|
|
|
const currentDay = ref(today.getDate()); // 当前日期号
|
|
|
|
|
const currentWeekday = ref(['星', '期', '日']); // 当前星期完整文字
|
|
|
|
|
|
|
|
|
|
const userStore = useUserStore();
|
|
|
|
|
// 打卡状态
|
|
|
|
|
const isCheckedIn = ref(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取当前用户唯一标识
|
|
|
|
|
const getUserKey = () => {
|
|
|
|
|
return userStore.userInfo?.userid || userStore.userInfo?.username || 'guest';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 检查今天是否已打卡
|
|
|
|
|
const checkToday = () => {
|
|
|
|
|
const todayStr = new Date().toISOString().slice(0, 10);
|
|
|
|
|
const userKey = getUserKey();
|
|
|
|
|
return localStorage.getItem(`checkin-${userKey}-${todayStr}`) === '1';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 打卡功能
|
|
|
|
|
const checkIn = () => {
|
|
|
|
|
const todayStr = new Date().toISOString().slice(0, 10);
|
|
|
|
|
const userKey = getUserKey();
|
|
|
|
|
isCheckedIn.value = true;
|
|
|
|
|
localStorage.setItem(`checkin-${userKey}-${todayStr}`, '1');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 初始化日期信息
|
|
|
|
|
const initializeDate = () => {
|
|
|
|
|
const months = [
|
|
|
|
@ -55,11 +77,7 @@ const initializeDate = () => {
|
|
|
|
|
currentMonthText.value = months[today.getMonth()].split('');
|
|
|
|
|
currentDay.value = today.getDate();
|
|
|
|
|
currentWeekday.value = weekdays[today.getDay()].split('');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 打卡功能
|
|
|
|
|
const checkIn = () => {
|
|
|
|
|
isCheckedIn.value = true;
|
|
|
|
|
isCheckedIn.value = checkToday();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 初始化
|
|
|
|
|