Commit Graph

34 Commits

Author SHA1 Message Date
浅念 6880ff1b97 feat(auth): 登录页(用户名/密码换 API token)+ 前端全链路登录态
后端:
- POST /api/auth/login:admin 账密(Settings 默认 admin/admin123,
  ADMIN_USER/ADMIN_PASSWORD 可覆盖)换取共享 api_token,免 token 中间件
- 防爆破:同 IP 15min 窗口内 5 次失败锁 15min(429),成功登录清零
- 错误信息统一「用户名或密码错误」(防用户名枚举)
- 测试 7 个新增(TDD),全量 500 绿

前端:
- LoginView + 路由守卫(未登录跳 /login,回跳 redirect)
- axios 请求拦截器自动带 Bearer;401 清登录态回登录页
- 媒体直链统一 mediaUrl() 带 ?token=(img/audio 标签发不了 header),
  替换 4 处裸拼;downloadBlob 手动带头
- isLoggedIn 按 key 存在判定 — 后端鉴权关闭时空 token 不锁死登录页
- MainLayout 侧栏底部退出登录

compose:两份编排透传 ADMIN_USER/ADMIN_PASSWORD(默认 admin/admin123)

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-09-03 15:03:20 +08:00
浅念 2c5cea1565 fix(staffchat): 聊天窗默认时段改全部时间+空态分语(用户报很多聊天记录空的)
defaultRange() 默认近 14 天窗,实测 78% 群(766/979)/89% 单聊(9374/10497)
的最新消息在任意 14 天窗外——这些会话打开即全空(典型:张士蓓「11台长安X5」
1016 条消息全在 7-27 前,默认窗滤成 0 条,云客后台却看得到)。云客默认直接
展示最近消息不限窗,对齐改为默认全部时间;首屏本就跳最后一页看最新+上翻
加载更旧,全量窗下首屏仍只拉一页。空态分语:有窗=「所选时间范围内无消息,
清空日期窗可查看全部」,无窗=「该会话无聊天记录」(真没聊过)。

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-27 15:15:41 +08:00
浅念 7e8624674e fix(staffchat): SessionPane 补请求序号防竞态(对齐全 pane 惯例)+置顶卡不显今日红点(spec §5)
Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-25 21:03:36 +08:00
浅念 50635d0df8 feat(staffchat): 入口改造(StaffList/CustomerList微信行切新页)+useStaffProfile缓存+StatsPane固定列/金额格式+vitest依赖化
Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-25 19:56:22 +08:00
浅念 4c3bc3ee93 feat(staffchat): 统计分析7tab(分型明细列+计数徽标+近7天窗+msgid定位,对齐云客)
- StatsPane 占位替换: 7 tab(label 带 (N) 计数)+daterange 默认近7天(清空后端兜底)
- 明细列配置驱动(KIND_COLS);link 列跳 single/group 聊天;红包/转账行带 ?msgid 定位
- 语音通话列对齐 CallList(通话人/类型/呼入呼出/接通状态/时长/录音播放 dialog/时间/操作)
- 敏感词 tab 空态卡(词库未配置,待 C1 接入,零请求)
- 员工微信列用资料卡信息(明细行无 staff 字段,数据本属该员工)
- counts 与明细解耦;双 seq 竞态守卫(兄弟组件惯例)
- api: getStaffStatsDetail kind 收紧为 StaffStatsKind 联合(后端 Literal 6 值)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-25 19:32:14 +08:00
浅念 8dba4a6104 fix(staffchat): ContactsPane 加请求序号防 ownerId/翻页切换竞态(对齐 ChatMain/MomentsPane 惯例)+修正跨tab关键词注释
Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-25 19:06:55 +08:00
浅念 0371484dad feat(staffchat): 通讯录(客户表+群表列对齐云客+批量勾选导出+分页)+朋友圈翻页失败内联重试
Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-25 18:56:02 +08:00
浅念 328aec80bc feat(staffchat): 朋友圈feed(作者卡+九宫格预览+点赞列表+滚动翻页,对齐云客)
Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-25 18:30:45 +08:00
浅念 91639b28d8 fix(chat): loadInitial/loadTalkerName 加请求序号防会话切换竞态(ChatMain+ChatTimeline同修)
Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-25 18:20:14 +08:00
浅念 3aaf4ec8fa feat(staffchat): 消息右列(近14天默认窗+9类类型过滤+msgid定位+导出,复制改造自ChatTimeline)
Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-25 18:10:30 +08:00
浅念 98fb4b8248 fix(staffchat): 回list模式重载会话列表(修复search期间切tab后列表与高亮标签矛盾的残留边缘)
Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-25 17:45:55 +08:00
浅念 026381f6e6 fix(staffchat): 搜索聚合取最新命中(ASC页1陷阱)+tab切换不清搜索结果+is_send守卫兜底名+截断提示+TAB_KEYS单源
Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-25 17:42:43 +08:00
浅念 0f7dee9693 feat(staffchat): 会话中列(双模式搜索+已删除好友tab+置顶区+相对时间,样式沿用墨玉主题)
Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-25 17:28:45 +08:00
浅念 eb0388c8b0 feat(staffchat): 页面骨架+左侧资料卡/5导航/折叠(三栏布局对齐云客)
- StaffChat.vue: 路由驱动 tab(single/group/moments/contacts/stats)+折叠态,
  三栏 flex(左栏240/中列280/右列flex:1,高calc(100vh-120px));资料卡走
  getAccounts(channel=wechat) 按 account_id 匹配,失败退 ownerId 兜底
- StaffChatSide.vue: 员工资料卡(头像/昵称/真名·电话/微信号)+竖排5导航+
  底部收起;墨玉主题沿用 ChatSidebar 手法(点阵底/玉绿渐变分隔线/药丸按钮)
- 5 占位组件(SessionPane/ChatMain/MomentsPane/ContactsPane/StatsPane),
  defineProps/defineEmits 签名按 Task 10-14 锁定
- relativeChatTime 签名可空友好(ms?: number|null,null→''),spec+1例

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-25 17:03:19 +08:00
浅念 c96f638bab fix(staff): 弹框富单元格TS修(Col加type字段+删unused staffInfo)+后端staff-chat-stats补head_image_url/real_name 2026-08-25 10:27:29 +08:00
浅念 b6eea3070a feat(staff): 弹框客户微信/员工微信列改富单元格(头像+昵称+ID+真实姓名,对齐云客)
Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-25 10:24:07 +08:00
浅念 0d19289fba feat(staff): 沟通数弹框加汇总说明(对齐云客:总X人次,重复Y,剩余Z条,玉绿左边框)
Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-25 10:08:44 +08:00
浅念 d4deb769e5 feat(chat): 会话侧栏全面美化(墨玉主题:药丸tab+圆角会话卡+今日红点+玉绿高亮)
Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-25 09:43:56 +08:00
浅念 85057e65dc feat(chat): 侧栏筛选改tab按钮式(好友列表|群列表带计数,对齐云客聊天窗口)
Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-24 18:34:16 +08:00
浅念 a7ef8632a0 feat(chat): 群聊隐藏左侧会话列表(对齐云客)+会话名WA去@s.whatsapp.net后缀显号码
Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-24 18:29:27 +08:00
浅念 ff73c056e9 feat(chat): 聊天排版升级微信标准(左右分侧+头像+绿气泡)+is_send数据修复
- is_send 根因:云客消息方向在 mine 字段(isSend 全 null),归一化加 fallback
  +存量回填 60.7 万行(51万收/16万发)——分侧数据首次完整
- MessageBubble:头像(对方=raw headUrl 在左/自己=默认在右)、自己侧隐藏昵称、
  接收白底描边/发送微信绿 #95ec69、气泡列 max-width 78%
- 实测混合对话:13发(绿+头像右)/7收(白+头像左)全部正确

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-20 15:26:04 +08:00
浅念 2154d050e5 fix(media): image_legacy渲染+下载覆盖+WA raw_json URL回退
Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-13 14:02:42 +08:00
浅念 5ce33232c1 feat(sync): 聊天图片本地化(message media_hash+download_message_images+local-first rendering)
- Message 模型新增 media_hash 列 (sha256 FK -> Media.media_hash)
- Alembic 迁移 e5f6a7b8c9d0_message_media_hash (batch_alter_table, SQLite/MySQL 通用)
- app/scraper/media.py:download_message_images 批量下载器,镜像 download_call_recordings
  - 候选: media_hash IS NULL AND channel IN ('wechat','whatsapp') AND type IN ('image','video','file') AND 任一 file_*_url LIKE 'http%'
  - image 类型优先 file_th_url (缩略图,小快省),video/file 优先 file_url
  - per-row try/except + per-run tried set,失败不挂循环
- sync_message_images orchestrator 入口 + ENTITY_MESSAGE_IMAGES 常量 (提交自身 SyncRun,镜像 call_recordings)
- scheduler: _run_message_images + ENTITY_FUNCS['message_images'] + 加入 daily all job (尾部)
- MessageOut schema 暴露 media_hash 字段
- MessageBubble.vue local-first: media_hash 优先 /api/media/{hash},否则回退 OSS file_url/file_th_url/file_hd_url
- types.ts: Message 接口添加 media_hash 字段
- 新增 test_message_images_downloader.py (6 tests, 镜像 test_recording_downloader)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-11 18:24:11 +08:00
浅念 538a0dc635 feat(sync): 长语音音频本地化(voice_clip media_hash+download+local-first playback)
Mirror download_call_recordings pattern for voice_clips:
- VoiceClip.media_hash column + Alembic migration (c4d5e6f7a8b9)
- VoiceClipOut.media_hash + frontend VoiceClip.media_hash type
- download_voice_clip_audio in app/scraper/media.py (resilient, sha256-dedup,
  same download_url/upsert_media helpers as call recordings)
- sync_voice_clip_audio orchestrator wrapper (commits own SyncRun, mirrors
  sync_call_recordings semantics)
- scheduler: _run_voice_clip_audio + ENTITY_FUNCS['voice_clip_audio'] +
  appended to daily _run_all job (after voice_clips)
- VoiceClipModal playClip local-first: /api/media/{media_hash} with OSS
  oss_file_name fallback (mirrors CallList.playRecord)

Tested: 376 pytest pass; vue-tsc clean; migration applied; 1523/1533 clips
localized (10 pending are genuine upstream HTTP 404s — resilient skip).

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-11 12:06:26 +08:00
浅念 2b2f863800 feat(calls): VoiceClipModal 录音异常检查(本地元数据标记+仅看异常筛选)
Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-11 10:50:49 +08:00
浅念 9da272b992 feat(calls): voice_clip 手动匹配(voice_clip↔customer 本地关联写操作)
- VoiceClip: 新增 matched_friend_id 列 (String(128), nullable) + alembic 迁移 b3c4d5e6f7a8
- PATCH /api/voice-clips/{id}/match: friend_id 关联 / null 取消 (本地写, 不回写云客)
- GET /api/voice-clips: 批量解析 matched_friend_name (remark>nickname>real>id)
- VoiceClipModal: 已匹配客户列 + 匹配/取消匹配按钮 + 嵌套客户选择 picker (默认按员工列客户, 名搜索走 /search)
- 测试: 17 passed (新增 7 个 match 用例覆盖 set/clear/name 解析/404)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-11 10:43:34 +08:00
浅念 f1b5861b35 feat(calls): VoiceClipModal 只读长语音列表+播放,接入 CallList(微信+WA语音)
Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-10 18:37:29 +08:00
浅念 394bfa8a7c feat(chat): getSessions + ChatSidebar 会话列表组件
Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-08 15:13:30 +08:00
浅念 1368e3a471 feat(modal): YkStaffDetailModal Col 支持可选 onClick(单元格可点)
Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-06 17:32:05 +08:00
浅念 02a709ba93 fix(staff): format time columns in detail modal
YkStaffDetailModal Col gains optional formatter; baseCustomerCols time cols render via formatTime instead of raw epoch.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-05 18:58:06 +08:00
浅念 8e79f80925 feat(ui): YkStaffDetailModal shared detail-modal component
Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-05 18:51:35 +08:00
浅念 8fde1d8597 fix: render chat media by URL (images/video/voice) instead of unknown-type placeholder
MessageBubble.vue was keys off the (incomplete) type code, so many messages
with real OSS media URLs (https://wx.oss.yunkecn.com/.../*.webp|*.mp4) showed
as '[未知消息]'. Rendering is now URL-driven: pick the best http URL from
file_url > file_hd_url > file_th_url, then render by extension
(image/video/audio/file). Type code is only used as a last-resort label.

- MessageBubble.vue: URL-driven cascade (URL by ext → duration →
  transcription → text → structured-type placeholder → localized tag).
  Image/video/audio/file children @click.stop so the all-fields drawer
  still opens on bubble click but not on media interactions.
- format.ts: wechatTypeLabel(type_raw) maps known codes (3→图片, 34→语音,
  43→图片/表情, 49→文件/名片, 42→名片, 9→表情, 20→红包/转账).
- ChatTimeline.vue drawer type tag uses wechatTypeLabel for WeChat msgs.
- style.css: compact .yk-msg__audio player for voice-with-URL messages.

Verified against smoke.db: 25 type-3 images + 3 type-43 videos that
previously showed '[未知消息]' now render as images/video. Build clean.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-05 10:23:01 +08:00
浅念 6ac47a1203 feat: full-field display for message/staff/accounts (raw_json + drawers)
Replicates the Customer all-fields pattern across the remaining three
entities. Backend now exposes `raw_json` on MessageOut / StaffOut /
AccountOut so the frontend can render every 云客 source field without a
second endpoint. Each entity gains a Chinese-label field utility + an
el-drawer surfacing all fields (structured-first, raw_json fallback,
unknown keys under 其他).

Backend:
- schemas.py: add `raw_json: dict | None` to MessageOut / StaffOut /
  AccountOut. MessageOut/StaffOut pick the column up via from_attributes;
  AccountOut is built explicitly in the router, which now threads
  `raw_json` through from both WechatAccount and WhatsappAccount rows.
- tests: new raw_json serialization tests for messages, staff, accounts
  (assert populated dict round-trips verbatim + NULL serializes as null).

Frontend (yunkes/):
- New utils: messageFields.ts, staffFields.ts, accountFields.ts — each
  with a 中文 label map, ordered groups, structured-column preference,
  and an 其他 fallback for unknown raw_json keys.
- Message: clicking a chat bubble opens an all-fields drawer (referMsg
  renders as pretty-printed JSON). Image preview + file download links
  stopPropagation so their own interactions still work.
- Staff: row click → drawer; columns relabeled (员工ID, 销售手机).
- Accounts: new AccountList.vue at /accounts with a 账号 nav item,
  unified WeChat/WhatsApp table (渠道/账号ID/昵称/微信号/归属员工/好友数/
  群数/收发/在职/最后更新), channel filter, pagination, row-click drawer.
- api: add Account type + getAccounts(); add raw_json to Message/Staff.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-01 17:47:50 +08:00
浅念 6c4cd92ae6 feat: vue3 frontend scaffold + org tree + customer list + chat timeline
M5b viewing frontend for the yunke data-mirror, under yunkes/.

- Scaffold: Vite + Vue 3 + TS, with element-plus, @element-plus/icons-vue,
  pinia, vue-router@4, axios. Dev server on :5173 with /api and /api/media
  proxied to the FastAPI backend on :8000.
- API client (src/api/): axios instance (baseURL '/api') whose response
  interceptor unwraps the axios envelope; typed wrappers (getCustomers,
  getMessages, getDepartments, getStaff) returning Page<T> / arrays; types
  mirroring the backend *Out schemas (Message typed as a permissive superset
  so file_th_url/duration/transcription_text degrade gracefully today and
  light up once MessageOut exposes them).
- Layout: el-header top bar (title + channel switch) + el-aside department
  tree (built from the flat parent_id list via useOrgStore, with search
  filter) + el-main router-view.
- CustomerList (/customers): el-table with channel filter, department filter
  driven by the tree selection (route query), pagination, and row-click into
  the chat timeline (channel + owner_account_id + talker_id).
- ChatTimeline (/chat/:channel/:ownerId/:talkerId): asc-ordered message
  bubbles keyed by is_send (direction) and type (text/image/video/voice/file/
  divider/system/unknown); lands on the most-recent page and prepends older
  pages via load-more with scroll anchoring.
- Home '/' redirects to '/customers'.

npm run build (vue-tsc -b + vite build) is clean.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-01 16:27:22 +08:00