Initial commit: 宁夏智慧养殖监管平台
This commit is contained in:
52
frontend/public/debug-devices.html
Normal file
52
frontend/public/debug-devices.html
Normal file
@@ -0,0 +1,52 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>设备数据调试</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>设备数据调试</h1>
|
||||
<div id="result"></div>
|
||||
|
||||
<script>
|
||||
async function testDeviceAPI() {
|
||||
const resultDiv = document.getElementById('result');
|
||||
|
||||
try {
|
||||
console.log('开始测试设备API...');
|
||||
|
||||
// 测试API调用
|
||||
const response = await fetch('http://localhost:5350/api/devices/public');
|
||||
const data = await response.json();
|
||||
|
||||
console.log('API响应:', data);
|
||||
|
||||
// 显示结果
|
||||
const devices = data.data || [];
|
||||
const statusCount = {};
|
||||
devices.forEach(device => {
|
||||
statusCount[device.status] = (statusCount[device.status] || 0) + 1;
|
||||
});
|
||||
|
||||
resultDiv.innerHTML = `
|
||||
<h2>API测试结果</h2>
|
||||
<p><strong>设备总数:</strong> ${devices.length}</p>
|
||||
<p><strong>在线设备:</strong> ${statusCount.online || 0}</p>
|
||||
<p><strong>离线设备:</strong> ${statusCount.offline || 0}</p>
|
||||
<p><strong>维护设备:</strong> ${statusCount.maintenance || 0}</p>
|
||||
<h3>前3个设备:</h3>
|
||||
<pre>${JSON.stringify(devices.slice(0, 3), null, 2)}</pre>
|
||||
`;
|
||||
|
||||
} catch (error) {
|
||||
console.error('API测试失败:', error);
|
||||
resultDiv.innerHTML = `<p style="color: red;">API测试失败: ${error.message}</p>`;
|
||||
}
|
||||
}
|
||||
|
||||
// 页面加载后执行测试
|
||||
window.addEventListener('load', testDeviceAPI);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
187
frontend/public/debug-users.html
Normal file
187
frontend/public/debug-users.html
Normal file
@@ -0,0 +1,187 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>用户管理调试页面</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
margin: 20px;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.container {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
background: white;
|
||||
padding: 20px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||
}
|
||||
.status {
|
||||
padding: 10px;
|
||||
margin: 10px 0;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.success {
|
||||
background-color: #d4edda;
|
||||
color: #155724;
|
||||
border: 1px solid #c3e6cb;
|
||||
}
|
||||
.error {
|
||||
background-color: #f8d7da;
|
||||
color: #721c24;
|
||||
border: 1px solid #f5c6cb;
|
||||
}
|
||||
.info {
|
||||
background-color: #d1ecf1;
|
||||
color: #0c5460;
|
||||
border: 1px solid #bee5eb;
|
||||
}
|
||||
button {
|
||||
background-color: #007bff;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 10px 20px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
margin: 5px;
|
||||
}
|
||||
button:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
pre {
|
||||
background-color: #f8f9fa;
|
||||
padding: 10px;
|
||||
border-radius: 4px;
|
||||
overflow-x: auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>用户管理调试页面</h1>
|
||||
|
||||
<div id="tokenStatus" class="status info">
|
||||
检查中...
|
||||
</div>
|
||||
|
||||
<div id="apiStatus" class="status info">
|
||||
等待测试...
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button onclick="checkToken()">检查Token</button>
|
||||
<button onclick="testLogin()">测试登录</button>
|
||||
<button onclick="testUsersAPI()">测试用户API</button>
|
||||
<button onclick="clearToken()">清除Token</button>
|
||||
</div>
|
||||
|
||||
<div id="results">
|
||||
<h3>测试结果:</h3>
|
||||
<pre id="output"></pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const API_BASE_URL = 'http://localhost:5350/api';
|
||||
|
||||
function log(message) {
|
||||
const output = document.getElementById('output');
|
||||
output.textContent += new Date().toLocaleTimeString() + ': ' + message + '\n';
|
||||
}
|
||||
|
||||
function checkToken() {
|
||||
const token = localStorage.getItem('token');
|
||||
const tokenStatus = document.getElementById('tokenStatus');
|
||||
|
||||
if (token) {
|
||||
tokenStatus.className = 'status success';
|
||||
tokenStatus.textContent = `Token存在 (长度: ${token.length})`;
|
||||
log('Token存在: ' + token.substring(0, 50) + '...');
|
||||
} else {
|
||||
tokenStatus.className = 'status error';
|
||||
tokenStatus.textContent = 'Token不存在';
|
||||
log('Token不存在');
|
||||
}
|
||||
}
|
||||
|
||||
async function testLogin() {
|
||||
try {
|
||||
log('开始测试登录...');
|
||||
const response = await fetch(`${API_BASE_URL}/auth/login`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
username: 'admin',
|
||||
password: '123456'
|
||||
})
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
log('登录响应: ' + JSON.stringify(data, null, 2));
|
||||
|
||||
if (data.success && data.token) {
|
||||
localStorage.setItem('token', data.token);
|
||||
log('Token已保存到localStorage');
|
||||
checkToken();
|
||||
} else {
|
||||
log('登录失败: ' + data.message);
|
||||
}
|
||||
} catch (error) {
|
||||
log('登录错误: ' + error.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function testUsersAPI() {
|
||||
try {
|
||||
log('开始测试用户API...');
|
||||
const token = localStorage.getItem('token');
|
||||
|
||||
if (!token) {
|
||||
log('错误: 没有找到token,请先登录');
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await fetch(`${API_BASE_URL}/users`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
log('用户API响应: ' + JSON.stringify(data, null, 2));
|
||||
|
||||
const apiStatus = document.getElementById('apiStatus');
|
||||
if (data.success && data.data) {
|
||||
apiStatus.className = 'status success';
|
||||
apiStatus.textContent = `API正常 (获取到${data.data.length}个用户)`;
|
||||
} else {
|
||||
apiStatus.className = 'status error';
|
||||
apiStatus.textContent = 'API异常';
|
||||
}
|
||||
} catch (error) {
|
||||
log('用户API错误: ' + error.message);
|
||||
const apiStatus = document.getElementById('apiStatus');
|
||||
apiStatus.className = 'status error';
|
||||
apiStatus.textContent = 'API调用失败';
|
||||
}
|
||||
}
|
||||
|
||||
function clearToken() {
|
||||
localStorage.removeItem('token');
|
||||
log('Token已清除');
|
||||
checkToken();
|
||||
}
|
||||
|
||||
// 页面加载时自动检查token
|
||||
window.onload = function() {
|
||||
checkToken();
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
90
frontend/public/map-test.html
Normal file
90
frontend/public/map-test.html
Normal file
@@ -0,0 +1,90 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>百度地图测试</title>
|
||||
<style>
|
||||
#mapContainer {
|
||||
width: 100%;
|
||||
height: 500px;
|
||||
border: 2px solid #ccc;
|
||||
margin: 20px 0;
|
||||
}
|
||||
.log {
|
||||
background: #f5f5f5;
|
||||
padding: 10px;
|
||||
margin: 10px 0;
|
||||
border-radius: 4px;
|
||||
font-family: monospace;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>百度地图测试页面</h1>
|
||||
<div id="mapContainer"></div>
|
||||
<div class="log" id="logContainer">正在加载百度地图API...</div>
|
||||
|
||||
<script>
|
||||
const logContainer = document.getElementById('logContainer');
|
||||
|
||||
function log(message) {
|
||||
console.log(message);
|
||||
logContainer.textContent += '\n' + new Date().toLocaleTimeString() + ': ' + message;
|
||||
}
|
||||
|
||||
// 百度地图API回调函数
|
||||
window.initBMap = function() {
|
||||
log('百度地图API加载成功');
|
||||
|
||||
try {
|
||||
// 创建地图实例
|
||||
const map = new BMap.Map('mapContainer');
|
||||
log('地图实例创建成功');
|
||||
|
||||
// 设置中心点和缩放级别
|
||||
const point = new BMap.Point(106.27, 38.47); // 银川市中心
|
||||
map.centerAndZoom(point, 12);
|
||||
log('地图中心点设置成功: ' + point.lng + ', ' + point.lat);
|
||||
|
||||
// 启用滚轮缩放
|
||||
map.enableScrollWheelZoom(true);
|
||||
log('滚轮缩放已启用');
|
||||
|
||||
// 添加控件
|
||||
map.addControl(new BMap.NavigationControl());
|
||||
map.addControl(new BMap.ScaleControl());
|
||||
log('地图控件添加成功');
|
||||
|
||||
// 添加测试标记
|
||||
const marker = new BMap.Marker(point);
|
||||
map.addOverlay(marker);
|
||||
log('测试标记添加成功');
|
||||
|
||||
// 添加信息窗口
|
||||
const infoWindow = new BMap.InfoWindow('这是一个测试标记点');
|
||||
marker.addEventListener('click', function() {
|
||||
map.openInfoWindow(infoWindow, point);
|
||||
});
|
||||
log('信息窗口事件绑定成功');
|
||||
|
||||
log('地图初始化完成!');
|
||||
|
||||
} catch (error) {
|
||||
log('地图初始化失败: ' + error.message);
|
||||
console.error('地图初始化失败:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// 动态加载百度地图API
|
||||
const script = document.createElement('script');
|
||||
script.src = 'https://api.map.baidu.com/api?v=3.0&ak=3AN3VahoqaXUs32U8luXD2Dwn86KK5B7&callback=initBMap';
|
||||
script.onerror = function() {
|
||||
log('百度地图API加载失败');
|
||||
};
|
||||
document.head.appendChild(script);
|
||||
log('开始加载百度地图API...');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
135
frontend/public/test-auto-login.html
Normal file
135
frontend/public/test-auto-login.html
Normal file
@@ -0,0 +1,135 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>自动登录测试</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
max-width: 800px;
|
||||
margin: 50px auto;
|
||||
padding: 20px;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.container {
|
||||
background: white;
|
||||
padding: 30px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||
}
|
||||
.test-item {
|
||||
margin: 20px 0;
|
||||
padding: 15px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.success {
|
||||
background-color: #f6ffed;
|
||||
border-color: #b7eb8f;
|
||||
}
|
||||
.error {
|
||||
background-color: #fff2f0;
|
||||
border-color: #ffccc7;
|
||||
}
|
||||
button {
|
||||
background-color: #1890ff;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 8px 16px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
margin: 5px;
|
||||
}
|
||||
button:hover {
|
||||
background-color: #40a9ff;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>自动登录功能测试</h1>
|
||||
|
||||
<div class="test-item">
|
||||
<h3>测试步骤:</h3>
|
||||
<ol>
|
||||
<li>点击"清除登录状态"按钮</li>
|
||||
<li>点击"访问登录页面"按钮</li>
|
||||
<li>观察是否自动登录并跳转到仪表盘</li>
|
||||
<li>点击"访问用户管理页面"测试路由守卫</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<div class="test-item">
|
||||
<h3>当前状态:</h3>
|
||||
<p>Token: <span id="token-status">检查中...</span></p>
|
||||
<p>用户信息: <span id="user-status">检查中...</span></p>
|
||||
</div>
|
||||
|
||||
<div class="test-item">
|
||||
<h3>测试操作:</h3>
|
||||
<button onclick="clearLoginState()">清除登录状态</button>
|
||||
<button onclick="checkLoginState()">检查登录状态</button>
|
||||
<button onclick="visitLoginPage()">访问登录页面</button>
|
||||
<button onclick="visitUsersPage()">访问用户管理页面</button>
|
||||
<button onclick="visitDashboard()">访问仪表盘</button>
|
||||
</div>
|
||||
|
||||
<div class="test-item">
|
||||
<h3>测试结果:</h3>
|
||||
<div id="test-results"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function addResult(message, isSuccess = true) {
|
||||
const results = document.getElementById('test-results');
|
||||
const div = document.createElement('div');
|
||||
div.className = isSuccess ? 'success' : 'error';
|
||||
div.style.margin = '10px 0';
|
||||
div.style.padding = '10px';
|
||||
div.style.borderRadius = '4px';
|
||||
div.innerHTML = `<strong>${new Date().toLocaleTimeString()}</strong>: ${message}`;
|
||||
results.appendChild(div);
|
||||
}
|
||||
|
||||
function clearLoginState() {
|
||||
localStorage.removeItem('token');
|
||||
localStorage.removeItem('user');
|
||||
addResult('已清除登录状态');
|
||||
checkLoginState();
|
||||
}
|
||||
|
||||
function checkLoginState() {
|
||||
const token = localStorage.getItem('token');
|
||||
const user = localStorage.getItem('user');
|
||||
|
||||
document.getElementById('token-status').textContent = token ? '已存在' : '不存在';
|
||||
document.getElementById('user-status').textContent = user ? JSON.parse(user).username : '未登录';
|
||||
|
||||
addResult(`登录状态检查 - Token: ${token ? '存在' : '不存在'}, 用户: ${user ? JSON.parse(user).username : '未登录'}`);
|
||||
}
|
||||
|
||||
function visitLoginPage() {
|
||||
addResult('正在访问登录页面...');
|
||||
window.open('http://localhost:5300/#/login', '_blank');
|
||||
}
|
||||
|
||||
function visitUsersPage() {
|
||||
addResult('正在访问用户管理页面...');
|
||||
window.open('http://localhost:5300/#/users', '_blank');
|
||||
}
|
||||
|
||||
function visitDashboard() {
|
||||
addResult('正在访问仪表盘...');
|
||||
window.open('http://localhost:5300/#/dashboard', '_blank');
|
||||
}
|
||||
|
||||
// 页面加载时检查状态
|
||||
window.onload = function() {
|
||||
checkLoginState();
|
||||
addResult('测试页面已加载,请按照测试步骤进行操作');
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
227
frontend/public/test-users-display.html
Normal file
227
frontend/public/test-users-display.html
Normal file
@@ -0,0 +1,227 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>用户数据显示测试</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
max-width: 1000px;
|
||||
margin: 50px auto;
|
||||
padding: 20px;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.container {
|
||||
background: white;
|
||||
padding: 30px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||
}
|
||||
.test-item {
|
||||
margin: 20px 0;
|
||||
padding: 15px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.success {
|
||||
background-color: #f6ffed;
|
||||
border-color: #b7eb8f;
|
||||
}
|
||||
.error {
|
||||
background-color: #fff2f0;
|
||||
border-color: #ffccc7;
|
||||
}
|
||||
button {
|
||||
background-color: #1890ff;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 8px 16px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
margin: 5px;
|
||||
}
|
||||
button:hover {
|
||||
background-color: #40a9ff;
|
||||
}
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-top: 15px;
|
||||
}
|
||||
th, td {
|
||||
border: 1px solid #ddd;
|
||||
padding: 8px;
|
||||
text-align: left;
|
||||
}
|
||||
th {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.json-display {
|
||||
background: #f8f8f8;
|
||||
padding: 10px;
|
||||
border-radius: 4px;
|
||||
font-family: monospace;
|
||||
white-space: pre-wrap;
|
||||
max-height: 300px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>用户数据显示测试</h1>
|
||||
|
||||
<div class="test-item">
|
||||
<h3>测试步骤:</h3>
|
||||
<ol>
|
||||
<li>点击"测试API调用"按钮</li>
|
||||
<li>查看API响应数据</li>
|
||||
<li>点击"访问用户管理页面"查看前端显示</li>
|
||||
<li>对比数据是否一致</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<div class="test-item">
|
||||
<h3>API测试:</h3>
|
||||
<button onclick="testAPI()">测试API调用</button>
|
||||
<button onclick="visitUsersPage()">访问用户管理页面</button>
|
||||
<button onclick="checkLocalStorage()">检查本地存储</button>
|
||||
</div>
|
||||
|
||||
<div class="test-item">
|
||||
<h3>API响应数据:</h3>
|
||||
<div id="api-response" class="json-display">点击"测试API调用"查看数据...</div>
|
||||
</div>
|
||||
|
||||
<div class="test-item">
|
||||
<h3>用户数据表格:</h3>
|
||||
<div id="users-table">暂无数据</div>
|
||||
</div>
|
||||
|
||||
<div class="test-item">
|
||||
<h3>测试结果:</h3>
|
||||
<div id="test-results"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function addResult(message, isSuccess = true) {
|
||||
const results = document.getElementById('test-results');
|
||||
const div = document.createElement('div');
|
||||
div.className = isSuccess ? 'success' : 'error';
|
||||
div.style.margin = '10px 0';
|
||||
div.style.padding = '10px';
|
||||
div.style.borderRadius = '4px';
|
||||
div.innerHTML = `<strong>${new Date().toLocaleTimeString()}</strong>: ${message}`;
|
||||
results.appendChild(div);
|
||||
}
|
||||
|
||||
async function testAPI() {
|
||||
try {
|
||||
addResult('正在调用用户API...');
|
||||
|
||||
const token = localStorage.getItem('token');
|
||||
if (!token) {
|
||||
addResult('未找到token,请先登录', false);
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await fetch('http://localhost:5350/api/users', {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
// 显示API响应
|
||||
document.getElementById('api-response').textContent = JSON.stringify(data, null, 2);
|
||||
|
||||
// 创建用户表格
|
||||
if (data.success && data.data) {
|
||||
createUsersTable(data.data);
|
||||
addResult(`API调用成功,获取到 ${data.data.length} 个用户`);
|
||||
} else {
|
||||
addResult('API响应格式异常', false);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
addResult(`API调用失败: ${error.message}`, false);
|
||||
document.getElementById('api-response').textContent = `错误: ${error.message}`;
|
||||
}
|
||||
}
|
||||
|
||||
function createUsersTable(users) {
|
||||
const tableContainer = document.getElementById('users-table');
|
||||
|
||||
if (!users || users.length === 0) {
|
||||
tableContainer.innerHTML = '<p>没有用户数据</p>';
|
||||
return;
|
||||
}
|
||||
|
||||
let tableHTML = `
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>用户名</th>
|
||||
<th>邮箱</th>
|
||||
<th>角色</th>
|
||||
<th>状态</th>
|
||||
<th>创建时间</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
`;
|
||||
|
||||
users.forEach(user => {
|
||||
tableHTML += `
|
||||
<tr>
|
||||
<td>${user.id}</td>
|
||||
<td>${user.username}</td>
|
||||
<td>${user.email}</td>
|
||||
<td>${user.role || '未知'}</td>
|
||||
<td>${user.status || '未知'}</td>
|
||||
<td>${user.created_at ? new Date(user.created_at).toLocaleString('zh-CN') : '未知'}</td>
|
||||
</tr>
|
||||
`;
|
||||
});
|
||||
|
||||
tableHTML += `
|
||||
</tbody>
|
||||
</table>
|
||||
`;
|
||||
|
||||
tableContainer.innerHTML = tableHTML;
|
||||
}
|
||||
|
||||
function visitUsersPage() {
|
||||
addResult('正在打开用户管理页面...');
|
||||
window.open('http://localhost:5300/#/users', '_blank');
|
||||
}
|
||||
|
||||
function checkLocalStorage() {
|
||||
const token = localStorage.getItem('token');
|
||||
const user = localStorage.getItem('user');
|
||||
|
||||
addResult(`Token: ${token ? '存在' : '不存在'}, 用户信息: ${user ? '存在' : '不存在'}`);
|
||||
|
||||
if (token) {
|
||||
addResult('Token内容: ' + token.substring(0, 50) + '...');
|
||||
}
|
||||
}
|
||||
|
||||
// 页面加载时检查登录状态
|
||||
window.onload = function() {
|
||||
checkLocalStorage();
|
||||
addResult('测试页面已加载,请按照测试步骤进行操作');
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user