Files
charlie f3bdaa4e88 feat: add TypeScript lessons and learning panel
- Introduced a new script to check TypeScript lesson files for errors.
- Created a main TypeScript file to render lessons and their details.
- Added lesson definitions with starter and answer codes.
- Implemented a user interface for navigating and running lessons.
- Styled the application with CSS for a better user experience.
- Updated README to reflect the new TypeScript section and usage instructions.
2026-03-19 10:06:11 +08:00

36 lines
878 B
JavaScript

function fakeFetchUser() {
return new Promise(function (resolve) {
setTimeout(function () {
resolve({
name: "林晨",
role: "前端学习者",
focus: "DOM + 事件 + 异步",
});
}, 900);
});
}
const loadButton = document.getElementById("load-user-btn");
const statusText = document.getElementById("user-status");
const userCard = document.getElementById("user-card");
async function loadUser() {
statusText.textContent = "加载中...";
userCard.innerHTML = "";
try {
const user = await fakeFetchUser();
userCard.innerHTML = `
<p>姓名:${user.name}</p>
<p>身份:${user.role}</p>
<p>当前重点:${user.focus}</p>
`;
statusText.textContent = "加载完成";
} catch (error) {
statusText.textContent = "加载失败";
}
}
loadButton.addEventListener("click", loadUser);