一个界面照着豆包抠的 AI 助手。主力是安卓端,完全离线自主:不依赖电脑、 不需要另外装 Termux。 安卓端 - 原生 Jetpack Compose,7 个页面,配色/圆角/间距对着真机截图量出来的 - 完整动效:抽屉滑入、页面切换、气泡淡入上移、面板底部升起、typing 三点、按钮回弹 - 内置 Termux:bash/apt/pkg 388 个命令、真 pty 终端; pty 不可用的 ROM 上自动降级成命令控制台 - APK 内嵌 CPython 3.13(Chaquopy),AI 内核跑在手机上 - 设备能力:定位 / 陀螺仪 / 加速度计 / 光线 / 电量 / 剪贴板 - 语音:朗读 + 语音输入,火山豆包音色 / OpenAI 兼容 / 设备自带三级引擎 AI 能力 - 10 家 OpenAI 兼容提供商:方舟 / OpenAI / DeepSeek / Kimi / 智谱 / 通义 / 硅基流动 / OpenRouter / 本地 Ollama / 自定义 - 思考强度按各家支持情况发不同字段(thinking / reasoning_effort / 不发), 认不出来的一律不发,避免给不支持的厂商发字段直接 400 - MCP 三种传输(http / stdio / inproc)、工具热加载、文件上传、权限模式 跨端 - 安卓走原生 Compose,Web / Windows 走 Lynx - Node 与 Python 两份内核接口逐字段一致,关键路径都有对拍脚本 自检脚本(都不需要真 Key) - verify-phone.mjs 设备端 24 项验收 - verify-speech.mjs 语音链路 31 项,两份内核各跑一遍 - parity-thinking.mjs 思考强度映射对拍 - probe-settings-wipe.mjs 设置防清空攻击测试 - mock-llm.mjs 假的 OpenAI + 火山语音服务 许可 MIT;第三方组件(Termux Apache-2.0、Chaquopy、Compose、LynxJS、Electron) 的授权见 LICENSE。
228 lines
6.7 KiB
HTML
228 lines
6.7 KiB
HTML
<!doctype html>
|
||
<html lang="zh-CN">
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
|
||
<title>豆包 · LynxJS 复刻</title>
|
||
<link rel="stylesheet" href="/static/css/client.css" />
|
||
<style>
|
||
html,
|
||
body {
|
||
margin: 0;
|
||
padding: 0;
|
||
height: 100%;
|
||
background: radial-gradient(120% 120% at 50% 0%, #23262f 0%, #0e1014 60%);
|
||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
|
||
'Microsoft YaHei', sans-serif;
|
||
-webkit-font-smoothing: antialiased;
|
||
}
|
||
.stage {
|
||
height: 100%;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
gap: 28px;
|
||
}
|
||
.phone {
|
||
position: relative;
|
||
width: 390px;
|
||
height: 844px;
|
||
border-radius: 42px;
|
||
background: #fff;
|
||
overflow: hidden;
|
||
box-shadow: 0 30px 70px rgba(0, 0, 0, 0.6), 0 0 0 10px #1b1e25,
|
||
0 0 0 11px #33373f;
|
||
}
|
||
.phone > lynx-view {
|
||
display: block;
|
||
width: 100%;
|
||
height: 100%;
|
||
}
|
||
.side {
|
||
color: #9aa3b2;
|
||
font-size: 13px;
|
||
line-height: 1.9;
|
||
max-width: 280px;
|
||
}
|
||
.side h1 {
|
||
font-size: 17px;
|
||
color: #e8ecf3;
|
||
margin: 0 0 10px;
|
||
font-weight: 600;
|
||
}
|
||
.side code {
|
||
background: #1b1f27;
|
||
padding: 1px 5px;
|
||
border-radius: 4px;
|
||
color: #9fd0ff;
|
||
}
|
||
.side button {
|
||
margin-top: 12px;
|
||
background: #2b7bff;
|
||
color: #fff;
|
||
border: 0;
|
||
border-radius: 10px;
|
||
padding: 9px 14px;
|
||
font-size: 13px;
|
||
cursor: pointer;
|
||
}
|
||
.side .tip {
|
||
margin-top: 8px;
|
||
color: #6b7482;
|
||
font-size: 12px;
|
||
}
|
||
@media (max-width: 900px) {
|
||
.side {
|
||
display: none;
|
||
}
|
||
}
|
||
@media (max-width: 460px), (max-height: 880px) {
|
||
.phone {
|
||
width: 100vw;
|
||
height: 100vh;
|
||
border-radius: 0;
|
||
box-shadow: none;
|
||
}
|
||
}
|
||
/* 桌面客户端模式:?frame=0 —— 去掉手机外壳,铺满窗口 */
|
||
html.frameless .stage {
|
||
display: block;
|
||
}
|
||
html.frameless .phone {
|
||
width: 100vw;
|
||
height: 100vh;
|
||
border-radius: 0;
|
||
box-shadow: none;
|
||
}
|
||
html.frameless .side {
|
||
display: none;
|
||
}
|
||
/* 拖拽上传遮罩 */
|
||
#drop-mask {
|
||
position: fixed;
|
||
inset: 0;
|
||
display: none;
|
||
align-items: center;
|
||
justify-content: center;
|
||
background: rgba(43, 123, 255, 0.14);
|
||
border: 3px dashed #2b7bff;
|
||
box-sizing: border-box;
|
||
color: #2b7bff;
|
||
font-size: 16px;
|
||
font-weight: 600;
|
||
z-index: 9999;
|
||
pointer-events: none;
|
||
}
|
||
#drop-mask.on {
|
||
display: flex;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="stage">
|
||
<div class="phone">
|
||
<lynx-view url="/main.web.bundle"></lynx-view>
|
||
</div>
|
||
<aside class="side">
|
||
<h1>豆包 · LynxJS 复刻</h1>
|
||
界面由 <code>ReactLynx</code> 渲染,跑在 <code>@lynx-js/web-core</code> 上。<br />
|
||
AI 内核在 <code>/api</code>:火山方舟 / OpenAI + MCP + Python 工具。<br />
|
||
左上角 <code>☰</code> 是会话抽屉,右上角 <code>✎</code> 是内核设置。
|
||
<div>
|
||
<button id="pick">选择文件发给豆包</button>
|
||
<div class="tip">也可以直接把文件拖进这个窗口。</div>
|
||
</div>
|
||
</aside>
|
||
</div>
|
||
<div id="drop-mask">松手即可发送文件</div>
|
||
<input id="file-input" type="file" multiple style="display: none" />
|
||
|
||
<script>
|
||
// ?page=drawer|profile|settings|skills|agents 指定首屏;?frame=0 进桌面客户端模式
|
||
(function () {
|
||
var params = new URLSearchParams(location.search);
|
||
if (params.get('frame') === '0') {
|
||
document.documentElement.classList.add('frameless');
|
||
}
|
||
var wanted = params.get('page');
|
||
if (wanted) {
|
||
document
|
||
.querySelector('lynx-view')
|
||
.setAttribute('global-props', JSON.stringify({ initialPage: wanted }));
|
||
}
|
||
})();
|
||
|
||
/**
|
||
* 文件上传:浏览器和桌面版共用同一条路 ——
|
||
* 传到 /api/upload 并标记为 pending,Lynx 界面轮询到之后自动挂到输入框上。
|
||
*/
|
||
(function () {
|
||
var mask = document.getElementById('drop-mask');
|
||
|
||
function readAsDataUrl(file) {
|
||
return new Promise(function (resolve, reject) {
|
||
var reader = new FileReader();
|
||
reader.onload = function () {
|
||
resolve(reader.result);
|
||
};
|
||
reader.onerror = reject;
|
||
reader.readAsDataURL(file);
|
||
});
|
||
}
|
||
|
||
async function upload(files) {
|
||
for (var i = 0; i < files.length; i += 1) {
|
||
var file = files[i];
|
||
try {
|
||
var dataUrl = await readAsDataUrl(file);
|
||
await fetch('/api/upload', {
|
||
method: 'POST',
|
||
headers: { 'Content-Type': 'application/json' },
|
||
body: JSON.stringify({ name: file.name, dataUrl: dataUrl, pending: true }),
|
||
});
|
||
} catch (err) {
|
||
console.error('[upload] 失败', file.name, err);
|
||
}
|
||
}
|
||
}
|
||
|
||
var depth = 0;
|
||
window.addEventListener('dragenter', function (e) {
|
||
e.preventDefault();
|
||
depth += 1;
|
||
mask.classList.add('on');
|
||
});
|
||
window.addEventListener('dragover', function (e) {
|
||
e.preventDefault();
|
||
});
|
||
window.addEventListener('dragleave', function (e) {
|
||
e.preventDefault();
|
||
depth = Math.max(0, depth - 1);
|
||
if (depth === 0) mask.classList.remove('on');
|
||
});
|
||
window.addEventListener('drop', function (e) {
|
||
e.preventDefault();
|
||
depth = 0;
|
||
mask.classList.remove('on');
|
||
if (e.dataTransfer && e.dataTransfer.files && e.dataTransfer.files.length) {
|
||
upload(e.dataTransfer.files);
|
||
}
|
||
});
|
||
|
||
var pick = document.getElementById('pick');
|
||
var input = document.getElementById('file-input');
|
||
if (pick && input) {
|
||
pick.addEventListener('click', function () {
|
||
input.click();
|
||
});
|
||
input.addEventListener('change', function () {
|
||
if (input.files && input.files.length) upload(input.files);
|
||
input.value = '';
|
||
});
|
||
}
|
||
})();
|
||
</script>
|
||
<script type="module" src="/static/js/client.js"></script>
|
||
</body>
|
||
</html>
|