feat: 第五轮开发 - 14项未来路线图功能完整实现

W1-W14 全部完成:
- W1: 消息搜索 (ILIKE全文检索 + SearchModal)
- W2: 对话导出 (JSON/Markdown/TXT三格式)
- W3: 记忆时间线 DevTools 可视化
- W4: 通知推送系统 (WebSocket + Browser Notification API)
- W5: 定时提醒 (30s轮询 + 重复提醒 + WebSocket推送)
- W6: 每日简报 (08:00自动生成: 天气+新闻+提醒+AI摘要)
- W7: IoT场景自动化 (规则引擎 10s轮询 + 条件评估 + 场景执行)
- W8: 语音输入 (浏览器 Speech Recognition API)
- W9: STT服务 (voice-service + whisper.cpp)
- W10: TTS服务 (浏览器 Speech Synthesis + edge-tts三档回退)
- W11: 文件管理 (上传/下载/缩略图/纯Go bilinear缩放)
- W12: 知识库RAG (PostgreSQL tsvector + 文档分块 + 检索)
- W13: 多模态 (图片上传+分析: Vision API + 本地Go分析回退)
- W14: PWA (Service Worker + 离线页 + install prompt)

总计: 6个Go微服务 + 10+前端组件 + 10+ PostgreSQL表 + 4个后台调度器
This commit is contained in:
2026-05-19 12:01:09 +08:00
parent 78e3f450c2
commit bcf4d4e621
69 changed files with 14599 additions and 150 deletions
+39
View File
@@ -0,0 +1,39 @@
{
"name": "Cyrene - AI 智能助手",
"short_name": "Cyrene",
"description": "你的 AI 生活伴侣,支持 IoT 控制、知识库、语音交互",
"start_url": "/",
"display": "standalone",
"background_color": "#fdf2f8",
"theme_color": "#ec4899",
"orientation": "any",
"icons": [
{
"src": "/images/Cyrene_Avatar/2nd_Form/Cyrene-2F-N-Happy-1.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "any maskable"
}
],
"categories": ["productivity", "utilities"],
"lang": "zh-CN",
"dir": "ltr",
"scope": "/",
"prefer_related_applications": false,
"shortcuts": [
{
"name": "新对话",
"url": "/#/new",
"description": "开始新对话"
}
],
"share_target": {
"action": "/#/share",
"method": "GET",
"params": {
"title": "title",
"text": "text",
"url": "url"
}
}
}
+130
View File
@@ -0,0 +1,130 @@
<!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>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
background: linear-gradient(135deg, #fdf2f8 0%, #fce7f3 50%, #fbcfe8 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
color: #374151;
}
.container {
text-align: center;
padding: 2rem;
max-width: 420px;
width: 100%;
}
.avatar {
width: 120px;
height: 120px;
border-radius: 28px;
object-fit: cover;
box-shadow: 0 8px 32px rgba(236, 72, 153, 0.3);
margin-bottom: 1.5rem;
border: 3px solid rgba(236, 72, 153, 0.3);
}
.avatar-placeholder {
width: 120px;
height: 120px;
border-radius: 28px;
background: linear-gradient(135deg, #ec4899, #f472b6);
margin: 0 auto 1.5rem;
display: flex;
align-items: center;
justify-content: center;
font-size: 64px;
box-shadow: 0 8px 32px rgba(236, 72, 153, 0.3);
border: 3px solid rgba(236, 72, 153, 0.3);
}
h1 {
font-size: 1.5rem;
font-weight: 700;
color: #be185d;
margin-bottom: 0.5rem;
}
p {
font-size: 0.95rem;
color: #9ca3af;
margin-bottom: 2rem;
line-height: 1.6;
}
.status-icon {
font-size: 3rem;
margin-bottom: 1rem;
}
button {
display: inline-flex;
align-items: center;
gap: 0.5rem;
background: linear-gradient(135deg, #ec4899, #f472b6);
color: white;
border: none;
padding: 0.75rem 2rem;
border-radius: 9999px;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
transition: all 0.2s ease;
box-shadow: 0 4px 16px rgba(236, 72, 153, 0.3);
}
button:hover {
transform: translateY(-1px);
box-shadow: 0 6px 24px rgba(236, 72, 153, 0.4);
}
button:active {
transform: translateY(0);
}
.auto-retry {
margin-top: 1.5rem;
font-size: 0.8rem;
color: #9ca3af;
}
.auto-retry.connected {
color: #059669;
font-weight: 600;
}
</style>
</head>
<body>
<div class="container">
<!-- Cyrene Avatar -->
<img
class="avatar"
src="/images/Cyrene_Avatar/2nd_Form/Cyrene-2F-N-Happy-1.png"
alt="昔涟"
onerror="this.style.display='none'; this.nextElementSibling.style.display='flex';"
/>
<div class="avatar-placeholder" style="display:none;">🌸</div>
<div class="status-icon">📡</div>
<h1>哎呀,网络连接断开了</h1>
<p>请检查网络连接后重试<br />昔涟正在等你回来~</p>
<button onclick="retry()">🔄 重新连接</button>
<div id="autoRetry" class="auto-retry">正在监听网络恢复...</div>
</div>
<script>
function retry() {
window.location.reload();
}
const autoRetryEl = document.getElementById('autoRetry');
window.addEventListener('online', function() {
autoRetryEl.textContent = '✅ 网络已恢复,正在重新加载...';
autoRetryEl.classList.add('connected');
setTimeout(function() {
window.location.reload();
}, 500);
});
</script>
</body>
</html>
+107
View File
@@ -0,0 +1,107 @@
const CACHE_NAME = 'cyrene-v1';
const ASSETS_TO_CACHE = [
'/',
'/index.html',
];
// Install: 缓存核心资源
self.addEventListener('install', (event) => {
event.waitUntil(
caches.open(CACHE_NAME).then((cache) => {
return cache.addAll(ASSETS_TO_CACHE);
})
);
self.skipWaiting();
});
// Activate: 清理旧缓存
self.addEventListener('activate', (event) => {
event.waitUntil(
caches.keys().then((keys) => {
return Promise.all(
keys.filter(key => key !== CACHE_NAME).map(key => caches.delete(key))
);
})
);
self.clients.claim();
});
// Fetch: 缓存优先策略(对 API 请求使用网络优先)
self.addEventListener('fetch', (event) => {
const url = new URL(event.request.url);
// API 请求:网络优先,失败时返回离线 JSON
if (url.pathname.startsWith('/api/')) {
event.respondWith(networkFirst(event.request));
} else if (url.pathname.startsWith('/ws')) {
// WebSocket 连接不缓存
event.respondWith(fetch(event.request));
} else {
// 静态资源:缓存优先
event.respondWith(cacheFirst(event.request));
}
});
async function cacheFirst(request) {
const cached = await caches.match(request);
if (cached) return cached;
try {
const response = await fetch(request);
if (response.ok) {
const cache = await caches.open(CACHE_NAME);
cache.put(request, response.clone());
}
return response;
} catch (e) {
// 返回离线页面(HTML 请求)
if (request.headers.get('Accept')?.includes('text/html')) {
return caches.match('/offline.html');
}
throw e;
}
}
async function networkFirst(request) {
try {
const response = await fetch(request);
const cache = await caches.open(CACHE_NAME);
cache.put(request, response.clone());
return response;
} catch (e) {
const cached = await caches.match(request);
if (cached) return cached;
return new Response(JSON.stringify({ error: '离线状态,请检查网络连接' }), {
status: 503,
headers: { 'Content-Type': 'application/json' }
});
}
}
// Push 通知
self.addEventListener('push', (event) => {
const data = event.data?.json() || { title: 'Cyrene', body: '新消息' };
event.waitUntil(
self.registration.showNotification(data.title, {
body: data.body,
icon: '/images/Cyrene_Avatar/2nd_Form/Cyrene-2F-N-Happy-1.png',
badge: '/images/Cyrene_Avatar/2nd_Form/Cyrene-2F-N-Happy-1.png',
data: data.data || {},
})
);
});
self.addEventListener('notificationclick', (event) => {
event.notification.close();
const sessionId = event.notification.data?.session_id;
const targetUrl = sessionId ? `/#/session/${sessionId}` : '/';
event.waitUntil(
clients.matchAll({ type: 'window' }).then((clientList) => {
for (const client of clientList) {
if (client.url.includes(targetUrl) && 'focus' in client) {
return client.focus();
}
}
if (clients.openWindow) return clients.openWindow(targetUrl);
})
);
});