diff --git a/pages/index/index.vue b/pages/index/index.vue index 48184d8..f3a1e77 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -37,6 +37,29 @@ + + + + 今日灵感 + {{ todayDate }} + + + + + {{ dailyGreeting }} + + + + + 复制 + + + 去制作 + + + + + @@ -115,8 +138,31 @@ const updateCountdown = () => { } }; +const todayDate = ref(""); +const dailyGreeting = ref( + "岁岁常欢愉,年年皆胜意。愿你新的一年,多喜乐,长安宁。", +); + +const copyGreeting = () => { + uni.setClipboardData({ + data: dailyGreeting.value, + success: () => { + uni.showToast({ title: "复制成功", icon: "none" }); + }, + }); +}; + +const useGreeting = () => { + uni.setStorageSync("TEMP_BLESSING_TEXT", dailyGreeting.value); + uni.switchTab({ + url: "/pages/make/index", + }); +}; + onMounted(() => { updateCountdown(); + const date = new Date(); + todayDate.value = `${date.getMonth() + 1}月${date.getDate()}日`; }); const features = ref([ @@ -347,6 +393,99 @@ onShareAppMessage(() => { } } +/* 今日灵感 */ +.daily-section { + margin: 24rpx 24rpx 0; + .daily-header { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 16rpx; + .daily-title { + font-size: 32rpx; + font-weight: 700; + color: #333; + } + .daily-date { + font-size: 24rpx; + color: #999; + font-family: monospace; + } + } + .daily-card { + background: #fff; + border-radius: 20rpx; + padding: 30rpx; + box-shadow: 0 8rpx 24rpx rgba(255, 59, 48, 0.08); + position: relative; + overflow: hidden; + } + .daily-card::before { + content: ""; + position: absolute; + top: 0; + left: 0; + width: 8rpx; + height: 100%; + background: #ff3b30; + } + .daily-content { + position: relative; + padding: 10rpx 20rpx; + .quote-mark { + font-size: 60rpx; + color: #ff3b30; + opacity: 0.2; + position: absolute; + line-height: 1; + font-family: serif; + } + .quote-mark:first-child { + top: -10rpx; + left: -10rpx; + } + .quote-mark.right { + bottom: -20rpx; + right: 0; + } + .daily-text { + font-size: 30rpx; + color: #444; + line-height: 1.8; + font-style: italic; + display: block; + text-align: justify; + } + } + .daily-actions { + display: flex; + justify-content: flex-end; + margin-top: 30rpx; + gap: 20rpx; + .action-btn { + display: flex; + align-items: center; + padding: 12rpx 24rpx; + border-radius: 999rpx; + font-size: 24rpx; + transition: all 0.2s; + .icon { + margin-right: 6rpx; + font-size: 26rpx; + } + } + .action-btn.copy { + background: #f5f5f5; + color: #666; + } + .action-btn.use { + background: #ff3b30; + color: #fff; + box-shadow: 0 4rpx 12rpx rgba(255, 59, 48, 0.3); + } + } +} + /* 通用区块标题 */ .section { margin-top: 28rpx; diff --git a/pages/make/index.vue b/pages/make/index.vue index bdef8a5..82a54ac 100644 --- a/pages/make/index.vue +++ b/pages/make/index.vue @@ -291,7 +291,12 @@ import { getCardTemplateContentList, } from "@/api/make"; import { createShareToken } from "@/api/system"; -import { onShareAppMessage, onLoad, onReachBottom } from "@dcloudio/uni-app"; +import { + onShareAppMessage, + onLoad, + onReachBottom, + onShow, +} from "@dcloudio/uni-app"; import { useUserStore } from "@/stores/user"; import LoginPopup from "@/components/LoginPopup/LoginPopup.vue"; @@ -396,6 +401,14 @@ onLoad((options) => { getTemplateContentList(); }); +onShow(() => { + const tempBlessing = uni.getStorageSync("TEMP_BLESSING_TEXT"); + if (tempBlessing) { + blessingText.value = { content: tempBlessing, id: "" }; + uni.removeStorageSync("TEMP_BLESSING_TEXT"); + } +}); + onReachBottom(() => { if (activeTool.value === "template") { loadMoreTemplates(); @@ -457,7 +470,9 @@ const getTemplateContentList = async () => { if (res.length) { greetingLib.value = res; displayedGreetings.value = greetingLib.value.slice(0, 2); - blessingText.value = greetingLib.value[0] || {}; + if (!blessingText.value.content) { + blessingText.value = greetingLib.value[0] || {}; + } } };