-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
125 lines (110 loc) · 3.94 KB
/
Copy pathtest.html
File metadata and controls
125 lines (110 loc) · 3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>开发者模式 - Turn any website into a native app. No rewrite. Zero Rust. Just config</title>
<link rel="stylesheet" href="assets/css/test.css"/>
</head>
<body>
<div class="container">
<h1>🧪 CapShell 测试中心</h1>
<p class="subtitle">验证原生能力注入 & AI 网关集成</p>
<div class="card-grid">
<!-- 1. GPS 测试 -->
<div class="card" onclick="startGpsTracking()">
<span class="icon">📍</span>
<div class="title">
启用GPS定位
<br/>
(请查看控制台)
</div>
<div class="desc">实时获取经纬度、海拔</div>
<span class="badge">原生能力</span>
</div>
<div class="card" onclick="stopGpsTracking()">
<span class="icon">📍</span>
<div class="title">关闭GPS定位</div>
<div class="desc">停止获取经纬度、海拔</div>
<span class="badge">原生能力</span>
</div>
<!-- 2. 摄像头测试 -->
<div class="card" onclick="openCamera()">
<span class="icon">📷</span>
<div class="title">打开相机</div>
<div class="desc">拍照并返回 Base64 数据</div>
<span class="badge">原生能力</span>
</div>
<div class="card" onclick="closeCamera()">
<span class="icon">📷</span>
<div class="title">关闭相机</div>
<div class="desc">直接关闭,无数据返回</div>
<span class="badge">原生能力</span>
</div>
<!-- 3. ✨ OrcaRouter AI 入口 -->
<a href="llm.html" class="card" style="border-color: #2563eb44;">
<span class="icon">🤖</span>
<div class="title">OrcaRouter 大模型网关</div>
<div class="desc">DeepSeek V4 · 千问 · 腾讯混元</div>
<span class="badge" style="border-color:#2563eb;color:#60a5fa;">AI 就绪</span>
</a>
</div>
<div class="footer">
<a href="https://github.com/TommysLee/CapShell" target="_blank" rel="noopener">GitHub</a>
· 由 <a href="https://www.orcarouter.ai/ref/ref_1cb54739ece31bb6a2d1" target="_blank" rel="noopener">OrcaRouter</a> 提供 AI 能力
</div>
</div>
<h1 class="tips">
请在 <span>config.json</span> 中配置应用URL。
<a href="https://github.com/TommysLee/CapShell/blob/main/src-tauri/default_config.json" target="_blank" rel="noopener">点击查看示例</a>
</h1>
<!-- 显示区域 -->
<div>
<img id="img" style="width: 500px"/>
</div>
<ul id="gps-list">
</ul>
<script src="assets/js/sdk.js"></script>
<script>
const imgEl = document.getElementById("img");
const gpsEl = document.getElementById("gps-list");
// 开启GPS实时定位
function startGpsTracking() {
Shell.startGpsTracking(position => {
const gps_data = JSON.stringify(position);
console.log("子页面:实时GPS", position, '\n', gps_data);
appendEl(gps_data);
}, err => {
console.log("子页面:GPS错误:", err);
})
appendEl('GPS 实时定位已开启');
}
// 关闭GPS实时定位
function stopGpsTracking() {
Shell.stopGpsTracking();
appendEl('GPS 实时定位 已关闭');
}
// 打开相机
function openCamera() {
Shell.openCamera((result) => {
console.log("子页面", result.type, " Callback: ", result);
if (result.type === 'CAMERA_RESULT') {
result.image && (imgEl.src = result.image);
}
})
}
// 关闭相机
function closeCamera() {
Shell.closeCamera((result) => {
console.log("子页面 closeCamera Callback: ", result);
})
}
// 工具函数
function appendEl(content) {
const el = document.createElement('li');
el.innerHTML = content;
gpsEl.appendChild(el);
}
</script>
</body>
</html>