smart-home/test_url_scheme.html
2026-02-26 09:16:34 +08:00

92 lines
2.8 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>URL Scheme 测试</title>
<style>
body {
font-family: Arial;
margin: 20px;
background: #f5f5f5;
}
.container {
max-width: 400px;
margin: 0 auto;
background: white;
padding: 20px;
border-radius: 8px;
}
button {
width: 100%;
padding: 15px;
margin: 10px 0;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
}
.test-btn {
background: #007bff;
color: white;
}
.test-btn:hover {
background: #0056b3;
}
</style>
</head>
<body>
<div class="container">
<h1>URL Scheme 测试</h1>
<p>这个页面用于测试从外部浏览器返回APP的功能</p>
<button class="test-btn" onclick="testUrlScheme()">
🔙 测试返回APP
</button>
<button class="test-btn" onclick="testWindowClose()">
❌ 测试关闭窗口
</button>
<button class="test-btn" onclick="testHistoryBack()">
⬅️ 测试返回上一页
</button>
<div id="result" style="margin-top: 20px; padding: 10px; background: #f8f9fa; border-radius: 4px;"></div>
</div>
<script>
function testUrlScheme() {
document.getElementById('result').innerHTML = '尝试使用URL Scheme返回APP...';
try {
window.location.href = 'archesens://config-complete';
} catch (e) {
document.getElementById('result').innerHTML = '❌ URL Scheme失败: ' + e.message;
}
}
function testWindowClose() {
document.getElementById('result').innerHTML = '尝试关闭窗口...';
try {
window.close();
} catch (e) {
document.getElementById('result').innerHTML = '❌ 关闭窗口失败: ' + e.message;
}
}
function testHistoryBack() {
document.getElementById('result').innerHTML = '尝试返回上一页...';
try {
if (history.length > 1) {
history.back();
} else {
document.getElementById('result').innerHTML = '❌ 没有上一页可返回';
}
} catch (e) {
document.getElementById('result').innerHTML = '❌ 返回上一页失败: ' + e.message;
}
}
</script>
</body>
</html>