豆包复刻:原生安卓(Compose + 内嵌 Termux)+ Web / Windows
一个界面照着豆包抠的 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。
1
app/.npmrc
Normal file
@@ -0,0 +1 @@
|
||||
registry=https://registry.npmjs.org/
|
||||
27
app/lynx.config.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin';
|
||||
import { defineConfig } from '@lynx-js/rspeedy';
|
||||
import { pluginTypeCheck } from '@rsbuild/plugin-type-check';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [pluginReactLynx(), pluginTypeCheck()],
|
||||
// web 环境用于在浏览器里跑(Lynx for Web),lynx 环境用于 LynxExplorer / 真机
|
||||
environments: {
|
||||
web: {},
|
||||
lynx: {
|
||||
output: {
|
||||
// 原生端没有「URL 前缀」概念,data URI 也不渲染(实测),
|
||||
// 所以把图片资源前缀指到 APK 的 assets:Fresco 的 LocalAssetFetchProducer 认这个 scheme。
|
||||
assetPrefix: 'asset:///',
|
||||
},
|
||||
},
|
||||
},
|
||||
server: {
|
||||
port: 3210,
|
||||
},
|
||||
output: {
|
||||
filenameHash: false,
|
||||
distPath: {
|
||||
root: 'dist',
|
||||
},
|
||||
},
|
||||
});
|
||||
6543
app/package-lock.json
generated
Normal file
25
app/package.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "doubao-lynx-app",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "豆包界面复刻 - ReactLynx (LynxJS) 客户端",
|
||||
"scripts": {
|
||||
"dev": "rspeedy dev",
|
||||
"build": "rspeedy build",
|
||||
"preview": "rspeedy preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@lynx-js/react": "^0.126.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@lynx-js/react-rsbuild-plugin": "^0.20.3",
|
||||
"@lynx-js/rspeedy": "^0.18.0",
|
||||
"@lynx-js/types": "^4.3.0",
|
||||
"@rsbuild/plugin-type-check": "^1.6.0",
|
||||
"typescript": "^5.9.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^20.19.0 || >=22.12.0"
|
||||
}
|
||||
}
|
||||
613
app/src/App.tsx
Normal file
@@ -0,0 +1,613 @@
|
||||
import { useCallback, useEffect, useRef, useState } from '@lynx-js/react';
|
||||
|
||||
import type { Agent, AppState, Attachment, ChatMessage, Security, StreamEvent } from './types.js';
|
||||
import { api, streamChat } from './api.js';
|
||||
import { cv } from './lynx-input.js';
|
||||
import { ChatPage } from './pages/Chat.js';
|
||||
import { Drawer } from './pages/Drawer.js';
|
||||
import { ProfilePage } from './pages/Profile.js';
|
||||
import { SettingsPage } from './pages/Settings.js';
|
||||
import { SkillsPage } from './pages/Skills.js';
|
||||
import { AgentsPage } from './pages/Agents.js';
|
||||
import { ModelPicker, modelRowLabel } from './pages/ModelPicker.js';
|
||||
import { TerminalPage } from './pages/Terminal.js';
|
||||
import './app.css';
|
||||
|
||||
type PageName = 'chat' | 'profile' | 'settings' | 'skills' | 'agents' | 'terminal';
|
||||
|
||||
const PAGES: PageName[] = ['chat', 'profile', 'settings', 'skills', 'agents', 'terminal'];
|
||||
|
||||
/** 宿主页可以用 global-props 指定首屏,方便截图/演示:/index.html?page=drawer */
|
||||
function bootPage(): { page: PageName; drawer: boolean } {
|
||||
const lynxGlobal = (globalThis as unknown as { lynx?: { __globalProps?: { initialPage?: string } } }).lynx;
|
||||
const wanted = lynxGlobal?.__globalProps?.initialPage;
|
||||
if (wanted === 'drawer') return { page: 'chat', drawer: true };
|
||||
if (wanted && (PAGES as string[]).includes(wanted)) return { page: wanted as PageName, drawer: false };
|
||||
return { page: 'chat', drawer: false };
|
||||
}
|
||||
|
||||
/** 给最后一条助手消息打补丁(流式输出用) */
|
||||
function patchLastAssistant(list: ChatMessage[], fn: (msg: ChatMessage) => ChatMessage): ChatMessage[] {
|
||||
const next = list.slice();
|
||||
for (let i = next.length - 1; i >= 0; i -= 1) {
|
||||
if (next[i].role === 'assistant') {
|
||||
next[i] = fn(next[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return next;
|
||||
}
|
||||
|
||||
export function App() {
|
||||
const boot = bootPage();
|
||||
const [state, setState] = useState<AppState | null>(null);
|
||||
const [page, setPage] = useState<PageName>(boot.page);
|
||||
const [drawerOpen, setDrawerOpen] = useState(boot.drawer);
|
||||
/** 抽屉里「模型」那一栏点开的面板 */
|
||||
const [modelPickerOpen, setModelPickerOpen] = useState(false);
|
||||
const [activeId, setActiveId] = useState('c_main');
|
||||
const [messages, setMessages] = useState<ChatMessage[]>([]);
|
||||
const [draft, setDraft] = useState('');
|
||||
const [attachments, setAttachments] = useState<Attachment[]>([]);
|
||||
const [streaming, setStreaming] = useState(false);
|
||||
const [memoryEnabled, setMemoryEnabled] = useState(true);
|
||||
const [scrollAnchor, setScrollAnchor] = useState('');
|
||||
const [scrollSignal, setScrollSignal] = useState(0);
|
||||
const [bootError, setBootError] = useState('');
|
||||
const [copyHint, setCopyHint] = useState('');
|
||||
const [apiDraft, setApiDraft] = useState('');
|
||||
/** 展开的思维链(按消息下标) */
|
||||
const [openReasoning, setOpenReasoning] = useState<Record<number, boolean>>({});
|
||||
const toggleReasoning = useCallback((index: number) => {
|
||||
setOpenReasoning((prev) => ({ ...prev, [index]: !prev[index] }));
|
||||
}, []);
|
||||
/** 正在看「思考过程」的消息下标 */
|
||||
const [thinkIndex, setThinkIndex] = useState<number | null>(null);
|
||||
/** 正在朗读第几条;-1 = 没在念。用来把那一行的喇叭图标点亮 */
|
||||
const [speakingIndex, setSpeakingIndex] = useState(-1);
|
||||
const audioRef = useRef<{ pause: () => void } | null>(null);
|
||||
/** shell 实际走哪条通道:termux / toybox / cmd / 未知 */
|
||||
const [shellChannel, setShellChannel] = useState('');
|
||||
|
||||
/** 问内核:shell 现在实际走哪条通道(Termux / toybox / cmd / sh) */
|
||||
const fallbackShellKind = state?.shellKind || 'sh';
|
||||
const refreshShellChannel = useCallback(async () => {
|
||||
try {
|
||||
// 直接跑一条最小命令看返回里的 via —— 比问"装没装 Termux"准,
|
||||
// 因为装了不等于开了 allow-external-apps
|
||||
const probe = await api.runTool('shell', { command: 'echo __doubao_probe__' });
|
||||
const via = (probe.result as { via?: string } | undefined)?.via || '';
|
||||
setShellChannel(via || fallbackShellKind);
|
||||
} catch {
|
||||
setShellChannel(fallbackShellKind);
|
||||
}
|
||||
}, [fallbackShellKind]);
|
||||
|
||||
// 必须先于下面那些 useCallback 计算出来:它们的依赖数组会在渲染期读它
|
||||
const activeAgent = state
|
||||
? (state.agents.find((a) => a.id === state.settings.activeAgentId) || state.agents[0] || null)
|
||||
: null;
|
||||
|
||||
/** 滚到底:每次 +1,scroll-top 用一个永远超过最大值的数就会被夹到底部 */
|
||||
const pinBottom = useCallback(() => {
|
||||
setScrollSignal((n) => n + 1);
|
||||
}, []);
|
||||
|
||||
const refresh = useCallback(async () => {
|
||||
try {
|
||||
const next = await api.state();
|
||||
setState(next);
|
||||
setBootError('');
|
||||
return next;
|
||||
} catch (err) {
|
||||
setBootError((err as Error).message);
|
||||
return null;
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
refresh();
|
||||
}, [refresh]);
|
||||
|
||||
/** 宿主页拖拽进来的文件:轮询待接入队列 */
|
||||
useEffect(() => {
|
||||
const timer = setInterval(async () => {
|
||||
try {
|
||||
const res = await api.pendingUploads();
|
||||
if (res.files && res.files.length) {
|
||||
setAttachments((prev) => {
|
||||
const known = new Set(prev.map((f) => f.id));
|
||||
return [...prev, ...res.files.filter((f) => !known.has(f.id))];
|
||||
});
|
||||
setPage('chat');
|
||||
pinBottom();
|
||||
}
|
||||
} catch {
|
||||
/* 内核没起来就忽略 */
|
||||
}
|
||||
}, 1500);
|
||||
return () => clearInterval(timer);
|
||||
}, [pinBottom]);
|
||||
|
||||
const showHint = useCallback((text: string) => {
|
||||
setCopyHint(text);
|
||||
setTimeout(() => setCopyHint(''), 1800);
|
||||
}, []);
|
||||
|
||||
const loadConversation = useCallback(async (id: string) => {
|
||||
setActiveId(id);
|
||||
setDrawerOpen(false);
|
||||
setPage('chat');
|
||||
try {
|
||||
const { conversation } = await api.conversation(id);
|
||||
setMessages(
|
||||
(conversation.messages || []).map((m) => ({
|
||||
role: m.role === 'user' ? 'user' : 'assistant',
|
||||
content: m.content,
|
||||
// 思维链要一起读回来,否则刷新后「思考过程」是空的
|
||||
reasoning: (m as unknown as { reasoning?: string }).reasoning || '',
|
||||
attachments: (m as unknown as { attachments?: Attachment[] }).attachments || [],
|
||||
})) as ChatMessage[],
|
||||
);
|
||||
} catch {
|
||||
setMessages([]);
|
||||
}
|
||||
pinBottom();
|
||||
}, [pinBottom]);
|
||||
|
||||
const newTopic = useCallback(async () => {
|
||||
try {
|
||||
const { conversation } = await api.createConversation('新对话');
|
||||
setState((prev) => (prev ? { ...prev, conversations: [conversation, ...prev.conversations] } : prev));
|
||||
setActiveId(conversation.id);
|
||||
setMessages([]);
|
||||
setAttachments([]);
|
||||
setDrawerOpen(false);
|
||||
setPage('chat');
|
||||
pinBottom();
|
||||
} catch {
|
||||
/* 离线时也能继续用界面 */
|
||||
}
|
||||
}, [pinBottom]);
|
||||
|
||||
const deleteConversation = useCallback(async (conv: { id: string; title: string }) => {
|
||||
try {
|
||||
await api.deleteConversation(conv.id);
|
||||
const next = await refresh();
|
||||
if (conv.id === activeId) {
|
||||
const fallback = next?.conversations?.[0];
|
||||
if (fallback) await loadConversation(fallback.id);
|
||||
}
|
||||
showHint(`已删除「${conv.title}」`);
|
||||
} catch (err) {
|
||||
showHint(`删除失败:${(err as Error).message}`);
|
||||
}
|
||||
}, [activeId, refresh, loadConversation, showHint]);
|
||||
|
||||
/** 真正发消息;regenerate 时复用同一段逻辑 */
|
||||
const runChat = useCallback(async (text: string, files: Attachment[], history: ChatMessage[]) => {
|
||||
setStreaming(true);
|
||||
pinBottom();
|
||||
try {
|
||||
await streamChat(
|
||||
{
|
||||
conversationId: activeId,
|
||||
message: text,
|
||||
history: history.filter((m) => m.content).map((m) => ({ role: m.role, content: m.content })),
|
||||
attachments: files,
|
||||
agentId: activeAgent?.id,
|
||||
},
|
||||
(event: StreamEvent) => {
|
||||
if (event.type === 'delta') {
|
||||
const chunk = event.text;
|
||||
setMessages((prev) => patchLastAssistant(prev, (m) => ({ ...m, content: m.content + chunk })));
|
||||
} else if (event.type === 'reasoning') {
|
||||
const chunk = event.text;
|
||||
setMessages((prev) =>
|
||||
patchLastAssistant(prev, (m) => ({ ...m, reasoning: (m.reasoning || '') + chunk }))
|
||||
);
|
||||
} else if (event.type === 'tool_call') {
|
||||
setMessages((prev) =>
|
||||
patchLastAssistant(prev, (m) => ({
|
||||
...m,
|
||||
toolTrace: [...(m.toolTrace || []), { id: event.id, name: event.name, args: event.args }],
|
||||
}))
|
||||
);
|
||||
} else if (event.type === 'tool_result') {
|
||||
setMessages((prev) =>
|
||||
patchLastAssistant(prev, (m) => ({
|
||||
...m,
|
||||
toolTrace: (m.toolTrace || []).map((t) =>
|
||||
t.id === event.id ? { ...t, ok: event.ok, result: event.result } : t
|
||||
),
|
||||
}))
|
||||
);
|
||||
} else if (event.type === 'error') {
|
||||
// API 报错必须看得见:气泡里写原因,顶部再弹一条可操作的建议
|
||||
const hint = event.hint ? `|${event.hint}` : '';
|
||||
setMessages((prev) =>
|
||||
patchLastAssistant(prev, (m) => ({
|
||||
...m,
|
||||
error: true,
|
||||
content: m.content || `出错了:${event.message}${hint}`,
|
||||
}))
|
||||
);
|
||||
showHint(`出错了:${event.message}${hint}`);
|
||||
} else if (event.type === 'saved') {
|
||||
refresh();
|
||||
}
|
||||
pinBottom();
|
||||
},
|
||||
);
|
||||
} catch (err) {
|
||||
const message = (err as Error).message || String(err);
|
||||
setMessages((prev) =>
|
||||
patchLastAssistant(prev, (m) => ({
|
||||
...m,
|
||||
error: true,
|
||||
content: m.content || `连不上内核:${message}`,
|
||||
}))
|
||||
);
|
||||
showHint(`连不上内核:${message}`);
|
||||
} finally {
|
||||
setStreaming(false);
|
||||
// 流式结束后再钉一次底部,否则操作栏会停在可视区外
|
||||
pinBottom();
|
||||
}
|
||||
}, [activeId, refresh, activeAgent, pinBottom, showHint]);
|
||||
|
||||
const send = useCallback(async () => {
|
||||
const text = draft.trim();
|
||||
if ((!text && attachments.length === 0) || streaming) return;
|
||||
const files = attachments;
|
||||
const history = messages;
|
||||
|
||||
setDraft('');
|
||||
setAttachments([]);
|
||||
setMessages((prev) => [
|
||||
...prev,
|
||||
{ role: 'user', content: text || `(发送了 ${files.length} 个附件)`, attachments: files },
|
||||
{ role: 'assistant', content: '' },
|
||||
]);
|
||||
|
||||
await runChat(text, files, history);
|
||||
}, [draft, attachments, streaming, messages, runChat]);
|
||||
|
||||
/** 重新生成:撤掉最后一条回答,用同样的输入再跑一次 */
|
||||
const regenerate = useCallback(async () => {
|
||||
if (streaming) return;
|
||||
const lastUserIndex = [...messages].reverse().findIndex((m) => m.role === 'user');
|
||||
if (lastUserIndex < 0) return;
|
||||
const index = messages.length - 1 - lastUserIndex;
|
||||
const userMsg = messages[index];
|
||||
const history = messages.slice(0, index);
|
||||
|
||||
setMessages([...history, userMsg, { role: 'assistant', content: '' }]);
|
||||
await runChat(userMsg.content, userMsg.attachments || [], history);
|
||||
}, [messages, streaming, runChat]);
|
||||
|
||||
const feedback = useCallback((index: number, value: 'up' | 'down') => {
|
||||
setMessages((prev) =>
|
||||
prev.map((msg, i) => (i === index ? { ...msg, feedback: msg.feedback === value ? null : value } : msg))
|
||||
);
|
||||
}, []);
|
||||
|
||||
const copy = useCallback(async (text: string) => { try {
|
||||
const nav = globalThis as unknown as { navigator?: { clipboard?: { writeText?: (t: string) => Promise<void> } } };
|
||||
if (nav.navigator?.clipboard?.writeText) {
|
||||
await nav.navigator.clipboard.writeText(text);
|
||||
} else {
|
||||
await api.clipboard(text);
|
||||
}
|
||||
showHint('已复制');
|
||||
} catch {
|
||||
try {
|
||||
await api.clipboard(text);
|
||||
showHint('已复制');
|
||||
} catch {
|
||||
showHint('复制失败');
|
||||
}
|
||||
}
|
||||
}, [showHint]);
|
||||
|
||||
/**
|
||||
* 朗读。
|
||||
*
|
||||
* 两条路:内核说 engine='system' 就用浏览器自带的 speechSynthesis(不联网);
|
||||
* 否则内核已经把音频合成好了,base64 直接塞进 data URL 交给 Audio 播。
|
||||
*
|
||||
* 为什么每次都 new Audio:data URL 是一次性的,复用同一个元素在第二次播时
|
||||
* 有些浏览器会不触发 loadeddata;新建一个最省心,代价只是几个对象。
|
||||
*/
|
||||
const speak = useCallback(async (text: string, index: number) => {
|
||||
stopSpeaking();
|
||||
setSpeakingIndex(index);
|
||||
try {
|
||||
const res = await api.speak(text);
|
||||
if (!res.ok) {
|
||||
showHint(`朗读失败:${res.error || '未知原因'}`);
|
||||
setSpeakingIndex(-1);
|
||||
return;
|
||||
}
|
||||
const g = globalThis as unknown as {
|
||||
speechSynthesis?: { speak: (u: unknown) => void; cancel: () => void };
|
||||
SpeechSynthesisUtterance?: new (t: string) => { lang: string; onend: () => void; onerror: () => void };
|
||||
Audio?: new (src: string) => {
|
||||
play: () => Promise<void>;
|
||||
pause: () => void;
|
||||
onended: () => void;
|
||||
onerror: () => void;
|
||||
};
|
||||
};
|
||||
if (res.engine === 'system' || !res.audio) {
|
||||
if (!g.speechSynthesis || !g.SpeechSynthesisUtterance) {
|
||||
showHint('这个环境没有系统朗读,请在设置里选云端音色');
|
||||
setSpeakingIndex(-1);
|
||||
return;
|
||||
}
|
||||
const u = new g.SpeechSynthesisUtterance(text);
|
||||
u.lang = 'zh-CN';
|
||||
u.onend = () => setSpeakingIndex(-1);
|
||||
u.onerror = () => setSpeakingIndex(-1);
|
||||
g.speechSynthesis.speak(u);
|
||||
} else {
|
||||
if (!g.Audio) {
|
||||
showHint('这个环境不能播放音频');
|
||||
setSpeakingIndex(-1);
|
||||
return;
|
||||
}
|
||||
const audio = new g.Audio(`data:${res.mime || 'audio/mpeg'};base64,${res.audio}`);
|
||||
audioRef.current = audio;
|
||||
audio.onended = () => setSpeakingIndex(-1);
|
||||
audio.onerror = () => {
|
||||
showHint('音频播放失败(格式可能不被支持)');
|
||||
setSpeakingIndex(-1);
|
||||
};
|
||||
await audio.play();
|
||||
}
|
||||
} catch (err) {
|
||||
showHint(`朗读失败:${(err as Error).message}`);
|
||||
setSpeakingIndex(-1);
|
||||
}
|
||||
}, [showHint]);
|
||||
|
||||
const stopSpeaking = useCallback(() => {
|
||||
const g = globalThis as unknown as { speechSynthesis?: { cancel: () => void } };
|
||||
try {
|
||||
g.speechSynthesis?.cancel();
|
||||
audioRef.current?.pause();
|
||||
} catch {
|
||||
/* 停不掉也无所谓,下面会把状态复位 */
|
||||
}
|
||||
audioRef.current = null;
|
||||
setSpeakingIndex(-1);
|
||||
}, []);
|
||||
|
||||
/** 选文件:桌面版走原生对话框,浏览器/手机端提示拖拽或走宿主页 */
|
||||
const pickFile = useCallback(async () => {
|
||||
try {
|
||||
const res = await api.pickFile();
|
||||
if (res.ok && res.files?.length) {
|
||||
setAttachments((prev) => {
|
||||
const known = new Set(prev.map((f) => f.id));
|
||||
return [...prev, ...res.files.filter((f) => !known.has(f.id))];
|
||||
});
|
||||
setPage('chat');
|
||||
pinBottom();
|
||||
} else if (res.error) {
|
||||
showHint('把文件拖到窗口里,或在电脑端选文件');
|
||||
}
|
||||
} catch {
|
||||
showHint('把文件拖到窗口里,或在电脑端选文件');
|
||||
}
|
||||
}, [showHint, pinBottom]);
|
||||
|
||||
const removeAttachment = useCallback((id: string) => {
|
||||
setAttachments((prev) => prev.filter((f) => f.id !== id));
|
||||
}, []);
|
||||
|
||||
const saveSettings = useCallback(async (patch: Record<string, unknown>) => {
|
||||
await api.saveSettings(patch);
|
||||
await refresh();
|
||||
}, [refresh]);
|
||||
|
||||
const saveSecurity = useCallback(async (security: Security) => {
|
||||
await api.saveSettings({ security });
|
||||
await refresh();
|
||||
}, [refresh]);
|
||||
|
||||
/**
|
||||
* 抽屉里「模型」那一栏:换模型 / 换思考强度。
|
||||
* 立即存盘并刷新,不关面板——这样用户能连着调两下看效果。
|
||||
*/
|
||||
const pickModel = useCallback(async (patch: Record<string, unknown>) => {
|
||||
try {
|
||||
await api.saveSettings(patch);
|
||||
await refresh();
|
||||
if (patch.model) showHint('已切换模型');
|
||||
else if (patch.thinkingLevel) showHint('已切换思考强度');
|
||||
} catch (err) {
|
||||
showHint(`切换失败:${(err as Error).message}`);
|
||||
}
|
||||
}, [refresh, showHint]);
|
||||
|
||||
const useAgent = useCallback(async (agent: Agent) => {
|
||||
await api.saveSettings({ activeAgentId: agent.id });
|
||||
await refresh();
|
||||
setPage('chat');
|
||||
showHint(`已切换到「${agent.name}」`);
|
||||
}, [refresh, showHint]);
|
||||
|
||||
if (!state) {
|
||||
return (
|
||||
<view className="page" style={{ alignItems: 'center', justifyContent: 'center', paddingLeft: '24px', paddingRight: '24px' }}>
|
||||
<text style={{ fontSize: '16px', color: '#1f2329', fontWeight: '600' }}>连不上 AI 内核</text>
|
||||
<text style={{ fontSize: '12px', color: '#8a8f99', marginTop: '8px', textAlign: 'center' }}>
|
||||
{bootError || '正在连接…'}
|
||||
{'\n'}内核跑在电脑上时,手机端要填电脑的局域网地址。
|
||||
</text>
|
||||
<input
|
||||
className="form-input"
|
||||
style={{ marginTop: '16px', width: '100%' }}
|
||||
placeholder="http://192.168.1.8:5199"
|
||||
{...cv(apiDraft)}
|
||||
bindinput={(e: { detail: { value: string } }) => setApiDraft(e.detail.value)}
|
||||
/>
|
||||
<view
|
||||
className="ghost-btn"
|
||||
style={{ marginTop: '12px' }}
|
||||
bindtap={async () => {
|
||||
const { setApiBase } = await import('./api.js');
|
||||
if (apiDraft.trim()) setApiBase(apiDraft.trim());
|
||||
setBootError('');
|
||||
await refresh();
|
||||
}}
|
||||
>
|
||||
<text className="ghost-btn-text">用这个地址重试</text>
|
||||
</view>
|
||||
<view className="ghost-btn" style={{ marginTop: '10px' }} bindtap={refresh}>
|
||||
<text className="ghost-btn-text">直接重试</text>
|
||||
</view>
|
||||
</view>
|
||||
);
|
||||
}
|
||||
|
||||
const { settings } = state;
|
||||
|
||||
return (
|
||||
<view className="app">
|
||||
{page === 'chat'
|
||||
? (
|
||||
<ChatPage
|
||||
messages={messages}
|
||||
streaming={streaming}
|
||||
draft={draft}
|
||||
agent={activeAgent}
|
||||
attachments={attachments}
|
||||
scrollAnchor={scrollAnchor}
|
||||
scrollSignal={scrollSignal}
|
||||
copyHint={copyHint}
|
||||
thinkingLevel={settings.thinkingLevel || 'auto'}
|
||||
openReasoning={openReasoning}
|
||||
onToggleReasoning={toggleReasoning}
|
||||
onOpenThink={setThinkIndex}
|
||||
thinkIndex={thinkIndex}
|
||||
onCloseThink={() => setThinkIndex(null)}
|
||||
onDraftChange={setDraft}
|
||||
onSend={send}
|
||||
onOpenDrawer={() => setDrawerOpen(true)}
|
||||
onOpenAgents={() => setPage('agents')}
|
||||
onOpenSettings={() => setPage('settings')}
|
||||
onPickFile={pickFile}
|
||||
onRemoveAttachment={removeAttachment}
|
||||
onRegenerate={regenerate}
|
||||
onFeedback={feedback}
|
||||
onCopy={copy}
|
||||
onSpeak={speak}
|
||||
speakingIndex={speakingIndex}
|
||||
/>
|
||||
)
|
||||
: null}
|
||||
|
||||
{page === 'profile'
|
||||
? (
|
||||
<ProfilePage
|
||||
nickname={settings.nickname}
|
||||
doubaoId={settings.doubaoId}
|
||||
memoryEnabled={memoryEnabled}
|
||||
onToggleMemory={() => setMemoryEnabled((v) => !v)}
|
||||
onOpenDrawer={() => setDrawerOpen(true)}
|
||||
onOpenSettings={() => setPage('settings')}
|
||||
onOpenAgents={() => setPage('agents')}
|
||||
onNewTopic={newTopic}
|
||||
/>
|
||||
)
|
||||
: null}
|
||||
|
||||
{page === 'settings'
|
||||
? <SettingsPage state={state} onBack={() => setPage('chat')} onSaved={saveSettings} />
|
||||
: null}
|
||||
|
||||
{page === 'skills'
|
||||
? (
|
||||
<SkillsPage
|
||||
state={state}
|
||||
onBack={() => setPage('chat')}
|
||||
onRefresh={async () => { await refresh(); }}
|
||||
onSaveSecurity={saveSecurity}
|
||||
/>
|
||||
)
|
||||
: null}
|
||||
|
||||
{page === 'agents'
|
||||
? (
|
||||
<AgentsPage
|
||||
state={state}
|
||||
activeAgentId={activeAgent?.id || ''}
|
||||
onBack={() => setPage('chat')}
|
||||
onUse={useAgent}
|
||||
onRefresh={async () => { await refresh(); }}
|
||||
/>
|
||||
)
|
||||
: null}
|
||||
|
||||
{page === 'terminal'
|
||||
? (
|
||||
<TerminalPage
|
||||
onBack={() => setPage('chat')}
|
||||
shellChannel={shellChannel}
|
||||
onRefreshChannel={refreshShellChannel}
|
||||
platform={state.platform}
|
||||
/>
|
||||
)
|
||||
: null}
|
||||
|
||||
{drawerOpen
|
||||
? (
|
||||
<Drawer
|
||||
conversations={state.conversations}
|
||||
activeId={activeId}
|
||||
nickname={settings.nickname}
|
||||
onSelect={loadConversation}
|
||||
onClose={() => setDrawerOpen(false)}
|
||||
onNewTopic={newTopic}
|
||||
onDelete={deleteConversation}
|
||||
onOpenProfile={() => {
|
||||
setDrawerOpen(false);
|
||||
setPage('profile');
|
||||
}}
|
||||
onOpenSettings={() => {
|
||||
setDrawerOpen(false);
|
||||
setPage('settings');
|
||||
}}
|
||||
onOpenSkills={() => {
|
||||
setDrawerOpen(false);
|
||||
setPage('skills');
|
||||
}}
|
||||
onOpenAgents={() => {
|
||||
setDrawerOpen(false);
|
||||
setPage('agents');
|
||||
}}
|
||||
modelLabel={modelRowLabel(state)}
|
||||
onOpenModel={() => setModelPickerOpen(true)}
|
||||
onOpenTerminal={() => {
|
||||
setDrawerOpen(false);
|
||||
setPage('terminal');
|
||||
refreshShellChannel();
|
||||
}}
|
||||
/>
|
||||
)
|
||||
: null}
|
||||
|
||||
{modelPickerOpen
|
||||
? (
|
||||
<ModelPicker
|
||||
state={state}
|
||||
onClose={() => setModelPickerOpen(false)}
|
||||
onPick={pickModel}
|
||||
/>
|
||||
)
|
||||
: null}
|
||||
</view>
|
||||
);
|
||||
}
|
||||
129
app/src/Icon.tsx
Normal file
@@ -0,0 +1,129 @@
|
||||
/** 图标:全部是本地 SVG 资源,运行时不需要联网 */
|
||||
import avatarCircle from './assets/icons-png/avatar-circle.png';
|
||||
import checkIcon from './assets/icons-png/check.png';
|
||||
import modelIcon from './assets/icons-png/model.png';
|
||||
import avatarC0 from './assets/icons-png/avatar-c0.png';
|
||||
import avatarC1 from './assets/icons-png/avatar-c1.png';
|
||||
import avatarC2 from './assets/icons-png/avatar-c2.png';
|
||||
import avatarC3 from './assets/icons-png/avatar-c3.png';
|
||||
import avatarC4 from './assets/icons-png/avatar-c4.png';
|
||||
// 智能体头像
|
||||
import agAnalyst from './assets/avatars-png/agent-analyst.png';
|
||||
import agCat from './assets/avatars-png/agent-cat.png';
|
||||
import agCloud from './assets/avatars-png/agent-cloud.png';
|
||||
import agCoder from './assets/avatars-png/agent-coder.png';
|
||||
import agCustom from './assets/avatars-png/agent-custom.png';
|
||||
import agRobot from './assets/avatars-png/agent-robot.png';
|
||||
import agStar from './assets/avatars-png/agent-star.png';
|
||||
import agWriter from './assets/avatars-png/agent-writer.png';
|
||||
import avatarDoubao from './assets/avatar-doubao.png';
|
||||
import avatarMain from './assets/avatar-main.png';
|
||||
import bell from './assets/icons-png/bell.png';
|
||||
import bellPurple from './assets/icons-png/bell-purple.png';
|
||||
import camera from './assets/icons-png/camera.png';
|
||||
import chevronRight from './assets/icons-png/chevron-right.png';
|
||||
import clock from './assets/icons-png/clock.png';
|
||||
import close from './assets/icons-png/close.png';
|
||||
import cloud from './assets/icons-png/cloud.png';
|
||||
import compose from './assets/icons-png/compose.png';
|
||||
import copy from './assets/icons-png/copy.png';
|
||||
import dislike from './assets/icons-png/dislike.png';
|
||||
import attach from './assets/icons-png/attach.png';
|
||||
import like from './assets/icons-png/like.png';
|
||||
import refresh from './assets/icons-png/refresh.png';
|
||||
import send from './assets/icons-png/send.png';
|
||||
import share from './assets/icons-png/share.png';
|
||||
import gear from './assets/icons-png/gear.png';
|
||||
import imageIcon from './assets/icons-png/image.png';
|
||||
import layers from './assets/icons-png/layers.png';
|
||||
import mapIcon from './assets/icons-png/map.png';
|
||||
import memory from './assets/icons-png/memory.png';
|
||||
import menu from './assets/icons-png/menu.png';
|
||||
import messageCircle from './assets/icons-png/message-circle.png';
|
||||
import more from './assets/icons-png/more.png';
|
||||
import person from './assets/icons-png/person.png';
|
||||
import phone from './assets/icons-png/phone.png';
|
||||
import plus from './assets/icons-png/plus.png';
|
||||
import plusCircleBlue from './assets/icons-png/plus-circle-blue.png';
|
||||
import scan from './assets/icons-png/scan.png';
|
||||
import search from './assets/icons-png/search.png';
|
||||
import sparkle from './assets/icons-png/sparkle.png';
|
||||
import sparkleSquare from './assets/icons-png/sparkle-square.png';
|
||||
import speaker from './assets/icons-png/speaker.png';
|
||||
import speakerPurple from './assets/icons-png/speaker-purple.png';
|
||||
import textSize from './assets/icons-png/text-size.png';
|
||||
import upgrade from './assets/icons-png/upgrade.png';
|
||||
import voice from './assets/icons-png/voice.png';
|
||||
|
||||
export const ICONS: Record<string, string> = {
|
||||
'avatar-circle': avatarCircle,
|
||||
'avatar-c0': avatarC0,
|
||||
'avatar-c1': avatarC1,
|
||||
'avatar-c2': avatarC2,
|
||||
'avatar-c3': avatarC3,
|
||||
'avatar-c4': avatarC4,
|
||||
bell,
|
||||
'bell-purple': bellPurple,
|
||||
camera,
|
||||
check: checkIcon,
|
||||
model: modelIcon,
|
||||
'chevron-right': chevronRight,
|
||||
clock,
|
||||
close,
|
||||
cloud,
|
||||
compose,
|
||||
copy,
|
||||
dislike,
|
||||
attach,
|
||||
like,
|
||||
refresh,
|
||||
send,
|
||||
share,
|
||||
gear,
|
||||
image: imageIcon,
|
||||
layers,
|
||||
map: mapIcon,
|
||||
memory,
|
||||
menu,
|
||||
'message-circle': messageCircle,
|
||||
more,
|
||||
person,
|
||||
phone,
|
||||
plus,
|
||||
'plus-circle-blue': plusCircleBlue,
|
||||
scan,
|
||||
search,
|
||||
sparkle,
|
||||
'sparkle-square': sparkleSquare,
|
||||
speaker,
|
||||
'speaker-purple': speakerPurple,
|
||||
'text-size': textSize,
|
||||
upgrade,
|
||||
voice,
|
||||
};
|
||||
|
||||
export function Icon(props: { name: string; className?: string }) {
|
||||
const src = ICONS[props.name];
|
||||
if (!src) return null;
|
||||
return <image className={props.className || 'icon'} src={src} />;
|
||||
}
|
||||
|
||||
/** 智能体头像表:key 与内核里的 agent.avatar 对应 */
|
||||
export const AGENT_AVATARS: Record<string, string> = {
|
||||
doubao: avatarDoubao,
|
||||
coder: agCoder,
|
||||
writer: agWriter,
|
||||
analyst: agAnalyst,
|
||||
cat: agCat,
|
||||
robot: agRobot,
|
||||
star: agStar,
|
||||
cloud: agCloud,
|
||||
custom: agCustom,
|
||||
};
|
||||
|
||||
export function AgentAvatar(props: { avatar: string; className?: string }) {
|
||||
const src = AGENT_AVATARS[props.avatar] || avatarMain;
|
||||
return <image className={props.className || 'conv-avatar'} src={src} />;
|
||||
}
|
||||
|
||||
export { avatarMain, avatarDoubao };
|
||||
293
app/src/api.ts
Normal file
@@ -0,0 +1,293 @@
|
||||
/**
|
||||
* 内核 API 客户端。
|
||||
* 之所以用绝对地址:Lynx 在原生端没有 location,web 端跑在 Worker 里,
|
||||
* 两种情况下相对路径都不够可靠。
|
||||
*/
|
||||
import type { Agent, AppState, Attachment, StreamEvent } from './types.js';
|
||||
|
||||
const FALLBACK_BASE = 'http://127.0.0.1:5199';
|
||||
const STORAGE_KEY = 'doubao.apiBase';
|
||||
|
||||
function store(): { getItem?: (k: string) => string | null; setItem?: (k: string, v: string) => void } | null {
|
||||
const g = globalThis as unknown as { localStorage?: ReturnType<typeof store> };
|
||||
return g.localStorage || null;
|
||||
}
|
||||
|
||||
/** 运行时可覆盖的内核地址(手机端连电脑、或内核换了端口时用得上) */
|
||||
let overrideBase = '';
|
||||
|
||||
export function setApiBase(url: string): void {
|
||||
const clean = String(url || '').trim().replace(/\/+$/, '');
|
||||
overrideBase = clean;
|
||||
try {
|
||||
store()?.setItem?.(STORAGE_KEY, clean);
|
||||
} catch {
|
||||
/* 某些宿主没有 localStorage */
|
||||
}
|
||||
}
|
||||
|
||||
export function getApiBaseOverride(): string {
|
||||
if (overrideBase) return overrideBase;
|
||||
try {
|
||||
const saved = store()?.getItem?.(STORAGE_KEY) || '';
|
||||
if (saved) {
|
||||
overrideBase = saved;
|
||||
return saved;
|
||||
}
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
export function apiBase(): string {
|
||||
const g = globalThis as unknown as {
|
||||
__DOUBAO_API__?: string;
|
||||
lynx?: { __globalProps?: { apiBase?: string } };
|
||||
location?: { origin?: string };
|
||||
};
|
||||
// 1) 宿主页注入 2) 原生壳(Android 端 updateGlobalProps)传进来的 3) 用户手填的 4) 同源 5) 本地默认
|
||||
if (g.__DOUBAO_API__) return String(g.__DOUBAO_API__).replace(/\/+$/, '');
|
||||
const fromNative = g.lynx?.__globalProps?.apiBase;
|
||||
if (fromNative) return String(fromNative).replace(/\/+$/, '');
|
||||
const saved = getApiBaseOverride();
|
||||
if (saved) return saved;
|
||||
const origin = g.location?.origin;
|
||||
if (origin && origin.startsWith('http')) return origin;
|
||||
return FALLBACK_BASE;
|
||||
}
|
||||
|
||||
async function request<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
const res = await fetch(`${apiBase()}${path}`, {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
...init,
|
||||
});
|
||||
const text = await res.text();
|
||||
if (!res.ok) throw new Error(`${res.status} ${text.slice(0, 200)}`);
|
||||
return text ? (JSON.parse(text) as T) : ({} as T);
|
||||
}
|
||||
|
||||
export const api = {
|
||||
state: () => request<AppState>('/api/state'),
|
||||
/**
|
||||
* 朗读:把文字交给内核合成。
|
||||
* 返回三种形状之一 —— engine='system' 表示用浏览器自带的 speechSynthesis,
|
||||
* 带 audio 表示云端已经把音频合成好了(base64),失败则 ok=false 带 error。
|
||||
*/
|
||||
speak: (text: string) =>
|
||||
request<{ ok: boolean; engine?: string; mime?: string; audio?: string; error?: string }>('/api/tts', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ text }),
|
||||
}),
|
||||
saveSettings: (patch: Record<string, unknown>) =>
|
||||
request<{ ok: boolean }>('/api/settings', { method: 'PUT', body: JSON.stringify(patch) }),
|
||||
conversations: () => request<{ conversations: AppState['conversations'] }>('/api/conversations'),
|
||||
createConversation: (title?: string) =>
|
||||
request<{ conversation: AppState['conversations'][number] }>('/api/conversations', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ title: title || '新对话' }),
|
||||
}),
|
||||
deleteConversation: (id: string) =>
|
||||
request<{ ok: boolean }>(`/api/conversations/${id}`, { method: 'DELETE' }),
|
||||
conversation: (id: string) =>
|
||||
request<{ conversation: { id: string; title: string; messages: { role: string; content: string }[] } }>(
|
||||
`/api/conversations/${id}`,
|
||||
),
|
||||
runTool: (name: string, args: Record<string, unknown>) =>
|
||||
request<{ ok: boolean; result?: unknown; error?: string }>('/api/tools/run', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ name, args }),
|
||||
}),
|
||||
connectMcp: (name?: string) =>
|
||||
request<{ ok: boolean; error?: string; results?: unknown }>('/api/mcp/connect', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ name }),
|
||||
}),
|
||||
disconnectMcp: (name: string) =>
|
||||
request<{ ok: boolean }>('/api/mcp/disconnect', { method: 'POST', body: JSON.stringify({ name }) }),
|
||||
mcpDetail: () =>
|
||||
request<{
|
||||
path: string;
|
||||
dir: string;
|
||||
text: string;
|
||||
canReveal: boolean;
|
||||
placeholders: Record<string, string>;
|
||||
}>('/api/mcp'),
|
||||
saveMcpConfig: (text: string) =>
|
||||
request<{ ok: boolean; count?: number; error?: string; results?: { name: string; ok: boolean; error?: string }[] }>(
|
||||
'/api/mcp/config',
|
||||
{ method: 'PUT', body: JSON.stringify({ text }) },
|
||||
),
|
||||
revealMcp: () => request<{ ok: boolean; path: string; error?: string }>('/api/mcp/reveal', { method: 'POST' }),
|
||||
|
||||
// 智能体
|
||||
agents: () => request<{ agents: Agent[] }>('/api/agents'),
|
||||
createAgent: (body: Partial<Agent>) =>
|
||||
request<{ agent: Agent }>('/api/agents', { method: 'POST', body: JSON.stringify(body) }),
|
||||
updateAgent: (id: string, body: Partial<Agent>) =>
|
||||
request<{ agent: Agent }>(`/api/agents/${id}`, { method: 'PATCH', body: JSON.stringify(body) }),
|
||||
deleteAgent: (id: string) => request<{ ok: boolean }>(`/api/agents/${id}`, { method: 'DELETE' }),
|
||||
|
||||
// 附件
|
||||
pickFile: () => request<{ ok: boolean; files: Attachment[]; error?: string }>('/api/pick-file', { method: 'POST', body: '{}' }),
|
||||
uploadFile: (name: string, dataUrl: string, pending = false) =>
|
||||
request<{ ok: boolean; file: Attachment; error?: string }>('/api/upload', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ name, dataUrl, pending }),
|
||||
}),
|
||||
pendingUploads: () => request<{ files: Attachment[] }>('/api/uploads/pending'),
|
||||
|
||||
// 复制到剪贴板(桌面版走原生,浏览器走 navigator.clipboard)
|
||||
clipboard: (text: string) =>
|
||||
request<{ ok: boolean; via: string }>('/api/clipboard', { method: 'POST', body: JSON.stringify({ text }) }),
|
||||
};
|
||||
|
||||
function decodeChunk(value: unknown): string {
|
||||
const g = globalThis as unknown as {
|
||||
TextDecoder?: new () => { decode: (v: unknown, o?: { stream?: boolean }) => string };
|
||||
TextCodecHelper?: { decode: (v: unknown) => string };
|
||||
};
|
||||
if (g.TextDecoder) return new g.TextDecoder().decode(value, { stream: true });
|
||||
if (g.TextCodecHelper) return g.TextCodecHelper.decode(value);
|
||||
return String(value);
|
||||
}
|
||||
|
||||
/** 解析 SSE 分片,把完整的 data: 行交给 onEvent */
|
||||
function drainBuffer(buffer: string, onEvent: (e: StreamEvent) => void, flush = false): string {
|
||||
let rest = buffer;
|
||||
let idx: number;
|
||||
while ((idx = rest.indexOf('\n\n')) >= 0) {
|
||||
const block = rest.slice(0, idx);
|
||||
rest = rest.slice(idx + 2);
|
||||
for (const line of block.split('\n')) {
|
||||
const trimmed = line.trim();
|
||||
if (!trimmed.startsWith('data:')) continue;
|
||||
const payload = trimmed.slice(5).trim();
|
||||
if (!payload) continue;
|
||||
try {
|
||||
onEvent(JSON.parse(payload) as StreamEvent);
|
||||
} catch {
|
||||
/* 忽略坏包 */
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flush && rest.trim()) {
|
||||
for (const line of rest.split('\n')) {
|
||||
const trimmed = line.trim();
|
||||
if (!trimmed.startsWith('data:')) continue;
|
||||
try {
|
||||
onEvent(JSON.parse(trimmed.slice(5).trim()) as StreamEvent);
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
rest = '';
|
||||
}
|
||||
return rest;
|
||||
}
|
||||
|
||||
export interface ChatPayload {
|
||||
conversationId: string;
|
||||
message: string;
|
||||
history: { role: string; content: string }[];
|
||||
attachments?: { id: string; name: string; size: number; mime?: string; path?: string; url?: string }[];
|
||||
agentId?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 这条 Lynx 宿主到底能不能"边收边解析"?
|
||||
*
|
||||
* 为什么要探测:Web 端 fetch 有 response.body,能拿到 ReadableStream;
|
||||
* 但 **Lynx 原生端(安卓)的 fetch 没有 body**,只能等到全部返回才知道内容 ——
|
||||
* 表现出来就是"等很久然后一次性吐出来"。
|
||||
* 所以启动时探一次,不支持就走轮询通道(内核把事件攒着,客户端 200ms 拉一次增量)。
|
||||
*/
|
||||
let streamProbe: Promise<boolean> | null = null;
|
||||
|
||||
async function supportsStreaming(): Promise<boolean> {
|
||||
if (streamProbe) return streamProbe;
|
||||
streamProbe = (async () => {
|
||||
try {
|
||||
const res = await fetch(`${apiBase()}/api/health`);
|
||||
const body = (res as unknown as { body?: { getReader?: unknown } }).body;
|
||||
return Boolean(body && typeof body.getReader === 'function');
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
return streamProbe;
|
||||
}
|
||||
|
||||
/** 轮询通道:POST 拿 runId,然后不停拉增量 */
|
||||
async function pollChat(payload: ChatPayload, onEvent: (e: StreamEvent) => void): Promise<void> {
|
||||
const start = await fetch(`${apiBase()}/api/chat`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ ...payload, transport: 'poll' }),
|
||||
});
|
||||
if (!start.ok) {
|
||||
const detail = await start.text().catch(() => '');
|
||||
throw new Error(`内核返回 ${start.status}:${detail.slice(0, 300)}`);
|
||||
}
|
||||
const { runId } = (await start.json()) as { runId?: string };
|
||||
if (!runId) throw new Error('内核没有返回 runId');
|
||||
|
||||
let cursor = 0;
|
||||
let idle = 0;
|
||||
for (;;) {
|
||||
const res = await fetch(`${apiBase()}/api/chat/poll?runId=${encodeURIComponent(runId)}&cursor=${cursor}`);
|
||||
if (!res.ok) {
|
||||
throw new Error(`轮询失败(HTTP ${res.status}),任务可能已过期`);
|
||||
}
|
||||
const data = (await res.json()) as { events?: StreamEvent[]; cursor?: number; done?: boolean };
|
||||
const events = data.events || [];
|
||||
for (const event of events) onEvent(event);
|
||||
cursor = data.cursor ?? cursor;
|
||||
if (data.done) return;
|
||||
|
||||
// 一直没新事件也别死等(比如内核那边的请求卡住了)
|
||||
idle = events.length === 0 ? idle + 1 : 0;
|
||||
if (idle > 600) throw new Error('长时间没有新内容(超过 2 分钟),已停止等待');
|
||||
await new Promise((resolve) => setTimeout(resolve, 200));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 流式对话:自动挑通道。
|
||||
* - 宿主支持 ReadableStream → SSE 增量读取(web / exe)
|
||||
* - 不支持(Lynx 原生端) → 轮询增量(观感基本一致)
|
||||
*/
|
||||
export async function streamChat(payload: ChatPayload, onEvent: (e: StreamEvent) => void): Promise<void> {
|
||||
if (!(await supportsStreaming())) {
|
||||
await pollChat(payload, onEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
const res = await fetch(`${apiBase()}/api/chat`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
if (!res.ok) {
|
||||
const detail = await res.text().catch(() => '');
|
||||
throw new Error(`内核返回 ${res.status}:${detail.slice(0, 300)}`);
|
||||
}
|
||||
|
||||
const body = (res as unknown as { body?: { getReader?: () => { read: () => Promise<{ done: boolean; value?: unknown }> } } }).body;
|
||||
if (body && typeof body.getReader === 'function') {
|
||||
const reader = body.getReader();
|
||||
let buffer = '';
|
||||
for (;;) {
|
||||
const { done, value } = await reader.read();
|
||||
if (done) break;
|
||||
buffer += decodeChunk(value);
|
||||
buffer = drainBuffer(buffer, onEvent);
|
||||
}
|
||||
drainBuffer(buffer, onEvent, true);
|
||||
return;
|
||||
}
|
||||
|
||||
// 探测说支持、实际却没拿到 body:兜底按整包解析,别让消息卡住
|
||||
const text = await res.text();
|
||||
drainBuffer(`${text}\n\n`, onEvent, true);
|
||||
}
|
||||
1752
app/src/app.css
Normal file
BIN
app/src/assets/avatar-doubao.png
Normal file
|
After Width: | Height: | Size: 68 KiB |
BIN
app/src/assets/avatar-main.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
app/src/assets/avatar-photo.png
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
app/src/assets/avatars-png/agent-analyst.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
app/src/assets/avatars-png/agent-cat.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
app/src/assets/avatars-png/agent-cloud.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
app/src/assets/avatars-png/agent-coder.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
app/src/assets/avatars-png/agent-custom.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
app/src/assets/avatars-png/agent-robot.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
app/src/assets/avatars-png/agent-star.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
app/src/assets/avatars-png/agent-writer.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
app/src/assets/avatars-png/analyst.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
app/src/assets/avatars-png/cat.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
app/src/assets/avatars-png/cloud.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
app/src/assets/avatars-png/coder.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
app/src/assets/avatars-png/custom.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
app/src/assets/avatars-png/robot.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
app/src/assets/avatars-png/star.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
app/src/assets/avatars-png/writer.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
1
app/src/assets/avatars/analyst.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><defs><linearGradient id="g2" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#4ED2A0"/><stop offset="1" stop-color="#12A150"/></linearGradient></defs><circle cx="24" cy="24" r="24" fill="url(#g2)"/><rect x="13" y="24" width="5" height="12" rx="2" fill="#fff"/><rect x="21.5" y="17" width="5" height="19" rx="2" fill="#fff"/><rect x="30" y="11" width="5" height="25" rx="2" fill="#fff"/></svg>
|
||||
|
After Width: | Height: | Size: 485 B |
1
app/src/assets/avatars/cat.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><defs><linearGradient id="g3" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#FFA8C8"/><stop offset="1" stop-color="#F0609B"/></linearGradient></defs><circle cx="24" cy="24" r="24" fill="url(#g3)"/><path d="M15 20l-1.6-5.4 5 2.2z" fill="#fff"/><path d="M33 20l1.6-5.4-5 2.2z" fill="#fff"/><circle cx="24" cy="25" r="9" fill="#fff"/><circle cx="20.4" cy="24" r="1.5" fill="#F0609B"/><circle cx="27.6" cy="24" r="1.5" fill="#F0609B"/><path d="M24 27.6l-1.4 1.6h2.8z" fill="#F0609B"/></svg>
|
||||
|
After Width: | Height: | Size: 580 B |
1
app/src/assets/avatars/cloud.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><defs><linearGradient id="g6" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#6FD8F5"/><stop offset="1" stop-color="#2AA7D6"/></linearGradient></defs><circle cx="24" cy="24" r="24" fill="url(#g6)"/><path d="M17 32h14a5 5 0 0 0 .6-9.9 7.4 7.4 0 0 0-14.2-1.3A5.6 5.6 0 0 0 17 32z" fill="#fff"/></svg>
|
||||
|
After Width: | Height: | Size: 391 B |
1
app/src/assets/avatars/coder.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><defs><linearGradient id="g0" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#5AA9FF"/><stop offset="1" stop-color="#2B6BE6"/></linearGradient></defs><circle cx="24" cy="24" r="24" fill="url(#g0)"/><text x="24" y="30" font-family="Segoe UI Symbol, Arial, sans-serif" font-size="17" font-weight="700" fill="#ffffff" text-anchor="middle"></></text></svg>
|
||||
|
After Width: | Height: | Size: 451 B |
1
app/src/assets/avatars/custom.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><defs><linearGradient id="g7" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#A9B4C4"/><stop offset="1" stop-color="#6B7785"/></linearGradient></defs><circle cx="24" cy="24" r="24" fill="url(#g7)"/><circle cx="24" cy="19" r="6" fill="#fff"/><path d="M13 36a11 11 0 0 1 22 0z" fill="#fff"/></svg>
|
||||
|
After Width: | Height: | Size: 388 B |
1
app/src/assets/avatars/robot.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><defs><linearGradient id="g4" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#B98BFF"/><stop offset="1" stop-color="#7A45E6"/></linearGradient></defs><circle cx="24" cy="24" r="24" fill="url(#g4)"/><rect x="13" y="16" width="22" height="17" rx="6" fill="#fff"/><circle cx="19.5" cy="24" r="2.2" fill="#7A45E6"/><circle cx="28.5" cy="24" r="2.2" fill="#7A45E6"/><rect x="22.5" y="10" width="3" height="6" rx="1.5" fill="#fff"/><circle cx="24" cy="9" r="2.2" fill="#fff"/></svg>
|
||||
|
After Width: | Height: | Size: 569 B |
1
app/src/assets/avatars/star.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><defs><linearGradient id="g5" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#FFD75E"/><stop offset="1" stop-color="#F5A623"/></linearGradient></defs><circle cx="24" cy="24" r="24" fill="url(#g5)"/><path d="M24 11l4 8.6 9 1.2-6.6 6.2 1.7 9-8.1-4.4-8.1 4.4 1.7-9L11 20.8l9-1.2z" fill="#fff"/></svg>
|
||||
|
After Width: | Height: | Size: 390 B |
1
app/src/assets/avatars/writer.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><defs><linearGradient id="g1" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#FFB259"/><stop offset="1" stop-color="#F07B2E"/></linearGradient></defs><circle cx="24" cy="24" r="24" fill="url(#g1)"/><text x="24" y="32" font-family="Segoe UI Symbol, Arial, sans-serif" font-size="24" font-weight="700" fill="#ffffff" text-anchor="middle">✎</text></svg>
|
||||
|
After Width: | Height: | Size: 445 B |
BIN
app/src/assets/icons-png/attach.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
app/src/assets/icons-png/avatar-c0.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
app/src/assets/icons-png/avatar-c1.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
app/src/assets/icons-png/avatar-c2.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
app/src/assets/icons-png/avatar-c3.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
app/src/assets/icons-png/avatar-c4.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
app/src/assets/icons-png/avatar-circle.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
app/src/assets/icons-png/bell-purple.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
app/src/assets/icons-png/bell.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
app/src/assets/icons-png/camera.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
app/src/assets/icons-png/check.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
app/src/assets/icons-png/chevron-right.png
Normal file
|
After Width: | Height: | Size: 808 B |
BIN
app/src/assets/icons-png/clock.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
app/src/assets/icons-png/close.png
Normal file
|
After Width: | Height: | Size: 292 B |
BIN
app/src/assets/icons-png/cloud.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
app/src/assets/icons-png/compose.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
app/src/assets/icons-png/copy.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
app/src/assets/icons-png/dislike.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
app/src/assets/icons-png/gear.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
app/src/assets/icons-png/image.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
app/src/assets/icons-png/layers.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
app/src/assets/icons-png/like.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
app/src/assets/icons-png/map.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
app/src/assets/icons-png/memory.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
app/src/assets/icons-png/menu.png
Normal file
|
After Width: | Height: | Size: 458 B |
BIN
app/src/assets/icons-png/message-circle.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
app/src/assets/icons-png/model.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
app/src/assets/icons-png/more.png
Normal file
|
After Width: | Height: | Size: 595 B |
BIN
app/src/assets/icons-png/person.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
app/src/assets/icons-png/phone.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
app/src/assets/icons-png/plus-circle-blue.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
app/src/assets/icons-png/plus.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
app/src/assets/icons-png/refresh.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
app/src/assets/icons-png/scan.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
app/src/assets/icons-png/search.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
app/src/assets/icons-png/send.png
Normal file
|
After Width: | Height: | Size: 292 B |
BIN
app/src/assets/icons-png/share.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
app/src/assets/icons-png/sparkle-square.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
app/src/assets/icons-png/sparkle.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
app/src/assets/icons-png/speaker-purple.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
app/src/assets/icons-png/speaker.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
app/src/assets/icons-png/text-size.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
app/src/assets/icons-png/upgrade.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
app/src/assets/icons-png/voice.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
1
app/src/assets/icons/attach.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#1F2329" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M18.5 11.5l-6.8 6.8a4.2 4.2 0 0 1-6-6l7.4-7.4a2.8 2.8 0 0 1 4 4l-7.4 7.4a1.4 1.4 0 0 1-2-2l6.8-6.8"/></svg>
|
||||
|
After Width: | Height: | Size: 294 B |
1
app/src/assets/icons/avatar-c0.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#F3A8D0"/><stop offset="1" stop-color="#C9A7F5"/></linearGradient></defs><circle cx="12" cy="12" r="12" fill="url(#g)" opacity="0.55"/><circle cx="12" cy="12" r="12" fill="#ffffff" opacity="0.25"/><path d="M7.6 9.4h8.8v5.2a1.4 1.4 0 0 1-1.4 1.4H9a1.4 1.4 0 0 1-1.4-1.4z" fill="#ffffff" opacity="0.95"/><path d="M9.8 16l-2 2.2V16z" fill="#ffffff" opacity="0.95"/><circle cx="10.3" cy="12.6" r="0.85" fill="#F3A8D0"/><circle cx="12.6" cy="12.6" r="0.85" fill="#F3A8D0"/><circle cx="14.9" cy="12.6" r="0.85" fill="#F3A8D0"/></svg>
|
||||
|
After Width: | Height: | Size: 696 B |
1
app/src/assets/icons/avatar-c1.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#FFC98B"/><stop offset="1" stop-color="#FF9E6B"/></linearGradient></defs><circle cx="12" cy="12" r="12" fill="url(#g)" opacity="0.55"/><circle cx="12" cy="12" r="12" fill="#ffffff" opacity="0.25"/><path d="M7.6 9.4h8.8v5.2a1.4 1.4 0 0 1-1.4 1.4H9a1.4 1.4 0 0 1-1.4-1.4z" fill="#ffffff" opacity="0.95"/><path d="M9.8 16l-2 2.2V16z" fill="#ffffff" opacity="0.95"/><circle cx="10.3" cy="12.6" r="0.85" fill="#FFC98B"/><circle cx="12.6" cy="12.6" r="0.85" fill="#FFC98B"/><circle cx="14.9" cy="12.6" r="0.85" fill="#FFC98B"/></svg>
|
||||
|
After Width: | Height: | Size: 696 B |
1
app/src/assets/icons/avatar-c2.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#FFE28A"/><stop offset="1" stop-color="#FFC24D"/></linearGradient></defs><circle cx="12" cy="12" r="12" fill="url(#g)" opacity="0.55"/><circle cx="12" cy="12" r="12" fill="#ffffff" opacity="0.25"/><path d="M7.6 9.4h8.8v5.2a1.4 1.4 0 0 1-1.4 1.4H9a1.4 1.4 0 0 1-1.4-1.4z" fill="#ffffff" opacity="0.95"/><path d="M9.8 16l-2 2.2V16z" fill="#ffffff" opacity="0.95"/><circle cx="10.3" cy="12.6" r="0.85" fill="#FFE28A"/><circle cx="12.6" cy="12.6" r="0.85" fill="#FFE28A"/><circle cx="14.9" cy="12.6" r="0.85" fill="#FFE28A"/></svg>
|
||||
|
After Width: | Height: | Size: 696 B |
1
app/src/assets/icons/avatar-c3.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#A8C8FF"/><stop offset="1" stop-color="#8AA6F5"/></linearGradient></defs><circle cx="12" cy="12" r="12" fill="url(#g)" opacity="0.55"/><circle cx="12" cy="12" r="12" fill="#ffffff" opacity="0.25"/><path d="M7.6 9.4h8.8v5.2a1.4 1.4 0 0 1-1.4 1.4H9a1.4 1.4 0 0 1-1.4-1.4z" fill="#ffffff" opacity="0.95"/><path d="M9.8 16l-2 2.2V16z" fill="#ffffff" opacity="0.95"/><circle cx="10.3" cy="12.6" r="0.85" fill="#A8C8FF"/><circle cx="12.6" cy="12.6" r="0.85" fill="#A8C8FF"/><circle cx="14.9" cy="12.6" r="0.85" fill="#A8C8FF"/></svg>
|
||||
|
After Width: | Height: | Size: 696 B |
1
app/src/assets/icons/avatar-c4.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#FFB3B3"/><stop offset="1" stop-color="#F58AA8"/></linearGradient></defs><circle cx="12" cy="12" r="12" fill="url(#g)" opacity="0.55"/><circle cx="12" cy="12" r="12" fill="#ffffff" opacity="0.25"/><path d="M7.6 9.4h8.8v5.2a1.4 1.4 0 0 1-1.4 1.4H9a1.4 1.4 0 0 1-1.4-1.4z" fill="#ffffff" opacity="0.95"/><path d="M9.8 16l-2 2.2V16z" fill="#ffffff" opacity="0.95"/><circle cx="10.3" cy="12.6" r="0.85" fill="#FFB3B3"/><circle cx="12.6" cy="12.6" r="0.85" fill="#FFB3B3"/><circle cx="14.9" cy="12.6" r="0.85" fill="#FFB3B3"/></svg>
|
||||
|
After Width: | Height: | Size: 696 B |
1
app/src/assets/icons/avatar-circle.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><defs><linearGradient id="a" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#BBD4FF"/><stop offset="1" stop-color="#DCE9FF"/></linearGradient></defs><circle cx="12" cy="12" r="12" fill="url(#a)"/><circle cx="12" cy="9.6" r="4.2" fill="#fff" opacity="0.92"/><path d="M3.4 21.4a8.8 8.8 0 0 1 17.2 0z" fill="#fff" opacity="0.92"/></svg>
|
||||
|
After Width: | Height: | Size: 426 B |
1
app/src/assets/icons/bell-purple.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><defs><linearGradient id="b" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#8B5CF6"/><stop offset="1" stop-color="#6D3BEB"/></linearGradient></defs><rect width="24" height="24" rx="7" fill="url(#b)"/><path d="M12 6.2a4 4 0 0 1 4 4v3.2H8V10.2a4 4 0 0 1 4-4z" fill="#fff"/><path d="M9.6 15.8a2.4 2.4 0 0 0 4.8 0z" fill="#fff"/><rect x="8" y="4.6" width="8" height="1.7" rx="0.85" fill="#fff"/></svg>
|
||||
|
After Width: | Height: | Size: 491 B |
1
app/src/assets/icons/bell.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#1F2329" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6.5 17.5V11a5.5 5.5 0 0 1 11 0v6.5"/><path d="M4.8 17.5h14.4"/><path d="M10 20.4a2.3 2.3 0 0 0 4 0"/></svg>
|
||||
|
After Width: | Height: | Size: 293 B |
1
app/src/assets/icons/camera.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#1F2329" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M4 8.6h3l1.5-2.2h7L17 8.6h3v9.4H4z"/><circle cx="12" cy="13.2" r="3.2"/></svg>
|
||||
|
After Width: | Height: | Size: 265 B |
1
app/src/assets/icons/check.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#2B7BFF" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg>
|
||||
|
After Width: | Height: | Size: 219 B |
1
app/src/assets/icons/chevron-right.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#8A8F99" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 5l7 7-7 7"/></svg>
|
||||
|
After Width: | Height: | Size: 206 B |
1
app/src/assets/icons/clock.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#1F2329" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><path d="M12 7v5.2l3.4 2"/></svg>
|
||||
|
After Width: | Height: | Size: 240 B |
1
app/src/assets/icons/close.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#FFFFFF" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M6 6l12 12"/><path d="M18 6L6 18"/></svg>
|
||||
|
After Width: | Height: | Size: 228 B |
1
app/src/assets/icons/cloud.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#1F2329" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7.5 18.5h9.8a3.7 3.7 0 0 0 .5-7.4 5.6 5.6 0 0 0-10.8-1A4.2 4.2 0 0 0 7.5 18.5z"/></svg>
|
||||
|
After Width: | Height: | Size: 273 B |
1
app/src/assets/icons/compose.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#1F2329" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M4 20h4l10-10a2.8 2.8 0 0 0-4-4L4 16v4z"/><path d="M14.5 5.5l4 4"/></svg>
|
||||
|
After Width: | Height: | Size: 260 B |
1
app/src/assets/icons/copy.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#6B7280" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="11" height="11" rx="2.4"/><path d="M15 9V6.4A2.4 2.4 0 0 0 12.6 4H6.4A2.4 2.4 0 0 0 4 6.4v6.2A2.4 2.4 0 0 0 6.4 15H9"/></svg>
|
||||
|
After Width: | Height: | Size: 328 B |
1
app/src/assets/icons/dislike.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#6B7280" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3.5V14l-4.3 6.4a1.6 1.6 0 0 1-2.9-.9V15H5.6a1.9 1.9 0 0 1-1.9-2.3l1.4-7A1.9 1.9 0 0 1 7 3.5z"/><path d="M17 3.5h2.4a1.1 1.1 0 0 1 1.1 1.1V13a1.1 1.1 0 0 1-1.1 1.1H17"/></svg>
|
||||
|
After Width: | Height: | Size: 365 B |
1
app/src/assets/icons/gear.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#1F2329" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3.2"/><path d="M12 2.8l1.1 2.3 2.5-.6.5 2.5 2.5.5-.6 2.5 2.3 1.1-2.3 1.1.6 2.5-2.5.5-.5 2.5-2.5-.6L12 21.2l-1.1-2.3-2.5.6-.5-2.5-2.5-.5.6-2.5L3.7 12 6 10.9l-.6-2.5 2.5-.5.5-2.5 2.5.6L12 2.8z"/></svg>
|
||||
|
After Width: | Height: | Size: 404 B |
1
app/src/assets/icons/image.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#1F2329" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="3.4" y="4.6" width="17.2" height="14.8" rx="3"/><circle cx="9" cy="9.6" r="1.6"/><path d="M4.5 17.4l4.6-4.2 3.4 3 2.6-2.4 4.4 4"/></svg>
|
||||
|
After Width: | Height: | Size: 323 B |
1
app/src/assets/icons/layers.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#1F2329" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3l8 4.5-8 4.5-8-4.5L12 3z"/><path d="M4 12.2l8 4.5 8-4.5"/><path d="M4 16.7l8 4.5 8-4.5"/></svg>
|
||||
|
After Width: | Height: | Size: 287 B |