feat: BossAi 老板AI助手初始版本
包含功能: - 法务参谋/经营决策/生活助理/情绪中心四大AI对话模块 - 专家咨询系统(用户选定→专家确认→咨询→回复→评价) - 角色登录(用户/专家/管理员)+ ProtectedRoute 权限控制 - 管理后台(用户管理/专家管理/AI使用统计/专家活跃度) - 专家工作台(待确认服务/待回复咨询/已回复咨询/服务中用户) - 服务关系取消(用户和专家均可取消,需自己确认) - 全页面移动端响应式适配 - 知识库RAG检索 - 对话历史(普通/保密模式) Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "BossAi - 老板智能助手",
|
||||
"short_name": "BossAi",
|
||||
"description": "隐私优先的企业法律与经营智能助手",
|
||||
"start_url": "/",
|
||||
"display": "standalone",
|
||||
"background_color": "#f8f9fb",
|
||||
"theme_color": "#0f172a",
|
||||
"orientation": "any",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/icon-192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png",
|
||||
"purpose": "any maskable"
|
||||
},
|
||||
{
|
||||
"src": "/icon-512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png",
|
||||
"purpose": "any maskable"
|
||||
}
|
||||
],
|
||||
"categories": ["business", "productivity"],
|
||||
"lang": "zh-CN",
|
||||
"dir": "ltr"
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
// BossAi Service Worker - 离线访问支持
|
||||
// 策略:API 请求 network-first,静态资源 cache-first
|
||||
|
||||
const CACHE_VERSION = 'bossai-v1'
|
||||
const STATIC_CACHE = `${CACHE_VERSION}-static`
|
||||
const API_CACHE = `${CACHE_VERSION}-api`
|
||||
|
||||
// 预缓存静态资源
|
||||
const PRECACHE_URLS = [
|
||||
'/',
|
||||
'/index.html',
|
||||
'/manifest.json',
|
||||
]
|
||||
|
||||
// 安装:预缓存
|
||||
self.addEventListener('install', (event) => {
|
||||
event.waitUntil(
|
||||
caches.open(STATIC_CACHE).then((cache) => cache.addAll(PRECACHE_URLS))
|
||||
.then(() => self.skipWaiting())
|
||||
)
|
||||
})
|
||||
|
||||
// 激活:清理旧缓存
|
||||
self.addEventListener('activate', (event) => {
|
||||
event.waitUntil(
|
||||
caches.keys().then((keys) =>
|
||||
Promise.all(
|
||||
keys
|
||||
.filter((key) => !key.startsWith(CACHE_VERSION))
|
||||
.map((key) => caches.delete(key))
|
||||
)
|
||||
).then(() => self.clients.claim())
|
||||
)
|
||||
})
|
||||
|
||||
// 请求拦截
|
||||
self.addEventListener('fetch', (event) => {
|
||||
const { request } = event
|
||||
const url = new URL(request.url)
|
||||
|
||||
// 只处理同源请求
|
||||
if (url.origin !== self.location.origin) return
|
||||
|
||||
// API 请求:network-first,失败时返回缓存
|
||||
if (url.pathname.startsWith('/api/')) {
|
||||
event.respondWith(
|
||||
fetch(request)
|
||||
.then((response) => {
|
||||
// 缓存成功的 GET 响应
|
||||
if (request.method === 'GET' && response.ok) {
|
||||
const clone = response.clone()
|
||||
caches.open(API_CACHE).then((cache) => cache.put(request, clone))
|
||||
}
|
||||
return response
|
||||
})
|
||||
.catch(() => {
|
||||
// 网络失败,尝试缓存
|
||||
if (request.method === 'GET') {
|
||||
return caches.match(request).then(
|
||||
(cached) => cached || new Response(
|
||||
JSON.stringify({ detail: '离线模式,数据不可用' }),
|
||||
{ status: 503, headers: { 'Content-Type': 'application/json' } }
|
||||
)
|
||||
)
|
||||
}
|
||||
// 非 GET 请求离线时返回错误
|
||||
return new Response(
|
||||
JSON.stringify({ detail: '离线模式,操作不可用' }),
|
||||
{ status: 503, headers: { 'Content-Type': 'application/json' } }
|
||||
)
|
||||
})
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
// 静态资源:cache-first,失败时网络
|
||||
event.respondWith(
|
||||
caches.match(request).then((cached) => {
|
||||
if (cached) return cached
|
||||
return fetch(request).then((response) => {
|
||||
// 缓存成功的响应
|
||||
if (response.ok && request.method === 'GET') {
|
||||
const clone = response.clone()
|
||||
caches.open(STATIC_CACHE).then((cache) => cache.put(request, clone))
|
||||
}
|
||||
return response
|
||||
})
|
||||
})
|
||||
)
|
||||
})
|
||||
Reference in New Issue
Block a user