Refactor homepage layout to dashboard style for audit compliance
This commit is contained in:
@@ -3,6 +3,23 @@ import { config } from '../../config';
|
||||
|
||||
const app = getApp<IAppOption>()
|
||||
|
||||
const MATH_QUOTES = [
|
||||
"万物皆数 — 毕达哥拉斯",
|
||||
"数学是科学的女皇 — 高斯",
|
||||
"几何无王者之道 — 欧几里得",
|
||||
"数统治着宇宙 — 毕达哥拉斯",
|
||||
"上帝是一位算术家 — 雅可比"
|
||||
];
|
||||
|
||||
const COMMON_FORMULAS = [
|
||||
{ title: "圆周率", value: "π ≈ 3.14159", icon: "🔴", desc: "无限不循环小数" },
|
||||
{ title: "黄金分割", value: "φ ≈ 0.618", icon: "✨", desc: "美的比例" },
|
||||
{ title: "自然常数", value: "e ≈ 2.718", icon: "📈", desc: "成长的极限" },
|
||||
{ title: "勾股定理", value: "a² + b² = c²", icon: "📐", desc: "直角三角形" },
|
||||
{ title: "欧拉公式", value: "e^(iπ) + 1 = 0", icon: "💫", desc: "最美公式" },
|
||||
{ title: "光速", value: "c ≈ 3×10⁸ m/s", icon: "⚡", desc: "宇宙速度极限" }
|
||||
];
|
||||
|
||||
Component({
|
||||
data: {
|
||||
userInfo: {
|
||||
@@ -10,11 +27,14 @@ Component({
|
||||
nickName: '未登录'
|
||||
},
|
||||
hasUserInfo: false,
|
||||
greeting: ''
|
||||
currentDate: '',
|
||||
currentWeekday: '',
|
||||
dailyQuote: '',
|
||||
formulas: COMMON_FORMULAS
|
||||
},
|
||||
pageLifetimes: {
|
||||
show() {
|
||||
this.updateGreeting();
|
||||
this.updateDateDisplay();
|
||||
// 每次显示页面时,重新获取最新的用户信息
|
||||
const session = wx.getStorageSync('USER_SESSION');
|
||||
if (session && session.userInfo) {
|
||||
@@ -26,7 +46,7 @@ Component({
|
||||
this.setData({
|
||||
userInfo: {
|
||||
avatarUrl: config.defaultAvatarUrl,
|
||||
nickName: '点击登录'
|
||||
nickName: '未登录'
|
||||
},
|
||||
hasUserInfo: false
|
||||
});
|
||||
@@ -39,6 +59,7 @@ Component({
|
||||
withShareTicket: false,
|
||||
menus: ['shareAppMessage', 'shareTimeline'] // 需要在 Component 中定义 onShareAppMessage
|
||||
});
|
||||
this.selectDailyQuote();
|
||||
},
|
||||
|
||||
onShareAppMessage() {
|
||||
@@ -49,16 +70,23 @@ Component({
|
||||
return config.share;
|
||||
},
|
||||
|
||||
updateGreeting() {
|
||||
const hour = new Date().getHours();
|
||||
let greeting = '';
|
||||
if (hour < 5) greeting = '夜深了,注意休息';
|
||||
else if (hour < 9) greeting = '早上好,新的一天';
|
||||
else if (hour < 12) greeting = '上午好';
|
||||
else if (hour < 14) greeting = '中午好';
|
||||
else if (hour < 19) greeting = '下午好';
|
||||
else greeting = '晚上好';
|
||||
this.setData({ greeting });
|
||||
updateDateDisplay() {
|
||||
const now = new Date();
|
||||
const month = now.getMonth() + 1;
|
||||
const day = now.getDate();
|
||||
const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
|
||||
const weekday = weekdays[now.getDay()];
|
||||
|
||||
this.setData({
|
||||
currentDate: `${month}月${day}日`,
|
||||
currentWeekday: weekday
|
||||
});
|
||||
},
|
||||
|
||||
selectDailyQuote() {
|
||||
// 简单的随机选择
|
||||
const idx = Math.floor(Math.random() * MATH_QUOTES.length);
|
||||
this.setData({ dailyQuote: MATH_QUOTES[idx] });
|
||||
},
|
||||
|
||||
goToProfile() {
|
||||
|
||||
Reference in New Issue
Block a user