主题概括
色相度、饱和度、亮度各值占比
- 色相度占比
- 饱和度占比
- 亮度值占比
选择按钮
常规按钮
开关按钮
翻页按钮
安全色卡
后色 mainColor
前色 onMainColor
后色 bgColor
前色1:linkColor
前色2:accentColor
前色3:textColor
后色 surfaceColor
前色1:linkColor
前色2:accentColor
前色3:textColor
后色 linkColor
前色 bgColor
后色 accentColor
前色 bgColor
后色 textColor
前色 bgColor
关于我
UI精灵网站及技术成果全部由我研发,如果想拥有和我一样的网站,或者需要我的技术支持,欢迎与我洽谈合作。点此发送邮件。
如果我的成果能够帮您节省宝贵的时间。不妨点击我的头像请我喝杯咖啡。并诚邀来github关注我的开源项目。
class Life {
constructor() {
this.memories = [];
this.lessonsLearned = new Set();
this.age = 0;
this.happiness = 0;
this.wisdom = 0;
}
// 生活是一个持续的事件循环
async live() {
while (true) {
try {
const event = await this.experienceLife();
const lesson = this.processEvent(event);
if (lesson) {
this.learn(lesson);
this.wisdom += 1;
}
this.age += 1;
this.happiness = Math.min(100, this.happiness + this.wisdom / 10);
} catch (error) {
console.error('人生错误:', error.message);
this.lessonsLearned.add(`从${error.name}中恢复`);
this.wisdom += 2; // 我们从错误中学得更多
} finally {
if (this.age % 10 === 0) {
this.reflect(); // 定期反思
}
}
}
}
// 经历生活 - 随机事件发生器
experienceLife() {
return new Promise((resolve, reject) => {
const events = [
'成功', '失败', '爱情', '失去', '机遇', '挑战',
'友谊', '背叛', '成长', '停滞', '创造', '破坏'
];
const randomEvent = events[Math.floor(Math.random() * events.length)];
const shouldFail = Math.random() > 0.8; // 20%几率失败
setTimeout(() => {
if (shouldFail) {
reject(new Error(randomEvent));
} else {
resolve(randomEvent);
}
}, 1000); // 生活不会立即给出答案
});
}
// 处理生活事件
processEvent(event) {
this.memories.push(event);
switch(event) {
case '成功':
this.happiness += 15;
return '成功是暂时的,保持谦逊';
case '失败':
this.happiness -= 10;
return '失败是最好的老师';
case '爱情':
this.happiness += 25;
return '爱需要付出与珍惜';
case '失去':
this.happiness -= 20;
return '失去教会我们珍惜拥有';
default:
return '每个经历都有其意义';
}
}
// 学习教训
learn(lesson) {
if (!this.lessonsLearned.has(lesson)) {
this.lessonsLearned.add(lesson);
console.log(`学到了: ${lesson}`);
}
}
// 反思人生
reflect() {
console.log('------ 人生反思 ------');
console.log(`年龄: ${this.age}`);
console.log(`幸福指数: ${this.happiness}`);
console.log(`智慧等级: ${this.wisdom}`);
console.log('最近的记忆:', this.memories.slice(-5));
console.log('学到的教训:', [...this.lessonsLearned].slice(-3));
console.log('---------------------');
}
}
// 启动人生
const myLife = new Life();
myLife.live().catch(() => {
console.log('人生终将结束,但智慧永存');
});