mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-05-12 02:20:58 +08:00
feat: 新增 AI 助手页面 + 图片识别功能 + 更新宣传素材
- 新增 AI 助手页面 (assistant.js/assistant.css/assistant.rs) - 新增图片识别截图 (13.png) 并加入官网和 README - 更新宣传视频 (promo-web.mp4) 含 AI 助手+工具调用+图片识别场景 - 更新视频封面 (video-cover.png/video-cover-light.png) 突出 AI 助手 - 更新 AI 助手演示 GIF (ai-assistant-demo.gif) 作为 README 首图 - 更新功能矩阵 GIF (feature-showcase.gif) AI 助手为 star 卡片 - 官网新增图片识别 showcase 区块 - README 新增图片识别特性和截图 - 视频封面改用专业设计版本 - 演示视频时长 badge 更新为 50 秒
This commit is contained in:
@@ -730,6 +730,50 @@ const handlers = {
|
||||
},
|
||||
}
|
||||
},
|
||||
// 数据目录 & 图片存储
|
||||
assistant_ensure_data_dir() {
|
||||
const dataDir = path.join(OPENCLAW_DIR, 'clawpanel')
|
||||
for (const sub of ['images', 'sessions', 'cache']) {
|
||||
const dir = path.join(dataDir, sub)
|
||||
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true })
|
||||
}
|
||||
return dataDir
|
||||
},
|
||||
|
||||
assistant_save_image({ id, data }) {
|
||||
const dir = path.join(OPENCLAW_DIR, 'clawpanel', 'images')
|
||||
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true })
|
||||
const pureB64 = data.includes(',') ? data.split(',')[1] : data
|
||||
const ext = data.startsWith('data:image/png') ? 'png'
|
||||
: data.startsWith('data:image/gif') ? 'gif'
|
||||
: data.startsWith('data:image/webp') ? 'webp' : 'jpg'
|
||||
const filepath = path.join(dir, `${id}.${ext}`)
|
||||
fs.writeFileSync(filepath, Buffer.from(pureB64, 'base64'))
|
||||
return filepath
|
||||
},
|
||||
|
||||
assistant_load_image({ id }) {
|
||||
const dir = path.join(OPENCLAW_DIR, 'clawpanel', 'images')
|
||||
for (const ext of ['jpg', 'png', 'gif', 'webp', 'jpeg']) {
|
||||
const filepath = path.join(dir, `${id}.${ext}`)
|
||||
if (fs.existsSync(filepath)) {
|
||||
const bytes = fs.readFileSync(filepath)
|
||||
const mime = ext === 'png' ? 'image/png' : ext === 'gif' ? 'image/gif' : ext === 'webp' ? 'image/webp' : 'image/jpeg'
|
||||
return `data:${mime};base64,${bytes.toString('base64')}`
|
||||
}
|
||||
}
|
||||
throw new Error(`图片 ${id} 不存在`)
|
||||
},
|
||||
|
||||
assistant_delete_image({ id }) {
|
||||
const dir = path.join(OPENCLAW_DIR, 'clawpanel', 'images')
|
||||
for (const ext of ['jpg', 'png', 'gif', 'webp', 'jpeg']) {
|
||||
const filepath = path.join(dir, `${id}.${ext}`)
|
||||
if (fs.existsSync(filepath)) fs.unlinkSync(filepath)
|
||||
}
|
||||
return null
|
||||
},
|
||||
|
||||
check_panel_update() { return { latest: null, url: 'https://github.com/qingchencloud/clawpanel/releases' } },
|
||||
write_env_file({ path: p, config }) {
|
||||
const expanded = p.startsWith('~/') ? path.join(homedir(), p.slice(2)) : p
|
||||
|
||||
Reference in New Issue
Block a user