generated from templates/ai-develops
41 lines
1.1 KiB
HTML
41 lines
1.1 KiB
HTML
|
|
<!doctype html>
|
||
|
|
<html lang="zh-CN">
|
||
|
|
<head>
|
||
|
|
<meta charset="utf-8" />
|
||
|
|
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||
|
|
<title>Demo - 主页</title>
|
||
|
|
<link rel="stylesheet" href="/static/css/style.css">
|
||
|
|
</head>
|
||
|
|
<body>
|
||
|
|
<main class="container">
|
||
|
|
<header>
|
||
|
|
<h1>Demo 应用</h1>
|
||
|
|
</header>
|
||
|
|
|
||
|
|
<section id="content">
|
||
|
|
<p id="greeting">正在检查登录状态……</p>
|
||
|
|
<div id="actions"></div>
|
||
|
|
</section>
|
||
|
|
</main>
|
||
|
|
<script>
|
||
|
|
// 简单客户端令牌检查
|
||
|
|
const token = localStorage.getItem('demo_auth_token');
|
||
|
|
const greeting = document.getElementById('greeting');
|
||
|
|
const actions = document.getElementById('actions');
|
||
|
|
|
||
|
|
if (token) {
|
||
|
|
greeting.textContent = '欢迎,已登录用户!';
|
||
|
|
const logoutBtn = document.createElement('button');
|
||
|
|
logoutBtn.textContent = '退出登录';
|
||
|
|
logoutBtn.onclick = () => {
|
||
|
|
localStorage.removeItem('demo_auth_token');
|
||
|
|
location.reload();
|
||
|
|
};
|
||
|
|
actions.appendChild(logoutBtn);
|
||
|
|
} else {
|
||
|
|
greeting.innerHTML = '你还未登录。前往 <a href="/login.html">登录页面</a>。';
|
||
|
|
}
|
||
|
|
</script>
|
||
|
|
</body>
|
||
|
|
</html>
|