Browse Source

提交当前前端改动,并把 README 收成简短说明。

涵盖回答展示、政策卡片、反馈和企业登录相关改动,以及运行时配置和政策库数据。README 不再保留按日长记录。

Co-Authored-By: Cursor <cursoragent@cursor.com>
gongtianxiao 15 hours ago
parent
commit
12c213bac2

+ 20 - 678
README.md

@@ -1,687 +1,29 @@
-# zhaoshang-llm 改动记录
+# 青浦区营商智能助手
 
-> 本文件当前只记录**按日期的改动**。项目概述、技术栈、目录结构、接口说明等内容,
-> 等项目结束时再统一总结。
+企业政策匹配与办事咨询的前端。Vue 3 + TypeScript + Vite。
 
-## 20260914
+用户提问后,对话走 `POST /api/chat`(SSE)。`src/components/api-chat-coordinator.ts` 把事件翻译成内容标记,再交给消息组件渲染正文、政策卡片、参考资料和补问。
 
-- AI 对话迁移到接口 `POST /api/chat`(SSE)
-  - 新增协议适配层 `src/components/api-chat-coordinator.ts`,把 SSE 事件翻译成既有渲染组件
-    可识别的内容标记,渲染层无需感知新协议
-  - 请求体严格只发 `{thread_id, question}`;`answer` 与 `result.response` 只展示一次;
-    未收到 `done`/`error` 即断流时按连接中断处理,不自动重试
-  - 旧协议实现 `src/components/stream-message-coordinator.ts` 保留未用
-- 新增环境变量 `VITE_CHAT_API`,新增 dev 代理 `/chat-api` → `http://192.168.2.23:8000`
-- 政策卡片、政策详情、参考资料、公司补问与候选确认接入新协议
-- 错误码翻译:把 HTTP 与 SSE 错误码转成中文提示(如 `thread_busy` → 该问题还在处理中)
+## 本地运行
 
-## 20260915
+```bash
+npm install
+npm run dev
+```
 
-- 修复回答内容顺序:正文 → 政策卡片 → 综合说明 → **参考资料**(参考资料移到最下方)
-- 修复换行丢失:块级 markdown 下单个换行会被折叠,导致列表后紧跟的说明行被并进上一条列表项
-- 修复复制功能:复制结果剔除协议标记,不再把 `<scope>`、`<!-- POLICY_TABLE -->`、
-  `<ref_links>` 等原始标记一起复制出来
-- 修复卡片顺序与「更多」列表不一致:卡片改为按接口 `priority.rank` 排序
-- 「更多」面板的列表改为复用卡片数据,不再拉取与卡片无关的公共政策库
-- 部门筛选还原为最初的 15 个固定部门与字面匹配(此前一度改为按接口数据动态生成)
-- 新增惠企政策库来源标识(来自惠企政策库的卡片在右上角打标)
-- 政策详情面板新增「条件核验 / 匹配依据 / 原文引用」三个区块
-- 建立本机开发工作流文件与接口参考目录(按 `.gitignore` 约定不入库)
+开发地址:https://localhost:8083
 
-## 20260916
+```bash
+npm run build
+npm run preview
+```
 
-- 打字机速度加快:每次打出字数 2 → 4(61 → **121 字符/秒**),积压加速档位同步上调。
-  基准取主流 AI 的实测输出速度(Claude 3.5 约 60 字符/秒、DeepSeek-R1 约 75,
-  主流区间 50~120),取区间上沿——因为本项目后端一次返回整段,打字机是纯额外延迟,
-  同样速度会比主流慢一整段
-- 「政策事项列表」统一为**一个列表、一个入口**:
-  - 卡片区「更多 >>」与详情的「返回政策事项列表」**走同一条路径、内容相同**
-  - 列表数据统一来自 `public/merchant-agent/policies_public.v1.json`
-    (262 条申报事项 / 38 个政策),**本轮匹配到的惠企政策置顶**
-- 「政策事项列表」**每次进入都重置筛选**(部门 / 分类 / 关键词 / 页码),
-  避免上次的筛选残留导致「条目少」或「筛不出东西」
-- 政策详情面板的「返回政策事项列表」按惠企政策区分:**只有惠企政策才显示该入口**;
-  惠企政策判定优先用接口字段 `is_policy_library`,缺失时回退到按标题在库中匹配
-  (已做归一化,容忍《》全半角括号等差异)
-- 公司补问改为按 `status` 字段判定形态(`found` / `not_found` / `failed` / 无 `status`),
-  替掉原先靠"候选数是否为 0"和 `input_help` 文案正则的猜测式判断
-  - `failed`(查询服务失败)此前会落进 `not_found` 分支,文案被填成"未查询到匹配的公司",
-    等于把失败说成查无公司,已改为独立分支并说明失败原因
-  - 无 `status`(初次询问是否需要公司信息)此前给"跳过公司查询",改为"不需要公司信息"
-- 补问卡片:输入框移到选项上方并常驻(原来在选项之后、需点击才展开)
-- 补问卡片:修复选项序号错乱——输入框在最上却拿 B、选项在下面却拿 A,现输入框取 A、选项顺延
-- 补问卡片:正文里已展示过的同一段文字不再在卡片内重复
-- 「跳过公司查询」由发送 `/skip` 改为发送选项文本「跳过公司查询」
-- 问卷提交:修复只取第一题(多题丢失)、多选只取第一项、以及数字开头选项被静默改写成纯数字
+部署后的接口与栏目配置在 `public/config.js`,可直接修改,不必重新打包。
 
-## 20260917
+## 目录
 
-- 修复切会话时误报「请求已取消」:
-  - 根因是**两处「内容是否为空」的判空口径不一致**——归一化用 `content.trim()`
-    (`<scope>` 进度块算作有内容),渲染层用 `stripScopeBlocks()`
-    (进度块不算内容)。同一段内容,一处认为「有」、一处认为「没有」
-  - 新协议的正文要等 `done` 才写入,处理期间内容**只有进度块**,把这个缝隙
-    从偶发放大成「一切会话就出现」:归一化认为有内容 → 不替换文案,却把状态翻成
-    Finish;渲染层认为没内容 → 显示「请求已取消」,而请求其实还在跑
-  - 修法:抽出**唯一**的判空口径 `hasVisibleMessageContent()`(`utils/interrupted-message.ts`),
-    归一化与渲染层都改用它
-  - 新增回归脚本 `harness/tools/verify-empty-content-agreement.mjs`,
-    断言的不变量就是「两处必须一致」,30 项断言
-- 删除政策详情面板的「原文引用」板块(条件核验、匹配依据保留)
-- 思考中卡片的阶段文案一律不换行:
-  - 原因:`ScopeContent` 按卡片宽度切样式 —— 没撑满容器时标题 `nowrap` + 省略号,
-    撑满时切成 `pre-wrap`。而阶段文案长度不一(新协议的文案比原来的"正在思考中..."长得多),
-    切换时表现为「突然换行」且卡片高度跳动
-  - 改法:拆开原本同时管标题与正文的规则 —— **正文保持可换行**,
-    标题恒定 `nowrap` + 省略号
-- 政策详情面板的「政策名称」支持点击跳转:由库条目的 `data.市级政策id`
-  拼出 `https://zwdt.sh.gov.cn/qykj/shell_oc_policy_zq/policy/policy-detail?id=<id>`
-  - 背景:库里 `apply_link` 字段 262 条**全为空**;`资源申请备注` 里的 URL 是按申报事项
-    零散对应、且混有内网地址(25 条指向 `http://10.235.238.34:7202/imanage/login`),
-    不能作为来源。`市级政策id` 有 261/262 条,可靠
-  - 没有 id 时不给链接(**不猜**),宁可没有也不指向打不开的地址
-- 查明「政策名称」显示为纯文本的真因,并调整政策库数据源(**开发环境改用本地 json**):
-  - 政策库其实有**两个来源**,字段并不一致:
-    - 本地 `public/merchant-agent/policies_public.v1.json`:262 条,`data.市级政策id` 有 **261** 条
-    - 远端 `VITE_DOWNLOAD_URL`:327 条,该字段**一条都没有**(它有的 `policy_id` 是 40 位、
-      与条目 `id` 相同,与 24 位的 市级政策id 是**两套 id 体系**)
-  - 而 `index.html` 原本是**远端优先**(远端带 CORS 头,浏览器里确实会赢),
-    于是取不到 id → 拼不出详情地址 → 「政策名称」是纯文本。
-    此前怀疑的「HMR 状态陈旧」「走了兜底路径」均**排除**
-  - 新增环境变量 `VITE_POLICY_LOCAL_FIRST`:**仅开发环境**打开(本地优先、远端兜底),
-    **生产仍远端优先**——生产该问题属后端数据缺失,需远端那份补上 `data.市级政策id`,
-    前端无法修
-  - 新增 `harness/tools/check-policy-sources.mjs`:对比两个来源的条数与字段覆盖率,
-    并在「远端也带上 id 了」时提醒可以移除该开关
-  - 代价:开发环境用的这份比远端少 65 条申报事项(262 vs 327)
-- 会话、问答记录与反馈**落地到 DMS 数据管理服务**(栏目 1887 助手会话 / 1889 助手问答记录)
-  - 提交问题时写入会话(按 `c_session_id` upsert:没有就新增、有就更新)与问答记录(先写问题);
-    回答完成补写回答;停止/断流也补写已生成的内容,避免中断的问答只有问题没有回答
-  - 会话列表、历史记录改为**从 DMS 读取**;会话改名、删除同步到 DMS
-  - 点赞/点踩/取消写入 DMS 的问答记录(按 `c_record_id` 定位那一行)
-  - **未登录的访客也写入**,以 `访客_<访客id>` 归属(访客 id 复用埋点的那个)
-  - 会话标识用前端的 `session.id`(它恒等于聊天协议的 `thread_id`);问答记录标识用
-    AI 消息 id(同时是反馈组件用的 `record.id`,因此从 DMS 读回的历史消息点赞仍能命中原始行)
-  - **token 只存在于 vite 代理侧**(`.env.development.local`,按约定不入库),
-    浏览器产物里没有 token;DMS 不可用时静默降级,聊天与本地历史不受影响
-  - 实测踩坑:DMS 的「删除」不是 `delContentById`(各种传法都返回参数错误),
-    而是 `POST /content/updateAudit` 把状态改成 `4`(销毁);`addContent` 会返回记录 uuid
-  - **存储粒度:一个会话一行**(不是一问一答一行)——整段对话的消息数组以 JSON 存进
-    该行,每次以本地消息列表为准整段重写;反馈记在 JSON 里对应那条消息上
-- 去掉**开发环境硬编码账号的自动登录**:此前开发环境下会无条件用内置账号登录,
-  表现为「没有登录也进入登录态」。现在默认即访客态,要企业态需显式带
-  `?access_token=` 或 `?credit_code=`
-- 本机工作流文件(`harness/`)结构对齐
-  [Learn Harness Engineering 的 OpenAI 高级包](https://walkinglabs.github.io/learn-harness-engineering/zh/resources/):
-  `docs/plans/` → `docs/exec-plans/`(`completed/` + `tech-debt-tracker.md`),
-  并新增结构校验脚本 `harness/tools/validate-harness.mjs`(机械约束优先于口头约定:
-  可检出假 passing、多个 in_progress、游离的计划文件等)
-- **`harness/`、`CLAUDE.md`、`agents.md` 纳入版本控制**(此前排除)
-  - 依据:参考资料的原则是「计划、质量、技术债**和代码一起版本化**」——
-    团队 clone 应当能看到状态、计划与契约文档,而不是只在本机
-  - 仍然排除的是带凭据的本机文件(`.env.*.local`、`.claude/settings.local.json`),
-    以及 esbuild 生成的 `harness/tools/_*.mjs`(构建产物,入库会与源码漂移);
-    产物重新生成的命令写在 `harness/tools/README.md`
-  - 入库前做了凭据扫描(无真实 token),并**模拟 fresh clone**(删光产物 →
-    按文档重新生成 → 四个验证脚本全绿)确认别人拿到仓库能跑通
-- 修复「同一政策的多个申报事项,点『查看详情』内容一样」:
-  - 根因:同一条政策下的多个申报事项会各出一张卡片,但适配层把卡片的 `title` 与
-    `declaration_item` 都取自 `card.name.text`(**只有政策名**),而后端不下发
-    `id`/`policy_id`(实测恒为 undefined)——这些卡片在字段上完全无法区分,
-    原来的反查只要任一条件命中就返回,于是点第二张也跳到第一张
-  - 修法:反查逻辑抽成纯函数 `resolvePolicyDetailIndex()`,**对象同一性优先**,
-    退化的字段比对**只在唯一命中时采信**,多命中时交给「直接展示被点条目」的兜底
-    —— 宁可走兜底,也不张冠李戴
-  - 新增回归脚本 `harness/tools/verify-policy-detail-index.mjs`(10 项断言,
-    含「点第 2 张 → 下标 1」这条针对本 bug 的断言)
-  - 详情面板的标题改为显示**具体申报事项**(如「…的通知 - 创业开办费补贴」):
-    适配层的 `declaration_item` 改用后端每条唯一的 `data.title`,不再与卡片标题同值;
-    **卡片区标题仍是政策名,观感不变**(含一处连带的 `panelData.title` 取值顺序修正——
-    否则改详情标题会连带改掉卡片标题)
-  - 新增 `harness/tools/verify-policy-card-fields.mjs`(8 项断言:同政策两条必须可区分、
-    卡片标题不变、无后缀时退化为政策名)
-- 卡片区「更多 >>」改为打开新的**「政策列表」侧边栏**:
-  - 标题「政策列表」,保留搜索框与热门搜索,**移除部门/分类筛选**
-  - 内容为**本条回答里出现的政策卡片**(去重、按匹配度排序)
-    —— 注:2026-09-18 按需求调整,此前一度做成「本会话内所有消息出现过的卡片」
-    (跨消息聚合),那套聚合与它的采集函数已随本次调整删除
-  - 详情面板的「返回政策事项列表」**仍打开原来的惠企政策库列表**(两套列表并存,
-    按要求只换「更多」入口)
-  - 面板新增第三种模式 `cardList`,与旧列表**共用同一套模板与样式类,未新增 CSS**;
-    旧列表逻辑靠既有守卫自然短路,`openPolicyList` 一行未动
-  - 新增 `harness/tools/verify-policy-card-list.mjs`(24 项断言:坏 JSON/空输入不抛错、
-    首见优先去重、降序+同分稳定、六面关键词过滤)
-    —— 断言数由 31 降为 24:随「收回会话级聚合」删掉了那 7 项聚合断言
-- DMS 的问答记录存储粒度**改回「一问一答一条」**(幂等键 `c_record_id`,
-  问题与回答各存一半)。曾一度改成「一个会话一行、整段对话 JSON 塞进 `c_answer`」,
-  现按需求改回——更贴近库表原本语义(`chat_record` 即一行一轮问答),也便于按轮次检索统计。
-  反馈随之改为写在该轮的 `c_feedback_*` 列上;会话删除连带清理其名下所有问答行
-- 计划归档:`harness/docs/exec-plans/completed/` 开始启用,
-  已实现的两个计划(DMS 落地、政策列表侧边栏)移入并更新状态;
-  结构校验脚本新增两条检查(`active/` 里状态写着已完成、`completed/` 里状态仍写进行中)
-- **按会话并行生成**(改为 ChatGPT 桌面那种模型):
-  - 此前全局只有一个协调器实例 + 一个全局 `isGenerating`,于是「同一时间只能一个会话在生成」,
-    并衍生出两个 bug:生成中切到别的会话,发送按钮仍显示「停止」(想发送却停了生成);
-    停止时目标会话解析错误(同步事件把它提前清空 → 回落到「当前会话」),
-    会把停止打在看的那条会话上、并凭空造出一条空的「请求已取消」消息
-  - 现在生成状态按会话隔离(`tasks` Map + 每轮独立协调器实例 + 监听器闭包捕获会话 id),
-    各会话并行、互不干扰;停止只停自己那一轮;新建会话不再打断正在生成的会话
-  - 顺带修好了两处静默失败:后端 409 等提示此前**无人监听**(现接到全局 Toast)、
-    同会话重复发送此前静默无反应(现提示「该会话已有回答在生成中」)
-  - 新增回归脚本:`verify-chat-task-utils.mjs`(33 项,含把「响应式容器破坏对象同一性」
-    这个陷阱钉死的断言)、`verify-coordinator-multi-instance.mjs`
-    (11 项,验证多实例事件隔离——并行化的地基)
-- 清理项目(用户要求):
-  - 删掉 **5 个无人读取的 env 变量**(`VITE_STREAM_SERVER` / `VITE_STREAM_TOKEN` /
-    `VITE_HUMAN_IDLE_MP4_URL` / `VITE_PLUGIN_URL` / `VITE_PLUGIN_ASR`)——数字人与插件那条
-    **从未接入本项目前端**的链路的遗留;其中两个还是入库的凭据
-  - 合并 `.env.development` 里重复定义的 `VITE_ASR` / `VITE_XF_ASR`(**后定义的才生效**)
-  - 删掉无代码使用的 vite `/stream/` 代理(`/asr/` 保留,是切讯飞 ASR 的退路)
-  - 删掉空目录 `public/images`、`public/pencil_exports` 与构建分析产物 `stats.html`
-- **恢复上传图片/附件功能**(此前因新协议只收两个字段而挂起):
-  - 采用「把 OSS 地址拼进 `question` 文本」的方案(用户拍板,**不需要后端配合**)
-  - 关键:`sendMessage` 拆成两个变量——发给后端的 `questionForBackend`(含附件地址)与
-    本地用的原文 `text`(气泡、会话标题、DMS 记录都不显示 URL)
-  - 恢复「上传图片 / 上传附件」两个按钮(原先整块注释);拖拽与粘贴本来就是通的
-  - 取签名的地址做成 env `VITE_UPLOAD_SIGN_URL`(四份 env 均写,值仍为厂商地址),
-    将来换自建签名服务只改配置
-  - 实测:厂商签名接口 `//qingpu-data-api.metamaker.cn/common/qp_signed_url` **无需鉴权**即可取签名;
-    文件实际存放在**厂商的 OSS bucket `heijing-products`(杭州)**,
-    外链为 `https://prod.heijingai.com/qingpu/<uuid>.<ext>`
-  - 新增回归脚本 `harness/tools/verify-attachment-question.mjs`(10 项断言)
-- 删除统计埋点的老接口(用户要求):
-  - 删除调用点(`BusinessAssistant.vue` 的页面浏览、`BusinessRecord.vue` 的反馈统计)
-    与整个 `src/network/api/assistant-statistics.ts`,以及已无人使用的
-    `VITE_ASSISTANT_STATISTICS_BASE_URL`
-  - **点赞由「双写」变为只写 DMS**;运营侧的埋点数据从此不再上报
-  - 只保留 `getOrCreateAssistantVisitorId`(DMS 的 `访客_<id>` 归属在用),搬进 DMS 模块,
-    **localStorage key 保持不变**(改了会让已存在的访客换新 id)
-- 清理死代码(用户确认直接删除,非注释):
-  - `src/network/api/card/index.js` 整文件删除(三个函数均无调用方)
-    及其未使用的 import
-  - `PolicyListUpdatedMatch.vue` **有意保留**——老会话历史里可能仍有
-    `<policy-list-updated>` 块,删了那些卡片列表会渲染不出来
-
-## 20260918
-
-- DMS 写入范围收窄为**只写问答记录**:
-  - **1887 助手会话不再写入**(用户指示「只传具体的会话记录,另一个接口不传了」)——
-    新建会话、改名都不再同步;会话列表退化为纯本地(与接 DMS 之前一致)
-  - 1889 问答记录照常写入(含 `title` = 问题文本);删除会话仍清理其名下的 1889 记录
-  - 调用点按约定**注释保留**并标 `[已停用]`,同时在 `verify-dms-payload-fields.mjs`
-    里加了**源码级断言**(不得出现未注释的 `upsertDmsSession` 调用),防止被顺手改回
-- DMS 写入补齐 `title` 与运营分析字段:
-  - 会话(1887):每次 upsert 都显式带 `title` = 会话标题 —— DMS 的系统字段 `title`
-    原本只在创建时初始化,**改 `c_title` 不会带动它**,所以前端改名后 DMS 里看到的标题不变
-  - 问答记录(1889):`title` 用**问题文本**(原先库里是字符串 "null",
-    在 DMS 列表里看不出是哪一轮)
-  - 写入带 `title`(用户需求);1887 另有四个 `must=true` 的运营字段
-    (`summary` / `qpyszx` / `qyzt` / `rzqpyx`)——**不带就 `214 数据错误`,四个必须全带**,
-    但**只传空值/默认值**(取值属业务口径,前端不猜;用户拍板「先传空值」)。
-    ⚠️ **只在新增时带、更新时一律不带**——否则会把后端将来回填的值冲成空
-  - 新增 `harness/tools/verify-dms-payload-fields.mjs`(9 项断言):**打桩 fetch 抓真实请求体**,
-    断言字段集合「不多不少」且 `title` 的值正确 —— 这条**不需要 DMS token** 就能跑
-- 环境变量整理:**地址类配置收进 env,不再写死在代码里**
-  - 新增 `VITE_CHAT_TARGET`(聊天后端真实地址)——此前它硬编码在 `vite.config.ts` 的
-    代理配置里;现由 `vite.config.ts` 从 env 读取(保留同值兜底)
-- 移动端真机样式修复(用户反馈:夸克上第 3 段建议词被输入框遮住、vivo 上后两段被遮):
-  - 按用户给的方案收紧首页元素:顶栏 64px → 52px、logo 130×88 → 96×65、
-    标题 28px → 22px 且恒定单行、建议词区内边距与间距收窄 —— 估算内容总高 −17%
-  - 再按用户反馈调观感:标题与介绍文案两侧各留 28px、标题 22px → 20px、介绍文案 14px → 13px
-  - ⚠️ **根因没动,只是让内容放得下**:`.home-fixed-input` 仍是 `position: fixed` 悬浮,
-    给它预留的是写死的 `padding-bottom: 180px`(与输入框实际高度无关);
-    另有 `height: 100dvh` 无 `100vh` 兜底、页面无 `text-size-adjust: 100%` ——
-    见技术债第 7 条,换台手机仍可能变样
-- 首页标题文案:一度按指示去掉「你好」,随即按要求**加回**(仍为 `你好,有什么我可以帮您的?`)
-- 首页标题字号:几经反复,**当前值以这里为准** ——
-  **PC 保持 32px 不变**;**移动端 22px**(`clamp(17px,5.7vw,22px)`,≥386px 的屏恒为 22px,
-  更窄的屏按比例收缩以免标题被顶出屏幕)。过程:一度整体 −4px(PC 32→28、移动端 20→16)
-  → 用户反馈移动端「太小了」→ 全部还原 → 用户要求移动端调到 22px
-- **企业信息分类同步**(对话带回 `company_info` → 分类接口 → DMS 企业两栏目):
-  - 对话 `result` 事件里的 `company_info` 非空时,回答完成后自动同步到 DMS 两栏目:
-    **1888 企业基础信息** ← 分类接口(`POST /api/company/classify`)的六个角度标签,
-    一行一家企业(幂等键 `c_credit_code`,字段级 diff,无差异零写入);
-    **1886 企业荣誉信息** ← **`company_info.honors.records`**(逐条真实荣誉),一条荣誉一行
-  - 1886 与库里该企业的行按「荣誉名+级别+来源」**全量对齐**(补新增、更新差异、删多余),
-    **仅当 `honors.complete === true` 才删**;荣誉名写 `c_honor` 与系统 `title`。
-    —— 数据源曾用分类接口的「资质荣誉」标签,实测宇树科技只给 2 个标签而真实荣誉有 31 条,
-    按用户要求改为以 `honors.records` 为准(分类标签仍写进 1888 的 `c_tag_honor`)
-  - 全程 fire-and-forget:任何失败只 warn,不影响聊天;同企业并发走串行链
-  - 适配层新增捕获 `company_info`(原先 `result` 分支是空的、数据被丢弃)
-  - 回归脚本:`verify-company-classify-sync.mjs`(53 项纯逻辑)、
-    `verify-company-info-passthrough.mjs`(10 项,假 SSE 流验证适配层把 company_info 原样带出)、
-    `verify-company-classify-dms.mjs`(23 项打真实 DMS)、
-    `verify-company-classify-e2e.mjs`(16 项端到端:真实分类接口 + 真实 DMS)
-  - ⚠️ **分类接口对「精简/合成」的请求体一律 422**(连接口文档里自己的示例片段也被拒),
-    换成**真实完整的 company_info** 就返回 200 —— 是对载荷完整性的校验,不是接口坏了;
-    已在 `api-chat.md` 补上 company_info 的契约章节
-  - DMS 侧字段已就绪(1888 扩到 47 字段、1886 扩到 12 字段,含 `c_tag_*` 分类标签字段);
-    **两栏目都已有数据**(DMS 侧 2026-09-17 灌入),所以同步多为「更新已存在的行」,
-    只动身份三字段与标签字段;1886 靠 `c_source` 标记所有权,绝不碰灌入的荣誉行
-- 移除移动端 `@media (max-width: 360px)` 里那条 `.heading { font-size: 28px }`:
-  它最初与基础值同值(空操作),09-18 基础值改小后**变成窄屏把标题放大回 28px** 的覆盖,
-  而标题是 `white-space: nowrap` —— 360px 屏下标题宽 356px、可用仅 272px,**会溢出屏幕 84px**;
-  窄屏收缩已由 `.heading` 自己的 `clamp` 负责(已注释保留原文并写明原因)
-
-## 20260920
-
-- **企业信息同步扩充**:`company_info` 里 DMS 有列的字段现在**全部同步**
-  - 1888 企业基础信息:补上 **36 个工商信息字段**(企业名/经营状态/注册地址/注册资本/
-    经营范围/成立日期/曾用名/行政区划…,逐字段映射、字段级 diff、**无差异零写入**)
-  - 1886 企业荣誉信息:按后端 `honors.records` 逐条荣誉对齐(一条一行,`c_honor` 存荣誉名)
-  - 三条实现要点:**空值一律不写**(不清存量)、**JSON 列按语义比较**(库里是 Python/jsonb
-    序列化,带空格且键按字母序,直接比字符串会每轮误判成"有差异"而反复写)、
-    工商与荣誉**不依赖分类接口**(分类接口慢且偶发失败,拆开后互不牵连)
-  - 字段覆盖审计工具 `harness/tools/audit-company-info-coverage.mjs`:1888 写 43/47 列、
-    1886 写 12/13 列;未覆盖的 4 列(`c_scope_brief`/`c_phone_number`/`c_email`/`c_industry`)
-    后端接口本就没返回
-- 政策详情面板的「政策名称 / 政策所属部门」一行**拉满整行宽度**(与下方两张卡片右对齐):
-  原先名称列 `max-width: 462px` + 部门列写死 `110px`,整行只有约 520px 宽、右侧空一大块,
-  部门写全称时还被挤成三行;改为名称列占满剩余空间、部门列可伸展(下限仍 110px)
-- **CIPA / 出海类问答展示企业微信二维码**:后端在 `result.data.cipa` 给出布尔值,
-  `true`(问的是 CIPA / 海外服务平台 / 出海服务)时在**参考资料之前**追加一张二维码图片
-  (`src/assets/qiyeweixin.png`,点击可放大)
-  - 走适配层翻译成既有的 `<image-scope>` 内容标记,**渲染层零改动**(该标记本来就有对应行类型)
-  - 复制按钮的剥离规则同步补上 `<image-scope>`,避免把图片地址复制进剪贴板
-  - 适配层 15 项新断言(含 `false`/缺字段/非布尔值不显示、跨轮不串、**补问轮不展示**)
-  - 位置:**参考资料之前**;**补问轮(等用户补充公司信息/确认候选)不展示**——那一轮还没有正文回答
-- **回答正文改为真实增量流式输出**(后端 F073:`answer_start` / `answer_delta` / `answer_end` /
-  `answer_abort`,契约见 `harness/docs/reference/token-streaming.md`)
-  - 正文**逐片段实时上屏**,不再是"整段到达后逐字打字";思考中卡片在第一个字到达时即退场
-  - 为此在适配层加了**增量 markdown 规整器**(`src/components/answer-stream.ts`):
-    正文块用的规整函数是**插入空行**的,若不做增量规整,`answer_end` 的"整块替换"会与已流文本
-    分歧 → 整段重建 → 思考中卡片每轮闪现重播。规整器保证「已上屏内容恒等于最终全文的逐步前缀」,
-    正常路径因此退化为**纯尾缀追加**(零抖动)
-  - 实测(真实后端 505 片 delta / 876 字):`concat(deltas) === answer_end.text` 成立;
-    `answer` 事件是正文开头的**压缩版**,流式轮跳过不重复渲染(仅当与正文公共前缀 < 90% 才保留)
-  - 用户主动**停止保留已流出文字**;后端出错 / 断流**撤掉未定稿的草稿**
-  - 旧后端(不下发流式事件)与 mock 测试按钮**仍走原来的打字机**(回归重点)
-  - 新增 `verify-answer-stream.mjs`(78 项:纯逻辑 + 协调器级假流)、`probe-answer-stream.mjs`(真后端探针)
-
-## 20260921
-
-- **卡片改为「正文开流前」上屏**(对齐后端契约 F079):有入选政策时后端先发完完整的 `source`/`item`
-  才开始 `answer_start`,而前端此前一直等 `done` 才显示卡片 —— 只能靠整块重写把卡片插到正文之上,
-  界面上表现为「正文先渲一遍、又从头再渲一遍」。现在开流前就把卡片上屏,收尾只做纯追加
-- **修「同一段回答内容出现两次」**:真载荷实测 `answer_end.text`(1610 字)比增量拼接(1309 字)
-  **多 301 字**,导致应用侧记录的"流式正文"不再是上屏内容的后缀 → 重排落兜底分支 → 正文上屏两份。
-  修法:`answer_end` 后同步"流式正文",并加固兜底(对不上时**绝不重复插入正文**)
-- **参考资料改为「正文定稿就上屏」**:实测 `done` 要等 `result`(375~390KB 的完整快照),
-  比正文定稿晚 **3~10 秒**,而参考资料的数据(`source` 事件)在正文开流前就发完了 —— 等于白等。
-  现在正文一定稿就发;二维码(来自 `result.cipa`、只能等)走定向重排,保住「在参考资料之前」的版式
-- **修「文字快渲染完时视图被拽回回答顶部」**:流式期间正文是即时渲染的,但最后一行一直被标成
-  "打字未完成",收尾时整套打字机机制被重新启用,其中一环会把视图滚到最后一条 AI 消息的顶部。
-  修法:收尾时把已在屏幕上的行补记为「打字完成」
-- **大块内容改为对齐它的顶部**(不再滚过它):卡片/参考资料是一整块插入的(300~900px),
-  此前贴底滚动会一步滚过整块 —— 用户刚拿到卡片却看不到卡片
-- **「流式草稿被最终文本整段替换」记为已接受行为**:契约要求「完整校验后绑定真实链接,
-  随最终替换出现」「不能用 text 覆盖…不能只保留草稿」。实测草稿与最终文本的公共前缀只有 11.7%
-  (最终版给标题补了序号、把纯文本换成 markdown 链接)
-- **DMS token 不用再每次手填**:token 约 24 小时过期,以前要「改 .env + 重启 dev server」。
-  现在放在本机单行文件 `.dms-token`,代理**每个请求现读**(换 token 不用重启):
-  `npm run dms:token`(从剪贴板读)、`npm run dms:login`(账号密码自动登录)、
-  `npm run dev` 前自动续期。顺带发现原来 `.env.development.local` 里的 token 写在了**下一行**,
-  dotenv 读出来是空串 —— 等于一直没生效
-- 注释掉输入框右侧的测试用 MOCK 按钮组(资料/问卷/流测/回放/打字/Scope/测试输入)
-
-## 20260922
-
-- **1887 助手会话写入企业相关字段**(未登录也写):企业名称、统一社会信用代码、企业图片、是否登录
-  - 规则:**登录态的值优先级最高**(库里已有值也覆盖);对话带出的 `company_info` 值**与库里不同就更新**;
-    但**已被登录态认领过的行**(`c_is_login="1"`)不许被后来的访客对话改写 —— 否则会把这行改到别的公司名下
-  - **企业看不到陌生访客的会话**:读「我的会话」时排除访客行(改造前访客标识是随机的、本来也匹配不上,
-    这里只是保持一致的可见范围)
-  - `c_title` 不写(标题由运营侧生成);DMS 系统字段 `title` 只在建行那一刻带上
-- **访客归属改用本机 IP**:新增取 IP 接口(返回纯文本 IP;**走同源代理** —— 它是 HTTP 而页面是 HTTPS,
-  直连会被浏览器按混合内容拦掉),IP 存进 `c_ip`,访客身份为 `访客_<IP>`;
-  取不到 IP 时退回浏览器随机 id,不影响任何写入
-- **复制回答去掉 markdown 语法符号**:`###`、`**`、反引号、`[文字](链接)` 的括号语法、无序列表的 `- `
-  都不再复制出去;**有序列表序号保留**(顺序是内容)、**链接地址保留**(写成「文字(地址)」)
-- 排查中撞到一个 DMS 协议坑并记录:payload 里含模型里**不存在**的列时,`addContent` 会忽略该列照写,
-  而 `updateContent` 会**静默丢弃整个更新**(返回仍是 `{"code":200,"message":"成功"}`)——
-  新增列时必须先确认 DMS 侧已加
-
-## 20260923
-
-- **多模态输入:新增 `pictures` / `files` 两个请求字段**(后端扩展了 `/api/chat` 的请求体)
-  - `pictures`:**图片 URL 列表**;`files`:非图片文件 URL 列表。两者都是**字符串数组**
-  - 截图、文档上传后不再把 OSS 地址拼进问题文本,而是随请求体发出 ——
-    地址不再被模型当正文读,本地消息、会话标题、DMS 记录也不再被 URL 污染
-  - 实测(打真实后端):元素必须是 URL 字符串,传对象数组会被 `422 invalid_request` 拒掉;
-    带上 `pictures` 问「这张图片里是什么」,模型确实描述了图的内容(不是收下就忽略);
-    空数组与不传都接受
-  - 没有附件时**不发**这两个字段 —— 请求体与从前逐字节一致
-- **附件改为上传到 DMS 文件服务**(用户 2026-09-23):图片/文件走
-  `POST {DMS}/file/uploadFile`(multipart,五个字段全必填:file / type / columnId / contentId / paraName),
-  返回**相对路径**(如 `/static/photo/1889-c_question-<uuid>.png`),它随请求体发给后端;
-  原先直传厂商 OSS 的实现整段停用保留
-  - 缩略图预览:相对路径本身打不开,拼上 DMS 代理前缀才能取(实测 200),
-    所以刷新页面后气泡里的图还在
-  - 实测细节:`type` 决定目录(0 图 → `/static/photo/`,其余 → `/static/file/`);
-    少任何一个字段都返回 `{"code":-1,"message":"缺少必传字段"}`
-- **附件支持格式对齐产品提示,且不支持的格式改为 toast 提示**(用户 2026-09-23):
-  - 图片:**JPEG、PNG、GIF、WebP**;文件:**Excel(xls/xlsx)、DOCX、文字 PDF**
-    (此前图片漏了 GIF,文件多了 doc/txt/md 却**缺 Excel** —— 与提示对不上)
-  - 不支持的格式:**弹 toast 提示 + 不放进输入框**(此前是 `window.alert`;
-    拖拽路径还会把不支持的文件**静默丢弃**,用户不知道文件为什么没进去)
-  - 顺带修掉一个真 bug:图片校验此前是 `file.type.startsWith('image/')`,
-    等于**任何 image/* 都放行** —— SVG / BMP / HEIC 全被当图片收下;现改为按扩展名判
-- **全局提示改成 Ant Design 的 message**(用户 2026-09-23:「现在的 toast 太丑了,
-  希望是图片中的类型,从顶部弹出,过一段时间消失」):
-  - 原来的 `<Toast>` 是**全屏黑遮罩 + 居中白框**(本质是模态框的观感,还会挡住整页)
-  - 现在统一走 `@/utils/app-message`(Ant Design Vue 4.x 的 `message`,本项目已有该依赖):
-    顶部弹出、3 秒自动消失、错误为粉底红感叹号 —— 就是设计稿那种小条
-  - 调用方签名不变(`showToast(text)`);顺带发现 `BusinessRecord.vue` 里那份
-    `<Toast>` 与 `showToast` **没有任何调用点、也没有子组件 inject**(死代码),一并停用
-- **语音输入的 4 处 `window.alert` 一并换成轻提示**(用户 2026-09-23:「另外那几处语音的
-  window.alert 一同更换」):PC 1 处(初始化失败)+ Mobile 3 处(麦克风权限 ×2、初始化失败 ×1)
-  - 换成 `showToast(...)` 后与全站提示同一条链路(顶部弹出、自动消失),
-    不再有阻塞式弹窗;**文案与收尾动作一字未动**(仍会释放语音实例、复位状态)
-  - PC 端 `openMicroPhone` 返回 `false` 时仍是**静默 return**(无任何提示)——
-    与 Mobile 不一致,属已报告的待定项,**未擅自补文案**
-  - 保留项:清空输入框那句 `window.confirm("可能会清空之前的文字…")` 不换 ——
-    它是要用户做决定的**模态确认**,不是轻提示
-- **轻提示时长 3s → 2s**(工作区改动,随本次一并提交;改 `APP_MESSAGE_DURATION` 一处即可)
-- **修:提交之后气泡里看不到图片**(用户 2026-09-23 报):
-  - 根因:附件换成 DMS 之后,上传返回的是**相对路径**(`/static/photo/…`),
-    而消息附件仍把**相对路径**当展示地址用 —— `<img src="/static/photo/…">` 经 dev server
-    取回的是 index.html(200 但 `text/html`),图解不出来。
-    实测对照:相对路径 → `text/html`;`/dms-api` + 相对路径 → `image/png` ✓
-  - 修法:消息附件按上传模块同款分成两个字段 —— `url`(**可显示地址**,气泡里 `<img>` 用)与
-    `fileUrl`(**相对路径**,随请求体 `pictures`/`files` 发给后端),
-    `toChatAttachmentUrls` 改取 `fileUrl`(发给后端的地址与从前一致,不受影响)
-  - 非图片附件没有展示地址(气泡里本来就是「文件条」,只显示名字/大小)
-  - 回归脚本 39 → **51/51**(新增【7】12 项钉死这个契约,并用变异测试确认两个方向都会红)
-- **附件路径随问答记录落 DMS(`c_image` / `c_file`)**(用户 2026-09-23:在「助手问答记录」里
-  新建了这两个字段,要求把对应的路径存进去):
-  - 存的是**相对路径**(`/static/photo/…`)—— 与请求体 `pictures`/`files` 里发给后端的是
-    **同一个值**,库里记的和后端收到的能对上账;不存 `/dms-api` 展示地址(那是环境相关的拼接结果)
-  - 多张图/多个文件用**逗号**分隔;**没有附件的那一轮不写这两列**
-  - 写入前先拉模型定义确认两列真的存在 —— DMS 的坑:`updateContent` 遇到模型里没有的列会
-    **静默丢弃整个 patch**(返回仍是 200「成功」),所以更新路径只在「真有附件值」时才捎上这两列,
-    最坏也只影响带附件的轮次,不会连累补 answer
-  - 验证:`verify-dms-chat-storage.mjs` 65 → **78/78**(打真实 DMS 的写入-读回-补 answer 全链路)
-- **只要对话就在「助手会话」(1887)建行**(用户 2026-09-23,推翻 2026-09-18 那条
-  「访客且没有企业信息就不建行」):
-  - 未登录且本轮没带回企业资料时,行里放**能填的那些**:`c_ip`(真实 IP)、`c_is_login="0"`、
-    时间戳、系统 `title`,以及四个必填运营位(`summary` 空串 + 三个布尔 `false`,只做空值兜底、
-    不猜业务值);**`c_credit_code` 留空**(用户拍板:这一列只放真实信用代码,不写访客标签)
-  - **建行时机不变**:仍只在回答**正常完成**(`totalResponse`)时写一次 —— 中断/报错的轮次不建行
-  - 运营分析回填列(`c_title`、`c_description`、`c_focus_points`、`c_core_needs`、
-    `c_contact_clues`、`c_follow_up_departments`、`c_settlement_intent_level`、`jygjbm` 等)
-    前端**一律不碰**,否则会把分析系统的值冲掉
-  - 读侧不受影响:远端会话列表本来就**排除 `c_is_login="0"` 的访客行**,且只在登录后拉取
-  - 验证:`verify-dms-chat-storage.mjs` 78 → **89/89**(打真实 DMS 新增 11 项,含"后续轮次带回
-    企业信息时这个纯访客行能正常被填上");变异测试注入旧行为 → 断言大面积失败
-- **语音识别换阿里云 NLS(第 1~2 步:token 通路)**(用户 2026-09-23):NLS 的 token 要用
-  **AccessKeySecret** 签名去换(`CreateToken`,24h 过期),而 secret **不能进前端产物** ——
-  所以走 **dev 端点** `GET /nls-token/`(`vite.config.ts` 的中间件,`apply:'serve'`),
-  由 vite 在 **node 侧**签名并把 `{token, expireAt, appkey}` 交给前端;凭据只写在
-  `.env.development.local`(gitignored,**值不进仓库任何文件**)。
-  - 签名口径收在 `harness/tools/nls-token.mjs`(唯一一份),命令行工具
-    `harness/tools/get-nls-token.mjs` 与 dev 端点共用;带 5 分钟提前刷新 + 并发去重
-  - 验证:端点 200;**拿端点发的 token 真调通一次识别**(`status:20000000 SUCCESS`);
-    `npm run build` 后**产物里搜三个凭据值 0 命中**
-- **实时语音识别已切到阿里云 NLS**(2026-09-23,接管旧厂商 SDK):
-  - 协议层 `src/asr/nls-protocol.ts`(纯函数:帧构建 / 事件折叠 / 16k PCM 编码)
-    + 类 `src/asr/nls.ts`(2026-09-24 前在 `src/three-libs/asr/`),**对外契约与旧 SDK 一致**
-    → 两个壳组件只改了 import 与一处构造参数(去掉硬编码 appKey),其余一行没动
-  - **协议是实测出来的**:`StartTranscription`→`TranscriptionStarted`→二进制音频帧→
-    `TranscriptionResultChanged`(中间结果,会被覆盖)→`SentenceEnd`(整句定稿)→`TranscriptionCompleted`;
-    两条硬约束——**每条指令都要带 appkey**、**task_id 不能是空串**(各踩过一次,已写成断言)
-  - 拼接全文只用 `SentenceEnd`;中间结果只用于实时显示
-  - 验证:`harness/tools/verify-nls-realtime.mjs`(**39/39**,2026-09-24 已长到 44/44),
-    含**真实识别**(Windows TTS 造语音 → 推流给真实网关 → 识别结果与所说话一致)与切线的源码级断言
-  - 重采样按实际 `audioContext.sampleRate` 算(旧实现写死 44100 的隐患不再沿用)
-  - 文档:`harness/docs/reference/asr-nls.md`(旧的 `asr-realtime.md` 标注为"换之前那套")
-  - ⚠️ 当时生产要由后端/网关做同样形态的 `/nls-token/` 端点 —— **2026-09-24 起改为直接调
-    后端网关的 `getALYToken`**(见本页 `## 20260924` 第一条),技术债 #10 已大半还清;
-    **浏览器实测由用户确认**(harness 不能替真人说话)
-- **实时语音转文字补了一份接口文档**(用户 2026-09-23 要求):
-  [`harness/docs/reference/asr-realtime.md`](harness/docs/reference/asr-realtime.md) ——
-  当时 SDK 就在仓库里(`src/three-libs/asr/index.ts`,**该文件已于 2026-09-24 删除**,
-  文档现在是历史记录),文档逐条对源码核对:构造参数与方法、
-  `transform`/`error` 事件契约、**底层 WebSocket 协议**(`/common/asr_hub?project=qingpu&engine=aliyun_dashscope…`、
-  首帧、16k/16bit 单声道 PCM 的二进制帧、结束帧、服务端 `start`/`stop` → mid/fin/breath 的映射)、
-  两端的生命周期与调用点、以及**6 条已知坑**(采样率换算写死 44100、"权限被拒绝"文案不可达、
-  `openMicroPhone` 只会 throw 或返回 true、非讯飞分支不主动关 socket、硬编码的十年期 JWT、
-  `clear()` 会清空所有监听)。**只是文档,没改任何代码。**
-- **🔴 待处理(登记进技术债 #9)**:`.env.production` **没有配 `VITE_DMS_API`**
-  —— 该环境打出来的包里附件**传不上去**(直接抛「未配置 DMS 接口地址」)、
-  DMS 会话落库也**静默跳过**。接生产要先定:DMS 从部署环境是否可达、**token 由谁注入**
-  (开发环境是 vite 代理加的,生产得 nginx 做同样的事)
-
-## 20260924
-
-> 今天两条主线:**语音识别换阿里云 NLS 收尾**(token 改由后端网关签发)+ **一次大清理**
-> (死代码、多余环境、走不到的引导链)。清理过程中出过一次回归,已修并补上守护脚本。
-
-- **部门筛选改为「只列 JSON 里实际存在的部门」**(用户 2026-09-24):
-  - 删掉硬编码的 15 个部门(`DEFAULT_DEPTS`),改为从惠企政策库的 `政策所属部门`
-    现算(去重 + 中文排序,前面固定「全部部门」)
-  - ⚠️ 用 ref + 打开菜单/面板时现算,**不能用 computed** —— `globalThis.policiesPublic`
-    是异步加载、没有响应式依赖,computed 会把首次的空列表缓存住
-  - 选中的部门若不在新清单里 → 自动退回「全部部门」(否则会筛空还没提示)
-  - 这推翻了先前「保持固定列表、不要当 bug 修」的决定 → 技术债 **#4 已还**
-  - 验证:`verify-policy-library` 29 → **35/35**(新增第 7 节:打印库里 10 个部门、
-    断言不再有硬编码列表、选项由数据派生、现算时机、失效回退、匹配口径)
-- **修问卷两个问题**(用户 2026-09-24 反馈,附截图):
-  - ①「下方已经新对话了,上方的问卷应该是只读状态」:`QuestionCard` 本来就有只读分支,
-    但判定是「内容里带 answers」,而**此前没有任何代码把答案写回内容** → 永远走不到。
-    新增 `src/utils/question-cards-answers.ts`(纯函数),提交时把答案写回最后一条带
-    `<question-cards>` 的 AI 消息 → 卡片立刻变只读,刷新后也保留
-  - ②「一次应该只有一个选项是选中样式」:`isFreeformSelected()` 对**常驻输入框恒返回 true**
-    → 那一行永远带选中边框。改成「填了内容、且单选时没选别的选项」才算选中
-  - 验证:新增 `verify-question-cards.mjs` **18/18**(含边界、幂等、多轮只替换最后一个、
-    源码级接线断言),**变异测试**两处都能红;其余回归全绿
-- **NLS 的 token 改由后端网关签发**(用户指定 `http://121.43.55.7:10011/proxy/verify/getALYToken`):
-  - 先验证再动前端:网关返回 `{code:200, content:"<token>"}`,**拿它 + 新 appkey 真调通一次识别**才改代码
-  - 前端改为调该端点(同源 `/aly-api/…`;端点只有 HTTP、页面是 HTTPS,必须走同源路径,
-    与 `/ip-api/` 同一个坑),**前端侧不再需要 AccessKeySecret** → vite 里那段"自己签 token"的
-    `/nls-token/` 中间件连同 AK/SK 通路一起删除
-  - 配置:`VITE_NLS_TOKEN_API` 进 `.env.development`;**appkey 放 `.env.development.local`**(gitignored)
-  - harness 工具统一成「显式 token → 网关 → AK/SK 自签」三级,**自动化验证走的就是生产同一条路**
-  - ⚠️ 生产仍需:nginx 转发 `/aly-api/` + 注入 `VITE_NLS_APPKEY`(技术债 #10)
-- **修「出字延迟高」**(用户反馈):实测定位到是**我自己的排空策略**——握手期间麦克风已在采集,
-  按 1× 实时排空那段积压**永远排不掉**(旧厂商 SDK 是 2×,所以它能追上)。
-  改成「平时实时、积压时 4× 追赶」+ 停止时按 ~5× 发 + 断句阈值 800→500ms。
-  A/B 实测(模拟 1s 积压):感知延迟 **1377~1434ms → 145~183ms**,定稿时 2087ms → 683ms。
-  另外实测确认:网关中间结果节奏恒 ~480ms(引擎固有,前端改不了)
-- **全量接口清点 → 死代码大清理**(用户:「列出来我来判断哪些可以删除」→「B 全部删掉」):
-  - 清点:grep 网络调用点 + 逐个 env 变量数引用,结果落进
-    [`harness/docs/reference/current-api-call-sites.md`](harness/docs/reference/current-api-call-sites.md) §0
-  - 删除:厂商 OSS 上传的停用实现(含 `VITE_UPLOAD_SIGN_URL`)、旧厂商 ASR 全套
-    (`three-libs/asr/index.ts` + `VITE_ASR` / `VITE_XF_ASR` + vite `/asr/` 代理 +
-    `index.html` 的 `globalThis.isXF`)、`stream-message-coordinator.ts` 整个类(~1100 行)
-    + 随之孤儿的 `utils/scope-stream-boundary.ts`、`updateSessionInfo`、
-    `getModelServerUrl` / `isKnowledgeApi`、三个空目录、两处停用注释块,
-    以及因此变成孤儿的 npm 依赖 `qs` / `@microsoft/fetch-event-source`(**净删 2257 行**)
-  - `MessageState` 枚举**是活的**,已从被删的协调器搬到 `src/types/record.ts`(取值未动)
-  - 教训记档:删文件要按**导出的符号名**反查引用(只查 import 路径会漏 ——
-    `components/utils.ts` 因此被误删,构建报错才发现,已恢复)
-- **环境只保留开发与生产**(用户要求):删除 qingpu / test 两个构建模式 ——
-  `.env.qingpu` / `.env.test` 删除前,先把它俩**独有的配置合并进 `.env.production`**:
-  `VITE_DOWNLOAD_URL="/api/download/"` 与 **`VITE_REDIRECT_MAP`**(后者 production 原本没有,
-  直接删会让 `redirect.html` 的产物变成 JS 语法错误 —— **顺带修掉了**:以前 `npm run build`
-  打出来的生产包里那个页面就是坏的)
-  - 脚本:删 `build:qingpu` / `build:test`,保留 `zip`,新增 `npm run deploy:qingpu`(= build + zip)
-  - `index.html` 里两处**本来就是死的** qingpu 分支一并删掉(`isQingpuEnv` 写的是字面量 `"MODE"`、
-    永远 false 且无人读;`isLanMode` 赋值后从未使用)
-- **删掉走不到的卡片引导链 + asr 搬家**(用户要求):先做影响评估再删 ——
-  `index.html` 的 `initToken()` / `initCardInfo()` / `else` 分支**两个环境都走不到**
-  (`isKnowledgeApi` 恒 true),产物(`globalThis.token` / `cardInfo`)**全仓库无读者**,
-  且那段本身是坏的(调用从未挂到 globalThis 的 `changeLoadingText`/`showReloadView`,走到会抛)。
-  一并删掉随之孤儿的 `randomString` / `changeLoadingText` / `showReloadView` 与 `VITE_APP_KEY`。
-  另:`src/three-libs/asr/` → **`src/asr/`**,`three-libs/` 目录删除(名字有误导性,且只剩 asr 一个子目录)
-- **修复:界面卡在「正在初始化,请稍候...」**(上面那次删除引入的回归):
-  删 `initToken` 时在 index.html 的内联脚本里留了个不配对的 `}` → 脚本语法错误 →
-  `hasSequence` 没置位、`sequenceLoaded` 没派发 → 加载遮罩永不隐藏。
-  **构建没抓到**,因为 Vite **不解析** index.html 里的普通 `<script>`(原样拷贝);
-  已修,并新增 `harness/tools/verify-inline-scripts.mjs`(编译 `dist/*.html` 的内联脚本 +
-  报出未替换的 `%VITE_*%` 占位符,变异测试确认会红),同时写进 `sops/verification.md`:
-  改了 index.html / redirect.html 必须跑它
-- **接口清单按当前代码重核**(用户:「再列出现在使用的接口」):13 个在用接口 + 5 条 vite 代理,
-  见 [`current-api-call-sites.md`](harness/docs/reference/current-api-call-sites.md) §0 A 表;
-  相比清点时新增一条漏记的(正文里 `<policy-list-updated>` 给的动态 link)
-
-## 20260928
-
-- **删掉政策列表「第三条腿」与 index.html 两处死枝**(同日早些时候,用户:「动手删 1、2」)——
-  详见 [`progress.md`](harness/progress.md) 续 50,本文不重复。
-- **删掉打包体积报告 `stats.html` 及相关配置**(用户:「这个不需要,把它和相关代码删掉」):
-  `vite.config.ts` 的 `rollup-plugin-visualizer` 插件块 + 该 devDependency
-  (`package.json` / `package-lock.json`)+ `.gitignore` 那两行 + 仓库根目录 1.78 MB 的报告本体。
-  - 顺带查明它**一直没落在配置写的 `dist/`**:插件 v5 的选项名是 `filename`(不是 `file`),
-    `file: "./dist/stats.html"` 被忽略 → 回落到默认名、按 cwd 解析 → 仓库根目录
-  - **产物零影响**:删除前后三个 chunk 的 hash 完全一致;构建 17.4s → 9.2s(少了报告的两遍压缩)
-- **修「Vite 依赖冷扫描失败」(`Failed to scan for dependencies`)+ 加护栏**:
-  - 根因:Vite 的依赖预扫描把 **`.vue` 也当 HTML**,扫描前先 `replace(/<!--.*?-->/gs, "<!---->")`
-    (可跨行)—— `.vue` 的 `<script>` 里一个**不成对**的 HTML 注释起始符会和后面任意一个结束符
-    (哪怕隔着几十行)配成注释**整段吃掉**。`BusinessRecord.vue` 的注释与 9 行后的正则就这么配上了对,
-    于是正则那行被并进注释、下一行以 `.replace(` 开头 → `Unexpected "."`
-  - 触发时机很阴:只在**依赖缓存失效**时炸(改 package.json / `--force`),`npm run build` **抓不到**
-  - 修法:政策表的两个标记字面量从 `.vue` 挪到 `stream-xml-filter.ts`
-    (`POLICY_TABLE_START` / `POLICY_TABLE_END`,顺带消掉重复);新增护栏脚本
-    [`verify-vue-script-html-comments.mjs`](harness/tools/verify-vue-script-html-comments.mjs),
-    并写进验证 SOP 与架构「关键约束」
-  - 验证:`npx vite --force` 冷扫描 **0 错误**;产物 hash 变了但**只差 70 字节**(字面量去重),语义等价
-- **删掉百度统计**(用户确认「删掉」):`index.html` 里那段第三方脚本(`hm.baidu.com/hm.js?d6307cb…`)整块移除
-  - 排查结论:抓 hm.js 本体看到站点配置 **`dm:["demo.heijingai.com"]`** ⇒ 数据进的是**厂商账号**,
-    本项目**从未用过**它的数据(`git log -S '_hmt.push'` 全历史为空,代码里也无人读 `_hmt`)
-  - jsdom 实测三个域(含青浦域):都会写 `HMACCOUNT`/`Hm_lvt_*`/`Hm_lpvt_*` cookie 并上报 `hm.gif`;
-    传的是访问元信息(URL / 来源 / 标题 / 屏幕 / 语言 + utm 渠道参数),**不含任何业务数据**
-  - 它是全站**唯一**往第三方发请求、并在青浦域名上写 cookie 的东西 ⇒ 政府站点又无告知环节,删除更省事
-- **删掉死配置 `VITE_DOWNLOAD_URL`**(用户确认):它只定义在 `.env.production`、**全仓库没有任何读者**
-  (`index.html` 的本地兜底早已写死 `/merchant-agent/policies_public.v2.json`)⇒
-  生产侧 nginx 也不再需要转发 `/api/download/`
-  - 护栏:`verify-policy-library.mjs` 新增 §10(含"政策库远端/本地兜底都还在"两条防误伤断言),
-    变异测试(把配置放回去)确认会红
-- **整理环境变量**(用户要求):先把「两份 env 的定义 × 代码里的读者」逐项对清,再动手
-  - 两份 env **重排为同一套分区**(构建信息 / 接口地址 / dev 代理 target / 云服务同源路径 / 已删说明);
-    改写前后**用脚本比对 key→value**:删除 0、值变化 0,dev 11 → 12(仅新增 `VITE_ALY_TARGET`)
-  - 补 `VITE_ALY_TARGET`:`vite.config.ts` 的 `/aly-api/` 代理只认它、缺了就落到硬编码兜底,
-    与另外三个 target 不对称;填入值同原兜底 ⇒ **零行为变化**
-  - 删 `runtime-config.ts` 的 `getApiBaseUrl()`:无人调用,且它读的 `globalThis.VITE_API`
-    **从来没有被赋值过**(index.html 只注入 CHAT / DMS / IP)⇒ 纯死代码
-  - `architecture.md` 的环境变量表按代码重写(原表还列着已删的 `VITE_MODEL_SERVER` /
-    `VITE_ASR` / `VITE_STREAM_SERVER`,并缺一半现役变量)
-  - dev 实测:页面 200 · `/aly-api` 经新 target 取到真实 token · `/ip-api` 取到真实 IP ·
-    产物 hash 未变(`main-D0U2AkA8`)
-  - ⚠️ 记一笔防误删:`.env.development.local` 里的 `ALIYUN_NLS_*` **不是残留** ——
-    是 harness 的 NLS 测试脚本在读
-- **NLS appkey 内置进代码 + 修 3 处过期说明**(用户要求):
-  - appkey 写进 `runtime-config.ts` 的 `NLS_APPKEY_BUILTIN` ⇒ **生产不再需要部署侧注入**
-    (覆盖链保留:`globalThis` 注入 → env → 内置值,临时换值不必改代码)
-  - ⚠️ 它**不是密钥**(换 token 不需要它、网关也不校验,且每次识别请求本就把它明文发出),
-    所以进产物/进仓库是可接受的;真正的 **AccessKeySecret 没有进仓库**,仍在 gitignored 的 `.env.development.local`
-  - 过期说明:`asr/nls.ts` 注释里的 `/nls-token/`、`asr-nls.md` 的「旧实现保留 / `VITE_ASR`·`VITE_XF_ASR` 仍在」
-    (两者早在 2026-09-24 就删了)、NLS 校验脚本里的断言标签
-  - 技术债 #10 的待办 ② 随之消掉,**生产只剩 nginx 转发 `/aly-api/`**
-  - 验证:产物里内置 appkey 命中 1 次、`verify-nls-realtime` **44/44**(含真实网关连接)
-- **删掉本机阿里云凭据**(用户确认「三个都删(含 AK/SK)」):`.env.development.local` 里
-  **不再保存任何凭据**(现在只剩一段说明)—— `ALIYUN_NLS_AK`/`SK` 是"网关取不到 token 时自签"的兜底,
-  `ALIYUN_NLS_APPKEY` 已内置在代码里
-  - harness 脚本改为从**代码内置值**读 appkey(`readBuiltinAppkey()`),启用条件放宽为"只要有 appkey"
-    ⇒ 删掉凭据后**真实网关段仍然会跑**:`verify-nls-realtime` 44/44、`verify-nls-browser-path` 4/4,
-    两者都是真实联网识别
-  - 顺手修 `dms/client.ts` 一条指错位置的提示(DMS token 在本机 `.dms-token`,不在 `.env.development.local`)
-  - **该文件随后整体删除**(用户:「文件没用的话也删掉」):确认无硬依赖(`loadEnv` / `readDotEnvFile` 都容忍文件缺失,
-    `.gitignore` 的 `.env.*.local` 模式仍在)⇒ 仓库只剩 `.env.development` / `.env.production` 两份;
-    同时修掉 4 处"凭据在那个文件里"的旧注释(`vite.config.ts` 的 DMS token 来源、两个 NLS 脚本头部、`.env.development` 头部)
-  - 验证(删文件后跑):`get-nls-token --check` 仍读得到内置 appkey · `verify-nls-realtime` 44/44(真实网关)·
-    dev 冒烟页面 200 且 `/dms-api` 返回**真实数据** · 构建 + `validate-harness` 通过
-- **DMS 默认服务账号写进代码**(用户给账号并要求「直接写进代码里」):
-  - `harness/tools/dms-login.mjs` 新增 `DEFAULT_ACCOUNT`;取值顺序变为
-    **参数 → 环境变量 → 代码内置默认 → 本机 `.dms-account`(兜底)**
-  - ⚠️ **这是本项目「凭据不落盘」规则的唯一例外**(2026-09-23 定的规则):用户确认要写进入库源码,
-    已知悉密码会进 git 历史(**本轮尚未提交**,提交后就撤不回来了);代码注释里写明了
-    「只准 node 侧用、绝不要复制进 `src/`」
-  - 验证:登录成功后 token 用户为 `user_yszs_web`(登录前是 `user_gtx`)· 直连 DMS `code=200` 取到数据 ·
-    dev 经 `/dms-api` 代理读写正常
-  - 📌 影响:**之后 DMS 新写入的行作者会变成 `user_yszs_web`**
-  - **随后删掉 `.dms-account`**(用户:「没用就删掉」):它已被代码内置的默认账号覆盖
-    (参数 → env → 内置 → 文件),本机那份是永远轮不到的旧账号;
-    **`.dms-token` 保留** —— 它是 dev 代理每个请求现读的当前 token(自动生成物,删了会自愈但没意义)
-- **删掉 `<policy-list-updated>` 整条链**(用户:「老对话仅测试,后续会全部清空」):
-  - 该块是旧协议里**后端在正文给出地址、前端再去取**的路径(接口清单 #11),
-    与已删的 #10 是同一个接口,只是地址由后端下发。新协议适配层**从不产出**它,
-    唯一的触发源就是旧会话历史 —— 保留理由随「旧对话要清空」一起消失。
-  - 删除范围:`PolicyListUpdatedMatch.vue` 整文件 · `BusinessRecord` 的挂载点/import/
-    `hasPolicyTableRow` 分支 · `StreamXMLFilter` 的枚举成员与标签规则 · 相关注释与文档。
-  - ⚠️ **副作用(用户已确认接受)**:标签规则删掉后,**清空之前**打开旧测试会话,
-    正文里那串 `<policy-list-updated>{"link":…}</policy-list-updated>` 会当**普通文本**显示。
-  - 顺带**只读排查**了其余只服务旧协议的标记(`<form>` / `<link-url>` / `<file-docx>` /
-    `<ui-form>` / `<followup>` / `<silence>` / `<qingpu_enterprise_notificaion>`),
-    结论写成 [`legacy-content-markers.md`](harness/docs/reference/legacy-content-markers.md):
-    前三个「只有旧历史能触发」,后四个**已经是死链**(消费端空实现或无人注册)——
-    本清单**没有据此改任何代码**。
-
-## 20260929
-
-- **代理前缀统一为「与服务真实路径同名」(用户指定)**:原来是 `/dms-api`(要补 `/dms` 前缀)+
-  `/ip-api` + `/aly-api`(后两条打的还是同一台 `121.43.55.7:10011`)。现在四条:
-
-  | 前缀 | 目标 | 是否改写 |
-  |---|---|---|
-  | `/oauth/**` | `121.43.55.7:10086`(DMS 登录,实测 `POST /oauth/api/user/login`) | **直通**(真实路径就带 `/oauth`) |
-  | `/dms/**` | `121.43.55.7:10081`(DMS 数据 + 政策库 json),代理侧注入 `token` 头 | **直通**(真实路径就带 `/dms`) |
-  | `/api/**` | `121.43.55.7:10011`(语音 token + 取本机 IP **共用**) | **剥掉 `/api`**(实测直连 `/api/proxy/…` 是 404) |
-  | `/chat-api/**` | 聊天后端(保留) | 剥前缀 |
-
-  - 名字跟着改:`VITE_DMS_API` `/dms-api`→`/dms`、`VITE_POLICY_REMOTE_URL` `/dms/static/…`、
-    `VITE_IP_API`→`/api`、`VITE_NLS_TOKEN_API`→`/api/proxy/verify/getALYToken`
-  - **代理 target 不再走环境变量**(用户同日要求「vite.config.ts 里面不要加环境变量」):
-    四个 target 直接写成 `vite.config.ts` 里的字面量,该文件不再 `loadEnv`;
-    原先的 `VITE_CHAT_TARGET` / `VITE_DMS_TARGET` / `VITE_OAUTH_TARGET` / `VITE_API_TARGET`
-    **四个变量已删除**(`.env.development` 里那条"target 区"改成说明)
-  - **连带**:`.env.production` 首次配上 `VITE_DMS_API="/dms"`(原来生产根本没有 ⇒ 技术债 #9 的
-    "未配置"那半已还,只剩 nginx 转发 + 注入 token)
-  - 实测(dev,四条全通):`/dms/content/selectContentList` 取到真实数据 · `/dms/static/…json` 393 KB ·
-    `/api/proxy/verify/getALYToken` 取到 token · `/api/proxy/verify/getIPByBrowser` 取到真实 IP ·
-    `/oauth/api/user/login` 用默认账号拿到 JWT
-  - 校验:`verify-policy-library` 54/54 · `verify-attachment-question` 57/57 · `verify-dms-payload-fields` 19/19 ·
-    `verify-question-cards` 36/36 · `validate-harness` 通过 · `npm run build` 通过(hash 变,因 env 值变)
-  - **硬编码 target 后复测**(页面 200 · `/dms` 真实数据 · `/api` token 与真实 IP · `/oauth` 到达业务层)全通过
-- **未登录访客的 DMS token 改由前端自己换**(用户要求):
-  - 新增 `src/network/api/dms/service-token.ts`:用**内置服务账号**经 `POST /oauth/api/user/login`
-    换 JWT(`message` 字段),缓存在内存、过期前 5 分钟刷新、并发共用同一个在途请求
-  - `client.ts` 随请求带 `token` 头;遇 201/212(token 失效)**丢掉重换一次**再试
-  - `vite.config.ts` 的 `/dms/` 代理改成**只在请求没带 token 时注入**(命令行走代理的排查方式不变)
-  - 新增 `VITE_OAUTH_LOGIN_URL`(两份 env);生产需 nginx **直通 `/oauth/` → `121.43.55.7:10086`**
-  - 📌 **该账号是用户专门准备的「默认账号」**(用户 2026-09-29 确认:已处理过、就是给这个用途的)
-  - ⚠️ 仍存在的两个代价:① 密码在公开产物里(要收紧就改密码并同步改两处代码);
-    ② token 落在浏览器。技术债 **#8**(已同步更新:暴露面扩大、生产接入前必须解决)
-  - 验证:新增 `harness/tools/verify-dms-service-token.mjs` **5/5** —— 含关键断言
-    「带假 token 被 DMS 拒(212)⇒ 代理没有覆盖前端带的 token」
-- **确认「独立页面、不再嵌入」后清掉父页面那套**(用户:「不会嵌入到其他页面,有什么可以删除的」):
-  - `index.html` 删掉 `initMessageChannel()`(监听父页面消息 + 回发 `{type:"ready"}`)与调用
-    —— ⚠️ **保留紧随其后的遮罩收尾三行**(`hasSequence` 等,`verify-inline-scripts` 守着)
-  - 删掉 `WeixinJSBridgeReady` 监听(回调里只剩 `console.log` + 注释掉的视频播放)
-  - 两份 env 删掉 `VITE_PARENT_ORIGIN`;文档(architecture env 表 / call-sites #12 / 技术债 #11)同步
-  - 验证:构建通过 · `verify-inline-scripts` **8/8** · `validate-harness` 通过
-- **旧协议内容标记全部清完**(用户:①死链删 ②旧对话已清空,`<form>/<link-url>/<file-docx>` 也删):
-  - `stream-xml-filter.ts` 删掉 **7 条规则 + 7 个枚举成员**(含两个随之失去调用方的私有方法与
-    "silence 透明容器"特判)⇒ **规则表只剩 4 条**(scope / image-scope / ref_links / question-cards)
-  - 删掉三个渲染组件(`FormContent` / `LinkURLContent` / `OfficeURLContent`)及其挂载、import、
-    `inject("formOptionsControl")`、`customProcessor`、`jsonrepair`;两个壳组件里已无人 inject 的同名 provide 也删
-  - 🐛 **顺带修掉一个更早就存在的解析器挂起 bug**:`isPossibleOpenPrefix()` 没检查"是否真的以规则名开头",
-    导致任意文本只要在第 N 个字符处是空格/`>` 就被当成"可能的前缀"而**永久挂起**
-    (实测 `<form id="a">…` 撞 `image-scope`、`</link-url>` 撞 `ref_links`)
-  - 验证:`verify-stream-filter-rules` **32/32** · `verify-question-cards` 36/36 · 构建通过 · dev 冒烟页面 200
-- **注释精简**(用户:「清理一下注释,只保留最基本的功能注释」):
-  - 范围:`src/` 全部 + `vite.config.ts` / `index.html` / 两份 `.env`(`harness/tools/*.mjs` 不动 —— 头部注释就是"怎么跑")
-  - 保留:一句用途 + **非显然硬约束**(鉴权头叫 `token`、`202` 是空结果、请求体只两字段、`/api` 剥前缀、遮罩收尾四行删不得…);
-    删除:日期/"用户要求"/踩坑史/演变叙述/`[已删]` 记录/代价论证
-  - 体量:42 个 `.ts`/`.vue` 的注释行 **2561 → 1638(−923,−36%)**;`.env` 的**变量行与 HEAD 逐字一致**
-  - 🔑 **代码未变的证明**:HEAD 与工作区分别 esbuild `minify` 后逐字节比对 ⇒ 31 个 `.ts` 里 **30 个完全一致**
-    (唯一不同者是上一条里我自己的代码改动);`.vue` 逐行审计也全是注释
-  - 验证:构建 ✓ · `verify-inline-scripts` 8/8 · `verify-answer-stream` 165/165 · 其余 8 个校验脚本全过 · dev 冒烟页面 200
-- **部署到 HTTP:隐藏麦克风入口 + 修好「HTTP 下复制失效」**(用户:「麦克风问题暂时无法解决,所以先隐藏掉」):
-  - 麦克风入口全仓库只有一处(`BusinessAssistantMobileInputShell.vue`,PC/Mobile 共用)⇒
-    加开关 `VOICE_INPUT_VISIBLE = false` + `v-if`;ASR 逻辑保留,改回 `window.isSecureContext` 即 HTTPS 自动恢复。
-    产物核对:麦克风 SVG 已被常量折叠,**生产包 0 命中**
-  - ⚠️ **顺带发现 HTTP 硬伤**:`navigator.clipboard` 在非安全上下文不存在,原写法
-    `navigator.clipboard.writeText(x).catch(…execCommand 兜底…)` 会**同步抛错**、兜底永不执行 ⇒
-    **全站「复制」失效**(主复制按钮就在 `FeedbackWidget` 里)。改成显式判断 + try/catch + 兜底;
-    新增 `verify-clipboard-fallback.mjs` **9/9**(HTTP / HTTPS / 权限被拒 三组桩)
-  - 非安全上下文风险点已核查:`crypto.randomUUID` 有守卫+兜底 · `mediaDevices`/`subtle`/`serviceWorker` 无虞或不可达
+- `src/components/BusinessAssistantPC.vue`、`BusinessAssistantMobile.vue`:页面主壳
+- `src/components/api-chat-coordinator.ts`:聊天协议适配
+- `src/components/Chat/`:回答渲染
+- `src/asr/`:语音识别
+- `public/merchant-agent/`:惠企政策库

+ 30 - 37
public/config.js

@@ -3,7 +3,7 @@
  * index.html 在应用脚本之前引入。
  *
  * ┌─ 环境区分 ─────────────────────────────────────────────
- * │ 当前默认:**政务网**(内网栏目 id)
+ * │ 当前默认:**政务网 / 内网**(内网栏目 id)
  * │ 切回互联网:把下方「政务网」块注释掉,解开「互联网」块,
  * │            并将 fieldDoubleCPrefix 改为 false。
  * └────────────────────────────────────────────────────────
@@ -19,37 +19,36 @@ window.__ZHAOSHANG_CONFIG__ = {
     // 其余项仅备案,代码尚未读取。
 
     // ---- 【互联网】外网 DMS(121.43…,原栏目 1886–1889)----
-    columns: {
-      honor: 1886,       // 企业荣誉信息
-      session: 1887,     // 助手会话
-      enterprise: 1888,  // 企业基础信息
-      record: 1889,      // 助手问答记录
-      // pageView: 1885, // 助手页面浏览(互联网)
-    },
-    models: {
-      honor: 2032,
-      session: 2034,
-      enterprise: 2036,
-      record: 2038,
-      // pageView: 2030,
-    },
-    // ---- 【互联网】结束 ---- 
-
-    // ---- 【政务网】内网 DMS(当前生效)----
-    // 父栏目「营商助手」3036(一般不管)
     // columns: {
-    //   enterprise: 3037, // 企业基础信息
-    //   honor: 3050, // 企业荣誉信息
-    //   session: 3055, // 助手会话
-    //   record: 3049, // 助手问答记录
-
+    //   honor: 1886, // 企业荣誉信息
+    //   session: 1887, // 助手会话
+    //   enterprise: 1888, // 企业基础信息
+    //   record: 1889, // 助手问答记录
+    //   // pageView: 1885, // 助手页面浏览(互联网)
     // },
     // models: {
-    //   enterprise: 2303, // 企业基础信息
-    //   honor: 2329, // 企业荣誉信息
-    //   session: 2339, // 助手会话
-    //   record: 2327, // 助手问答记录
+    //   honor: 2032,
+    //   session: 2034,
+    //   enterprise: 2036,
+    //   record: 2038,
+    //   // pageView: 2030,
     // },
+    // ---- 【互联网】结束 ----
+
+    // ---- 【政务网】内网 DMS ----
+    // 父栏目「营商助手」3036(一般不管)
+    columns: {
+      enterprise: 3037, // 企业基础信息
+      honor: 3050, // 企业荣誉信息
+      session: 3055, // 助手会话
+      record: 3049, // 助手问答记录
+    },
+    models: {
+      enterprise: 2303, // 企业基础信息
+      honor: 2329, // 企业荣誉信息
+      session: 2339, // 助手会话
+      record: 2327, // 助手问答记录
+    },
     // ---- 【政务网】结束 ----
 
     /**
@@ -57,15 +56,9 @@ window.__ZHAOSHANG_CONFIG__ = {
      * - 政务网 true(建栏时字段名已带 c_,DMS 克隆后再加一层 → c_c_xxx)
      * - 互联网 false
      */
-    fieldDoubleCPrefix: false,
+    fieldDoubleCPrefix: true,
 
-    /**
-     * 政策库在 DMS 上的相对路径(uploadFile 返回的 content)。
-     * 前端拼成 `{VITE_DMS_API}` + 该路径;取不到再本地兜底。
-     * 【互联网】示例仍保留在下一行;政务网重新 upload 后改成新路径。
-     */
-    // 【互联网】"/static/file/1889-c_question-83859739-17d2-4b7f-b427-7ee27e098e79.json"
-    policyRemotePath:
-      "/static/file/1889-c_question-83859739-17d2-4b7f-b427-7ee27e098e79.json",
+    // 政策库:2026-10-28 起不再上传/不再读远端,始终使用随包本地
+    // public/merchant-agent/policies_public.v2.json(旧的 policyRemotePath 已停用)。
   },
 };

File diff suppressed because it is too large
+ 612 - 8118
public/merchant-agent/policies_public.v2.json


+ 269 - 11
src/components/BusinessAssistantMobile.vue

@@ -102,6 +102,7 @@
           <!-- <div class="date-indicator">{{ todayLabel }}</div> -->
           <ScrollList v-if="currentSession" ref="scrollListRef" :data="currentSession.messages" :height="listHeight"
             :maxHeight="listHeight" :topPadding="8" :bottomPadding="chatSuggestionsBottomPadding" :native-scroll-mode="true"
+            :smooth-follow="isLastAiRecordStreaming"
             @scrollPositionChange="handleBusinessScrollPositionChange">
             <template #item="{ data, isLast }">
               <div class="message-row" :ref="(el) => setMessageRowRef(data.id, el)"
@@ -110,8 +111,10 @@
                   :sessionId="currentSession?.id" :sessionViewedBefore="currentSessionVisitedBefore"
                   enableFeedback
                   @refreshScroll="handleBusinessRecordRefreshScroll"
+                  @scopeExitStateChange="handleScopeExitStateChange"
                   @scopeHeightLockChange="handleScopeHeightLockChange"
-                  @typewriterStateChange="handleBusinessRecordTypewriterStateChange" />
+                  @typewriterStateChange="handleBusinessRecordTypewriterStateChange"
+                  @displayPacingStateChange="handleBusinessRecordDisplayPacingStateChange" />
                 <Transition name="chat-suggestions-fade" appear>
                   <div v-if="isLast && data.role === 'ai' && currentSessionSuggestions.length > 0"
                     ref="chatSuggestionsContainerRef" class="chat-suggestions-container">
@@ -131,6 +134,26 @@
         </section>
 
         <div class="fixed-input" v-show="!isFreeformInputActive">
+          <Transition name="scroll-latest-fade">
+            <button
+              v-if="showScrollToLatest"
+              type="button"
+              class="scroll-to-latest-btn"
+              aria-label="回到最新进度"
+              title="回到最新进度"
+              @click="scrollToLatest"
+            >
+              <svg width="18" height="18" viewBox="0 0 24 24" fill="none" aria-hidden="true">
+                <path
+                  d="M12 5v12.5M6.5 12 12 17.5 17.5 12"
+                  stroke="currentColor"
+                  stroke-width="1.8"
+                  stroke-linecap="round"
+                  stroke-linejoin="round"
+                />
+              </svg>
+            </button>
+          </Transition>
           <BusinessAssistantComposer
             v-model="inputText"
             :uploaded-files="uploadedFiles"
@@ -391,6 +414,7 @@
 
 <script setup lang="ts">
 import { computed, nextTick, onBeforeUnmount, onMounted, provide, reactive, ref, watch } from 'vue';
+import { MessageState } from '@/types/record';
 import BusinessRecord from "./Chat/BusinessRecord.vue";
 import ScrollList from './Common/ScrollList.vue';
 import BusinessAssistantComposer from './business-assistant/BusinessAssistantComposer.vue';
@@ -557,7 +581,10 @@ const {
     currentPage.value = 'chat';
     await scrollToBottom(true);
   },
-  onMessageUpdated: () => scrollToBottom(),
+  onMessageUpdated: () => {
+    scrollToBottomFollow();
+    updateScrollToLatestVisibility();
+  },
   getInputFileTransmission: consumeSuccessfulFileTransmission,
 });
 
@@ -690,6 +717,46 @@ const getLastAiMessage = () => {
   return null;
 };
 
+// 「思考中」退场补偿状态(补偿期间正文行会短暂隐藏,不能在这个窗口释放高度锁/关闭跟随)
+const scopeExitStates = reactive<Record<string, { active: boolean }>>({});
+const handleScopeExitStateChange = (payload?: { recordId?: string | number; active?: boolean }) => {
+  const recordId = payload?.recordId;
+  if (recordId === undefined || recordId === null) {
+    return;
+  }
+  const key = String(recordId);
+  if (payload?.active) {
+    scopeExitStates[key] = { active: true };
+  } else {
+    delete scopeExitStates[key];
+  }
+};
+
+// 排字缓冲进行中(可能已 finishTask,但仍有约 1s 存量在上屏)→ 仍按「生成中」处理
+const lastAiRecordDisplayPacingStates = ref<Record<string, boolean>>({});
+const handleBusinessRecordDisplayPacingStateChange = (payload?: {
+  recordId?: string | number;
+  active?: boolean;
+}) => {
+  const recordId = payload?.recordId;
+  if (recordId === undefined || recordId === null) {
+    return;
+  }
+  lastAiRecordDisplayPacingStates.value[String(recordId)] = Boolean(payload?.active);
+};
+const isLastAiRecordPacing = () => {
+  const lastAiMessage = getLastAiMessage();
+  if (!lastAiMessage) {
+    return false;
+  }
+  return Boolean(lastAiRecordDisplayPacingStates.value[String(lastAiMessage.id)]);
+};
+
+// 豆包式平滑贴底:仅在新后端真实流式期间开启(mock 打字机 / 历史仍瞬时贴底)。
+const isLastAiRecordStreaming = computed(
+  () => Boolean(getLastAiMessage()?.contentStreaming) || isLastAiRecordPacing()
+);
+
 const getRowScrollTop = (scrollElement: HTMLElement, rowElement: HTMLElement) => {
   const scrollRect = scrollElement.getBoundingClientRect();
   const rowRect = rowElement.getBoundingClientRect();
@@ -766,7 +833,19 @@ const getOrCreateLastAiRowTopSnapshot = (recordId: string, rowOffsetTop: number)
   return lastAiRowTopSnapshot.value;
 };
 
+/**
+ * [已停用 2026-10-27] 用户要求「回答过程中自由滚动、回答结束不要跳回句首」。
+ * 原逻辑在最后一条 AI 行滚到视口顶部时 scrollToPositionInstant(行顶 - 8),
+ * 是全仓库**唯一**会把视图滚回回答顶部的路径(见 progress 续 14)。
+ * 保留实现便于回退,但不再触发。
+ */
+const ENABLE_LAST_AI_ROW_TOP_PIN = false;
+
 const stopAutoScrollAtLastAiRowTopIfNeeded = () => {
+  if (!ENABLE_LAST_AI_ROW_TOP_PIN) {
+    return false;
+  }
+
   const scrollList = scrollListRef.value;
   if (scrollList && typeof scrollList.isAutoScrollTopPinSuppressedByUser === "function" && scrollList.isAutoScrollTopPinSuppressedByUser()) {
     return false;
@@ -838,6 +917,66 @@ const stopAutoScrollAtLastAiRowTopIfNeeded = () => {
   return result.didStop;
 };
 
+/** 当前最后一条 AI 消息是否已经触发过「到达视口顶部即停止跟随」。 */
+const isAnswerTopReachedForCurrentRecord = () => {
+  const lastAiMessage = getLastAiMessage();
+  if (!lastAiMessage) {
+    return false;
+  }
+  return lastAiRowTopConsumedRecordId.value === String(lastAiMessage.id);
+};
+
+/**
+ * 用户没有操作时,自动跟随到「回答内容的顶部到达对话窗顶部」就停止(**不移动视图**),
+ * 下方继续生成,箭头出现。每条回答只触发一次;点箭头或手动滚回底部后本条不再触发。
+ */
+const maybeStopAutoScrollAtAnswerTop = () => {
+  const scrollList = scrollListRef.value;
+  if (!scrollList || typeof scrollList.getScrollElement !== 'function') {
+    return false;
+  }
+
+  const lastAiMessage = getLastAiMessage();
+  if (!lastAiMessage) {
+    return false;
+  }
+  // 只在真实流式生成中;回答结束 / 历史 / 打字机不参与
+  if (!lastAiMessage.contentStreaming && !isLastAiRecordPacing()) {
+    return false;
+  }
+  if (isAnswerTopReachedForCurrentRecord()) {
+    return false;
+  }
+
+  const isAutoScrollActive =
+    typeof scrollList.isAutoScrollEnabled === 'function' ? scrollList.isAutoScrollEnabled() : true;
+  if (!isAutoScrollActive) {
+    // 用户已经自己滚走了,不再干预
+    return false;
+  }
+
+  const scrollElement = scrollList.getScrollElement();
+  const rowElement = messageRowRefs[String(lastAiMessage.id)];
+  if (!scrollElement || !rowElement) {
+    return false;
+  }
+
+  const rowOffsetTop = getRowScrollTop(scrollElement, rowElement);
+  if (!Number.isFinite(rowOffsetTop)) {
+    return false;
+  }
+  // 回答顶部还没到视口顶部 → 继续跟随
+  if (scrollElement.scrollTop < rowOffsetTop - 1) {
+    return false;
+  }
+
+  consumeLastAiRowTopForRecord(lastAiMessage.id);
+  if (typeof scrollList.disableAutoScroll === 'function') {
+    scrollList.disableAutoScroll();
+  }
+  return true;
+};
+
 const syncAutoScrollFollowState = () => {
   const scrollList = scrollListRef.value;
   if (!scrollList || typeof scrollList.getScrollElement !== "function") {
@@ -871,12 +1010,16 @@ const syncAutoScrollFollowState = () => {
     return;
   }
 
-  if (stopAutoScrollAtLastAiRowTopIfNeeded()) {
+  if (maybeStopAutoScrollAtAnswerTop()) {
     return;
   }
 
   if (distanceToBottom < BUSINESS_RECORD_BOTTOM_STICKY_DISTANCE && typeof scrollList.enableAutoScroll === "function") {
-    scrollList.enableAutoScroll();
+    // 已冻结在回答顶部时,只有用户自己滚回底部(suppression)才恢复跟随;
+    // 程序化滚动/布局变化不能把它悄悄重新打开。
+    if (isUserScrollSuppressed || !isAnswerTopReachedForCurrentRecord()) {
+      scrollList.enableAutoScroll();
+    }
   }
 };
 
@@ -1155,6 +1298,58 @@ const scrollToBottom = async (force = false) => {
   }
 };
 
+// 流式贴底跟随:ScrollList 内部按 smoothFollow 决定平滑还是瞬时;
+// 旧组件没有该方法时退化为原来的瞬时贴底。
+const scrollToBottomFollow = async () => {
+  await nextTick();
+  if (!scrollListRef.value) {
+    return;
+  }
+  if (typeof scrollListRef.value.scrollToBottomFollow === 'function') {
+    scrollListRef.value.scrollToBottomFollow();
+  } else {
+    scrollListRef.value.scrollToBottom();
+  }
+  if (scrollHostRef.value) {
+    scrollHostRef.value.scrollTop = scrollHostRef.value.scrollHeight;
+  }
+};
+
+// ── 回到最新进度(豆包式圆形下箭头)──
+// 生成中且用户滚离底部超过阈值时出现;点击恢复自动跟随并平滑滚到底。
+const SCROLL_TO_LATEST_THRESHOLD = 80;
+const scrollAwayFromBottom = ref(false);
+const updateScrollToLatestVisibility = () => {
+  const scrollList = scrollListRef.value;
+  if (!scrollList || typeof scrollList.getDistanceToBottom !== 'function') {
+    return;
+  }
+  scrollAwayFromBottom.value = scrollList.getDistanceToBottom() > SCROLL_TO_LATEST_THRESHOLD;
+};
+const showScrollToLatest = computed(
+  () =>
+    (currentSessionGenerating.value || isLastAiRecordPacing()) &&
+    scrollAwayFromBottom.value
+);
+const scrollToLatest = () => {
+  const scrollList = scrollListRef.value;
+  if (!scrollList) {
+    return;
+  }
+  if (typeof scrollList.enableAutoScroll === 'function') {
+    scrollList.enableAutoScroll();
+  }
+  // 用户明确选择「回到最新进度」→ 本条回答不再触发「到达顶部冻结」
+  const lastAiMessage = getLastAiMessage();
+  if (lastAiMessage) {
+    consumeLastAiRowTopForRecord(lastAiMessage.id);
+  }
+  releaseLastAiRowTopPin("user-scroll");
+  scrollAwayFromBottom.value = false;
+  scrollBusinessAssistantListToBottom(scrollList, 'once');
+  syncAutoScrollFollowState();
+};
+
 const scrollToBottomAfterSessionSwitch = async () => {
   await scrollToBottom(true);
   await nextTick();
@@ -1275,14 +1470,36 @@ const anchorLargeBlockTop = (heightGrowth: number): boolean => {
 };
 
 const handleBusinessRecordRefreshScroll = async (payload?: { heightGrowth?: number; scrollDelta?: number; onComplete?: () => void }) => {
+  updateScrollToLatestVisibility();
   const scrollList = scrollListRef.value;
+
+  // 回答已结束(且排字也排完):反馈/参考资料/追问等尾部落入时不再自动贴底,
+  // 否则用户会在「渲染完」的瞬间被带着往下滚一大段(观感上就是往上弹)。
+  const settledMessage = getLastAiMessage();
+  const scopeExitActive = Boolean(
+    settledMessage && scopeExitStates[String(settledMessage.id)]?.active
+  );
+  const answerSettled =
+    !!settledMessage &&
+    !settledMessage.history &&
+    settledMessage.state === MessageState.Finish &&
+    !settledMessage.contentStreaming &&
+    !isLastAiRecordPacing() &&
+    // scope 退场补偿期间正文行会短暂隐藏,必须保持跟随,否则滚动会被钳制
+    !scopeExitActive;
+  if (answerSettled) {
+    if (scrollList && typeof scrollList.disableAutoScroll === 'function') {
+      scrollList.disableAutoScroll();
+    }
+    payload?.onComplete?.();
+    return;
+  }
   if (scrollList && typeof scrollList.isAutoScrollTopPinned === "function" && scrollList.isAutoScrollTopPinned()) {
     payload?.onComplete?.();
     return;
   }
 
-  if (stopAutoScrollAtLastAiRowTopIfNeeded()) {
-    syncAutoScrollFollowState();
+  if (maybeStopAutoScrollAtAnswerTop()) {
     payload?.onComplete?.();
     return;
   }
@@ -1308,7 +1525,10 @@ const handleBusinessRecordRefreshScroll = async (payload?: { heightGrowth?: numb
       return;
     }
 
-    scrollList.enableAutoScroll();
+    // 已经冻结在「回答顶部」时不再自动恢复跟随(用户点箭头或手动滚回底部才恢复)
+    if (!isAnswerTopReachedForCurrentRecord()) {
+      scrollList.enableAutoScroll();
+    }
     payload?.onComplete?.();
     return;
   }
@@ -1367,7 +1587,7 @@ const handleBusinessRecordRefreshScroll = async (payload?: { heightGrowth?: numb
 
   if (!Number.isFinite(heightGrowth) || heightGrowth <= 0) {
     if (distanceAfterGrowth <= 24) {
-      scrollBusinessAssistantListToBottom(scrollListRef.value, 'instant');
+      scrollBusinessAssistantListToBottom(scrollListRef.value, 'follow');
     } else {
       scrollBusinessAssistantListToBottom(scrollListRef.value);
     }
@@ -1385,7 +1605,7 @@ const handleBusinessRecordRefreshScroll = async (payload?: { heightGrowth?: numb
     }
 
     if (distanceAfterGrowth <= 24) {
-      scrollBusinessAssistantListToBottom(scrollListRef.value, 'instant');
+      scrollBusinessAssistantListToBottom(scrollListRef.value, 'follow');
     } else {
       scrollBusinessAssistantListToBottom(scrollListRef.value, 'once');
     }
@@ -1395,14 +1615,14 @@ const handleBusinessRecordRefreshScroll = async (payload?: { heightGrowth?: numb
 };
 
 const handleBusinessScrollPositionChange = (payload?: { isTrusted?: boolean; isProgrammaticScroll?: boolean }) => {
+  updateScrollToLatestVisibility();
   if (payload?.isTrusted && !payload?.isProgrammaticScroll) {
     cancelMobileScrollAnimation();
     consumeLastAiRowTopForRecord(getLastAiMessage()?.id ?? null);
     releaseLastAiRowTopPin("user-scroll");
   }
 
-  if (stopAutoScrollAtLastAiRowTopIfNeeded()) {
-    syncAutoScrollFollowState();
+  if (maybeStopAutoScrollAtAnswerTop()) {
     return;
   }
 
@@ -2064,6 +2284,44 @@ const confirmDeleteSession = () => {
   background: linear-gradient(180deg, rgba(249, 249, 255, 0) 0%, #f9f9ff 26%, #f9f9ff 100%);
 }
 
+/* 回到最新进度:豆包式圆形下箭头(生成中滚离底部时出现) */
+.scroll-to-latest-btn {
+  position: absolute;
+  top: -46px;
+  left: 50%;
+  transform: translateX(-50%);
+  width: 36px;
+  height: 36px;
+  padding: 0;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  border-radius: 50%;
+  border: 1px solid rgba(199, 196, 216, 0.55);
+  background: rgba(255, 255, 255, 0.96);
+  color: #3525cd;
+  box-shadow: 0 6px 16px rgba(20, 27, 43, 0.14);
+  cursor: pointer;
+  z-index: 12;
+  transition: transform 160ms ease, box-shadow 160ms ease;
+  backdrop-filter: blur(6px);
+}
+
+.scroll-to-latest-btn:active {
+  transform: translateX(-50%) scale(0.96);
+}
+
+.scroll-latest-fade-enter-active,
+.scroll-latest-fade-leave-active {
+  transition: opacity 160ms ease, transform 160ms ease;
+}
+
+.scroll-latest-fade-enter-from,
+.scroll-latest-fade-leave-to {
+  opacity: 0;
+  transform: translateX(-50%) translateY(4px);
+}
+
 .home-fixed-input {
   position: fixed;
   left: 0;

+ 79 - 11
src/components/BusinessAssistantMobileInputShell.vue

@@ -1,5 +1,5 @@
 <template>
-  <section class="chat-input-area">
+  <section class="chat-input-area" :class="{ 'is-desktop': isDesktop }">
     <div class="chat-input-box">
       <div v-if="uploadedFiles.length > 0" class="attachments-area">
         <div v-for="file in uploadedFiles" :key="file.id" class="attachment-item"
@@ -34,14 +34,16 @@
       <div class="input-actions-bar">
         <div class="actions-left">
           <!-- 上传入口:附件先传到 OSS,再随请求体的 `pictures` / `files` 字段发给后端 -->
-          <button type="button" class="action-btn" aria-label="上传图片" @click="emit('imageUpload')">
+          <button type="button" class="action-btn" aria-label="上传图片" @click="emit('imageUpload')"
+            @mouseenter="showActionTip($event, '上传图片')" @mouseleave="hideActionTip">
             <svg width="18" height="18" viewBox="0 0 18 18" fill="none">
               <path
                 d="M2 18c-.55 0-1.02-.2-1.41-.59A1.93 1.93 0 0 1 0 16V2C0 1.45.2.98.59.59A1.93 1.93 0 0 1 2 0h14c.55 0 1.02.2 1.41.59.39.39.59.86.59 1.41v14c0 .55-.2 1.02-.59 1.41-.39.39-.86.59-1.41.59H2Zm0-2h14V2H2v14Zm1-2h12v-1.41L11.25 7l-3 4-2.25-3-3 4.59V14Z"
                 fill="currentColor" />
             </svg>
           </button>
-          <button type="button" class="action-btn" aria-label="上传附件" @click="emit('fileUpload')">
+          <button type="button" class="action-btn" aria-label="上传附件" @click="emit('fileUpload')"
+            @mouseenter="showActionTip($event, '上传附件')" @mouseleave="hideActionTip">
             <svg width="13" height="20" viewBox="0 0 13 20" fill="none">
               <path
                 d="M12.5 13.75c0 1.73-.61 3.21-1.83 4.43C9.46 19.39 7.98 20 6.25 20s-3.21-.61-4.43-1.82A6.02 6.02 0 0 1 0 13.75V4.5c0-1.25.44-2.31 1.31-3.19A4.34 4.34 0 0 1 4.5 0c1.25 0 2.31.44 3.19 1.31A4.34 4.34 0 0 1 9 4.5v8.75c0 .77-.27 1.42-.8 1.95-.53.53-1.18.8-1.95.8s-1.42-.27-1.95-.8c-.53-.53-.8-1.18-.8-1.95V4h2v9.25c0 .22.07.4.21.54.14.14.32.21.54.21s.4-.07.54-.21c.14-.14.21-.32.21-.54V4.5c-.02-.7-.26-1.29-.74-1.78A2.37 2.37 0 0 0 4.5 2c-.7 0-1.29.24-1.78.73A2.42 2.42 0 0 0 2 4.5v9.25c-.02 1.18.39 2.19 1.23 3.01.83.83 1.84 1.24 3.02 1.24 1.17 0 2.16-.41 2.98-1.24.82-.82 1.24-1.83 1.27-3.01V4h2v9.75Z"
@@ -50,7 +52,8 @@
           </button>
           <button v-if="VOICE_INPUT_VISIBLE" type="button" class="action-btn"
             :class="{ 'voice-active': isVoiceInputMode }" :aria-pressed="isVoiceInputMode"
-            :disabled="isVoiceInputStarting" aria-label="语音输入" @click="emit('voiceToggle')">
+            :disabled="isVoiceInputStarting" aria-label="语音输入" @click="emit('voiceToggle')"
+            @mouseenter="showActionTip($event, '语音输入')" @mouseleave="hideActionTip">
             <svg width="14" height="19" viewBox="0 0 14 19" fill="none">
               <path
                 d="M7 12c-.83 0-1.54-.29-2.13-.88A2.9 2.9 0 0 1 4 9V3c0-.83.29-1.54.87-2.13A2.9 2.9 0 0 1 7 0c.83 0 1.54.29 2.13.87C9.71 1.46 10 2.17 10 3v6c0 .83-.29 1.54-.87 2.12A2.9 2.9 0 0 1 7 12Zm-1 7v-3.08a7.04 7.04 0 0 1-4.3-2.32A6.91 6.91 0 0 1 0 9h2c0 1.38.49 2.56 1.46 3.54A4.82 4.82 0 0 0 7 14c1.38 0 2.56-.49 3.54-1.46A4.82 4.82 0 0 0 12 9h2c0 1.75-.57 3.28-1.7 4.6A7.04 7.04 0 0 1 8 15.92V19H6Zm1-9c.28 0 .52-.1.71-.29.19-.19.29-.43.29-.71V3c0-.28-.1-.52-.29-.71A.97.97 0 0 0 7 2a.97.97 0 0 0-.71.29A.97.97 0 0 0 6 3v6c0 .28.1.52.29.71.19.19.43.29.71.29Z"
@@ -109,11 +112,15 @@
         </div>
       </div>
     </div>
+    <Teleport to="body">
+      <div v-if="actionTip.visible" class="action-name-tip"
+        :style="{ left: `${actionTip.x}px`, top: `${actionTip.y}px` }">{{ actionTip.text }}</div>
+    </Teleport>
   </section>
 </template>
 
 <script setup lang="ts">
-import { computed, nextTick, onMounted, ref, watch } from 'vue';
+import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue';
 import type { BusinessAssistantUploadedFile } from './business-assistant/shared';
 
 const props = defineProps<{
@@ -135,13 +142,11 @@ const showMockStreamTestButton = computed(() => props.showMockStreamTestButton =
 /**
  * 语音输入入口是否显示。
  *
- * 当前部署在 **HTTP** 上:这不是安全上下文,`getUserMedia` 会被浏览器直接拒绝
- * (`getUserMedia` 只在 HTTPS 或 localhost 下可用)⇒ 入口先隐藏,避免用户点了没反应。
- *
- * 要恢复:改成 `window.isSecureContext`(HTTPS/localhost 下自动出现、HTTP 下自动隐藏)。
- * 组件里的 props / emits / ASR 逻辑都还在,改这一行即可。
+ * 2026-10-28 用户需要调试语音链路 → 恢复为按安全上下文判断:
+ * HTTPS/localhost 显示,HTTP 隐藏(HTTP 下 getUserMedia 本来也不能用)。
+ * 入口全仓库只有这一处;ASR 逻辑与内部实现在 src/asr/。
  */
-const VOICE_INPUT_VISIBLE = false;
+const VOICE_INPUT_VISIBLE = typeof window !== "undefined" && window.isSecureContext;
 
 const emit = defineEmits<{
   'update:modelValue': [value: string];
@@ -162,6 +167,48 @@ const emit = defineEmits<{
   testQuestionCard: [];
 }>();
 
+const ACTION_TIP_DELAY = 300;
+const actionTip = reactive({ visible: false, text: '', x: 0, y: 0 });
+let actionTipTimer: number | null = null;
+let actionTipEl: HTMLElement | null = null;
+
+const clearActionTipTimer = () => {
+  if (actionTipTimer !== null) {
+    window.clearTimeout(actionTipTimer);
+    actionTipTimer = null;
+  }
+};
+
+const placeActionTip = (el: HTMLElement) => {
+  const rect = el.getBoundingClientRect();
+  actionTip.x = rect.left + rect.width / 2;
+  actionTip.y = rect.top;
+};
+
+const showActionTip = (event: MouseEvent, text: string) => {
+  if (!props.isDesktop) return;
+  const el = event.currentTarget as HTMLElement | null;
+  if (!el) return;
+  clearActionTipTimer();
+  actionTipEl = el;
+  placeActionTip(el);
+  actionTip.text = text;
+  actionTipTimer = window.setTimeout(() => {
+    actionTipTimer = null;
+    if (actionTipEl) placeActionTip(actionTipEl);
+    actionTip.visible = true;
+  }, ACTION_TIP_DELAY);
+};
+
+const hideActionTip = () => {
+  clearActionTipTimer();
+  actionTipEl = null;
+  actionTip.visible = false;
+  actionTip.text = '';
+};
+
+onBeforeUnmount(hideActionTip);
+
 const deepThinkValue = computed({
   get: () => props.isDeepThink,
   set: (value: boolean) => emit('update:isDeepThink', value),
@@ -396,6 +443,27 @@ const getFileStatusText = (file: BusinessAssistantUploadedFile) => {
   cursor: pointer;
 }
 
+.chat-input-area.is-desktop .action-btn:hover {
+  background: #e3e3e3;
+}
+
+.action-name-tip {
+  position: fixed;
+  z-index: 4000;
+  max-width: 280px;
+  padding: 8px 10px;
+  border-radius: 8px;
+  background: #141b2b;
+  color: #ffffff;
+  font-size: 12px;
+  font-weight: 500;
+  line-height: 1.5;
+  box-shadow: 0 8px 20px rgba(20, 27, 43, 0.18);
+  pointer-events: none;
+  transform: translate(-50%, calc(-100% - 8px));
+  white-space: nowrap;
+}
+
 .action-btn:active {
   background: #e3e3e3;
   color: #3525cd;

+ 422 - 69
src/components/BusinessAssistantPC.vue

@@ -159,44 +159,28 @@
             />
 
             <div class="bento-features">
-              <article class="bento-card bento-card-blue">
-                <div class="bento-icon">
-                  <svg width="22" height="22" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"
-                    aria-hidden="true">
-                    <path fill="currentColor"
-                      d="M18 8l-1.25-2.75-2.75-1.25 2.75-1.25 1.25-2.75 1.25 2.75 2.75 1.25-2.75 1.25-1.25 2.75 0 0m0 14l-1.25-2.75-2.75-1.25 2.75-1.25 1.25-2.75 1.25 2.75 2.75 1.25-2.75 1.25-1.25 2.75 0 0m-10-3l-2.5-5.5-5.5-2.5 5.5-2.5 2.5-5.5 2.5 5.5 5.5 2.5-5.5 2.5-2.5 5.5 0 0m0-4.85l1-2.15 2.15-1-2.15-1-1-2.15-1 2.15-2.15 1 2.15 1 1 2.15 0 0m0-3.15l0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0" />
-                  </svg>
-                </div>
-                <div class="bento-content">
-                  <div class="bento-title">政策精准匹配</div>
-                  <div class="bento-desc">基于最新的 AI 模型,深度解析青浦区各项惠企政策,为用户提供现场级的精准匹配与申报建议。</div>
-                </div>
-              </article>
-              <article class="bento-card bento-card-amber">
-                <div class="bento-icon">
-                  <svg width="16" height="20" viewBox="0 0 16 20" fill="none" xmlns="http://www.w3.org/2000/svg"
-                    aria-hidden="true">
-                    <path fill="currentColor"
-                      d="M8 20c-2.31667-0.58333-4.22917-1.9125-5.7375-3.9875-1.50833-2.075-2.2625-4.37917-2.2625-6.9125l0-6.1 8-3 8 3 0 6.1c0 2.53333-0.75417 4.8375-2.2625 6.9125-1.50833 2.075-3.42083 3.40416-5.7375 3.9875l0 0m0-2.1c1.61667-0.5 2.96667-1.4875 4.05-2.9625 1.08333-1.475 1.71667-3.12083 1.9-4.9375l-5.95 0 0-7.875-6 2.25 0 4.725c0 0.18333 0 0.33333 0 0.45 0 0.11667 0.01667 0.26667 0.05 0.45l5.95 0 0 7.9 0 0" />
-                  </svg>
-                </div>
-                <div class="bento-content">
-                  <div class="bento-title">营商环境分析</div>
-                  <div class="bento-desc">多维度剖析区域营商环境,实时追踪行业动向,为企业投资决策提供专业的数据支撑。</div>
-                </div>
-              </article>
-              <article class="bento-card bento-card-rose">
-                <div class="bento-icon">
-                  <svg width="18" height="20" viewBox="0 0 18 20" fill="none" xmlns="http://www.w3.org/2000/svg"
-                    aria-hidden="true">
-                    <path fill="currentColor"
-                      d="M6.6 14.6l1.4-1.45-2.15-2.15 2.15-2.15-1.4-1.45-3.6 3.6 3.6 3.6 0 0m4.8 0l3.6-3.6-3.6-3.6-1.4 1.45 2.15 2.15-2.15 2.15 1.4 1.45 0 0m-9.4 5.4c-0.55 0-1.02083-0.19583-1.4125-0.5875-0.39167-0.39167-0.5875-0.8625-0.5875-1.4125l0-14c0-0.55 0.19583-1.02083 0.5875-1.4125 0.39167-0.39167 0.8625-0.5875 1.4125-0.5875l4.2 0c0.21667-0.6 0.57917-1.08333 1.0875-1.45 0.50833-0.36667 1.07917-0.55 1.7125-0.55 0.63333 0 1.20417 0.18333 1.7125 0.55 0.50833 0.36667 0.87083 0.85 1.0875 1.45l4.2 0c0.55 0 1.02083 0.19583 1.4125 0.5875 0.39167 0.39167 0.5875 0.8625 0.5875 1.4125l0 14c0 0.55-0.19583 1.02083-0.5875 1.4125-0.39167 0.39167-0.8625 0.5875-1.4125 0.5875l-14 0 0 0m0-2l14 0 0 0 0 0 0-14 0 0 0 0-14 0 0 0 0 0 0 14 0 0 0 0 0 0m7-14.75c0.21667 0 0.39583-0.07083 0.5375-0.2125 0.14167-0.14167 0.2125-0.32083 0.2125-0.5375 0-0.21667-0.07083-0.39583-0.2125-0.5375-0.14167-0.14167-0.32083-0.2125-0.5375-0.2125-0.21667 0-0.39583 0.07083-0.5375 0.2125-0.14167 0.14167-0.2125 0.32083-0.2125 0.5375 0 0.21667 0.07083 0.39583 0.2125 0.5375 0.14167 0.14167 0.32083 0.2125 0.5375 0.2125l0 0m-7 14.75l0 0 0 0 0-14 0 0 0 0 0 0 0 0 0 0 0 14 0 0 0 0 0 0 0 0" />
-                  </svg>
-                </div>
-                <div class="bento-content">
-                  <div class="bento-title">惠企办事指引</div>
-                  <div class="bento-desc">提供办事指南、窗口导办等咨询答疑服务,助力企业高效对接青浦政务服务资源。</div>
+              <article
+                v-for="item in bentoFeatures"
+                :key="item.id"
+                class="bento-card"
+                :class="item.toneClass"
+              >
+                <div class="bento-head">
+                  <div class="bento-icon">
+                    <svg
+                      :width="item.icon.width"
+                      :height="item.icon.height"
+                      :viewBox="item.icon.viewBox"
+                      fill="none"
+                      xmlns="http://www.w3.org/2000/svg"
+                      aria-hidden="true"
+                    >
+                      <path fill="currentColor" :d="item.icon.path" />
+                    </svg>
+                  </div>
+                  <div class="bento-title">{{ item.title }}</div>
                 </div>
+                <div class="bento-desc">{{ item.desc }}</div>
               </article>
             </div>
           </div>
@@ -206,7 +190,8 @@
           <div class="chat-layout">
             <div class="chat-messages" ref="chatMessagesRef">
               <ScrollList v-if="currentSession" :data="currentSession.messages" ref="scrollListRef" :height="listHeight"
-                :maxHeight="listHeight" :topPadding="8" @scrollPositionChange="handleBusinessScrollPositionChange">
+                :maxHeight="listHeight" :topPadding="8" :smooth-follow="isLastAiRecordStreaming"
+                @scrollPositionChange="handleBusinessScrollPositionChange">
                 <template #item="{ data, isLast }">
                   <div class="message-row" :ref="(el) => setMessageRowRef(data.id, el)"
                     :class="[data.role, { 'is-last': isLast, 'is-scope-exiting': isScopeExiting(data.id) }]"
@@ -220,7 +205,8 @@
                       @refreshScroll="handleBusinessRecordRefreshScroll"
                       @scopeExitStateChange="handleScopeExitStateChange"
                       @scopeHeightLockChange="handleScopeHeightLockChange"
-                      @typewriterStateChange="handleBusinessRecordTypewriterStateChange" />
+                      @typewriterStateChange="handleBusinessRecordTypewriterStateChange"
+                      @displayPacingStateChange="handleBusinessRecordDisplayPacingStateChange" />
                     <div v-if="data.role === 'user'" class="user-avatar">
                       <div class="user-avatar-bg">
                         <svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -238,6 +224,26 @@
             </div>
 
             <div class="chat-input-wrapper">
+              <Transition name="scroll-latest-fade">
+                <button
+                  v-if="showScrollToLatest"
+                  type="button"
+                  class="scroll-to-latest-btn"
+                  aria-label="回到最新进度"
+                  title="回到最新进度"
+                  @click="scrollToLatest"
+                >
+                  <svg width="18" height="18" viewBox="0 0 24 24" fill="none" aria-hidden="true">
+                    <path
+                      d="M12 5v12.5M6.5 12 12 17.5 17.5 12"
+                      stroke="currentColor"
+                      stroke-width="1.8"
+                      stroke-linecap="round"
+                      stroke-linejoin="round"
+                    />
+                  </svg>
+                </button>
+              </Transition>
               <BusinessAssistantComposer
                 class="chat-composer-shell"
                 :modelValue="inputText"
@@ -338,7 +344,8 @@
 </template>
 
 <script setup lang="ts">
-import { ref, onMounted, onBeforeUnmount, nextTick, computed, provide, watch, reactive } from 'vue';
+import { ref, reactive, onMounted, onBeforeUnmount, nextTick, computed, provide, watch } from 'vue';
+import { MessageState } from '@/types/record';
 import { useResizeObserver } from '@vueuse/core';
 import BusinessRecord from "./Chat/BusinessRecord.vue";
 import ScrollList from './Common/ScrollList.vue';
@@ -365,6 +372,94 @@ provide("speechControl", {
 
 const imageInputRef = ref<HTMLInputElement | null>(null);
 const fileInputRef = ref<HTMLInputElement | null>(null);
+
+/** 首页能力卡片(仅 PC):两行 × 三列,描述固定 3 行省略 */
+type BentoFeature = {
+  id: string;
+  title: string;
+  desc: string;
+  toneClass: string;
+  icon: { width: number; height: number; viewBox: string; path: string };
+};
+
+const bentoFeatures: BentoFeature[] = [
+  {
+    id: 'policy-match',
+    title: '惠企政策匹配',
+    desc: '依托 AI 解析青浦惠企政策,根据企业画像智能匹配适用条款,梳理申报路径,直达政策红利。',
+    toneClass: 'bento-card-blue',
+    icon: {
+      width: 22,
+      height: 22,
+      viewBox: '0 0 24 24',
+      path: 'M18 8l-1.25-2.75-2.75-1.25 2.75-1.25 1.25-2.75 1.25 2.75 2.75 1.25-2.75 1.25-1.25 2.75 0 0m0 14l-1.25-2.75-2.75-1.25 2.75-1.25 1.25-2.75 1.25 2.75 2.75 1.25-2.75 1.25-1.25 2.75 0 0m-10-3l-2.5-5.5-5.5-2.5 5.5-2.5 2.5-5.5 2.5 5.5 5.5 2.5-5.5 2.5-2.5 5.5 0 0m0-4.85l1-2.15 2.15-1-2.15-1-1-2.15-1 2.15-2.15 1 2.15 1 1 2.15 0 0m0-3.15l0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0',
+    },
+  },
+  {
+    id: 'service-guide',
+    title: '办事指南咨询',
+    desc: '提供涉企事项全流程指引,明确办理材料、渠道与审核要点,精简企业办事环节。',
+    toneClass: 'bento-card-rose',
+    icon: {
+      width: 18,
+      height: 20,
+      viewBox: '0 0 18 20',
+      path: 'M6.6 14.6l1.4-1.45-2.15-2.15 2.15-2.15-1.4-1.45-3.6 3.6 3.6 3.6 0 0m4.8 0l3.6-3.6-3.6-3.6-1.4 1.45 2.15 2.15-2.15 2.15 1.4 1.45 0 0m-9.4 5.4c-0.55 0-1.02083-0.19583-1.4125-0.5875-0.39167-0.39167-0.5875-0.8625-0.5875-1.4125l0-14c0-0.55 0.19583-1.02083 0.5875-1.4125 0.39167-0.39167 0.8625-0.5875 1.4125-0.5875l4.2 0c0.21667-0.6 0.57917-1.08333 1.0875-1.45 0.50833-0.36667 1.07917-0.55 1.7125-0.55 0.63333 0 1.20417 0.18333 1.7125 0.55 0.50833 0.36667 0.87083 0.85 1.0875 1.45l4.2 0c0.55 0 1.02083 0.19583 1.4125 0.5875 0.39167 0.39167 0.5875 0.8625 0.5875 1.4125l0 14c0 0.55-0.19583 1.02083-0.5875 1.4125-0.39167 0.39167-0.8625 0.5875-1.4125 0.5875l-14 0 0 0m0-2l14 0 0 0 0 0 0-14 0 0 0 0-14 0 0 0 0 0 0 14 0 0 0 0 0 0m7-14.75c0.21667 0 0.39583-0.07083 0.5375-0.2125 0.14167-0.14167 0.2125-0.32083 0.2125-0.5375 0-0.21667-0.07083-0.39583-0.2125-0.5375-0.14167-0.14167-0.32083-0.2125-0.5375-0.2125-0.21667 0-0.39583 0.07083-0.5375 0.2125-0.14167 0.14167-0.2125 0.32083-0.2125 0.5375 0 0.21667 0.07083 0.39583 0.2125 0.5375 0.14167 0.14167 0.32083 0.2125 0.5375 0.2125l0 0m-7 14.75l0 0 0 0 0-14 0 0 0 0 0 0 0 0 0 0 0 14 0 0 0 0 0 0 0 0',
+    },
+  },
+  {
+    id: 'service-items',
+    title: '服务事项咨询',
+    desc: '整合出海、人才、金融、科创、政策、法治六大服务资源,为企业精准对接各类专业服务。',
+    toneClass: 'bento-card-teal',
+    icon: {
+      width: 20,
+      height: 20,
+      viewBox: '0 0 24 24',
+      // 六宫格:六大服务领域
+      path: 'M3 3h7v7H3V3zm11 0h7v7h-7V3zM3 14h7v7H3v-7zm11 0h7v7h-7v-7z',
+    },
+  },
+  {
+    id: 'finance',
+    title: '金融产品推荐',
+    desc: '联动 E 企融平台,结合企业经营情况智能匹配信贷产品,打通银企对接渠道,破解融资难题。',
+    toneClass: 'bento-card-indigo',
+    icon: {
+      width: 20,
+      height: 20,
+      viewBox: '0 0 24 24',
+      // 币形圆环
+      path: 'M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm.5-13H11v2.02c-1.75.27-3 1.5-3 3.23 0 2.05 1.76 3.25 4 3.25 1.47 0 2.5-.55 2.5-1.5 0-.9-.78-1.3-2.5-1.7-2.38-.55-4-1.45-4-3.55 0-1.65 1.25-2.85 3-3.2V5h1.5v1.05c1.55.3 2.7 1.3 2.85 2.85H13.2c-.15-.9-.85-1.4-2.2-1.4-1.35 0-2.15.55-2.15 1.4 0 .75.7 1.15 2.45 1.55 2.4.55 4.05 1.45 4.05 3.6 0 1.75-1.3 3-3.35 3.3V19H11.5v-1.08z',
+    },
+  },
+  {
+    id: 'business-env',
+    title: '营商环境咨询',
+    desc: '全方位介绍青浦区位优势、产业配套与平台资源,全景展示区域营商发展生态。',
+    toneClass: 'bento-card-amber',
+    icon: {
+      width: 16,
+      height: 20,
+      viewBox: '0 0 16 20',
+      path: 'M8 20c-2.31667-0.58333-4.22917-1.9125-5.7375-3.9875-1.50833-2.075-2.2625-4.37917-2.2625-6.9125l0-6.1 8-3 8 3 0 6.1c0 2.53333-0.75417 4.8375-2.2625 6.9125-1.50833 2.075-3.42083 3.40416-5.7375 3.9875l0 0m0-2.1c1.61667-0.5 2.96667-1.4875 4.05-2.9625 1.08333-1.475 1.71667-3.12083 1.9-4.9375l-5.95 0 0-7.875-6 2.25 0 4.725c0 0.18333 0 0.33333 0 0.45 0 0.11667 0.01667 0.26667 0.05 0.45l5.95 0 0 7.9 0 0',
+    },
+  },
+  {
+    id: 'store-open',
+    title: '开店流程咨询',
+    desc: '围绕 “开店一件事”,解读准入条件与全流程事项,为创业主体提供一站式开办指引。',
+    toneClass: 'bento-card-cyan',
+    icon: {
+      width: 20,
+      height: 20,
+      viewBox: '0 0 24 24',
+      // 店面门头
+      path: 'M4 6l1.5-4h13L20 6c0 1.1-.9 2-2 2s-2-.9-2-2c0 1.1-.9 2-2 2s-2-.9-2-2c0 1.1-.9 2-2 2s-2-.9-2-2c0 1.1-.9 2-2 2s-2-.9-2-2zm1 4h14v10H5V10zm5 2v6h4v-6h-4z',
+    },
+  },
+];
+
 const {
   uploadedFiles,
   triggerImageUpload,
@@ -428,7 +523,10 @@ const {
     }
   },
   afterSend: () => scrollToBottom(true),
-  onMessageUpdated: () => scrollToBottom(),
+  onMessageUpdated: () => {
+    scrollToBottomFollow();
+    updateScrollToLatestVisibility();
+  },
   getInputFileTransmission: consumeSuccessfulFileTransmission,
 });
 
@@ -714,6 +812,31 @@ const getLastAiMessage = () => {
   return null;
 };
 
+// 排字缓冲进行中(可能已 finishTask,但仍有约 1s 存量在上屏)→ 仍按「生成中」处理
+const lastAiRecordDisplayPacingStates = ref<Record<string, boolean>>({});
+const handleBusinessRecordDisplayPacingStateChange = (payload?: {
+  recordId?: string | number;
+  active?: boolean;
+}) => {
+  const recordId = payload?.recordId;
+  if (recordId === undefined || recordId === null) {
+    return;
+  }
+  lastAiRecordDisplayPacingStates.value[String(recordId)] = Boolean(payload?.active);
+};
+const isLastAiRecordPacing = () => {
+  const lastAiMessage = getLastAiMessage();
+  if (!lastAiMessage) {
+    return false;
+  }
+  return Boolean(lastAiRecordDisplayPacingStates.value[String(lastAiMessage.id)]);
+};
+
+// 豆包式平滑贴底:仅在新后端真实流式期间开启(mock 打字机 / 历史仍瞬时贴底)。
+const isLastAiRecordStreaming = computed(
+  () => Boolean(getLastAiMessage()?.contentStreaming) || isLastAiRecordPacing()
+);
+
 const getRowScrollTop = (scrollElement: HTMLElement, rowElement: HTMLElement) => {
   const scrollRect = scrollElement.getBoundingClientRect();
   const rowRect = rowElement.getBoundingClientRect();
@@ -789,7 +912,19 @@ const getOrCreateLastAiRowTopSnapshot = (recordId: string, rowOffsetTop: number)
   return lastAiRowTopSnapshot.value;
 };
 
+/**
+ * [已停用 2026-10-27] 用户要求「回答过程中自由滚动、回答结束不要跳回句首」。
+ * 原逻辑在最后一条 AI 行滚到视口顶部时 scrollToPositionInstant(行顶 - 8),
+ * 是全仓库**唯一**会把视图滚回回答顶部的路径(见 progress 续 14)。
+ * 保留实现便于回退,但不再触发。
+ */
+const ENABLE_LAST_AI_ROW_TOP_PIN = false;
+
 const stopAutoScrollAtLastAiRowTopIfNeeded = () => {
+  if (!ENABLE_LAST_AI_ROW_TOP_PIN) {
+    return false;
+  }
+
   const scrollList = scrollListRef.value;
   if (scrollList && typeof scrollList.isAutoScrollTopPinSuppressedByUser === "function" && scrollList.isAutoScrollTopPinSuppressedByUser()) {
     return false;
@@ -861,6 +996,66 @@ const stopAutoScrollAtLastAiRowTopIfNeeded = () => {
   return result.didStop;
 };
 
+/** 当前最后一条 AI 消息是否已经触发过「到达视口顶部即停止跟随」。 */
+const isAnswerTopReachedForCurrentRecord = () => {
+  const lastAiMessage = getLastAiMessage();
+  if (!lastAiMessage) {
+    return false;
+  }
+  return lastAiRowTopConsumedRecordId.value === String(lastAiMessage.id);
+};
+
+/**
+ * 用户没有操作时,自动跟随到「回答内容的顶部到达对话窗顶部」就停止(**不移动视图**),
+ * 下方继续生成,箭头出现。每条回答只触发一次;点箭头或手动滚回底部后本条不再触发。
+ */
+const maybeStopAutoScrollAtAnswerTop = () => {
+  const scrollList = scrollListRef.value;
+  if (!scrollList || typeof scrollList.getScrollElement !== "function") {
+    return false;
+  }
+
+  const lastAiMessage = getLastAiMessage();
+  if (!lastAiMessage) {
+    return false;
+  }
+  // 只在真实流式生成中;回答结束 / 历史 / 打字机不参与
+  if (!lastAiMessage.contentStreaming && !isLastAiRecordPacing()) {
+    return false;
+  }
+  if (isAnswerTopReachedForCurrentRecord()) {
+    return false;
+  }
+
+  const isAutoScrollActive =
+    typeof scrollList.isAutoScrollEnabled === "function" ? scrollList.isAutoScrollEnabled() : true;
+  if (!isAutoScrollActive) {
+    // 用户已经自己滚走了,不再干预
+    return false;
+  }
+
+  const scrollElement = scrollList.getScrollElement();
+  const rowElement = messageRowRefs[String(lastAiMessage.id)];
+  if (!scrollElement || !rowElement) {
+    return false;
+  }
+
+  const rowOffsetTop = getRowScrollTop(scrollElement, rowElement);
+  if (!Number.isFinite(rowOffsetTop)) {
+    return false;
+  }
+  // 回答顶部还没到视口顶部 → 继续跟随
+  if (scrollElement.scrollTop < rowOffsetTop - 1) {
+    return false;
+  }
+
+  consumeLastAiRowTopForRecord(lastAiMessage.id);
+  if (typeof scrollList.disableAutoScroll === "function") {
+    scrollList.disableAutoScroll();
+  }
+  return true;
+};
+
 const syncAutoScrollFollowState = () => {
   const scrollList = scrollListRef.value;
   if (!scrollList || typeof scrollList.getScrollElement !== "function") {
@@ -894,12 +1089,16 @@ const syncAutoScrollFollowState = () => {
     return;
   }
 
-  if (stopAutoScrollAtLastAiRowTopIfNeeded()) {
+  if (maybeStopAutoScrollAtAnswerTop()) {
     return;
   }
 
   if (distanceToBottom < BUSINESS_RECORD_BOTTOM_STICKY_DISTANCE && typeof scrollList.enableAutoScroll === "function") {
-    scrollList.enableAutoScroll();
+    // 已冻结在回答顶部时,只有用户自己滚回底部(suppression)才恢复跟随;
+    // 程序化滚动/布局变化不能把它悄悄重新打开。
+    if (isUserScrollSuppressed || !isAnswerTopReachedForCurrentRecord()) {
+      scrollList.enableAutoScroll();
+    }
   }
 };
 
@@ -1089,6 +1288,55 @@ const scrollToBottom = async (force = false) => {
   }
 };
 
+// 流式贴底跟随:ScrollList 内部按 smoothFollow 决定平滑还是瞬时;
+// 旧组件没有该方法时退化为原来的瞬时贴底。
+const scrollToBottomFollow = async () => {
+  await nextTick();
+  if (!scrollListRef.value) {
+    return;
+  }
+  if (typeof scrollListRef.value.scrollToBottomFollow === "function") {
+    scrollListRef.value.scrollToBottomFollow();
+  } else {
+    scrollListRef.value.scrollToBottom();
+  }
+};
+
+// ── 回到最新进度(豆包式圆形下箭头)──
+// 生成中且用户滚离底部超过阈值时出现;点击恢复自动跟随并平滑滚到底。
+const SCROLL_TO_LATEST_THRESHOLD = 80;
+const scrollAwayFromBottom = ref(false);
+const updateScrollToLatestVisibility = () => {
+  const scrollList = scrollListRef.value;
+  if (!scrollList || typeof scrollList.getDistanceToBottom !== "function") {
+    return;
+  }
+  scrollAwayFromBottom.value = scrollList.getDistanceToBottom() > SCROLL_TO_LATEST_THRESHOLD;
+};
+const showScrollToLatest = computed(
+  () =>
+    (currentSessionGenerating.value || isLastAiRecordPacing()) &&
+    scrollAwayFromBottom.value
+);
+const scrollToLatest = () => {
+  const scrollList = scrollListRef.value;
+  if (!scrollList) {
+    return;
+  }
+  if (typeof scrollList.enableAutoScroll === "function") {
+    scrollList.enableAutoScroll();
+  }
+  // 用户明确选择「回到最新进度」→ 本条回答不再触发「到达顶部冻结」
+  const lastAiMessage = getLastAiMessage();
+  if (lastAiMessage) {
+    consumeLastAiRowTopForRecord(lastAiMessage.id);
+  }
+  releaseLastAiRowTopPin("user-scroll");
+  scrollAwayFromBottom.value = false;
+  scrollBusinessAssistantListToBottom(scrollList, "once");
+  syncAutoScrollFollowState();
+};
+
 const scrollToBottomAfterSessionSwitch = async () => {
   await scrollToBottom(true);
   await nextTick();
@@ -1173,14 +1421,37 @@ const anchorLargeBlockTop = (heightGrowth: number): boolean => {
 };
 
 const handleBusinessRecordRefreshScroll = async (payload?: { heightGrowth?: number; scrollDelta?: number; onComplete?: () => void }) => {
+  updateScrollToLatestVisibility();
   const scrollList = scrollListRef.value;
+
+  // 回答已结束(且排字也排完):反馈/参考资料/追问等尾部落入时不再自动贴底,
+  // 否则用户会在「渲染完」的瞬间被带着往下滚一大段(观感上就是往上弹)。
+  const settledMessage = getLastAiMessage();
+  const scopeExitActive = Boolean(
+    settledMessage && scopeExitStates[String(settledMessage.id)]?.active
+  );
+  const answerSettled =
+    !!settledMessage &&
+    !settledMessage.history &&
+    settledMessage.state === MessageState.Finish &&
+    !settledMessage.contentStreaming &&
+    !isLastAiRecordPacing() &&
+    // scope 退场补偿期间正文行会短暂隐藏,必须保持跟随,否则滚动会被钳制
+    !scopeExitActive;
+  if (answerSettled) {
+    if (scrollList && typeof scrollList.disableAutoScroll === "function") {
+      scrollList.disableAutoScroll();
+    }
+    payload?.onComplete?.();
+    return;
+  }
+
   if (scrollList && typeof scrollList.isAutoScrollTopPinned === "function" && scrollList.isAutoScrollTopPinned()) {
     payload?.onComplete?.();
     return;
   }
 
-  if (stopAutoScrollAtLastAiRowTopIfNeeded()) {
-    syncAutoScrollFollowState();
+  if (maybeStopAutoScrollAtAnswerTop()) {
     payload?.onComplete?.();
     return;
   }
@@ -1200,7 +1471,10 @@ const handleBusinessRecordRefreshScroll = async (payload?: { heightGrowth?: numb
       return;
     }
 
-    scrollList.enableAutoScroll();
+    // 已经冻结在「回答顶部」时不再自动恢复跟随(用户点箭头或手动滚回底部才恢复)
+    if (!isAnswerTopReachedForCurrentRecord()) {
+      scrollList.enableAutoScroll();
+    }
     payload?.onComplete?.();
     return;
   }
@@ -1252,7 +1526,7 @@ const handleBusinessRecordRefreshScroll = async (payload?: { heightGrowth?: numb
   // 如果没有高度增长,我们只根据当前的实际距离决定如何滚动到底部
   if (!Number.isFinite(heightGrowth) || heightGrowth <= 0) {
     if (distanceAfterGrowth <= 24) {
-      scrollBusinessAssistantListToBottom(scrollListRef.value, "instant");
+      scrollBusinessAssistantListToBottom(scrollListRef.value, "follow");
     } else {
       scrollBusinessAssistantListToBottom(scrollListRef.value);
     }
@@ -1269,9 +1543,9 @@ const handleBusinessRecordRefreshScroll = async (payload?: { heightGrowth?: numb
       return;
     }
 
-    // 高度增加后判断新增前是否贴近底部:极近(<= 24px)则瞬间跳到底部,否则平滑滚动
+    // 高度增加后判断新增前是否贴近底部:极近(<= 24px)则跟随贴底(流式平滑、其余瞬时),否则平滑滚动
     if (distanceAfterGrowth <= 24) {
-      scrollBusinessAssistantListToBottom(scrollListRef.value, "instant");
+      scrollBusinessAssistantListToBottom(scrollListRef.value, "follow");
     } else {
       scrollBusinessAssistantListToBottom(scrollListRef.value, "once");
     }
@@ -1281,13 +1555,13 @@ const handleBusinessRecordRefreshScroll = async (payload?: { heightGrowth?: numb
 };
 
 const handleBusinessScrollPositionChange = (payload?: { isTrusted?: boolean; isProgrammaticScroll?: boolean }) => {
+  updateScrollToLatestVisibility();
   if (payload?.isTrusted && !payload?.isProgrammaticScroll) {
     consumeLastAiRowTopForRecord(getLastAiMessage()?.id ?? null);
     releaseLastAiRowTopPin("user-scroll");
   }
 
-  if (stopAutoScrollAtLastAiRowTopIfNeeded()) {
-    syncAutoScrollFollowState();
+  if (maybeStopAutoScrollAtAnswerTop()) {
     return;
   }
 
@@ -1934,13 +2208,16 @@ const isScopeExiting = (recordId: string | number) => {
   flex-direction: column;
   align-items: center;
   padding: 24px 24px 96px 24px;
-  /* overflow-y: auto;
-  overflow-x: hidden; */
   height: 0;
   position: relative;
   z-index: 1;
 }
 
+.canvas-area:not(.chatting-canvas) {
+  overflow: hidden;
+  padding: 16px 32px 16px;
+}
+
 .chatting-canvas {
   padding: 0;
   /* overflow: hidden; */
@@ -1948,12 +2225,14 @@ const isScopeExiting = (recordId: string | number) => {
 
 .hero-shell {
   width: 100%;
+  max-width: 1180px;
   display: flex;
   flex-direction: column;
   align-items: center;
-  gap: 14.8px;
-  margin-top: 54px;
-  padding-bottom: 48px;
+  gap: 12px;
+  margin-top: 20px;
+  padding-bottom: 0;
+  min-height: 0;
 }
 
 .overlay-border {
@@ -2387,11 +2666,12 @@ textarea::placeholder {
 
 .bento-features {
   display: grid;
-  grid-template-columns: repeat(3, 384px);
-  gap: 24px;
-  margin-top: 96px;
+  grid-template-columns: repeat(3, minmax(0, 1fr));
+  grid-template-rows: repeat(2, auto);
+  gap: 12px 16px;
+  margin-top: 40px;
   width: 100%;
-  max-width: none;
+  max-width: 1180px;
   justify-content: center;
 }
 
@@ -2399,11 +2679,19 @@ textarea::placeholder {
   background: rgba(241, 243, 255, 0.5);
   border: 1px solid rgba(199, 196, 216, 0.1);
   border-radius: 16px;
-  padding: 24px;
+  padding: 14px 16px;
   display: flex;
   flex-direction: column;
-  gap: 16px;
-  min-height: 184px;
+  gap: 8px;
+  min-height: 0;
+  height: auto;
+}
+
+.bento-head {
+  display: flex;
+  align-items: center;
+  gap: 12px;
+  min-width: 0;
 }
 
 .bento-icon {
@@ -2413,6 +2701,7 @@ textarea::placeholder {
   display: flex;
   align-items: center;
   justify-content: center;
+  flex-shrink: 0;
 }
 
 .bento-card-blue .bento-icon {
@@ -2430,11 +2719,19 @@ textarea::placeholder {
   color: #3525cd;
 }
 
-.bento-content {
-  display: flex;
-  flex-direction: column;
-  gap: 7px;
-  text-align: left;
+.bento-card-teal .bento-icon {
+  background: rgba(13, 148, 136, 0.12);
+  color: #0f766e;
+}
+
+.bento-card-indigo .bento-icon {
+  background: rgba(79, 70, 229, 0.12);
+  color: #4338ca;
+}
+
+.bento-card-cyan .bento-icon {
+  background: rgba(8, 145, 178, 0.12);
+  color: #0e7490;
 }
 
 .bento-title {
@@ -2442,12 +2739,15 @@ textarea::placeholder {
   font-size: 18px;
   font-weight: 600;
   line-height: 1.4;
+  min-width: 0;
 }
 
 .bento-desc {
+  width: 100%;
   color: #464555;
   font-size: 14px;
   line-height: 1.6;
+  text-align: left;
 }
 
 .chat-layout {
@@ -2573,6 +2873,45 @@ textarea::placeholder {
   position: relative;
 }
 
+/* 回到最新进度:豆包式圆形下箭头(生成中滚离底部时出现) */
+.scroll-to-latest-btn {
+  position: absolute;
+  top: -48px;
+  left: 50%;
+  transform: translateX(-50%);
+  width: 36px;
+  height: 36px;
+  padding: 0;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  border-radius: 50%;
+  border: 1px solid rgba(199, 196, 216, 0.55);
+  background: rgba(255, 255, 255, 0.96);
+  color: #3525cd;
+  box-shadow: 0 6px 16px rgba(20, 27, 43, 0.14);
+  cursor: pointer;
+  z-index: 12;
+  transition: transform 160ms ease, box-shadow 160ms ease;
+  backdrop-filter: blur(6px);
+}
+
+.scroll-to-latest-btn:hover {
+  transform: translateX(-50%) translateY(-1px);
+  box-shadow: 0 8px 20px rgba(20, 27, 43, 0.18);
+}
+
+.scroll-latest-fade-enter-active,
+.scroll-latest-fade-leave-active {
+  transition: opacity 160ms ease, transform 160ms ease;
+}
+
+.scroll-latest-fade-enter-from,
+.scroll-latest-fade-leave-to {
+  opacity: 0;
+  transform: translateX(-50%) translateY(4px);
+}
+
 .chat-suggestions-container {
   position: absolute;
   bottom: 100%;
@@ -2671,7 +3010,21 @@ textarea::placeholder {
   letter-spacing: 0.12px;
 }
 
-@media (max-width: 1180px) {
+@media (max-width: 1280px) {
+  .bento-features {
+    grid-template-columns: repeat(3, minmax(0, 1fr));
+    padding: 0 24px;
+    box-sizing: border-box;
+  }
+}
+
+@media (max-width: 980px) {
+  .bento-features {
+    grid-template-columns: repeat(2, minmax(0, 1fr));
+  }
+}
+
+@media (max-width: 640px) {
   .bento-features {
     grid-template-columns: 1fr;
   }

+ 29 - 2
src/components/Chat/AccountInfo.vue

@@ -71,7 +71,11 @@
             <img src="@/assets/20260810-173429.png" alt="" />
           </div>
           <div class="enterprise-bubble-text"
-            >识别到您为我们区内企业<br /><span class="enterprise-bubble-highlight">推荐登录</span
+            >识别到您为我们区内企业<br /><button
+              type="button"
+              class="enterprise-bubble-highlight"
+              @click="handleRecommendLogin"
+            >推荐登录</button
             >后获取更详尽的回答!</div
           >
           <button
@@ -146,6 +150,7 @@
 <script setup lang="ts">
 import { onBeforeUnmount, onMounted, ref, watch } from "vue";
 import { useEnterpriseAuth } from "@/components/useEnterpriseAuth";
+import { ENTERPRISE_BUBBLE_EVENT } from "@/utils/qingpu-enterprise";
 
 const emit = defineEmits<{
   (e: "logout"): void;
@@ -159,7 +164,6 @@ const showEnterpriseBubble = ref(false);
 const bubbleRef = ref<HTMLElement | null>(null);
 const dismissed = ref(false);
 
-const ENTERPRISE_BUBBLE_EVENT = "qingpu:enterprise-notification";
 const ENTERPRISE_BUBBLE_DURATION = 10000;
 
 const updateBubblePosition = () => {
@@ -200,6 +204,11 @@ const dismissEnterpriseBubble = () => {
   window.removeEventListener("scroll", updateBubblePosition, true);
 };
 
+const handleRecommendLogin = () => {
+  dismissEnterpriseBubble();
+  redirectToLogin();
+};
+
 const handleLogout = () => {
   showLogoutConfirm.value = false;
   logout();
@@ -351,6 +360,12 @@ onBeforeUnmount(() => {
   z-index: 9999;
   bottom: 70px;
   left: 10px;
+  /*
+   * ⚠️ 必须有确定的高度:气泡同时有 bottom(CSS)与 top(JS 定位)。
+   * position: fixed + top/bottom 都给、height:auto 时,盒子会被拉伸成两者之间的剩余高度,
+   * 滚动时 JS 改 top → 高度跟着变。fit-content 让高度只由内容决定。
+   */
+  height: fit-content;
   pointer-events: auto;
   /* 透明渐变:背景由半透明白渐变到不透明白,配合 backdrop-filter 形成柔和毛玻璃 */
   background: linear-gradient(
@@ -400,7 +415,19 @@ onBeforeUnmount(() => {
 }
 
 .enterprise-bubble-highlight {
+  display: inline;
+  margin: 0;
+  padding: 0;
+  border: none;
+  background: transparent;
+  font: inherit;
+  font-weight: inherit;
   color: #3525cd;
+  cursor: pointer;
+}
+
+.enterprise-bubble-highlight:hover {
+  text-decoration: underline;
 }
 
 .enterprise-bubble-close {

+ 182 - 5
src/components/Chat/BusinessRecord.vue

@@ -109,6 +109,7 @@
                   :paused="false"
                   :scopeExitCompensating="isScopeExitCompensating"
                   :enableRevealFade="false"
+                  :enableStreamReveal="isStreamRevealEnabled"
                   :initialMinWidth="scopeExitWidth"
                   @typingFinished="handleTypingFinished(row.id)"
                   @typingStateChange="handleTypingStateChange(row.id, $event)"
@@ -138,6 +139,7 @@
                   :policyContent="row.content"
                   :recordMode="true"
                   :sessionId="policyMatchSessionId"
+                  :animateCards="!record.history"
                 />
                 <QuestionCard
                   v-if="row.type === RecordRowTypes.QuestionCards"
@@ -383,6 +385,7 @@ import {
   trimDisplayTextContentEnd,
   trimDisplayTextContentStart,
 } from "./text-content-utils";
+import { createDisplayPacer, resolveDisplayAdvance } from "./display-pacing";
 import {
   isEmptyScopeRow,
   isRemovableEmptyScopeStatusRow,
@@ -446,6 +449,7 @@ const emit = defineEmits([
   "scopeExitStateChange",
   "scopeHeightLockChange",
   "typewriterStateChange",
+  "displayPacingStateChange",
 ]);
 
 const policyMatchSessionId = computed(
@@ -683,6 +687,32 @@ const textRowTypingActive = ref<Record<number, boolean>>({});
 const imageRowRevealFinished = ref<Record<number, boolean>>({});
 const imageRowRevealActive = ref<Record<number, boolean>>({});
 
+// ── 流式排字缓冲(豆包式)──
+// 上屏比后端晚约 1 秒:最后一片文字之后、后端 answer_end/done 之前的收尾空档
+// (实测约 0.8–1.0s)由缓冲存量填上,用户看到的是连续出字而不是「打完停住」。
+// 语义见 display-pacing.ts(时间式抖动缓冲,不是固定字速)。
+const DISPLAY_PACING_BUFFER_MS = 1000;
+// 单帧最多推进的字符数:后端偶尔会一次送达一大块(多行),不限速会让好几行同时播渐显。
+// 正常流式每帧只有 1~2 字,不受影响;突发块会被摊到多帧里逐行出现。
+const MAX_PACED_CHARS_PER_FRAME = 12;
+// 协议标记块(卡片 / 参考资料 / 补问 / 二维码 / 追问)不能按 12 字/帧拆开推进:
+// 标记里可能是几 KB 的 JSON,拆开会把收尾拖成几百帧。检测到标记后本次排字不再限速。
+const PACING_BLOCK_MARKERS = [
+  "<scope",
+  "<ref_links",
+  "<question-cards",
+  "<image-scope",
+  "<silence",
+  "<followup",
+  POLICY_TABLE_START,
+];
+const displayPacer = createDisplayPacer(DISPLAY_PACING_BUFFER_MS);
+const displayPacingActive = ref(false);
+let displayPacingFrame = 0;
+let displayPacingGeneration = 0;
+let pendingStreamedRowsMark = false;
+let pendingFinishEvent = false;
+
 const displayRecordRows = ref<DisplayRecordRow[]>([]);
 const updateRecordRowIndex = ref(0);
 const activeRecordState = computed(() => props.state ?? record.value.state);
@@ -696,6 +726,11 @@ const hasRecordTextContent = computed(
   () => String(record.value.content || props.content || "").trim().length > 0
 );
 const shouldRenderTextInstantly = computed(() => !record.value.isAI || !!record.value.history);
+// 豆包式流式模糊渐显:只在新后端真实流式期间开启(mock 打字机 / 历史不变)。
+// 收尾排字阶段(contentStreaming 已清、缓冲还在排)也要保持,否则最后一段会变回硬切。
+const isStreamRevealEnabled = computed(
+  () => Boolean(record.value.contentStreaming) || displayPacingActive.value
+);
 const canAnimateAiText = computed(
   () =>
     record.value.isAI &&
@@ -878,8 +913,10 @@ const hasUnfinishedRevealRows = computed(() =>
 const shouldDriveTypewriter = computed(
   () =>
     canAnimateAiText.value &&
-    // 正文本身是增量流式到达的,再逐字重放等于多等一遍,故关掉打字机
+    // 正文本身是增量流式到达的,再逐字重放等于多等一遍,故关掉打字机;
+    // 收尾排字阶段同样不能翻真(否则剩余文字会被打字机重放一遍)
     !record.value.contentStreaming &&
+    !displayPacingActive.value &&
     (activeRecordState.value !== MessageState.Finish || hasUnfinishedRevealRows.value)
 );
 const isSessionReadableLogButtonEnabled =
@@ -902,6 +939,8 @@ const shouldRenderFeedback = computed(() => {
   if (props.sessionViewedBefore) return true;
   if (activeRecordState.value !== MessageState.Finish) return false;
   if (shouldWaitForTypewriterCompletion.value) return false;
+  // 收尾排字还没排完时先不显示反馈,避免文字还在出、按钮先跳出来
+  if (displayPacingActive.value) return false;
   if ((mediaList.value?.length || 0) > displayMediaList.value.length) return false;
   return true;
 });
@@ -1137,6 +1176,79 @@ const resetDisplayContent = () => {
   count.value = 0;
 };
 
+// ── 流式排字缓冲 ──────────────────────────────────────────────────────────
+const cancelDisplayPacingFrame = () => {
+  if (displayPacingFrame) {
+    cancelAnimationFrame(displayPacingFrame);
+    displayPacingFrame = 0;
+  }
+};
+
+const flushPendingStreamedRowsMark = () => {
+  if (!pendingStreamedRowsMark) {
+    return;
+  }
+  pendingStreamedRowsMark = false;
+  markStreamedRowsAsTypingFinished();
+};
+
+const tickDisplayPacing = (now: number) => {
+  displayPacingFrame = 0;
+  const generation = displayPacingGeneration;
+
+  const target = displayPacer.targetLength(now);
+  if (target > count.value) {
+    const content = originContent.value;
+    const advance = resolveDisplayAdvance({
+      content,
+      cursor: count.value,
+      target,
+      maxCharsPerFrame: MAX_PACED_CHARS_PER_FRAME,
+      blockMarkers: PACING_BLOCK_MARKERS,
+    });
+
+    if (advance.end > count.value) {
+      processRecordSections(content.slice(count.value, advance.end));
+      count.value = advance.end;
+    }
+  }
+
+  // 期间可能发生整块重写/停止(resetDisplayPacing 会换 generation)
+  if (generation !== displayPacingGeneration) {
+    return;
+  }
+
+  if (originContent.value.length > count.value) {
+    displayPacingActive.value = true;
+    displayPacingFrame = requestAnimationFrame(tickDisplayPacing);
+    return;
+  }
+
+  displayPacingActive.value = false;
+  flushPendingStreamedRowsMark();
+  if (pendingFinishEvent) {
+    pendingFinishEvent = false;
+    handleFinishEvent();
+  }
+};
+
+const ensureDisplayPacingLoop = () => {
+  if (displayPacingFrame) {
+    return;
+  }
+  displayPacingActive.value = true;
+  displayPacingFrame = requestAnimationFrame(tickDisplayPacing);
+};
+
+const resetDisplayPacing = () => {
+  displayPacingGeneration += 1;
+  cancelDisplayPacingFrame();
+  displayPacer.reset();
+  displayPacingActive.value = false;
+  pendingStreamedRowsMark = false;
+  // pendingFinishEvent 不清:整块重写会直接全量上屏,排字结束后仍要补触发结束动作
+};
+
 const clearScopeExitTimer = () => {
   if (scopeExitTimer === null) {
     return;
@@ -1508,14 +1620,17 @@ watch(
     if (!val || showInterruptedState.value) {
       changeFlag++;
       resetDisplayContent();
+      resetDisplayPacing();
       return;
     }
 
     // 内容不是纯追加时必须整体重置再全量解析:增量解析只吃多出来的那一段(val.slice(count)),
     // 整块重写时切出来的是新内容的中段,会被当正文渲染出来。
-    if (!val.startsWith(originContent.value)) {
+    const rewritten = !val.startsWith(originContent.value);
+    if (rewritten) {
       changeFlag++;
       resetDisplayContent();
+      resetDisplayPacing();
       xmlFilter.reset(); // 解析器也有状态(buffer / 未闭合标签),一并清
       if (import.meta.env.MODE !== "production") {
         /* console.warn("[record] 内容被整块重写,已重置并全量重解析", {
@@ -1525,11 +1640,32 @@ watch(
       }
     }
 
+    // 真实流式(含收尾排字):内容先进缓冲,按约 1s 的时间窗匀速上屏。
+    // 整块重写不走排字(直接全量上屏,与改前一致)。
+    if (
+      !rewritten &&
+      !record.value.history &&
+      (record.value.contentStreaming || displayPacingActive.value)
+    ) {
+      originContent.value = val;
+      if (val.length > count.value) {
+        displayPacer.push(val.length, performance.now());
+        ensureDisplayPacingLoop();
+      }
+      return;
+    }
+
     const diffText = val.slice(count.value);
     processRecordSections(diffText);
     originContent.value = val;
     count.value = val.length;
 
+    // 整块重写发生在收尾排字期间:内容已全部上屏,补触发被延后的结束动作
+    if (pendingFinishEvent) {
+      pendingFinishEvent = false;
+      handleFinishEvent();
+    }
+
     timer = setInterval(() => handleTimerTick(val), gapTime);
   }
 );
@@ -1553,11 +1689,24 @@ const markStreamedRowsAsTypingFinished = () => {
   }
 };
 
+// 排字缓冲进行中(含 finishTask 之后仍在排 1s 的收尾):壳层据此保持平滑跟随与下箭头
+watch(displayPacingActive, (active) => {
+  emit("displayPacingStateChange", {
+    recordId: record.value.id,
+    active,
+  });
+});
+
 watch(
   () => record.value.contentStreaming,
   (val, oldVal) => {
     if (oldVal && !val) {
-      markStreamedRowsAsTypingFinished();
+      // 收尾排字还没排完时延后补记,否则剩余文字会被切进打字机路径
+      if (displayPacingActive.value || originContent.value.length > count.value) {
+        pendingStreamedRowsMark = true;
+      } else {
+        markStreamedRowsAsTypingFinished();
+      }
     }
   }
 );
@@ -1584,7 +1733,12 @@ watch(
       );
       stopSpeech({ answer: rawContent, record_id: record.value.id });
     } else if (!timer && val === MessageState.Finish) {
-      handleFinishEvent();
+      // 收尾排字还没排完:等排完再触发结束动作(语音、反馈、参考资料、追问)
+      if (displayPacingActive.value) {
+        pendingFinishEvent = true;
+      } else {
+        handleFinishEvent();
+      }
     }
   }
 );
@@ -1798,7 +1952,12 @@ watch(
   isLastAiStreamingRecord,
   (isStreaming) => {
     if (!isStreaming) {
-      recordHeightLock.value = null;
+      // ⚠️ scope 退场补偿期间正文行会被暂时隐藏(见 shouldRenderTextContentRow)。
+      // 这时释放高度锁会让记录瞬间变矮 → 滚动位置被浏览器钳制(表现为「回答渲完往上弹」)。
+      // 等补偿结束、正文行挂回来之后再释放。
+      if (!isScopeExitCompensating.value) {
+        recordHeightLock.value = null;
+      }
       return;
     }
 
@@ -1807,6 +1966,12 @@ watch(
   { immediate: true }
 );
 
+watch(isScopeExitCompensating, (compensating) => {
+  if (!compensating && !isLastAiStreamingRecord.value) {
+    recordHeightLock.value = null;
+  }
+});
+
 onMounted(() => {
   unregisterRefLinksModal = modalMutex.register(refLinksModalId, {
     close: closeRefLinksPanel,
@@ -1825,6 +1990,8 @@ onMounted(() => {
 onBeforeUnmount(() => {
   closeRefLinksPanel();
   unregisterRefLinksModal?.();
+  resetDisplayPacing();
+  emit("displayPacingStateChange", { recordId: record.value.id, active: false });
   emitTypewriterStateChange(false);
   lastRecordResizeObserver?.disconnect();
   lastRecordResizeObserver = null;
@@ -2538,6 +2705,16 @@ async function handleFeedbackChange(feedback: FeedbackType) {
   }
 }
 
+/*
+ * 双换行会被 splitStreamingTextContentRows 拆成多个 TextContent 行;
+ * 行内段落是 p:last-child、margin 被清零,导致段落之间实际没有额外间距(实测 0px)。
+ * 这里给「以段落结尾的文本行」补 8px,使 \n\n 的间距与「标题 → 正文」的 8px 一致;
+ * 标题行 / 列表行的间距保持它们自己的 margin 不变(相邻 margin 取较大值)。
+ */
+.business-record .content > .markdown-content.block-markdown:has(> p) {
+  margin-bottom: 8px;
+}
+
 .request-interrupted-status {
   display: inline-flex;
   align-items: center;

+ 382 - 80
src/components/Chat/PolicyMatch.vue

@@ -1,10 +1,12 @@
 <template>
-  <div v-if="showSummary" class="policy-match-summary" :class="{ 'record-mode': recordMode }">
+  <div v-if="showSummary" class="policy-match-summary"
+    :class="{ 'record-mode': recordMode, 'animate-cards': animateCards }">
     <div class="policy-header" v-if="panelData.length > 0">匹配完成!推荐您了解以下政策事项</div>
     <div class="policy-content-wrapper">
       <div class="policy-line"></div>
       <div class="policy-box">
-        <div class="policy-item" v-for="(item, index) in panelData" :key="`${item.title}-${index}`">
+        <div class="policy-item" v-for="(item, index) in panelData" :key="`${item.title}-${index}`"
+          :style="{ animationDelay: `${Math.min(index, 5) * 60}ms` }">
           <div class="policy-item-header">
             <div class="policy-badge">
               <svg width="11" height="14" viewBox="0 0 11 14" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -21,15 +23,28 @@
               <span class="value">{{ item.match_degree }}</span>
             </div> -->
           </div>
-          <div class="policy-title">{{ item.title }}</div>
-          <div class="policy-desc" v-if="item.desc">{{ item.desc }}</div>
-          <div class="policy-item-action" @click.stop="openDetailByItem(item)">查看详情</div>
+          <div
+            class="policy-title"
+            @mouseenter="handlePolicyTitleEnter($event, item.title)"
+            @mousemove="handlePolicyTitleMove($event)"
+            @mouseleave="hidePolicyTitleTip"
+          >{{ item.title }}</div>
+          <div class="policy-desc">{{ item.desc }}</div>
+          <div class="policy-item-action" @click.stop="openDetailByItem(item, false)">查看详情</div>
         </div>
       </div>
       <div class="view-all-btn" @click.stop="openCardList">更多 >></div>
     </div>
   </div>
 
+  <Teleport to="body">
+    <div
+      v-if="policyTitleTip.visible"
+      class="policy-title-tip"
+      :style="{ left: `${policyTitleTip.x}px`, top: `${policyTitleTip.y}px` }"
+    >{{ policyTitleTip.text }}</div>
+  </Teleport>
+
   <Teleport to="body">
     <div v-if="panelVisible" class="policy-viewer-modal"
       :class="[{ 'is-wide': isWide }, recordMode ? 'record-theme' : '']">
@@ -131,7 +146,7 @@
 
               <div class="list-items-container">
                 <div class="list-item-wrapper" v-for="(item, index) in paginatedPolicies"
-                  :key="`${item.title}-${index}`" @click.stop="openDetailByItem(item)">
+                  :key="`${item.title}-${index}`" @click.stop="openDetailByItem(item, panelMode === 'list')">
                   <div class="list-item" :class="{ 'record-list-item': recordMode }">
                     <div class="list-item-content">
                       <div class="list-item-tag" v-if="item.tag && !recordMode">
@@ -186,7 +201,7 @@
                         <div class="record-match-text">{{ formatMatchDegree(item.match_degree) }}</div>
                       </div> -->
                       <!-- <div class="record-match-meta">匹配度</div> -->
-                      <button class="record-detail-btn" @click.stop="openDetailByItem(item)">查看详情</button>
+                      <button class="record-detail-btn" @click.stop="openDetailByItem(item, panelMode === 'list')">查看详情</button>
                     </div>
 
                     <div v-if="item.isRecommended && !recordMode" class="list-item-recommend">推荐</div>
@@ -227,14 +242,26 @@
                 </svg>
                 <span>返回政策事项列表</span>
               </div>
-              <div class="record-main-title">{{ selectedPolicyItem?.declaration_item ||
+              <!-- 顶部事项:本地列表 → project-detail;AI → 原 apply_link(事项页)。政策名 → policy-detail?id=政策id -->
+              <a
+                v-if="detailMatterLink"
+                :href="detailMatterLink"
+                target="_blank"
+                class="record-main-title policy-link"
+                rel="noopener noreferrer"
+              >{{ selectedPolicyItem?.declaration_item ||
+                '建立重点产品碳足迹背景数据库,构建碳足迹因子核算和发布工作机制' }}</a>
+              <div
+                v-else
+                class="record-main-title"
+              >{{ selectedPolicyItem?.declaration_item ||
                 '建立重点产品碳足迹背景数据库,构建碳足迹因子核算和发布工作机制' }}</div>
               <div class="record-meta-info">
                 <div class="record-meta-item meta-name">
                   <div class="meta-label">政策名称</div>
                   <div class="meta-value">
-                    <a v-if="selectedPolicyItem?.apply_link" :href="selectedPolicyItem.apply_link" target="_blank" class="policy-link" rel="noopener noreferrer">{{ selectedPolicyItem?.title || '上海市青浦区加强知识产权保护、促进质量提升和标准体系建设的政策措施' }}</a>
-                    <template v-else>{{ selectedPolicyItem?.title || '上海市青浦区加强知识产权保护、促进质量提升和标准体系建设的政策措施' }}</template>
+                    <a v-if="detailPolicyNameLink" :href="detailPolicyNameLink" target="_blank" class="policy-link" rel="noopener noreferrer">{{ detailPolicyDisplayName }}</a>
+                    <template v-else>{{ detailPolicyDisplayName }}</template>
                   </div>
                 </div>
                 <div class="record-meta-divider"></div>
@@ -246,8 +273,8 @@
               <div class="mobile-record-meta-info">
                 <div class="mobile-record-meta-item meta-name">
                   <div class="meta-value">
-                    <a v-if="selectedPolicyItem?.apply_link" :href="selectedPolicyItem.apply_link" target="_blank" class="policy-link" rel="noopener noreferrer">{{ selectedPolicyItem?.title || '上海市青浦区加强知识产权保护、促进质量提升和标准体系建设的政策措施' }}</a>
-                    <template v-else>{{ selectedPolicyItem?.title || '上海市青浦区加强知识产权保护、促进质量提升和标准体系建设的政策措施' }}</template>
+                    <a v-if="detailPolicyNameLink" :href="detailPolicyNameLink" target="_blank" class="policy-link" rel="noopener noreferrer">{{ detailPolicyDisplayName }}</a>
+                    <template v-else>{{ detailPolicyDisplayName }}</template>
                   </div>
                 </div>
               </div>
@@ -369,8 +396,9 @@
                   class="condition-match-card" :class="getConditionLevelClass(condition?.status)">
                   <div class="match-card-header">
                     <div class="match-card-title">
-                      <span>{{ condition?.dimension || '其他条件' }} · {{ condition?.status || '待确认' }}</span>
+                      <span>{{ condition?.dimension || '其他条件' }}</span>
                     </div>
+                    <div class="match-badge">{{ condition?.status || '待确认' }}</div>
                   </div>
                   <div class="match-card-body">
                     <div v-if="condition?.requirement">要求:{{ condition.requirement }}</div>
@@ -392,8 +420,9 @@
                   class="condition-match-card" :class="getBasisLevelClass(basis?.status)">
                   <div class="match-card-header">
                     <div class="match-card-title">
-                      <span>{{ basis?.dimension || '其他' }} · {{ formatBasisStatus(basis?.status) }}</span>
+                      <span>{{ basis?.dimension || '其他' }}</span>
                     </div>
+                    <div class="match-badge">{{ formatBasisStatus(basis?.status) }}</div>
                   </div>
                   <div class="match-card-body">
                     <div v-if="basis?.explanation">{{ basis.explanation }}</div>
@@ -441,12 +470,14 @@
 </template>
 
 <script setup lang="ts">
-import { computed, inject, nextTick, onBeforeUnmount, onMounted, ref, watch } from "vue";
+import { computed, inject, nextTick, onBeforeUnmount, onMounted, reactive, ref, watch } from "vue";
 import { parsePolicyTableContent } from "@/utils/stream-xml-filter";
 import { isZhaoshangLLM as isZhaoshangLLMModel } from "@/utils";
 import {
+  buildLibraryItemPolicyMap,
   buildLibraryNameSet,
   buildPolicyDetailUrl,
+  buildPolicyProjectDetailUrl,
   collectMatchedLibraryNames,
   isPolicyLibraryItem,
   pinMatchedFirst,
@@ -463,6 +494,11 @@ import { MODAL_MUTEX_KEY } from "../business-assistant/modal-mutex";
 
 type RawPolicyItem = Record<string, any>;
 
+type PolicyAttachment = {
+  name: string;
+  url: string;
+};
+
 type PolicyItem = {
   title: string;
   desc: string;
@@ -471,9 +507,10 @@ type PolicyItem = {
   support_measures: string;
   apply_conditions: string;
   apply_materials: string;
-  attachments: string;
+  attachments: PolicyAttachment[];
   match_reason: string;
   tag: string;
+  auto_granted: boolean;
   source: string;
   match_score: number;
   match_degree: string;
@@ -492,6 +529,11 @@ const props = withDefaults(
     policyContent?: string;
     recordMode?: boolean;
     sessionId?: string;
+    /**
+     * 卡片首次出现时是否播入场动画。
+     * 实时回答 / 新消息为 true;历史会话回放为 false(切会话时不要整屏卡片一起动)。
+     */
+    animateCards?: boolean;
   }>(),
   {
     visible: true,
@@ -499,6 +541,7 @@ const props = withDefaults(
     policyContent: "",
     recordMode: false,
     sessionId: "",
+    animateCards: true,
   }
 );
 
@@ -506,6 +549,50 @@ const emit = defineEmits<{
   (e: "update:visible", value: boolean): void;
 }>();
 
+/** PC 端标题溢出时,跟随鼠标右上角展示完整标题 */
+const policyTitleTip = reactive({
+  visible: false,
+  text: "",
+  x: 0,
+  y: 0,
+});
+
+const isDesktopPolicyTipEnabled = () =>
+  typeof window !== "undefined" && window.matchMedia("(min-width: 768px)").matches;
+
+const isPolicyTitleOverflow = (el: HTMLElement) =>
+  el.scrollHeight > el.clientHeight + 1 || el.scrollWidth > el.clientWidth + 1;
+
+const placePolicyTitleTip = (event: MouseEvent) => {
+  policyTitleTip.x = event.clientX + 12;
+  policyTitleTip.y = event.clientY - 8;
+};
+
+const handlePolicyTitleEnter = (event: MouseEvent, title: string) => {
+  if (!isDesktopPolicyTipEnabled()) {
+    hidePolicyTitleTip();
+    return;
+  }
+  const el = event.currentTarget as HTMLElement | null;
+  if (!el || !isPolicyTitleOverflow(el)) {
+    hidePolicyTitleTip();
+    return;
+  }
+  policyTitleTip.text = title;
+  policyTitleTip.visible = true;
+  placePolicyTitleTip(event);
+};
+
+const handlePolicyTitleMove = (event: MouseEvent) => {
+  if (!policyTitleTip.visible) return;
+  placePolicyTitleTip(event);
+};
+
+const hidePolicyTitleTip = () => {
+  policyTitleTip.visible = false;
+  policyTitleTip.text = "";
+};
+
 const policies = ref<PolicyItem[]>([]);
 const policyListItems = ref<PolicyItem[]>([]);
 const policyListTotal = ref(0);
@@ -552,7 +639,8 @@ const collectDeptOptions = (): string[] => {
   const unique = [
     ...new Set(
       getLibraryPolicies()
-        .map((item) => String(item?.["政策所属部门"] ?? "").trim())
+        // 新标准库字段「所属部门」;旧 v2 用「政策所属部门」
+        .map((item) => String(item?.["所属部门"] ?? item?.["政策所属部门"] ?? "").trim())
         .filter((value) => value && looksLikeSingleDept(value))
     ),
   ].sort((a, b) => a.localeCompare(b, "zh-CN"));
@@ -782,90 +870,147 @@ const stripPolicyIdText = (value: unknown) => {
     .trim();
 };
 
-const normalizePolicy = (item: RawPolicyItem): PolicyItem => {
-  const minimal = isMinimalFormat(item);
-  const suggestedConditions = item.data?.["梳理后建议申报条件"] || item?.['申报条件'] || item.data?.["申报条件"] || [];
-  const policyDetails = parsePolicyDetails(item);
+const textOf = (value: unknown): string => {
+  const stripped = stripPolicyIdText(value);
+  return stripped === undefined || stripped === null ? ""
+    : typeof stripped === "string" ? stripped : String(stripped);
+};
 
-  // 处理申报条件:兼容 JSON 字符串、数组、普通字符串三种格式
-  let processedConditions = suggestedConditions || [];
-  if (typeof suggestedConditions === 'string') {
-    try {
-      const parsed = JSON.parse(suggestedConditions.replace(/'/g, '"'));
-      if (Array.isArray(parsed)) {
-        processedConditions = parsed;
-      } else {
-        processedConditions = suggestedConditions;
+/** 兼容四种条件格式:字符串数组、JSON 字符串、{条件,权重} 数组、普通字符串 */
+const collectPolicyConditions = (item: RawPolicyItem): string => {
+  const raw =
+    item.data?.['梳理后建议申报条件'] ??
+    item?.['梳理后建议申报条件'] ??
+    item?.['申报条件'] ??
+    item.data?.['申报条件'] ??
+    '';
+
+  let value: any = raw;
+  if (typeof value === 'string') {
+    const text = value.trim();
+    if (text.startsWith('[') && text.endsWith(']')) {
+      try {
+        value = JSON.parse(text.replace(/'/g, '"'));
+      } catch {
+        value = text;
       }
-    } catch (e) {
-      processedConditions = suggestedConditions;
     }
   }
 
-  processedConditions = Array.isArray(processedConditions) ? processedConditions.join(";\n") : processedConditions;
+  if (Array.isArray(value)) {
+    return value
+      .map((entry) => (entry && typeof entry === 'object' ? entry.条件 ?? '' : entry))
+      .filter((entry) => entry !== undefined && entry !== null && String(entry).trim() !== '')
+      .join(';\n');
+  }
+  if (value && typeof value === 'object') {
+    return String((value as any).条件 ?? '');
+  }
+  return String(value ?? '');
+};
+
+const normalizeAttachments = (value: unknown): PolicyAttachment[] => {
+  if (!Array.isArray(value)) {
+    return [];
+  }
+  return value
+    .map((entry) => {
+      if (!entry || typeof entry !== 'object') {
+        return null;
+      }
+      const name = String((entry as any).name ?? '').trim();
+      const url = String((entry as any).url ?? '').trim();
+      return url || name ? { name, url } : null;
+    })
+    .filter((entry): entry is PolicyAttachment => entry !== null);
+};
+
+const normalizePolicy = (item: RawPolicyItem): PolicyItem => {
+  const minimal = isMinimalFormat(item);
+  const policyDetails = parsePolicyDetails(item);
+  const rawAttachments =
+    item['附件'] ?? item.data?.['相关附件'] ?? item?.['相关附件'] ?? item.attachments;
+  const attachments = normalizeAttachments(rawAttachments);
+  const firstAttachmentUrl = attachments.find((entry) => entry.url)?.url || '';
+  const startDate = String(
+    item['申报开始时间'] ?? item['开始时间'] ?? item.declaration_start_time ?? ''
+  ).trim();
+  const endDate = String(
+    item['申报结束时间'] ?? item['结束时间'] ?? item.declaration_end_time ?? ''
+  ).trim();
+  const autoGranted =
+    item.auto_granted === true ||
+    item['是否免申即享'] === true ||
+    item['是否免申即享'] === '是' ||
+    item['是否免申'] === '是' ||
+    String(
+      item.metadata?.['建议是否“免申即享”'] ?? item.metadata?.['建议是否“免申即享” '] ?? ''
+    ).trim() === '是';
 
   return {
-    title: stripPolicyIdText(
+    title: textOf(
       item.name ||
       item.title || item?.['政策名称'] ||
       (minimal
         ? `${formatMatchDegree(item.match_degree)} · ${(item.id || "").slice(0, 8)}`
         : "暂无政策名称")
     ),
-    desc: stripPolicyIdText(item.desc || (minimal ? item.match_reason || "" : "")),
-    declaration_item: stripPolicyIdText(
+    desc: textOf(item.desc || (minimal ? item.match_reason || "" : "")),
+    declaration_item: textOf(
       item.declaration_item ||
       item.originalData?.declaration_item || item?.['申报事项'] ||
-      // v2 数据的字段名(一个政策下多个申报事项,这两列实测 170 条全一致)
-      item?.['部门上报事项'] || item?.['大模型拆解申报事项'] ||
+      // 新标准库字段「事项名称」;旧 v2 用这两列(一个政策下多个申报事项)
+      item?.['事项名称'] || item?.['部门上报事项'] || item?.['大模型拆解申报事项'] ||
       (minimal ? "查看政策详情" : "暂无申报项")
     ),
-    support_objects: stripPolicyIdText(
+    support_objects: textOf(
       item.data?.["支持对象"] || item?.['支持对象'] || item.support_objects || (minimal ? "" : "暂无数据")
     ),
-    support_measures: stripPolicyIdText(
+    support_measures: textOf(
       item.data?.["支持方式和标准"] || item?.['支持方式和标准'] || item.support_measures || (minimal ? "" : "暂无数据")
     ),
-    apply_conditions: stripPolicyIdText(processedConditions) ||
-      item.apply_conditions ||
+    apply_conditions: textOf(collectPolicyConditions(item)) ||
+      textOf(item.apply_conditions) ||
       (minimal ? "" : "暂无数据"),
-    match_reason: stripPolicyIdText(item.match_reason || "暂无匹配理由"),
-    tag:
-      (item.auto_granted || !!item?.['是否免申即享'])
-        ? "免申即享"
-        : item.tag || (minimal ? item.match_degree || "" : ""),
-    source: stripPolicyIdText(
+    match_reason: textOf(item.match_reason || "暂无匹配理由"),
+    tag: autoGranted
+      ? "免申即享"
+      : item.tag || (minimal ? item.match_degree || "" : ""),
+    auto_granted: autoGranted,
+    source: textOf(
       item.department || item?.['部门'] || item.source ||
-      // v2 数据的部门字段名(取值形如「区经委」,与筛选列表口径一致)
-      item?.['政策所属部门'] || ""
+      // 新标准库字段「所属部门」;旧 v2 用「政策所属部门」
+      item?.['政策所属部门'] || item?.['所属部门'] || ""
     ),
     match_score: Number(item.match_score || 0),
     match_degree: item.match_degree || "",
-    enterprise_benefit: stripPolicyIdText(
+    enterprise_benefit: textOf(
       item.enterprise_benefit ||
       item?.['企业收益'] ||
       item.metadata?.['企业收益'] ||
       policyDetails?.['企业收益'] ||
       ""
     ),
-    apply_materials: stripPolicyIdText(
-      item.data?.["申报材料"] || item?.['申报材料'] || item.apply_materials || (minimal ? "" : "暂无数据")
+    apply_materials: textOf(
+      item.data?.["申报材料"] || item?.['申报材料'] || item.metadata?.['申报材料'] ||
+      item.apply_materials || (minimal ? "" : "暂无数据")
     ),
-    attachments: stripPolicyIdText(item.data?.["相关附件"] || item?.['相关附件'] || item.attachments || ""),
+    attachments,
     isRecommended: ["高", "中"].includes(item.match_degree),
-    date:
-      item.date || item?.declaration_end_time || item?.['结束时间'] ||
-        (item.declaration_start_time && item.declaration_end_time)
-        ? `${item.declaration_start_time || item?.['开始时间'] || ""} 至 ${item.declaration_end_time || item?.['结束时间'] || ""}`
-        : "",
-    // v2 数据的日期字段是「开始时间 / 结束时间」(结束时间可能是"未标明"这类文本)
-    end_date: item.declaration_end_time || item.date || item?.['申报结束时间'] || item?.['结束时间'] || "",
+    date: item.date || (
+      startDate && endDate
+        ? `${startDate} 至 ${endDate}`
+        : startDate || endDate
+    ),
+    end_date: endDate || item.date || "",
+    // AI 卡片优先用接口/来源给的链接;库条目 apply_link 为空时再用政策id 拼详情页
     apply_link:
       item.apply_link ||
+      item?.['申报链接'] ||
       item?.['政策原文地址'] ||
       item.data?.['政策原文地址'] ||
-      // 库里 apply_link 全空,用「市级政策id」拼政策详情页地址
       buildPolicyDetailUrl(item) ||
+      firstAttachmentUrl ||
       "",
     originalData: item,
   };
@@ -910,15 +1055,17 @@ const getLibraryPolicies = (): RawPolicyItem[] =>
   Array.isArray(globalThis.policiesPublic) ? globalThis.policiesPublic : [];
 
 const getLibraryNameSet = (): Set<string> => buildLibraryNameSet(getLibraryPolicies());
+const getLibraryItemPolicyMap = (): Map<string, string> =>
+  buildLibraryItemPolicyMap(getLibraryPolicies());
 
-/** 本轮卡片里匹配到的惠企政策名(用于在政策库列表里置顶) */
+/** 本轮卡片里匹配到的惠企政策名(用于在政策库列表里置顶;政策名/事项名两条路都认) */
 const matchedLibraryNames = computed(() =>
-  collectMatchedLibraryNames(policies.value, getLibraryNameSet())
+  collectMatchedLibraryNames(policies.value, getLibraryNameSet(), getLibraryItemPolicyMap())
 );
 
 /** 当前详情页正在看的政策是否惠企政策——决定是否显示"返回政策列表" */
 const selectedIsPolicyLibrary = computed(() =>
-  isPolicyLibraryItem(selectedPolicyItem.value, getLibraryNameSet())
+  isPolicyLibraryItem(selectedPolicyItem.value, getLibraryNameSet(), getLibraryItemPolicyMap())
 );
 
 /** 构建惠企政策库列表:本轮匹配到的置顶,其余保持库内原顺序 */
@@ -932,7 +1079,7 @@ const buildLibraryPolicyList = () => {
     if (dept && String(item.source || "") !== dept) {
       return false;
     }
-    const autoGranted = !!item.originalData?.auto_granted;
+    const autoGranted = item.auto_granted === true;
     if (currentFilterOption.value === "只看免申即享" && !autoGranted) return false;
     if (currentFilterOption.value === "非免申即享" && autoGranted) return false;
     if (keyword) {
@@ -959,7 +1106,7 @@ const buildRecordPolicyList = () => {
     if (dept && String(item.source || "") !== dept) {
       return false;
     }
-    const autoGranted = !!item.originalData?.auto_granted;
+    const autoGranted = item.auto_granted === true;
     if (currentFilterOption.value === "只看免申即享" && !autoGranted) return false;
     if (currentFilterOption.value === "非免申即享" && autoGranted) return false;
     if (keyword) {
@@ -1044,6 +1191,58 @@ const selectedPolicyItem = computed(() => {
   return selectedPolicyOverride.value || policies.value[selectedPolicy.value] || null;
 });
 
+/**
+ * 是否从本地「政策事项列表」点进详情(由 openDetailByItem 的显式参数置位,
+ * 不能靠 panelMode 默认值推断——panelMode 初始就是 "list",会把首次点 AI 卡片误判成库列表)。
+ * 本地列表:事项 → project-detail?id=事项id&freeEnjoy=(数据用库条目)
+ * AI / 会话卡片:事项 → 原 apply_link(数据以 AI 返回为准)
+ * 两者「政策名称」都拼 policy-detail?id=政策id
+ */
+const detailFromLibraryList = ref(false);
+
+/** 详情顶部事项跳转 */
+const detailMatterLink = computed(() => {
+  if (!selectedPolicyItem.value) return "";
+  if (detailFromLibraryList.value) {
+    return buildPolicyProjectDetailUrl(selectedPolicyItem.value);
+  }
+  return selectedPolicyItem.value.apply_link || "";
+});
+
+/** 详情「政策名称」跳转:拼政策id → policy-detail */
+const detailPolicyNameLink = computed(() => {
+  if (!selectedPolicyItem.value) return "";
+  return buildPolicyDetailUrl(selectedPolicyItem.value) || "";
+});
+
+/**
+ * 详情展示的真实政策名称(卡片 title 不动)。
+ * 优先「政策名称」(含接口 policy_relation.parent_title),否则按政策id 反查本地库,再退回 title。
+ */
+const detailPolicyDisplayName = computed(() => {
+  const item = selectedPolicyItem.value;
+  if (!item) {
+    return "上海市青浦区加强知识产权保护、促进质量提升和标准体系建设的政策措施";
+  }
+  const raw = item.originalData || {};
+  const named = String(raw["政策名称"] ?? "").trim();
+  if (named) return named;
+
+  const policyId = String(raw["政策id"] ?? raw.policy_id ?? "").trim();
+  if (policyId) {
+    const hit = getLibraryPolicies().find(
+      (entry: any) => String(entry?.["政策id"] ?? "").trim() === policyId
+    );
+    const fromLib = String(hit?.["政策名称"] ?? "").trim();
+    if (fromLib) return fromLib;
+  }
+
+  return (
+    item.title ||
+    "上海市青浦区加强知识产权保护、促进质量提升和标准体系建设的政策措施"
+  );
+});
+
 /**
  * /api/chat 协议独有、随 POLICY_TABLE 一起传入的附加数据(由 normalizePolicy 留在 originalData 里),
  * 仅记录模式(对话内)展示。
@@ -1129,6 +1328,7 @@ const emitPanelWidth = () => {
 };
 
 const openDetail = async (index: number) => {
+  detailFromLibraryList.value = false;
   selectedPolicyOverride.value = null;
   selectedPolicy.value = index;
   panelMode.value = "detail";
@@ -1139,7 +1339,31 @@ const openDetail = async (index: number) => {
   emitPanelWidth();
 };
 
-const openDetailByItem = async (item: { originalData?: RawPolicyItem; support_objects?: string }) => {
+/**
+ * @param fromLibraryList 仅本地「政策事项列表」点进时传 true;
+ *   对话卡片 / 会话「更多」列表传 false(默认),数据与事项链接以 AI 返回为准。
+ */
+const openDetailByItem = async (
+  item: { originalData?: RawPolicyItem; support_objects?: string },
+  fromLibraryList = false
+) => {
+  // 从本地「政策事项列表」点进详情:必须用列表这条(含 事项id/政策id),
+  // 不能再反查 AI 卡片——否则会丢库字段、跳转拼不出来。
+  if (fromLibraryList) {
+    detailFromLibraryList.value = true;
+    selectedPolicyOverride.value = "support_objects" in item ? (item as PolicyItem) : null;
+    selectedPolicy.value = 0;
+    panelMode.value = "detail";
+    const openTicket = modalMutex?.requestOpen(policyModalId);
+    await nextTick();
+    if (modalMutex && openTicket !== undefined && !modalMutex.isCurrentRequest(policyModalId, openTicket)) return;
+    panelVisible.value = true;
+    emitPanelWidth();
+    return;
+  }
+
+  // AI / 会话卡片:数据以 AI 返回为准,事项跳转用 apply_link
+  detailFromLibraryList.value = false;
   // 反查下标(唯一命中才采信),详见 policy-match-utils.ts 的 resolvePolicyDetailIndex
   const index = resolvePolicyDetailIndex(policies.value, item);
 
@@ -1251,6 +1475,7 @@ onMounted(() => {
 });
 
 onBeforeUnmount(() => {
+  hidePolicyTitleTip();
   unregisterPolicyModal?.();
   document.dispatchEvent(
     new CustomEvent("policyPanelWidthChange", {
@@ -1312,6 +1537,51 @@ onBeforeUnmount(() => {
   flex-direction: column;
 }
 
+/*
+ * 推荐卡片入场:不再整块「弹」出来。
+ * 标题 / 卡片 / 更多按钮依次淡入上浮;卡片之间按 60ms 错开(由模板的 animationDelay 控制,
+ * 最多错开 5 张)。历史会话不播(animateCards=false)。
+ * fill-mode 用 backwards:延迟期间保持隐藏,播完回到基础样式,不残留 transform。
+ */
+@keyframes policy-card-enter {
+  from {
+    opacity: 0;
+    transform: translateY(8px);
+  }
+
+  to {
+    opacity: 1;
+    transform: translateY(0);
+  }
+}
+
+.policy-match-summary.animate-cards {
+
+  .policy-header,
+  .view-all-btn {
+    animation: policy-card-enter 240ms cubic-bezier(0.22, 1, 0.36, 1) backwards;
+  }
+
+  .policy-item {
+    animation: policy-card-enter 280ms cubic-bezier(0.22, 1, 0.36, 1) backwards;
+  }
+
+  .view-all-btn {
+    animation-delay: 120ms;
+  }
+}
+
+@media (prefers-reduced-motion: reduce) {
+  .policy-match-summary.animate-cards {
+
+    .policy-header,
+    .policy-item,
+    .view-all-btn {
+      animation: none;
+    }
+  }
+}
+
 .policy-item-header {
   display: flex;
   justify-content: space-between;
@@ -1390,6 +1660,24 @@ onBeforeUnmount(() => {
   text-overflow: ellipsis;
 }
 
+.policy-title-tip {
+  position: fixed;
+  z-index: 4000;
+  max-width: 280px;
+  padding: 8px 10px;
+  border-radius: 8px;
+  background: #141b2b;
+  color: #ffffff;
+  font-size: 12px;
+  font-weight: 500;
+  line-height: 1.5;
+  box-shadow: 0 8px 20px rgba(20, 27, 43, 0.18);
+  pointer-events: none;
+  transform: translateY(-100%);
+  white-space: normal;
+  word-break: break-word;
+}
+
 .policy-item-action {
   display: flex;
   justify-content: center;
@@ -1520,14 +1808,19 @@ onBeforeUnmount(() => {
   display: flex;
   align-items: center;
   gap: 12px;
+  flex: 1;
+  min-width: 0;
   font-size: 14px;
   font-weight: 500;
   color: #464555;
 }
 
 .match-badge {
-  padding: 4px 8px;
+  flex-shrink: 0;
+  padding: 2px 8px;
   border-radius: 4px;
+  border: 1px solid currentColor;
+  background: transparent;
   font-size: 12px;
   font-weight: 500;
   line-height: 1.4;
@@ -1537,7 +1830,7 @@ onBeforeUnmount(() => {
 .match-card-body {
   font-size: 14px;
   line-height: 1.6;
-  color: #141b2b;
+  color: rgba(70, 69, 85, 0.55);
 }
 
 /* \u9ad8\u5339\u914d\u6837\u5f0f */
@@ -1549,8 +1842,7 @@ onBeforeUnmount(() => {
 }
 
 .match-high .match-badge {
-  background: #dcfce7;
-  color: #15803d;
+  color: #22c55e;
 }
 
 .match-high .match-card-title svg {
@@ -1566,8 +1858,7 @@ onBeforeUnmount(() => {
 }
 
 .match-medium .match-badge {
-  background: #fef9c3;
-  color: #a16207;
+  color: #eab308;
 }
 
 .match-medium .match-card-title svg {
@@ -1576,19 +1867,18 @@ onBeforeUnmount(() => {
 
 /* \u4f4e\u5339\u914d\u6837\u5f0f */
 .match-low {
-  border-left-color: #ef4444;
+  border-left-color: #C64A07;
   border-top: 1px solid rgba(199, 196, 216, 0.5);
   border-right: 1px solid rgba(199, 196, 216, 0.5);
   border-bottom: 1px solid rgba(199, 196, 216, 0.5);
 }
 
 .match-low .match-badge {
-  background: #fee2e2;
-  color: #b91c1c;
+  color: #C64A07;
 }
 
 .match-low .match-card-title svg {
-  color: #dc2626;
+  color: #C64A07;
 }
 
 /* \u9ed8\u8ba4\u5339\u914d\u6837\u5f0f */
@@ -1600,8 +1890,7 @@ onBeforeUnmount(() => {
 }
 
 .match-default .match-badge {
-  background: #f1f5f9;
-  color: #475569;
+  color: #94a3b8;
 }
 
 .match-default .match-card-title svg {
@@ -2273,6 +2562,19 @@ onBeforeUnmount(() => {
   letter-spacing: -0.64px;
 }
 
+/* 顶部事项可跳转:保留标题字号,用链接色+下划线提示可点 */
+a.record-main-title.policy-link {
+  display: inline-block;
+  color: #3525cd;
+  text-decoration: underline;
+  text-underline-offset: 4px;
+  cursor: pointer;
+}
+
+a.record-main-title.policy-link:hover {
+  color: #2b1ea8;
+}
+
 .mobile-record-meta-info {
   display: none;
 }

+ 14 - 3
src/components/Chat/ScopeContent.vue

@@ -106,6 +106,9 @@ const closeReg = new RegExp(tagCloseName, "i");
 const CARD_R = 12;
 const LOOP_MS = 3500;
 const MAX_WIDTH_EPSILON = 1;
+// 「思考中」文字的最大行宽(换行长度):约 45 个汉字/行,避免长段思考文字把卡片撑到
+// 整个消息区宽度(最多 1200px)。⚠️ 必须与下方样式的 max-width 保持一致。
+const MAX_CARD_WIDTH_PX = 720;
 
 const scopeTitle = computed(() => {
   const content = props.content || "";
@@ -185,7 +188,9 @@ function updateMaxWidthReached() {
     return;
   }
 
-  isMaxWidthReached.value = cardWidth >= parentWidth - MAX_WIDTH_EPSILON;
+  // 卡片可用宽度 = min(父容器宽度, 阅读宽度上限):到了上限就切换成换行模式。
+  const availableWidth = Math.min(parentWidth, MAX_CARD_WIDTH_PX);
+  isMaxWidthReached.value = cardWidth >= availableWidth - MAX_WIDTH_EPSILON;
 }
 
 watch(
@@ -477,7 +482,11 @@ onMounted(() => {
   orbs[0].el = orbPurpleRef.value;
   orbs[1].el = orbCyanRef.value;
   orbs[2].el = orbPurple2Ref.value;
-  resizeObserver = new ResizeObserver(() => updatePaths());
+  resizeObserver = new ResizeObserver(() => {
+    updatePaths();
+    // 窗口/面板宽度变化时父容器会跟着变,换行判定要重算(否则窗口变窄后文字会被省略号截断)
+    updateMaxWidthReached();
+  });
   if (cardRef.value) {
     resizeObserver.observe(cardRef.value);
   }
@@ -512,7 +521,9 @@ onBeforeUnmount(() => {
 .scope-content-wrap {
   position: relative;
   width: fit-content;
-  max-width: 100%;
+  // 合理的换行长度:长段思考文字最多 720px 一行(约 45 个汉字),不再撑满消息区。
+  // ⚠️ 720px 必须与脚本里的 MAX_CARD_WIDTH_PX 保持一致(那里用它判断何时切换成换行)。
+  max-width: min(100%, 720px);
   will-change: opacity, max-height, transform;
   border-radius: 12px;
   overflow: hidden;

+ 64 - 29
src/components/Chat/TextContent.vue

@@ -9,8 +9,8 @@
 
 <script setup>
 import { computed, onBeforeUnmount, ref, watch, nextTick } from 'vue'
-import { marked } from "marked";
-import { normalizeBareLinks, shouldRestartTypewriter, trimDisplayTextContent } from "./text-content-utils";
+import { renderMarkdownToHtml, shouldRestartTypewriter, trimDisplayTextContent } from "./text-content-utils";
+import { mergeStreamTextReveal } from "./stream-text-reveal";
 
 const props = defineProps({
   content: {
@@ -41,6 +41,12 @@ const props = defineProps({
     type: Boolean,
     default: true,
   },
+  // 流式实时模糊渐显:开启后,内容前缀增长时走 DOM 增量合并,只给新增文字播动画。
+  // 由 BusinessRecord 仅在 record.contentStreaming 为真时传入。
+  enableStreamReveal: {
+    type: Boolean,
+    default: false,
+  },
   initialMinWidth: {
     type: Number,
     default: 0,
@@ -55,22 +61,6 @@ const typewriterMinHeightStyle = computed(() =>
   props.blockMarkdown ? undefined : (minHeight.value ? `${minHeight.value}px` : undefined)
 )
 
-const renderer = new marked.Renderer();
-
-renderer.heading = function ({ tokens, depth }) {
-  const headingText = this.parser.parseInline(tokens)
-  return `<h${depth}>${headingText}</h${depth}>`
-};
-
-renderer.link = function ({ href, title, text }) {
-  // rel="noopener noreferrer" 防钓鱼;target="_blank" 在新标签页打开
-  return `<a href="${href}" target="_blank" rel="noopener noreferrer">${text}</a>`;
-};
-
-marked.setOptions({
-  renderer,
-});
-
 const typewriterRef = ref(null)
 const typedText = ref("")
 const minHeight = ref(0)
@@ -123,12 +113,7 @@ function setTypingActive(next) {
 }
 
 function parseContent(text) {
-  const trimmedText = trimDisplayTextContent(text)
-  let content = props.blockMarkdown
-    ? marked.parse(normalizeBareLinks(trimmedText))
-    : marked.parseInline(normalizeBareLinks(trimmedText))
-  content = content.replace(/\[citation:\s*(\d+)\]/g, "[$1]")
-  return content
+  return renderMarkdownToHtml(text, props.blockMarkdown)
 }
 
 function appendBatchReveal(batchText) {
@@ -228,10 +213,7 @@ function getBatchRevealHost() {
 function commitParsedText() {
   if (!typewriterRef.value) return
 
-  const content = props.blockMarkdown
-    ? marked.parse(normalizeBareLinks(typedText.value))
-    : marked.parseInline(normalizeBareLinks(typedText.value))
-  typewriterRef.value.innerHTML = content.replace(/\[citation:\s*(\d+)\]/g, "[$1]")
+  typewriterRef.value.innerHTML = renderMarkdownToHtml(typedText.value, props.blockMarkdown)
   scheduleTypewriterHeightMeasure()
 
   activeBatchRevealNode = null
@@ -400,11 +382,24 @@ function renderInstantly(text) {
     activeTypewriter: props.activeTypewriter,
     paused: props.paused,
   })
+  // ⚠️ 必须在 clearTypewriter / clearTypingQueue 之前取:它们会把 typedText 清空。
+  const prevText = typedText.value;
   clearTypewriter(false);
   clearTypingQueue();
   clearBatchRevealState()
   typedText.value = trimDisplayTextContent(text);
-  typewriterRef.value.innerHTML = parseContent(text);
+  const nextHtml = parseContent(text);
+  // 流式前缀增长:增量合并,只给新增文字播模糊渐显;其余情况整块重渲(改前行为)。
+  const merged =
+    props.enableStreamReveal &&
+    !props.instant &&
+    prevText.length > 0 &&
+    typedText.value.length > prevText.length &&
+    typedText.value.startsWith(prevText) &&
+    mergeStreamTextReveal(typewriterRef.value, nextHtml, prevText, typedText.value);
+  if (!merged) {
+    typewriterRef.value.innerHTML = nextHtml;
+  }
   setTypingActive(false)
   emit("typingFinished");
 }
@@ -620,6 +615,34 @@ onBeforeUnmount(() => {
   box-sizing: border-box;
 }
 
+/*
+ * 流式新增文字的轻渐显(豆包式,只作用于**最新一行**)。
+ * 节点由 stream-text-reveal.ts 在 JS 里创建,没有 scoped 的 data-v 属性 → 必须 :deep()。
+ * 不用 fill-mode:动画结束后回到基础样式,不会给长回答留下成百上千个 filter 栈上下文。
+ * 不用 inline-block:会破坏词内换行。
+ * 起始透明度不低于 0.35、模糊不超过 1.5px:动画期间文字仍然可读,不会像占位符。
+ */
+.markdown-content :deep(.doubao-reveal) {
+  animation: doubao-reveal 160ms cubic-bezier(0.22, 1, 0.36, 1);
+}
+
+@keyframes doubao-reveal {
+  from {
+    opacity: 0.35;
+    filter: blur(1.5px);
+  }
+  to {
+    opacity: 1;
+    filter: blur(0);
+  }
+}
+
+@media (prefers-reduced-motion: reduce) {
+  .markdown-content :deep(.doubao-reveal) {
+    animation: none;
+  }
+}
+
 .markdown-content :deep(a),
 .markdown-content a {
   display: inline-block;
@@ -630,6 +653,18 @@ onBeforeUnmount(() => {
   white-space: normal;
 }
 
+/* 正文里的图片 URL(normalizeBareLinks → ![](url)) */
+.markdown-content :deep(img),
+.markdown-content img {
+  display: block;
+  max-width: min(100%, 360px);
+  width: auto;
+  height: auto;
+  margin: 8px 0;
+  border-radius: 8px;
+  object-fit: contain;
+}
+
 .typewriter.scope-exit-compensating {
   display: block;
   width: 100%;

+ 123 - 0
src/components/Chat/display-pacing.ts

@@ -0,0 +1,123 @@
+/**
+ * 流式回答的「排字缓冲」:把上屏延迟固定在一个时间窗口后面(默认约 1 秒),
+ * 让最后一片文字之后、后端 answer_end/done 之前的收尾空档由缓冲存量填上,
+ * 用户看到的是连续出字,而不是「打完最后一段 → 停住约 1 秒」。
+ *
+ * 语义(时间式抖动缓冲,不是固定字速):
+ *   - 每次收到新内容时 push(已收到总长度, 到达时刻);
+ *   - targetLength(now) 返回「到达时间 ≤ now - bufferMs」的最新总长度;
+ *   - 显示端只把内容推进到 targetLength,于是显示永远比后端晚 bufferMs,
+ *     但出字节奏等于后端到达节奏(后端匀速时显示也匀速;突发时同样突发)。
+ *   - 后端停止后,缓冲里的存量还会继续显示 bufferMs 那么久。
+ *
+ * 纯逻辑、无 DOM,harness/tools/verify-display-pacing.mjs 直接测。
+ */
+
+export interface DisplayPacer {
+  /** 记录一次内容增长(length = 当前已收到的全文长度,at = 到达时刻 ms) */
+  push(length: number, at: number): void;
+  /** now 时刻最多可以显示到的全文长度 */
+  targetLength(now: number): number;
+  reset(): void;
+}
+
+interface ArrivalSample {
+  length: number;
+  at: number;
+}
+
+/**
+ * 计算一帧最多把上屏游标推进到哪里。
+ *
+ * - 正常流式每帧只有 1~2 字,直接推进到 target;
+ * - 后端突发一大块时,按 maxCharsPerFrame 拆帧,避免文字一下子铺满;
+ * - 协议标记块(卡片 / 参考资料等,里面可能是几 KB JSON)不能拆帧:
+ *   本帧一旦在窗口内发现标记,就把这一帧推进到 target(把标记块整段喂给解析器)。
+ *   ⚠️ 只对**当前帧**生效,不能变成整轮不限速——否则卡片标记之后的全部正文都会失去限速。
+ */
+export interface DisplayAdvanceInput {
+  content: string;
+  cursor: number;
+  target: number;
+  maxCharsPerFrame: number;
+  blockMarkers: readonly string[];
+}
+
+export interface DisplayAdvanceResult {
+  end: number;
+}
+
+export function resolveDisplayAdvance(input: DisplayAdvanceInput): DisplayAdvanceResult {
+  const contentLength = String(input.content || "").length;
+  const cursor = Math.max(0, Math.min(Number(input.cursor) || 0, contentLength));
+  const target = Math.max(0, Math.min(Number(input.target) || 0, contentLength));
+  const maxChars = Math.max(1, Number(input.maxCharsPerFrame) || 1);
+
+  if (target <= cursor) {
+    return { end: cursor };
+  }
+  if (target <= cursor + maxChars) {
+    return { end: target };
+  }
+
+  // 多看点字符,避免标记刚好跨过本帧窗口边界
+  const lookaheadEnd = Math.min(contentLength, cursor + maxChars + 64);
+  const window = input.content.slice(cursor, lookaheadEnd);
+  if (input.blockMarkers.some((marker) => marker && window.includes(marker))) {
+    return { end: target };
+  }
+
+  return { end: cursor + maxChars };
+}
+
+export function createDisplayPacer(bufferMs: number): DisplayPacer {
+  const buffer = Math.max(0, Number(bufferMs) || 0);
+  let samples: ArrivalSample[] = [];
+  let head = 0;
+  // 已滑出窗口的最大长度(采样被丢弃后仍要记住,否则 target 会回退)
+  let consumedLength = 0;
+
+  return {
+    push(length: number, at: number) {
+      if (!Number.isFinite(length) || !Number.isFinite(at) || length <= 0) {
+        return;
+      }
+
+      const last = samples[samples.length - 1];
+      if (last && length <= last.length) {
+        return; // 只接受增长;整块重写由调用方 reset()
+      }
+
+      samples.push({
+        length,
+        at: last ? Math.max(at, last.at) : at, // 到达时刻按单调处理
+      });
+
+      // 丢掉已经消费掉的采样,避免长回答里无限增长
+      if (head > 64 && head * 2 > samples.length) {
+        samples = samples.slice(head);
+        head = 0;
+      }
+    },
+
+    targetLength(now: number) {
+      if (!Number.isFinite(now)) {
+        return consumedLength;
+      }
+
+      const cutoff = now - buffer;
+      while (head < samples.length && samples[head].at <= cutoff) {
+        consumedLength = samples[head].length;
+        head += 1;
+      }
+
+      return consumedLength;
+    },
+
+    reset() {
+      samples = [];
+      head = 0;
+      consumedLength = 0;
+    },
+  };
+}

+ 128 - 20
src/components/Chat/policy-library-utils.ts

@@ -4,27 +4,70 @@
  * 抽成独立模块,是为了让 `harness/tools/` 的验证脚本能直接引用同一份实现。
  */
 
-/** 政策详情页地址前缀(一网通办·青浦惠企政策专区) */
+/** 政策文件详情页(拼「政策id」) */
 export const POLICY_DETAIL_URL_BASE =
   "https://zwdt.sh.gov.cn/qykj/shell_oc_policy_zq/policy/policy-detail";
 
+/** 申报事项详情页(拼「事项id」+ freeEnjoy) */
+export const POLICY_PROJECT_DETAIL_URL_BASE =
+  "https://zwdt.sh.gov.cn/qykj/shell_oc_policy_zq/policy/project-detail";
+
 /**
- * 由库条目的「市级政策id」拼出政策详情页地址(库里的 `apply_link` 全为空,
- * 「资源申请备注」里的 URL 零散且混有内网地址,只有这个 id 可靠)。
+ * 由库条目的「政策id」拼出政策文件详情页:
+ * `.../policy-detail?id=` + 政策id
  *
- * 没有 id 时返回空串 —— **不猜**:宁可没有链接,也不给一个打不开的地址。
+ * 新标准库用顶层 `政策id`;旧数据/接口可能在 `data.市级政策id`。
+ * 没有 id 时返回空串 —— **不猜**。
  */
 export const buildPolicyDetailUrl = (item: any): string => {
-  const id = item?.data?.["市级政策id"];
+  const id =
+    item?.["政策id"] ??
+    item?.originalData?.["政策id"] ??
+    item?.data?.["市级政策id"] ??
+    item?.["市级政策id"];
   const value = String(id ?? "").trim();
   return value ? `${POLICY_DETAIL_URL_BASE}?id=${encodeURIComponent(value)}` : "";
 };
 
-/** 政策名归一化:库里带《》,卡片标题不带,另有全半角括号、连接符、空白等差异 */
-export const normPolicyName = (text: unknown): string =>
-  String(text || "")
+/**
+ * 由库条目的「事项id」拼出申报事项详情页(仅本地政策事项列表进详情时用):
+ * `.../project-detail?id=` + 事项id + `&freeEnjoy=` + true/false
+ *
+ * freeEnjoy 由「是否免申」判定:是 → true,否/缺省 → false。
+ */
+export const buildPolicyProjectDetailUrl = (item: any): string => {
+  const raw = item?.originalData && typeof item.originalData === "object" ? item.originalData : item;
+  const id = String(raw?.["事项id"] ?? item?.["事项id"] ?? "").trim();
+  if (!id) return "";
+
+  const freeEnjoy =
+    raw?.["是否免申"] === "是" ||
+    raw?.["是否免申即享"] === "是" ||
+    raw?.["是否免申即享"] === true ||
+    item?.auto_granted === true;
+
+  return `${POLICY_PROJECT_DETAIL_URL_BASE}?id=${encodeURIComponent(id)}&freeEnjoy=${
+    freeEnjoy ? "true" : "false"
+  }`;
+};
+
+/**
+ * 政策名归一化。
+ *
+ * 需要同时抹平三类差异:
+ *   1. 库里带书名号《》、卡片标题不带;
+ *   2. 卡片标题是「政策名 - 申报事项」,库里的政策名只有政策名;
+ *   3. 新标准库的政策名是**完整文件名**(如「…关于印发《政策名》的通知」),
+ *      后端卡片用的是《》里的短政策名 —— 取书名号里的内容做核心名。
+ */
+export const normPolicyName = (text: unknown): string => {
+  const withoutItemSuffix = String(text || "").replace(/\s+-\s+.*$/, "");
+  const innerTitleMatch = withoutItemSuffix.match(/《([^》]+)》/);
+  const coreName = innerTitleMatch ? innerTitleMatch[1] : withoutItemSuffix;
+  return coreName
     .replace(/[《》\s()()·—–\-_]/g, "")
     .toLowerCase();
+};
 
 /**
  * 从惠企政策库原始条目里取出用于匹配的政策名集合。
@@ -38,31 +81,96 @@ export const buildLibraryNameSet = (libraryPolicies: unknown[] | null | undefine
       .filter(Boolean)
   );
 
+/** 事项名归一化(只抹平标点/空白/大小写;不取书名号) */
+export const normPolicyItemName = (text: unknown): string =>
+  String(text || "")
+    .replace(/[《》\s()()·—–\-_、,,。;;::]/g, "")
+    .toLowerCase();
+
+/**
+ * 新标准库里「事项名 → 政策名」索引。 *
+ * 后端有的卡片标题只有**申报事项名**(如「集成电路配套扶持」),没有政策名,
+ * 只靠名称集合匹配不到;用这张表可以按事项名反查政策名做置顶。
+ */
+export const buildLibraryItemPolicyMap = (
+  libraryPolicies: unknown[] | null | undefined
+): Map<string, string> => {
+  const map = new Map<string, string>();
+  (Array.isArray(libraryPolicies) ? libraryPolicies : []).forEach((p: any) => {
+    const itemName = normPolicyItemName(
+      p?.['事项名称'] ?? p?.['申报事项'] ?? p?.['部门上报事项'] ?? p?.['大模型拆解申报事项']
+    );
+    const policyName = normPolicyName(p?.['政策名称'] ?? p?.name);
+    if (itemName && policyName) {
+      map.set(itemName, policyName);
+    }
+  });
+  return map;
+};
+
 /**
  * 判断某个条目是否惠企政策。
  *
  * 优先用接口下发的 `is_policy_library` 字段(精确、无需匹配);
  * 字段缺失时回退到"标题能在惠企政策库里找到"(兼容旧数据)。
  */
-export const isPolicyLibraryItem = (item: any, libraryNameSet: Set<string>): boolean => {
+export const isPolicyLibraryItem = (
+  item: any,
+  libraryNameSet: Set<string>,
+  itemPolicyMap?: Map<string, string>
+): boolean => {
   if (item?.originalData?.is_policy_library === true) {
     return true;
   }
-  const name = normPolicyName(item?.title);
-  return !!name && libraryNameSet.has(name);
+
+  const candidates = [item?.title, item?.declaration_item, item?.originalData?.declaration_item];
+  if (candidates.some((value) => {
+    const name = normPolicyName(value);
+    return !!name && libraryNameSet.has(name);
+  })) {
+    return true;
+  }
+
+  if (itemPolicyMap) {
+    return candidates.some((value) => {
+      const itemName = normPolicyItemName(value);
+      return !!itemName && itemPolicyMap.has(itemName);
+    });
+  }
+
+  return false;
 };
 
-/** 收集本轮卡片里匹配到的惠企政策名 */
+/** 收集本轮卡片里匹配到的惠企政策名(政策名 / 事项名两条路都认) */
 export const collectMatchedLibraryNames = (
   cards: any[] | null | undefined,
-  libraryNameSet: Set<string>
-): Set<string> =>
-  new Set(
-    (Array.isArray(cards) ? cards : [])
-      .filter((item) => isPolicyLibraryItem(item, libraryNameSet))
-      .map((item) => normPolicyName(item?.title))
-      .filter(Boolean)
-  );
+  libraryNameSet: Set<string>,
+  itemPolicyMap?: Map<string, string>
+): Set<string> => {
+  const matched = new Set<string>();
+
+  (Array.isArray(cards) ? cards : []).forEach((item) => {
+    const candidates = [item?.title, item?.declaration_item, item?.originalData?.declaration_item];
+    for (const value of candidates) {
+      const name = normPolicyName(value);
+      if (name && libraryNameSet.has(name)) {
+        matched.add(name);
+        return;
+      }
+    }
+    if (itemPolicyMap) {
+      for (const value of candidates) {
+        const policyName = itemPolicyMap.get(normPolicyItemName(value));
+        if (policyName) {
+          matched.add(policyName);
+          return;
+        }
+      }
+    }
+  });
+
+  return matched;
+};
 
 /**
  * 把匹配到的条目置顶,其余保持原顺序。

+ 54 - 0
src/components/Chat/record-theme.scss

@@ -167,6 +167,60 @@
     margin-bottom: 16px;
   }
 
+  // PC:一开始就是一行 3 列,不随卡片数量从单列跳成三列。
+  // 标题 / 描述最多 3 行;同一行卡片拉伸到最高的那张(Mobile 不改)
+  &.desktop {
+    .policy-match-summary {
+      width: 100%;
+      align-self: stretch;
+    }
+
+    .policy-box {
+      display: grid;
+      width: 100%;
+      grid-template-columns: repeat(3, minmax(0, 1fr));
+      column-gap: 16px;
+      row-gap: 16px;
+      align-items: stretch;
+      align-content: start;
+    }
+
+    .policy-item {
+      width: auto;
+      min-width: 0;
+      height: auto;
+      display: flex;
+      flex-direction: column;
+      margin-bottom: 0;
+    }
+
+    .policy-item-header {
+      margin-bottom: 10px;
+    }
+
+    .policy-item .policy-title {
+      margin-bottom: 8px;
+    }
+
+    .policy-item .policy-desc {
+      margin-bottom: 12px;
+    }
+
+    .policy-item .policy-title,
+    .policy-item .policy-desc {
+      min-height: 0;
+      overflow: hidden;
+      display: -webkit-box;
+      -webkit-box-orient: vertical;
+      -webkit-line-clamp: 3;
+      word-break: break-word;
+    }
+
+    .policy-item-action {
+      margin-top: auto;
+    }
+  }
+
   .policy-item-action {
     display: flex;
     justify-content: center;

+ 422 - 0
src/components/Chat/stream-text-reveal.ts

@@ -0,0 +1,422 @@
+/**
+ * 豆包式流式文本「模糊渐显」的 DOM 增量合并。
+ *
+ * 背景:流式回答每帧整体重写 TextContent 的 innerHTML(renderInstantly),
+ * 若想在已有文字上做「新到文字模糊渐显」,不能整块重渲(会把旧文字也重播动画)。
+ * 这里对「活 DOM」与「新内容解析出的 DOM」做前缀增长的树合并:
+ *   - 相同前缀原样保留(旧文字保持清晰);
+ *   - 只有新增的文字被包进 <span class="doubao-reveal"> 播放模糊渐显动画;
+ *   - markdown 结构(加粗、列表、表格…)仍由完整解析结果决定,不出现裸语法。
+ *
+ * 前置条件:新文本是旧文本的前缀增长(nextText.startsWith(prevText))。
+ * 不满足或首次渲染时返回 false,调用方退回整块 innerHTML 重渲(改前行为)。
+ *
+ * 正确性不变式(harness/tools/verify-stream-text-reveal.mjs 断言):
+ *   合并后活树的 textContent ≡ 直接解析 nextHtml 的 textContent;
+ *   活树元素 tagName 序列(跳过 .doubao-reveal 的 SPAN 包裹层)≡ 直接解析结果的同序列。
+ *
+ * 纯 DOM 实现,零依赖(jsdom 兼容)。document 只在函数内部引用。
+ */
+
+export const STREAM_REVEAL_CLASS = "doubao-reveal";
+
+const TEXT_NODE = 3;
+const ELEMENT_NODE = 1;
+
+let parseHost: HTMLDivElement | null = null;
+
+function getParseHost(): HTMLDivElement {
+  if (!parseHost) {
+    parseHost = document.createElement("div");
+  }
+  return parseHost;
+}
+
+function isRevealTextSpan(node: Node | null): node is HTMLElement {
+  return (
+    !!node &&
+    node.nodeType === ELEMENT_NODE &&
+    (node as Element).tagName === "SPAN" &&
+    (node as Element).classList.contains(STREAM_REVEAL_CLASS)
+  );
+}
+
+/**
+ * 属性比较时忽略 STREAM_REVEAL_CLASS:
+ * 新插入的整块元素(新段落 / 新 li / 新 tr)是带类克隆的,后续继续在其内部追加文字时
+ * 不应被当成「结构分叉」而整块替换 —— 那样整段会每帧重播动画。
+ */
+function attributesMatch(a: Element, b: Element): boolean {
+  const aAttrs = Array.from(a.attributes).filter((attr) => attr.name !== "class");
+  const bAttrs = Array.from(b.attributes).filter((attr) => attr.name !== "class");
+  if (aAttrs.length !== bAttrs.length) {
+    return false;
+  }
+  for (const attr of aAttrs) {
+    if (b.getAttribute(attr.name) !== attr.value) {
+      return false;
+    }
+  }
+
+  const aClasses = Array.from(a.classList)
+    .filter((name) => name !== STREAM_REVEAL_CLASS)
+    .sort();
+  const bClasses = Array.from(b.classList).sort();
+  if (aClasses.length !== bClasses.length) {
+    return false;
+  }
+  for (let i = 0; i < aClasses.length; i += 1) {
+    if (aClasses[i] !== bClasses[i]) {
+      return false;
+    }
+  }
+  return true;
+}
+
+/**
+ * 从 first 开始消费连续的已定 reveal span(它们的文字依次是新余量的前缀),
+ * 返回最后保留的节点和已覆盖的字符数。改 textContent 不会重启动画,
+ * 所以只有真正新增的字符才需要包新 span。
+ */
+function keepSettledRevealRun(
+  first: Node | null,
+  expectedText: string
+): { lastKept: Node | null; consumed: number } {
+  let lastKept: Node | null = null;
+  let consumed = 0;
+  let cursor = first;
+
+  // 已定的内容可能是普通文本(较早的行)或 reveal span(最新的一行),两者都要保留。
+  while (cursor) {
+    const isText = cursor.nodeType === TEXT_NODE;
+    const isReveal = isRevealTextSpan(cursor);
+    if (!isText && !isReveal) {
+      break;
+    }
+
+    const text = cursor.textContent || "";
+    if (!text) {
+      cursor = cursor.nextSibling;
+      continue;
+    }
+    if (!expectedText.startsWith(text, consumed)) {
+      break;
+    }
+
+    consumed += text.length;
+    lastKept = cursor;
+    cursor = cursor.nextSibling;
+  }
+
+  return { lastKept, consumed };
+}
+
+/** 移除 node 之后的全部兄弟节点。 */
+function removeSiblingsAfter(node: Node) {
+  const parent = node.parentNode;
+  if (!parent) {
+    return;
+  }
+  while (node.nextSibling) {
+    parent.removeChild(node.nextSibling);
+  }
+}
+
+function commonPrefixLength(a: string, b: string): number {
+  const max = Math.min(a.length, b.length);
+  let i = 0;
+  while (i < max && a.charCodeAt(i) === b.charCodeAt(i)) {
+    i += 1;
+  }
+  return i;
+}
+
+function wrapRevealText(text: string): HTMLSpanElement {
+  const span = document.createElement("span");
+  span.className = STREAM_REVEAL_CLASS;
+  span.textContent = text;
+  return span;
+}
+
+function findLastMeaningfulTextNode(root: Node): Text | null {
+  let found: Text | null = null;
+  const walk = (node: Node) => {
+    for (let child = node.firstChild; child; child = child.nextSibling) {
+      if (child.nodeType === TEXT_NODE) {
+        if ((child.textContent || "").trim()) {
+          found = child as Text;
+        }
+      } else if (child.nodeType === ELEMENT_NODE) {
+        walk(child);
+      }
+    }
+  };
+  walk(root);
+  return found;
+}
+
+/**
+ * 整个新元素(新段落 / 新 li / 新 ul …)只让**最后一个文本节点**播渐显。
+ * 否则一次插入多行(例如一个含多条 li 的新列表)会整块同时发虚。
+ */
+function wrapRevealElementTail(element: Element): Element {
+  const clone = element.cloneNode(true) as Element;
+  const lastText = findLastMeaningfulTextNode(clone);
+  if (lastText && lastText.parentNode) {
+    const text = lastText.textContent || "";
+    const leading = text.match(/^\s*/)?.[0] || "";
+    const trailing = text.match(/\s*$/)?.[0] || "";
+    const core = text.slice(leading.length, text.length - trailing.length);
+    if (core) {
+      const parent = lastText.parentNode;
+      parent.insertBefore(document.createTextNode(leading), lastText);
+      parent.insertBefore(wrapRevealText(core), lastText);
+      parent.insertBefore(document.createTextNode(trailing), lastText);
+      parent.removeChild(lastText);
+      return clone;
+    }
+  }
+
+  clone.classList.add(STREAM_REVEAL_CLASS);
+  return clone;
+}
+
+function createRevealFragment(text: string): DocumentFragment {
+  const fragment = document.createDocumentFragment();
+  // 保留换行符作为独立段,找出最后一个有内容的行
+  const segments = String(text || "").split(/(\n)/);
+  let lastContentIndex = -1;
+  for (let i = segments.length - 1; i >= 0; i -= 1) {
+    if (segments[i].trim()) {
+      lastContentIndex = i;
+      break;
+    }
+  }
+
+  if (lastContentIndex < 0) {
+    fragment.appendChild(document.createTextNode(text));
+    return fragment;
+  }
+
+  const leading = segments.slice(0, lastContentIndex).join("");
+  if (leading) {
+    fragment.appendChild(document.createTextNode(leading));
+  }
+  fragment.appendChild(wrapRevealText(segments[lastContentIndex]));
+  const trailing = segments.slice(lastContentIndex + 1).join("");
+  if (trailing) {
+    fragment.appendChild(document.createTextNode(trailing));
+  }
+  return fragment;
+}
+
+function appendTailRevealText(parent: Node, text: string) {
+  parent.appendChild(createRevealFragment(text));
+}
+
+function insertTailRevealText(parent: Node, text: string, before: Node | null) {
+  parent.insertBefore(createRevealFragment(text), before);
+}
+
+function appendPlainChild(parent: Node, node: Node) {
+  if (node.nodeType === TEXT_NODE) {
+    const text = node.textContent || "";
+    if (text) {
+      parent.appendChild(document.createTextNode(text));
+    }
+    return;
+  }
+  parent.appendChild(node.cloneNode(true));
+}
+
+/** 移除 parent 中下标 >= fromIndex 的全部子节点(fromIndex 可为 childNodes.length)。 */
+function removeChildrenFrom(parent: Node, fromIndex: number) {
+  while (parent.childNodes.length > fromIndex) {
+    parent.removeChild(parent.childNodes[parent.childNodes.length - 1]);
+  }
+}
+
+/**
+ * 把 newParent 从 fromIndex 起的子节点追加到 parent。
+ * 只有**最后一个有内容的节点**播渐显,之前的节点直接以清晰状态出现——
+ * 一次插入多行/多个块时不会整片同时发虚。
+ */
+function appendWrappedChildren(parent: Node, newParent: Node, fromIndex: number) {
+  const children = newParent.childNodes;
+  let lastContentIndex = -1;
+  for (let i = children.length - 1; i >= fromIndex; i -= 1) {
+    const child = children[i];
+    if (child.nodeType === TEXT_NODE) {
+      if ((child.textContent || "").trim()) {
+        lastContentIndex = i;
+        break;
+      }
+    } else if (child.nodeType === ELEMENT_NODE) {
+      lastContentIndex = i;
+      break;
+    }
+  }
+
+  for (let i = fromIndex; i < children.length; i += 1) {
+    const child = children[i];
+    if (i !== lastContentIndex) {
+      appendPlainChild(parent, child);
+      continue;
+    }
+
+    if (child.nodeType === TEXT_NODE) {
+      appendTailRevealText(parent, child.textContent || "");
+    } else if (child.nodeType === ELEMENT_NODE) {
+      parent.appendChild(wrapRevealElementTail(child as Element));
+    } else {
+      parent.appendChild(child.cloneNode(true));
+    }
+  }
+}
+
+/**
+ * 两指针合并:
+ *   o = 旧侧已消费的子节点数;i = 新侧下标。
+ * 不变量:任何插入都发生在「旧侧已消费点之后」,且插入前先清掉该点之后的全部旧兄弟,
+ * 因此插入节点与未消费旧节点永不交错,位置式清理恒正确。
+ */
+function mergeChildren(oldParent: Node, newParent: Node) {
+  const oldChildren = oldParent.childNodes; // 活 NodeList:删除会实时反映
+  const newChildren = newParent.childNodes;
+  let o = 0;
+  let i = 0;
+
+  while (i < newChildren.length && o < oldChildren.length) {
+    const oldChild = oldChildren[o];
+    const newChild = newChildren[i];
+
+    // 1) 旧侧是纯文本
+    if (oldChild.nodeType === TEXT_NODE) {
+      if (newChild.nodeType === TEXT_NODE) {
+        const oldText = oldChild.textContent || "";
+        const newText = newChild.textContent || "";
+        const common = commonPrefixLength(oldText, newText);
+
+        if (common === oldText.length) {
+          if (common === newText.length) {
+            o += 1;
+            i += 1;
+            continue;
+          }
+
+          // 增长:把紧邻的已定内容(普通文本 / reveal span)尽量保留,
+          // 只把新增部分里的**最后一行**包成新 span。
+          const delta = newText.slice(common);
+          const { lastKept, consumed } = keepSettledRevealRun(
+            oldChild.nextSibling,
+            delta
+          );
+          if (lastKept) {
+            removeSiblingsAfter(lastKept);
+            if (delta.length > consumed) {
+              insertTailRevealText(
+                oldParent,
+                delta.slice(consumed),
+                lastKept.nextSibling
+              );
+            }
+            appendWrappedChildren(oldParent, newParent, i + 1);
+            return;
+          }
+
+          removeChildrenFrom(oldParent, o + 1);
+          insertTailRevealText(oldParent, delta, oldChild.nextSibling);
+          appendWrappedChildren(oldParent, newParent, i + 1);
+          return;
+        }
+
+        // 收缩(流式通常不出现;停止/截断时可能):保留公共前缀,去掉旧余量。
+        const rest = (oldChild as Text).splitText(common);
+        oldParent.removeChild(rest);
+        if (common === newText.length) {
+          o += 1;
+          i += 1;
+          continue;
+        }
+        removeChildrenFrom(oldParent, o + 1);
+        insertTailRevealText(oldParent, newText.slice(common), oldChild.nextSibling);
+        appendWrappedChildren(oldParent, newParent, i + 1);
+        return;
+      }
+
+      // 旧文本 vs 新元素(如 "**bo" 补全成 <strong>)→ 结构分叉
+      removeChildrenFrom(oldParent, o);
+      appendWrappedChildren(oldParent, newParent, i);
+      return;
+    }
+
+    // 2) 旧侧是已定 reveal span,新侧仍是文本:保留已显示部分,只包新增字符
+    if (isRevealTextSpan(oldChild) && newChild.nodeType === TEXT_NODE) {
+      const newText = newChild.textContent || "";
+      const { lastKept, consumed } = keepSettledRevealRun(oldChild, newText);
+      if (lastKept) {
+        removeSiblingsAfter(lastKept);
+        if (newText.length > consumed) {
+          insertTailRevealText(
+            oldParent,
+            newText.slice(consumed),
+            lastKept.nextSibling
+          );
+        }
+        appendWrappedChildren(oldParent, newParent, i + 1);
+        return;
+      }
+      removeChildrenFrom(oldParent, o);
+      appendWrappedChildren(oldParent, newParent, i);
+      return;
+    }
+
+    // 3) 同标签同属性 → 递归
+    if (oldChild.nodeType === ELEMENT_NODE && newChild.nodeType === ELEMENT_NODE) {
+      const oldElement = oldChild as Element;
+      const newElement = newChild as Element;
+      if (
+        oldElement.tagName === newElement.tagName &&
+        attributesMatch(oldElement, newElement)
+      ) {
+        mergeChildren(oldElement, newElement);
+        o += 1;
+        i += 1;
+        continue;
+      }
+    }
+
+    // 4) 其余(注释 / 标签或属性不同)→ 分叉:清旧剩余,整体包裹新剩余
+    removeChildrenFrom(oldParent, o);
+    appendWrappedChildren(oldParent, newParent, i);
+    return;
+  }
+
+  if (i >= newChildren.length) {
+    removeChildrenFrom(oldParent, o); // 收缩:移除多余旧节点
+  } else {
+    appendWrappedChildren(oldParent, newParent, i); // 追加新节点(包裹)
+  }
+}
+
+/**
+ * 前缀增长时把新内容合并进活 DOM,返回 true;否则返回 false(调用方整块重渲)。
+ */
+export function mergeStreamTextReveal(
+  liveRoot: HTMLElement,
+  nextHtml: string,
+  prevText: string,
+  nextText: string
+): boolean {
+  if (!liveRoot || !prevText || !nextText || !nextText.startsWith(prevText)) {
+    return false;
+  }
+  if (liveRoot.childNodes.length === 0) {
+    return false;
+  }
+
+  const host = getParseHost();
+  host.innerHTML = nextHtml;
+  mergeChildren(liveRoot, host);
+  return true;
+}

+ 56 - 0
src/components/Chat/text-content-utils.ts

@@ -1,3 +1,5 @@
+import { marked } from "marked";
+
 const bareUrlReg = /(^|[^\]("'=])\b(https?:\/\/[^\s<]+)/gi;
 const urlStopChars = new Set([
   ",",
@@ -45,6 +47,24 @@ function splitUrlTail(value: string) {
   };
 }
 
+/** 路径(可带 ?query / #hash)是否像图片资源 */
+export function isImageUrl(url: string): boolean {
+  const raw = String(url || "").trim();
+  if (!raw) return false;
+  try {
+    return /\.(?:png|jpe?g|gif|webp|bmp|svg)$/i.test(new URL(raw).pathname);
+  } catch {
+    // 非法绝对 URL 时仍按路径尾巴判断(兼容无协议残片,一般不会走到)
+    const pathOnly = raw.split(/[?#]/)[0] || "";
+    return /\.(?:png|jpe?g|gif|webp|bmp|svg)$/i.test(pathOnly);
+  }
+}
+
+/**
+ * 把正文里的裸 URL 规整成 markdown:
+ * - 图片地址(按扩展名)→ `![](url)`,渲染成 <img>
+ * - 其它地址 → `<url>` 自动链接
+ */
 export function normalizeBareLinks(content: string) {
   return String(content || "").replace(bareUrlReg, (match, prefix: string, rawUrl: string) => {
     const { url, tail } = splitUrlTail(rawUrl);
@@ -52,6 +72,10 @@ export function normalizeBareLinks(content: string) {
       return match;
     }
 
+    if (isImageUrl(url)) {
+      return `${prefix}![](${url})${tail}`;
+    }
+
     return `${prefix}<${url}>${tail}`;
   });
 }
@@ -105,6 +129,38 @@ export function splitStreamingTextContentRows(
   return segments;
 }
 
+// ── markdown 渲染管线(从 TextContent.vue 搬出,harness 测试跑同一份实现) ──
+
+const renderer = new marked.Renderer();
+
+renderer.heading = function ({ tokens, depth }) {
+  const headingText = this.parser.parseInline(tokens);
+  return `<h${depth}>${headingText}</h${depth}>`;
+};
+
+renderer.link = function ({ href, text }) {
+  // rel="noopener noreferrer" 防钓鱼;target="_blank" 在新标签页打开
+  return `<a href="${href}" target="_blank" rel="noopener noreferrer">${text}</a>`;
+};
+
+marked.setOptions({
+  renderer,
+});
+
+/** 协议里的可读化占位符:[citation: 1] → [1] */
+export function replaceCitationPlaceholders(html: string) {
+  return String(html || "").replace(/\[citation:\s*(\d+)\]/g, "[$1]");
+}
+
+/** 把一段 markdown 源文本渲染成 HTML(正文块 / 行内两种模式)。 */
+export function renderMarkdownToHtml(text: string, blockMarkdown: boolean) {
+  const trimmedText = trimDisplayTextContent(text);
+  const content = blockMarkdown
+    ? marked.parse(normalizeBareLinks(trimmedText))
+    : marked.parseInline(normalizeBareLinks(trimmedText));
+  return replaceCitationPlaceholders(content);
+}
+
 export function shouldRestartTypewriter({
   oldContent,
   newContent,

+ 83 - 25
src/components/Common/FeedbackWidget.vue

@@ -2,17 +2,20 @@
   <div class="like-component-wrapper">
     <!-- 默认状态:3个按钮 (复制 / 点赞 / 点踩),初始 None 或未选中时显示 -->
     <div class="action-buttons" v-if="localFeedback === FeedbackType.Unselected || localFeedback === FeedbackType.None">
-      <div class="btn-icon" @click="handleCopy" ref="copyBtnRef" title="复制">
+      <div class="btn-icon" @click="handleCopy" ref="copyBtnRef"
+        @mouseenter="showActionTip($event, '复制')" @mouseleave="hideActionTip">
         <svg width="13" height="15" viewBox="0 0 13 15" fill="none" xmlns="http://www.w3.org/2000/svg">
           <path d="M4.5 12C4.0875 12 3.73438 11.8531 3.44062 11.5594C3.14687 11.2656 3 10.9125 3 10.5V1.5C3 1.0875 3.14687 0.734375 3.44062 0.440625C3.73438 0.146875 4.0875 0 4.5 0H11.25C11.6625 0 12.0156 0.146875 12.3094 0.440625C12.6031 0.734375 12.75 1.0875 12.75 1.5V10.5C12.75 10.9125 12.6031 11.2656 12.3094 11.5594C12.0156 11.8531 11.6625 12 11.25 12H4.5ZM4.5 10.5H11.25V1.5H4.5V10.5ZM1.5 15C1.0875 15 0.734375 14.8531 0.440625 14.5594C0.146875 14.2656 0 13.9125 0 13.5V3H1.5V13.5H9.75V15H1.5ZM4.5 10.5V1.5V10.5Z" fill="#464555" fill-opacity="0.5"/>
         </svg>
       </div>
-      <div class="btn-icon" @click="handleLike" title="点赞">
+      <div class="btn-icon" @click="handleLike"
+        @mouseenter="showActionTip($event, '点赞')" @mouseleave="hideActionTip">
         <svg width="16" height="15" viewBox="0 0 16 15" fill="none" xmlns="http://www.w3.org/2000/svg">
           <path d="M12 15H3.75V5.25L9 0L9.9375 0.9375C10.025 1.025 10.0969 1.14375 10.1531 1.29375C10.2094 1.44375 10.2375 1.5875 10.2375 1.725V1.9875L9.4125 5.25H14.25C14.65 5.25 15 5.4 15.3 5.7C15.6 6 15.75 6.35 15.75 6.75V8.25C15.75 8.3375 15.7375 8.43125 15.7125 8.53125C15.6875 8.63125 15.6625 8.725 15.6375 8.8125L13.3875 14.1C13.275 14.35 13.0875 14.5625 12.825 14.7375C12.5625 14.9125 12.2875 15 12 15ZM5.25 13.5H12L14.25 8.25V6.75H7.5L8.5125 2.625L5.25 5.8875V13.5ZM5.25 5.8875V6.75V8.25V13.5V5.8875ZM3.75 5.25V6.75H1.5V13.5H3.75V15H0V5.25H3.75Z" fill="#464555" fill-opacity="0.5"/>
         </svg>
       </div>
-      <div class="btn-icon" @click="handleDislike" title="点踩">
+      <div class="btn-icon" @click="handleDislike"
+        @mouseenter="showActionTip($event, '点踩')" @mouseleave="hideActionTip">
         <svg width="16" height="15" viewBox="0 0 16 15" fill="none" xmlns="http://www.w3.org/2000/svg">
           <path d="M3.75 0H12V9.75L6.75 15L5.8125 14.0625C5.725 13.975 5.65313 13.8562 5.59688 13.7063C5.54063 13.5563 5.5125 13.4125 5.5125 13.275V13.0125L6.3375 9.75H1.5C1.1 9.75 0.75 9.6 0.45 9.3C0.15 9 0 8.65 0 8.25V6.75C0 6.6625 0.0125 6.56875 0.0375 6.46875C0.0625 6.36875 0.0875 6.275 0.1125 6.1875L2.3625 0.9C2.475 0.65 2.6625 0.4375 2.925 0.2625C3.1875 0.0875 3.4625 0 3.75 0ZM10.5 1.5H3.75L1.5 6.75V8.25H8.25L7.2375 12.375L10.5 9.1125V1.5ZM10.5 9.1125V8.25V6.75V1.5V9.1125ZM12 9.75V8.25H14.25V1.5H12V0H15.75V9.75H12Z" fill="#464555" fill-opacity="0.5"/>
         </svg>
@@ -58,11 +61,9 @@
       <transition name="popover-fade">
         <div
           v-if="showCancelPopover"
-          class="cancel-popover"
+          class="action-name-tip"
           :style="popoverStyle"
-        >
-          <span class="cancel-label">取消</span>
-        </div>
+        >取消</div>
       </transition>
     </Teleport>
 
@@ -78,11 +79,16 @@
         </div>
       </transition>
     </Teleport>
+
+    <Teleport to="body">
+      <div v-if="actionTip.visible" class="action-name-tip"
+        :style="{ left: `${actionTip.x}px`, top: `${actionTip.y}px` }">{{ actionTip.text }}</div>
+    </Teleport>
   </div>
 </template>
 
 <script setup lang="ts">
-import { computed, inject, nextTick, ref, watch } from "vue";
+import { computed, inject, nextTick, onBeforeUnmount, reactive, ref, watch } from "vue";
 import { FeedbackType } from "@/types/record";
 
 const props = defineProps<{
@@ -99,6 +105,51 @@ const emit = defineEmits<{
 const { openDislikeDialog } = inject<{ openDislikeDialog: (id: number | string) => void }>("dislikeDialogControl", { openDislikeDialog: () => {} });
 const { submitLikeFeedback, cancelFeedback } = inject<{ submitLikeFeedback: (id: number | string) => void; cancelFeedback: (id: number | string) => void }>("feedbackControl", { submitLikeFeedback: () => {}, cancelFeedback: () => {} });
 
+const ACTION_TIP_DELAY = 300;
+const actionTip = reactive({ visible: false, text: "", x: 0, y: 0 });
+let actionTipTimer: number | null = null;
+let actionTipEl: HTMLElement | null = null;
+
+const isDesktopTip = () =>
+  typeof window !== "undefined" && window.matchMedia("(min-width: 768px)").matches;
+
+const clearActionTipTimer = () => {
+  if (actionTipTimer !== null) {
+    window.clearTimeout(actionTipTimer);
+    actionTipTimer = null;
+  }
+};
+
+const placeActionTip = (el: HTMLElement) => {
+  const rect = el.getBoundingClientRect();
+  actionTip.x = rect.left + rect.width / 2;
+  actionTip.y = rect.top;
+};
+
+const showActionTip = (event: MouseEvent, text: string) => {
+  if (!isDesktopTip()) return;
+  const el = event.currentTarget as HTMLElement | null;
+  if (!el) return;
+  clearActionTipTimer();
+  actionTipEl = el;
+  placeActionTip(el);
+  actionTip.text = text;
+  actionTipTimer = window.setTimeout(() => {
+    actionTipTimer = null;
+    if (actionTipEl) placeActionTip(actionTipEl);
+    actionTip.visible = true;
+  }, ACTION_TIP_DELAY);
+};
+
+const hideActionTip = () => {
+  clearActionTipTimer();
+  actionTipEl = null;
+  actionTip.visible = false;
+  actionTip.text = "";
+};
+
+onBeforeUnmount(hideActionTip);
+
 const showCancelPopover = ref(false);
 const popoverStyle = ref<Record<string, string>>({});
 const copyPopoverVisible = ref(false);
@@ -115,10 +166,11 @@ const localFeedback = computed({
 
 watch(() => props.feedback, () => {
   showCancelPopover.value = false;
+  hideActionTip();
 });
 
 function updateCancelPopoverAt(e: MouseEvent) {
-  // 定位点取鼠标指针(clientX/clientY),偏移量见 .cancel-popover 的 transform
+  // 定位点取鼠标指针(clientX/clientY),偏移量见 .action-name-tip 的 transform
   popoverStyle.value = {
     position: "fixed",
     left: e.clientX + "px",
@@ -148,6 +200,7 @@ function showCopyPopoverAt(target: HTMLElement) {
 }
 
 function handleLike() {
+  hideActionTip();
   if (submitLikeFeedback) {
     submitLikeFeedback(props.id);
   }
@@ -155,6 +208,7 @@ function handleLike() {
 }
 
 function handleDislike() {
+  hideActionTip();
   if (openDislikeDialog) {
     openDislikeDialog(props.id);
   }
@@ -229,13 +283,19 @@ function handleCancelFeedback() {
   .btn-icon {
     width: 18px;
     height: 18px;
-    border-radius: 2px;
+    padding: 4px;
+    box-sizing: content-box;
+    border-radius: 4px;
     cursor: pointer;
     display: flex;
     align-items: center;
     justify-content: center;
     overflow: hidden;
     flex-shrink: 0;
+
+    &:hover {
+      background: #e3e3e3;
+    }
   }
 }
 
@@ -269,26 +329,24 @@ function handleCancelFeedback() {
 </style>
 
 <style lang="scss">
-.cancel-popover {
-  background: #ffffff;
-  border-radius: 2px;
-  box-shadow: 2px 2px 10.5px rgba(0, 0, 0, 0.12);
-  padding: 2px 8px;
+.action-name-tip {
+  position: fixed;
+  z-index: 4000;
+  max-width: 280px;
+  padding: 8px 10px;
+  border-radius: 8px;
+  background: #141b2b;
+  color: #ffffff;
+  font-size: 12px;
+  font-weight: 500;
+  line-height: 1.5;
+  box-shadow: 0 8px 20px rgba(20, 27, 43, 0.18);
   pointer-events: none;
-  z-index: 99999;
-  // 定位点 = 鼠标指针,translate 把它抬到鼠标正上方居中 8px 处
   transform: translate(-50%, calc(-100% - 8px));
   white-space: nowrap;
-
-  .cancel-label {
-    color: #000000;
-    font-family: "HarmonyOS Sans SC", sans-serif;
-    font-size: 14px;
-    font-weight: 400;
-    line-height: 1.5;
-  }
 }
 
+
 // 复制成功提示气泡:定位点为复制按钮中心,translate 把它放在按钮上方居中处
 .copy-popover {
   background: #ffffff;

+ 65 - 2
src/components/Common/ScrollList.vue

@@ -36,7 +36,7 @@
 import { computed, ref, onMounted, onBeforeUnmount, nextTick, watch } from "vue";
 import { useResizeObserver } from "@vueuse/core";
 import { sleep } from "../utils";
-const props = defineProps(["data", "height", "maxHeight", "showDragger", "bottomPadding", "topPadding", "nativeScrollMode"]);
+const props = defineProps(["data", "height", "maxHeight", "showDragger", "bottomPadding", "topPadding", "nativeScrollMode", "smoothFollow"]);
 const emit = defineEmits(["scrollPositionChange"]);
 const listRef = ref(null);
 const listWrap = ref(null);
@@ -278,6 +278,7 @@ onBeforeUnmount(() => {
   }
   window.removeEventListener("mousemove", onDraggerMouseMove);
   window.removeEventListener("mouseup", onDraggerMouseUp);
+  stopScrollFollow();
   cancelScrollAnimation();
 });
 
@@ -288,7 +289,9 @@ useResizeObserver(listWrap, (entry) => {
   if (isScrollAnimationActive) {
     return;
   }
-  scrollToBottom();
+  // 流式增长时这里每帧都会触发;走跟随方法,避免瞬时跳底抵消平滑。
+  // smoothFollow 为假时该方法内部退化回原来的瞬时贴底。
+  scrollToBottomFollow();
 });
 
 let requestId = null;
@@ -408,6 +411,7 @@ const handleScrollEvent = (event) => {
 
 const disableAutoScroll = () => {
   isAutoScroll.value = false;
+  stopScrollFollow();
 };
 
 const scrollToBottom = () => {
@@ -419,6 +423,63 @@ const scrollToBottom = () => {
   }
 };
 
+// ── 流式贴底跟随(豆包式平滑滚动)──
+// smoothFollow 为真时用 rAF 缓动逼近底部;否则退化为原来的瞬时贴底。
+// ⚠️ 程序化设定 scrollTop 产生的是 trusted 滚动事件(Chromium),每帧都必须
+//    beginProgrammaticScroll("single") 打标,否则自己的滚动会被当成用户滚动
+//    → cancelAutoScroll → 循环自杀,且 pin 抑制标志会被污染。
+const FOLLOW_SCROLL_RATIO = 0.35;
+const FOLLOW_SNAP_DISTANCE = 1.5;
+let followFrameId = 0;
+
+const stopScrollFollow = () => {
+  if (followFrameId) {
+    cancelAnimationFrame(followFrameId);
+    followFrameId = 0;
+  }
+};
+
+const scrollToBottomFollow = () => {
+  if (!listRef.value) {
+    return;
+  }
+
+  if (!props.smoothFollow) {
+    scrollToBottom();
+    return;
+  }
+
+  // 幂等:已有一个循环在跑就交给它继续逼近;用户滚走后不再追。
+  if (followFrameId || !isAutoScroll.value) {
+    return;
+  }
+
+  const step = () => {
+    followFrameId = 0;
+    if (!listRef.value || !isAutoScroll.value || !props.smoothFollow) {
+      clearProgrammaticScroll();
+      return;
+    }
+
+    const maxScrollTop = Math.max(
+      0,
+      listRef.value.scrollHeight - listRef.value.clientHeight
+    );
+    const distance = maxScrollTop - listRef.value.scrollTop;
+
+    beginProgrammaticScroll("single");
+    if (distance <= FOLLOW_SNAP_DISTANCE) {
+      listRef.value.scrollTop = maxScrollTop;
+      return;
+    }
+
+    listRef.value.scrollTop += distance * FOLLOW_SCROLL_RATIO;
+    followFrameId = requestAnimationFrame(step);
+  };
+
+  followFrameId = requestAnimationFrame(step);
+};
+
 const scrollToBottomOnce = () => {
   const targetTop = Math.max(0, listRef.value.scrollHeight - listRef.value.clientHeight);
   return animateScrollTo(targetTop);
@@ -514,6 +575,7 @@ const isNearBottom = () => {
 };
 
 const cancelAutoScroll = () => {
+  stopScrollFollow();
   cancelScrollAnimation();
   const isAtBottom = listRef.value.scrollTop + listRef.value.clientHeight >= listRef.value.scrollHeight;
   isAutoScroll.value = isAtBottom;
@@ -609,6 +671,7 @@ watch(
 
 defineExpose({
   scrollToBottom,
+  scrollToBottomFollow,
   scrollToBottomOnce,
   scrollToBottomInstant,
   scrollToPositionInstant,

+ 26 - 10
src/components/answer-stream.ts

@@ -13,6 +13,30 @@ export const LIST_ITEM_RE = /^\s*(?:[-*+]|\d+[.)])\s+\S/;
  * 规整 markdown 换行:渲染层是 `white-space: normal`,单个 \n 会被折叠,
  * 于是把非列表项之间的单换行提升为空行;连续列表项之间保留单换行,不打断编号。
  */
+/**
+ * 两行之间是否需要插入空行。
+ *
+ * 规则(2026-10-29 用户要求「\n\n 换两行」):
+ *   - 普通行之间**保留原始换行**:单个 \n = 段内换行(一行),双个 \n = 空一行(分段);
+ *   - 连续列表项保持紧排(不插空行);
+ *   - 列表项与普通行之间必须插空行,否则 markdown 会把普通行并进列表项(懒续行)。
+ */
+const needsBlankBetweenLines = (prev: string, line: string): boolean => {
+  const prevBlank = prev.trim() === '';
+  const lineBlank = line.trim() === '';
+  if (prevBlank || lineBlank) {
+    return false;
+  }
+
+  const prevList = LIST_ITEM_RE.test(prev);
+  const lineList = LIST_ITEM_RE.test(line);
+  if (prevList && lineList) {
+    return false;
+  }
+
+  return prevList || lineList;
+};
+
 export function normalizeChatMarkdown(text: string): string {
   const value = String(text || '');
   if (!value.includes('\n')) {
@@ -24,11 +48,8 @@ export function normalizeChatMarkdown(text: string): string {
   for (let i = 1; i < lines.length; i++) {
     const prev = lines[i - 1];
     const line = lines[i];
-    const prevBlank = prev.trim() === '';
-    const lineBlank = line.trim() === '';
-    const tightList = LIST_ITEM_RE.test(prev) && LIST_ITEM_RE.test(line);
 
-    if (!prevBlank && !lineBlank && !tightList) {
+    if (needsBlankBetweenLines(prev, line)) {
       result.push('');
     }
     result.push(line);
@@ -72,12 +93,7 @@ export const createIncrementalMarkdownNormalizer = (): IncrementalMarkdownNormal
   let received = false;
 
   /** 两行之间是否需要插入空行(与 normalizeChatMarkdown 同一判据) */
-  const needsBlankBetween = (prev: string, line: string): boolean => {
-    const prevBlank = prev.trim() === '';
-    const lineBlank = line.trim() === '';
-    const tightList = LIST_ITEM_RE.test(prev) && LIST_ITEM_RE.test(line);
-    return !prevBlank && !lineBlank && !tightList;
-  };
+  const needsBlankBetween = needsBlankBetweenLines;
 
   /**
    * 开出一行:先补空行(需要的话),再写内容。

+ 74 - 35
src/components/api-chat-coordinator.ts

@@ -3,17 +3,18 @@
  *
  * 协议适配层:把新协议的 SSE 事件翻译成原界面本来就能渲染的内容标记
  * (item → POLICY_TABLE 块、source → ref_links、interrupt → question-cards、
- * result.cipa → image-scope 二维码、progress/heartbeat → scope 卡片、answer_* → answerStream* 事件),
+ * progress/heartbeat → scope 卡片、answer_* → answerStream* 事件),
  * 对上层保持与原协调器一致的接口,渲染组件一行都不用改。
  *
+ * 📌 2026-11-02:停用 result.cipa → 企业微信二维码注入。后端已把图片 URL 写进正文,
+ * 由 TextContent / normalizeBareLinks 渲成 <img>;前端再注一张会重复且不是同一张图。
+ *
  * 硬约束(详见 接口文档/api-chat.md):
  * - 请求体只接受 {thread_id, question},多余字段返回 422
  * - answer.text 与 result.response 相同,只能展示一次
  * - 未收到 done/error 就断开 → 按“连接中断”处理,不自动重试
  */
 import mitt, { Emitter } from 'mitt';
-// 企业微信二维码(Vite 资源导入 → 构建时变成带 hash 的产物地址,不要写死路径)
-import cipaQrcodeUrl from '@/assets/qiyeweixin.png';
 import {
   applyAnswerStreamEvent,
   createAnswerStreamState,
@@ -106,6 +107,13 @@ export interface ChatItemPayload {
   eligibility?: string;
   recommendation_status?: string;
   priority?: { rank?: number | string; basis?: string };
+  /** 一网通办政策文件 id(新后端会下发;用于拼 policy-detail) */
+  政策id?: string;
+  policy_id?: string;
+  /** 完整政策文件名;有则详情「政策名称」优先用它(卡片标题仍用 card.name) */
+  政策名称?: string;
+  /** 事项挂在政策文件下时,政策文件名在 parent_title */
+  policy_relation?: { parent_title?: string; original_id?: string; role?: string };
 }
 
 export interface ChatSourcePayload {
@@ -161,7 +169,10 @@ export interface ChatResultPayload {
   errors?: unknown[];
   /** 企业资料(协调器不解析,只在 done 时原样交给应用侧 → syncCompanyInfoFromChat) */
   company_info?: unknown;
-  /** 是否展示企业微信二维码:问的是 CIPA / 海外服务平台 / 出海服务时为 true */
+  /**
+   * @deprecated 2026-11-02 起前端不再消费。后端把图片写进正文即可;
+   * 字段仍可能出现在 SSE 里,忽略即可。
+   */
   cipa?: unknown;
 }
 
@@ -209,18 +220,6 @@ export function mapChatErrorText(code?: string, message?: string): string {
   return CHAT_ERROR_TEXT[code || ''] || '服务异常,请稍后再试';
 }
 
-/** 二维码上方的一句引导语 */
-export const CIPA_QRCODE_TIP =
-  '如果您还有其他疑问,欢迎随时向我咨询,也可以联系CIPA海外服务平台获取支持。';
-
-/**
- * 企业微信二维码的内容标记(上文下码):渲染层认 `<image-scope>` 块,
- * 引导语与图片标记之间**空一行**(渲染层按空行切成「文本行 + 图片行」)。
- */
-export function buildCipaQrcodeContent(): string {
-  return `${CIPA_QRCODE_TIP}\n\n<image-scope>\n${cipaQrcodeUrl}\n</image-scope>`;
-}
-
 export const CHAT_ENDPOINT_PATH = '/api/chat';
 
 /**
@@ -299,16 +298,51 @@ const getSourceUrl = (source?: ChatSourcePayload): string => {
   return '';
 };
 
+/** 从 item / source.full_record 里取出可展示的中文字段(政策id、政策名称等) */
+const resolveRecordField = (
+  item: ChatItemPayload,
+  source: ChatSourcePayload | undefined,
+  key: string,
+): string => {
+  const fromItem = (item as Record<string, unknown>)[key];
+  if (typeof fromItem === 'string' && fromItem.trim()) {
+    return fromItem.trim();
+  }
+  const record = source?.full_record as Record<string, unknown> | undefined;
+  const fromRecord = record?.[key];
+  if (typeof fromRecord === 'string' && fromRecord.trim()) {
+    return fromRecord.trim();
+  }
+  return '';
+};
+
 /** 把一条 item 映射成 PolicyMatch 期望的政策对象字段 */
-const toPolicyTableItem = (item: ChatItemPayload, sourceUrl: string) => {
+const toPolicyTableItem = (item: ChatItemPayload, source?: ChatSourcePayload) => {
   const card = item.card ?? null;
   const nameText = resolveFieldText(card?.name);
+  // 卡片区标题:仍用 card.name(用户要求卡片展示不变)
   const title = nameText || item.title || '';
 
   // 详情面板的「申报事项」要用后端每条唯一的 `item.title`(同政策多个申报事项时是
   // 「政策名 - 申报事项」),`card.name.text` 只有政策名
   const declarationItem = item.title || title;
 
+  // 详情「政策名称」用完整文件名;政策id 用来拼 policy-detail
+  const policyId =
+    resolveRecordField(item, source, '政策id') ||
+    String(item.policy_id || '').trim();
+  const parentTitle = (value: unknown): string => {
+    if (!value || typeof value !== 'object') return '';
+    const title = (value as { policy_relation?: { parent_title?: unknown } }).policy_relation?.parent_title;
+    return typeof title === 'string' ? title.trim() : '';
+  };
+  // 新载荷没有「政策名称」,政策文件名在 policy_relation.parent_title。
+  // card.name.text 是事项名,不能拿来当政策名称。
+  const policyName =
+    resolveRecordField(item, source, '政策名称') ||
+    parentTitle(item) ||
+    parentTitle(source?.full_record);
+
   // 卡片区按 match_score 倒序取前 6 条;新接口给的是 priority.rank(1 为第一位),
   // 这里换算成递减分值,使卡片顺序与接口给的展示优先级一致
   const rank = Number(item.priority?.rank);
@@ -327,7 +361,10 @@ const toPolicyTableItem = (item: ChatItemPayload, sourceUrl: string) => {
     support_measures: resolveFieldText(card?.support_methods_standards),
     apply_conditions: resolveFieldText(card?.application_conditions),
     match_reason: card?.match_reason?.text || item.match_reason || '',
-    apply_link: sourceUrl,
+    // 来源 URL:详情顶部「事项」跳转仍用它(一网通办事项页)
+    apply_link: getSourceUrl(source),
+    ...(policyId ? { 政策id: policyId } : {}),
+    ...(policyName ? { 政策名称: policyName } : {}),
     // 新协议独有字段,经 normalizePolicy 保留在 originalData 里供详情面板新增区块使用
     conditions: Array.isArray(item.conditions) ? item.conditions : [],
     match_basis: Array.isArray(item.match_basis) ? item.match_basis : [],
@@ -349,7 +386,10 @@ export const buildPolicyTableContent = (
   }
 
   const data = items.map((item) =>
-    toPolicyTableItem(item, getSourceUrl(sources.find((source) => source?.id === item.source_id))),
+    toPolicyTableItem(
+      item,
+      sources.find((source) => source?.id === item.source_id),
+    ),
   );
 
   return `${POLICY_TABLE_START} ${JSON.stringify({ data })} ${POLICY_TABLE_END}`;
@@ -745,6 +785,11 @@ export type ApiChatEventMap = {
   close: undefined;
   loadingState: { type: string; state: boolean };
   totalResponse: ApiChatTotalResponsePayload;
+  /**
+   * `result` 一到且带 company_info 就发(往往早于 done/totalResponse)。
+   * 应用侧可在正文已开始渲染后立刻弹推荐登录,不必等整轮结束。
+   */
+  companyInfo: { company_info: unknown };
 };
 
 export interface ApiChatCoordinatorArgs {
@@ -775,8 +820,6 @@ export class ApiChatCoordinator {
   private pendingSummary: ChatSummaryPayload | null = null;
   private pendingInterrupt: ChatInterruptPayload | null = null;
   private pendingCompanyInfo: unknown = null;
-  /** 本轮是否需要展示企业微信二维码(result.cipa) */
-  private pendingCipa = false;
   /** 正文流状态(start/delta/end/abort 折算;见 answer-stream.ts) */
   private answerStream: AnswerStreamState = createAnswerStreamState();
   /** 增量规整器:让 delta 通道发出的内容恒等于最终文本的逐步前缀 */
@@ -1002,7 +1045,6 @@ export class ApiChatCoordinator {
     this.pendingSummary = null;
     this.pendingInterrupt = null;
     this.pendingCompanyInfo = null;
-    this.pendingCipa = false;
     this.answerStream = createAnswerStreamState();
     this.answerStreamNormalizer = createIncrementalMarkdownNormalizer();
     this.contentFlushed = false;
@@ -1197,13 +1239,8 @@ export class ApiChatCoordinator {
       });
     }
 
-    // 企业微信二维码:位置在**参考资料之前**。
-    // ⚠️ 补问轮(interrupt)不展示:那时界面上是补问卡片,还没给出正文回答。
-    if (this.pendingCipa && !this.pendingInterrupt) {
-      parts.push({ key: 'cipa', text: buildCipaQrcodeContent() });
-    }
-
-    // 参考资料放在最后(引用来源,排在正文、卡片与二维码之后)
+    // 参考资料放在最后(引用来源,排在正文与卡片之后)
+    // 📌 2026-11-02:不再按 result.cipa 注入企业微信二维码(正文自带图片 URL)
     const refLinks = buildRefLinksContent(this.pendingSources);
     if (refLinks) {
       parts.push({ key: 'refs', text: refLinks });
@@ -1213,14 +1250,13 @@ export class ApiChatCoordinator {
   }
 
   /** 尾部各块的最终顺序(重排判断用) */
-  private static readonly TAIL_ORDER = ['notices', 'interrupt', 'cipa', 'refs'];
+  private static readonly TAIL_ORDER = ['notices', 'interrupt', 'refs'];
 
   /**
    * **正文定稿就把「数据已就绪」的尾部立即上屏**,不等 done。
    *
    * `done` 要等 `result`(375~390KB 的完整快照,实测比正文定稿晚 3~10 秒),
-   * 而 `notices` / 参考资料的数据早就到了。只发数据已就绪的块:二维码来自 `result.cipa`,
-   * 只能等 done,那时再插到参考资料之前(见 `flushContent` 的重排分支)。
+   * 而 `notices` / 参考资料的数据早就到了。
    * 触发点选在 `summary`:它到了 `notices` 才齐,否则 notices 会排在参考资料之后。
    *
    * 两种情况不抢跑(提前发反而要在 done 时抹回来):卡片没提前上屏、`answer` 概述要保留。
@@ -1237,7 +1273,7 @@ export class ApiChatCoordinator {
     }
 
     const pending = this.buildTrailingParts(this.answerStream.text).filter(
-      (part) => part.key !== 'cipa' && !this.tailSent.has(part.key)
+      (part) => !this.tailSent.has(part.key)
     );
     if (!pending.length) {
       return;
@@ -1384,11 +1420,14 @@ export class ApiChatCoordinator {
         break;
 
       // result.response 与 answer.text 相同(最终快照),不再输出;
-      // 但 company_info 只有这里有,暂存下来等 done 时随 totalResponse 交给应用侧
+      // company_info 暂存供 totalResponse,并立刻 emit 一份给应用侧(可提前弹登录气泡)
       case 'result': {
         const result = data as ChatResultPayload;
         this.pendingCompanyInfo = result.company_info ?? null;
-        this.pendingCipa = result.cipa === true;
+        // result.cipa 已停用:不再注入前端二维码(见文件头说明)
+        if (this.pendingCompanyInfo != null) {
+          this._eventbus.emit('companyInfo', { company_info: this.pendingCompanyInfo });
+        }
         break;
       }
 

+ 7 - 1
src/components/business-assistant/scroll-list-bottom.ts

@@ -1,10 +1,11 @@
 export type BusinessAssistantScrollList = {
   scrollToBottom?: () => void;
+  scrollToBottomFollow?: () => void;
   scrollToBottomInstant?: () => void;
   scrollToBottomOnce?: () => void;
 };
 
-export type BusinessAssistantScrollBottomMode = "default" | "instant" | "once";
+export type BusinessAssistantScrollBottomMode = "default" | "instant" | "once" | "follow";
 
 export const scrollBusinessAssistantListToBottom = (
   scrollList: BusinessAssistantScrollList | null | undefined,
@@ -19,6 +20,11 @@ export const scrollBusinessAssistantListToBottom = (
     return;
   }
 
+  if (mode === "follow" && typeof scrollList.scrollToBottomFollow === "function") {
+    scrollList.scrollToBottomFollow();
+    return;
+  }
+
   if (mode === "once" && typeof scrollList.scrollToBottomOnce === "function") {
     scrollList.scrollToBottomOnce();
     return;

+ 63 - 4
src/components/business-assistant/useBusinessAssistantChat.ts

@@ -30,10 +30,19 @@ import {
 } from './shared';
 import { buildTestDocumentLineStreamChunks } from './test-document-line-stream';
 
-import { getChatHistoryStorageKey, enterpriseInfo } from '@/components/useEnterpriseAuth';
+import {
+  getChatHistoryStorageKey,
+  enterpriseInfo,
+  withEnterpriseQuestionPrefix,
+} from '@/components/useEnterpriseAuth';
 import { fetchRemoteSessionRecords, deleteSessionInfo, type RemoteSession } from '@/network/api/chat-sessions';
 import { upsertDmsRecord, upsertDmsSession } from '@/network/api/dms/chat-sessions-dms';
 import { syncCompanyInfoFromChat } from '@/network/api/dms/company-info-sync';
+import {
+  creditCodeFromCompanyInfo,
+  isQingpuDistrictEnterprise,
+  notifyQingpuEnterpriseLogin,
+} from '@/utils/qingpu-enterprise';
 import { hasVisibleMessageContent } from '@/utils/interrupted-message';
 import { applyQuestionCardsAnswers } from '@/utils/question-cards-answers';
 import {
@@ -295,6 +304,27 @@ export function useBusinessAssistantChat(options: UseBusinessAssistantChatOption
      * 这样 `<scope>` 进度标记等此前已上屏的内容不会被误伤。
      */
     const stream = { active: false, streamId: '', baseIndex: -1, baseText: '', body: '', lastHistorySaveAt: 0 };
+    /** 区内企业推荐登录:等正文开始渲染后再弹,不必等整轮结束 */
+    let answerBodyStarted = false;
+    let pendingQingpuCompanyInfo: unknown = null;
+    let qingpuBubbleNotified = false;
+
+    const tryNotifyQingpuLoginBubble = () => {
+      if (qingpuBubbleNotified || !pendingQingpuCompanyInfo || !answerBodyStarted) return;
+      if (isEnterpriseLoggedIn()) {
+        pendingQingpuCompanyInfo = null;
+        return;
+      }
+      if (!isQingpuDistrictEnterprise(pendingQingpuCompanyInfo)) {
+        pendingQingpuCompanyInfo = null;
+        return;
+      }
+      const code = creditCodeFromCompanyInfo(pendingQingpuCompanyInfo);
+      if (!code) return;
+      notifyQingpuEnterpriseLogin(code);
+      qingpuBubbleNotified = true;
+      pendingQingpuCompanyInfo = null;
+    };
 
     /** 流式相关诊断日志(仅非生产环境):内容被整块改写的问题只能靠它定位是哪条路径改的 */
     const debugStream = (tag: string, detail: Record<string, unknown>) => {
@@ -410,10 +440,29 @@ export function useBusinessAssistantChat(options: UseBusinessAssistantChatOption
       if (tasks.value.get(sessionId) !== task) return;
       if (!getSessionById(sessionId)) return;
       // 流式时这条通道上跑的就是正文增量:自己留一份,收尾对齐/重排/撤稿都以它为准
-      if (stream.active) stream.body += msg;
+      if (stream.active) {
+        stream.body += msg;
+        // 正文增量已开始上屏(不是仅有卡片/思考 scope)→ 允许弹区内登录气泡
+        if (!answerBodyStarted && stream.body.trim()) {
+          answerBodyStarted = true;
+          tryNotifyQingpuLoginBubble();
+        }
+      } else if (!answerBodyStarted && String(msg || '').trim()) {
+        // 非流式:flush 出来的正文块也算「已开始渲染」
+        answerBodyStarted = true;
+        tryNotifyQingpuLoginBubble();
+      }
       task.chunkBuffer.push(msg);
     });
 
+    // result 常早于 done:拿到 company_info 就排队,等正文开始渲染后再弹
+    coordinator?.addEventListener('companyInfo', (payload: any) => {
+      if (tasks.value.get(sessionId) !== task) return;
+      if (payload?.company_info == null) return;
+      pendingQingpuCompanyInfo = payload.company_info;
+      tryNotifyQingpuLoginBubble();
+    });
+
     coordinator?.addEventListener('totalResponse', (payload: any) => {
       if (tasks.value.get(sessionId) !== task) return;
       const session = getSessionById(sessionId);
@@ -434,6 +483,13 @@ export function useBusinessAssistantChat(options: UseBusinessAssistantChatOption
       // (fire-and-forget:内部全程 try/catch + 只 warn,不阻塞也不影响聊天)
       if (payload?.company_info) syncCompanyInfoFromChat(payload.company_info);
 
+      // 兜底:若 result 很晚才到 / 漏听 companyInfo,收尾时再试一次(正文此时必已上屏)
+      if (payload?.company_info && !qingpuBubbleNotified) {
+        answerBodyStarted = true;
+        pendingQingpuCompanyInfo = payload.company_info;
+        tryNotifyQingpuLoginBubble();
+      }
+
       // 顺带把企业相关的值写进 1887「助手会话」:未登录时只在本轮确实带回了 company_info
       // 时写,登录后用登录态的值覆盖(写哪些、谁覆盖谁见 upsertDmsSession 的注释)
       void upsertDmsSession({
@@ -563,6 +619,9 @@ export function useBusinessAssistantChat(options: UseBusinessAssistantChatOption
     const pendingAiMessage = ensurePendingAiMessage(session.messages);
     inputText.value = '';
 
+    // 登录后发给后端 / 写入 DMS 的 question 在原文前拼公司名;界面气泡仍用用户原文
+    const questionForBackend = withEnterpriseQuestionPrefix(text);
+
     // 本轮独立的协调器:thread_id 就是这个会话 id;实例的生命周期与本轮任务一致
     const coordinator = new ApiChatCoordinator({
       baseUrl: getChatApiBaseUrl(),
@@ -579,14 +638,14 @@ export function useBusinessAssistantChat(options: UseBusinessAssistantChatOption
     saveTurnToDms({
       sessionId: session.id,
       recordId: pendingAiMessage.id,
-      question: text,
+      question: questionForBackend,
       // 附件路径一并落库:直接复用给后端的那两份,
       // 保证 **DMS 里存的就是后端收到的**(相对路径),不会各存一份口径不同的地址
       images: attachmentsForBackend.pictures,
       files: attachmentsForBackend.files,
     });
 
-    void coordinator.generateAnswer(text, attachmentsForBackend);
+    void coordinator.generateAnswer(questionForBackend, attachmentsForBackend);
   };
 
   const playMockStreamMessage = async ({

+ 145 - 17
src/components/useEnterpriseAuth.ts

@@ -6,11 +6,95 @@ const AUTH_HISTORY_KEY = 'ba_chat_history';
 const AUTH_CURRENT_SESSION_KEY = 'ba_current_session_id';
 const ENTERPRISE_INFO_KEY = 'ba_enterprise_info';
 const AUTH_TOKEN_KEY = 'ba_auth_token';
+/** 登录快照:公司名、信用代码、是否登录 —— 刷新可恢复;退出时清掉 */
+const LOGIN_STATE_KEY = 'ba_enterprise_login';
+
+export type EnterpriseLoginState = {
+  isLoggedIn: boolean;
+  name: string;
+  credit_code: string;
+};
 
 export const enterpriseInfo = ref<EnterpriseInfo | null>(null);
 const authLoading = ref(false);
 const authError = ref(false);
 
+function readLoginState(): EnterpriseLoginState | null {
+  try {
+    const raw = localStorage.getItem(LOGIN_STATE_KEY);
+    if (!raw) return null;
+    const parsed = JSON.parse(raw) as EnterpriseLoginState;
+    if (!parsed || typeof parsed !== 'object') return null;
+    return {
+      isLoggedIn: parsed.isLoggedIn === true,
+      name: String(parsed.name || '').trim(),
+      credit_code: String(parsed.credit_code || '').trim(),
+    };
+  } catch {
+    return null;
+  }
+}
+
+function persistLoginState(info: Pick<EnterpriseInfo, 'name' | 'credit_code'>) {
+  const state: EnterpriseLoginState = {
+    isLoggedIn: true,
+    name: String(info.name || '').trim(),
+    credit_code: String(info.credit_code || '').trim(),
+  };
+  localStorage.setItem(LOGIN_STATE_KEY, JSON.stringify(state));
+}
+
+function clearPersistedAuth() {
+  localStorage.removeItem(LOGIN_STATE_KEY);
+  localStorage.removeItem(ENTERPRISE_INFO_KEY);
+  localStorage.removeItem(AUTH_TOKEN_KEY);
+}
+
+function applyEnterpriseGlobals(creditCode: string) {
+  (globalThis as any).credit_code = creditCode;
+  (globalThis as any).transmission = {
+    ...((globalThis as any).transmission || {}),
+    credit_code: creditCode,
+  };
+}
+
+function clearEnterpriseGlobals() {
+  globalThis.authToken = undefined;
+  globalThis.token = undefined;
+  (globalThis as any).credit_code = undefined;
+  if ((globalThis as any).transmission) {
+    delete (globalThis as any).transmission.credit_code;
+  }
+}
+
+function applyLoggedInEnterprise(info: EnterpriseInfo) {
+  enterpriseInfo.value = info;
+  const cc = info.credit_code || '';
+  applyEnterpriseGlobals(cc);
+  persistLoginState(info);
+  localStorage.setItem(ENTERPRISE_INFO_KEY, JSON.stringify(info));
+}
+
+/**
+ * 登录后发给 `/api/chat` 的 question:在用户原文前拼公司名。
+ * 纯函数便于单测;界面消息仍用原文;补问协议串不要走这里。
+ */
+export function buildEnterpriseQuestionPrefix(
+  enterpriseName: string | null | undefined,
+  question: string,
+): string {
+  const text = String(question || '').trim();
+  if (!text) return text;
+  const name = String(enterpriseName || '').trim();
+  if (!name) return text;
+  if (text.startsWith(name)) return text;
+  return `${name}:${text}`;
+}
+
+export function withEnterpriseQuestionPrefix(question: string): string {
+  return buildEnterpriseQuestionPrefix(enterpriseInfo.value?.name, question);
+}
+
 // Global fetch interceptor: any 401 response → clear enterprise info (logout)
 (function setupFetchInterceptor() {
   if (typeof window === 'undefined') return;
@@ -19,10 +103,8 @@ const authError = ref(false);
     const response = await originalFetch(...args);
     if (response.status === 401 && enterpriseInfo.value) {
       enterpriseInfo.value = null;
-      globalThis.authToken = undefined;
-      globalThis.token = undefined;
-      localStorage.removeItem(ENTERPRISE_INFO_KEY);
-      localStorage.removeItem(AUTH_TOKEN_KEY);
+      clearEnterpriseGlobals();
+      clearPersistedAuth();
     }
     return response;
   };
@@ -58,6 +140,60 @@ export function useEnterpriseAuth() {
   const enterpriseName = computed(() => enterpriseInfo.value?.name || '');
   const creditCode = computed(() => enterpriseInfo.value?.credit_code || '');
 
+  const restoreFromLoginState = () => {
+    const state = readLoginState();
+    if (!state?.isLoggedIn || !state.credit_code) return false;
+
+    const token = localStorage.getItem(AUTH_TOKEN_KEY) || '';
+    if (token) {
+      globalThis.authToken = token;
+      globalThis.token = token;
+    }
+
+    // 优先用完整企业信息缓存;没有则用快照里的公司名 + 信用代码撑起登录态
+    try {
+      const fullRaw = localStorage.getItem(ENTERPRISE_INFO_KEY);
+      if (fullRaw) {
+        const full = JSON.parse(fullRaw) as EnterpriseInfo;
+        if (full?.credit_code) {
+          applyLoggedInEnterprise({
+            ...full,
+            name: full.name || state.name,
+            credit_code: full.credit_code || state.credit_code,
+          });
+          return true;
+        }
+      }
+    } catch {
+      /* 损坏则走快照 */
+    }
+
+    applyLoggedInEnterprise({
+      credit_code: state.credit_code,
+      name: state.name || state.credit_code,
+      regno: '',
+      peid: '',
+      op_from: '',
+      op_to: '',
+      es_date: '',
+      appr_date: '',
+      reg_cap: 0,
+      op_scope: '',
+      dom: '',
+      ent_type_name: '',
+      industry_phy_name: '',
+      industry_co_name: '',
+      reg_org_name: '',
+      reg_org_province: '',
+      reg_org_city: '',
+      reg_org_county: '',
+      reg_cap_cur_name: '',
+      ent_status_name: '',
+      fr_name: '',
+    });
+    return true;
+  };
+
   const initAuth = async () => {
     const creditCodeParam = getQueryParamUniversal('credit_code');
     const accessToken = getQueryParamUniversal('access_token');
@@ -95,7 +231,8 @@ export function useEnterpriseAuth() {
       return await initAuthWithCreditCode(creditCodeParam);
     }
 
-    // 3. 无参数: 保持未登录状态
+    // 3. 无参数: 从本地登录快照恢复(公司名 / 信用代码 / isLoggedIn)
+    restoreFromLoginState();
   };
 
   const initAuthWithCreditCode = async (creditCodeParam: string) => {
@@ -105,14 +242,7 @@ export function useEnterpriseAuth() {
     try {
       const info = await fetchEnterpriseInfo(creditCodeParam);
       if (info) {
-        enterpriseInfo.value = info;
-        const cc = info.credit_code || creditCodeParam;
-        (globalThis as any).credit_code = cc;
-        (globalThis as any).transmission = {
-          ...((globalThis as any).transmission || {}),
-          credit_code: cc,
-        };
-        localStorage.setItem(ENTERPRISE_INFO_KEY, JSON.stringify(info));
+        applyLoggedInEnterprise(info);
       }
     } catch {
       authError.value = true;
@@ -123,10 +253,8 @@ export function useEnterpriseAuth() {
 
   const logout = () => {
     enterpriseInfo.value = null;
-    globalThis.authToken = undefined;
-    globalThis.token = undefined;
-    localStorage.removeItem(ENTERPRISE_INFO_KEY);
-    localStorage.removeItem(AUTH_TOKEN_KEY);
+    clearEnterpriseGlobals();
+    clearPersistedAuth();
   };
 
   const redirectToLogin = () => {

+ 3 - 0
src/network/api/dms/chat-sessions-dms.ts

@@ -67,6 +67,9 @@ export const resolveDmsCreditCode = (): string =>
  *
  * ⚠️ 故意传空值:它们是运营分析口径,取值由业务方决定,不要顺手填业务判断。
  * ⚠️ **只在新增(addContent)时带**:更新时不带,否则会把后端回填的值冲成空。
+ * ⚠️ **这里写裸名,不要加 `c_`**:互联网模型里它们本来就不带 `c_`;内网克隆只加一层,
+ *    线上名是 `c_summary` / `c_qpyszx` / `c_qyzt` / `c_rzqpyx`(不是 `c_c_*`)。
+ *    映射统一在 `client.ts` 的 `encodeDmsFieldName` / `decodeDmsFieldName` 里。
  */
 const buildRequiredSessionFields = (): DmsRow => ({
   summary: "",

+ 25 - 4
src/network/api/dms/client.ts

@@ -67,19 +67,40 @@ export const isDmsFieldDoubleCPrefix = (): boolean =>
   Boolean(readDmsRuntimeConfig().fieldDoubleCPrefix);
 
 /**
- * 业务字段名 → 线上字段名。只处理以 `c_` 开头的自定义列;`id` / `title` 等不动。
+ * 互联网模型里**本来就不带 `c_`** 的遗留运营字段。
+ *
+ * 内网模型是克隆出来的:克隆给所有字段加一层 `c_` ——
+ *   - 原本就是 `c_question` 的 → `c_c_question`(双层)
+ *   - 原本是 `summary` 的     → `c_summary`(**单层**,不是 `c_c_summary`)
+ * 所以这四个字段不能走「只给 c_ 开头字段加层」的通用规则,要单独映射。
+ */
+const DMS_LEGACY_BARE_FIELDS = new Set(["summary", "qpyszx", "qyzt", "rzqpyx"]);
+
+/**
+ * 业务字段名 → 线上字段名。
+ * - 遗留裸字段(summary 等)在内网补一层 `c_`;
+ * - 其它以 `c_` 开头的业务列在内网再叠一层(`c_*` → `c_c_*`);
+ * - `id` / `title` 等系统字段不动。
  */
 export const encodeDmsFieldName = (field: string): string => {
   if (!isDmsFieldDoubleCPrefix()) return field;
+  if (DMS_LEGACY_BARE_FIELDS.has(field)) return `c_${field}`;
   if (!field.startsWith("c_") || field.startsWith("c_c_")) return field;
   return `c_${field}`;
 };
 
-/** 线上字段名 → 业务字段名(`c_c_question` → `c_question`) */
+/**
+ * 线上字段名 → 业务字段名。
+ * - `c_c_question` → `c_question`;
+ * - 遗留字段 `c_summary` → `summary`。
+ */
 export const decodeDmsFieldName = (field: string): string => {
   if (!isDmsFieldDoubleCPrefix()) return field;
-  if (!field.startsWith("c_c_")) return field;
-  return field.slice(2);
+  if (field.startsWith("c_c_")) return field.slice(2);
+  if (field.startsWith("c_") && DMS_LEGACY_BARE_FIELDS.has(field.slice(2))) {
+    return field.slice(2);
+  }
+  return field;
 };
 
 const mapRowKeys = (row: DmsRow, mapKey: (key: string) => string): DmsRow => {

+ 4 - 3
src/network/api/nls-token.ts

@@ -1,8 +1,9 @@
 /**
- * 取阿里云 NLS 的 token(实时语音识别用)——**走后端网关**。
+ * 取阿里云 NLS 的 token(实时语音识别用)。
  *
- * 端点是 `{VITE_GATEWAY_API}/proxy/verify/getALYToken`(默认 `/api/…`,同源路径:
- * 与取本机 IP 共用一条代理;dev 由 vite 代理,生产由 nginx 转发)。
+ * 2026-10-28 起**不再走 `/api` 反向代理**,直接请求 HTTPS 地址
+ * `https://kdyjs-proxy.metamaker.cn/proxy_proxy/proxy/verify/getALYToken`
+ * (该地址带 `Access-Control-Allow-Origin: *`,浏览器可跨域直连)。
  * 返回形态:`{ code: 200, message: "成功", content: "<32 位 token>" }`。
  *
  * **前端不持有任何阿里云凭据**:签名要 AccessKeySecret,而前端 bundle 是公开的,

+ 16 - 55
src/utils/policy-library-loader.ts

@@ -1,19 +1,17 @@
 /**
- * 惠企政策库加载(只读):
- * 远端路径来自 `public/config.js` 的 `dms.policyRemotePath`
- * (DMS uploadFile 会改名,必须填实际上传返回的相对路径)。
- * 未配置或取不到 → 随包本地副本。
+ * 惠企政策库加载(只读)。
+ *
+ * 2026-10-28 用户要求:**不再上传、不再读 DMS 远端**,所有情况都用随包本地副本
+ * `public/merchant-agent/policies_public.v2.json`
+ * (内容为 2026-10-28 的标准库;时间戳原件已删除,只保留这一份)。
+ *
+ * 启动时由 `main.ts` 调用 `ensurePolicyLibrary()`;应用不等待它(读取方每次现读
+ * `globalThis.policiesPublic`)。
  */
 
-import { getDmsApiBaseUrl } from "@/utils/runtime-config";
-
 export const POLICY_LIBRARY_FILE_NAME = "policies_public.v2.json";
 export const POLICY_LIBRARY_LOCAL_URL = `/merchant-agent/${POLICY_LIBRARY_FILE_NAME}`;
 
-type FetchResult =
-  | { ok: true; data: unknown }
-  | { ok: false; status: number; error: unknown };
-
 const applyPolicies = (data: unknown, source: string): void => {
   const list = Array.isArray(data) ? data : (data as { data?: unknown })?.data;
   globalThis.policiesPublic = Array.isArray(list) ? list : [];
@@ -23,58 +21,21 @@ const applyPolicies = (data: unknown, source: string): void => {
   ); */
 };
 
-const fetchPolicyJson = async (url: string): Promise<FetchResult> => {
+const loadLocalPolicyLibrary = async (): Promise<void> => {
   try {
-    const response = await fetch(url);
+    const response = await fetch(POLICY_LIBRARY_LOCAL_URL);
     if (!response.ok) {
-      return { ok: false, status: response.status, error: new Error(`HTTP ${response.status}`) };
+      throw new Error(`HTTP ${response.status}`);
     }
     const data = await response.json();
-    return { ok: true, data };
+    applyPolicies(data, "local");
   } catch (error) {
-    return { ok: false, status: 0, error };
+    /* console.warn("[zhaoshang] 政策列表本地加载失败:", error); */
+    globalThis.policiesPublic = [];
   }
 };
 
-/** 读 config.js 里配置的 DMS 相对路径(空 = 不走远端) */
-export const getPolicyLibraryRemotePath = (): string => {
-  const root = (globalThis as { __ZHAOSHANG_CONFIG__?: { dms?: { policyRemotePath?: string } } })
-    .__ZHAOSHANG_CONFIG__;
-  return String(root?.dms?.policyRemotePath || "").trim();
-};
-
-/** 拼出可 fetch 的完整 URL;未配置远端时返回空 */
-export const getPolicyLibraryRemoteUrl = (): string => {
-  const rel = getPolicyLibraryRemotePath();
-  if (!rel) return "";
-  if (/^https?:\/\//i.test(rel)) return rel;
-  const base = getDmsApiBaseUrl();
-  if (!base) return "";
-  return `${base}${rel.startsWith("/") ? "" : "/"}${rel}`;
-};
-
-const loadLocalFallback = async (): Promise<void> => {
-  const local = await fetchPolicyJson(POLICY_LIBRARY_LOCAL_URL);
-  if (local.ok) {
-    applyPolicies(local.data, "local");
-    return;
-  }
-  /* console.warn("[zhaoshang] 政策列表本地兜底也失败:", local.error); */
-  globalThis.policiesPublic = [];
-};
-
-/** 启动时调用:config 远端 → 本地兜底(不上传)。 */
+/** 启动时调用:始终读取随包本地副本(不再有远端/上传路径)。 */
 export const ensurePolicyLibrary = async (): Promise<void> => {
-  const remoteUrl = getPolicyLibraryRemoteUrl();
-
-  if (remoteUrl) {
-    const remote = await fetchPolicyJson(remoteUrl);
-    if (remote.ok) {
-      applyPolicies(remote.data, "dms");
-      return;
-    }
-    /* console.warn("[zhaoshang] 政策列表远端不可用,改用本地:", remoteUrl, remote.error); */
-  }
-
-  await loadLocalFallback();
+  await loadLocalPolicyLibrary();
 };

+ 93 - 0
src/utils/qingpu-enterprise.ts

@@ -0,0 +1,93 @@
+/**
+ * 区内(青浦)企业识别 + 推荐登录气泡事件。
+ *
+ * 判据:优先 `company_info.profile.data.Area.County`,其次 AreaCode / 地址 / 信用代码区划段。
+ * 气泡 UI 在 AccountInfo;回答结束后由 chat hook 派发本事件。
+ */
+
+export const ENTERPRISE_BUBBLE_EVENT = "qingpu:enterprise-notification";
+
+/** 青浦区行政区划代码(国标 6 位) */
+export const QINGPU_AREA_CODE = "310118";
+
+type Dict = Record<string, unknown>;
+
+const asRecord = (value: unknown): Dict | null =>
+  value !== null && typeof value === "object" && !Array.isArray(value)
+    ? (value as Dict)
+    : null;
+
+const asText = (value: unknown): string => {
+  if (typeof value === "string") return value.trim();
+  if (typeof value === "number" && Number.isFinite(value)) return String(value);
+  return "";
+};
+
+/** Area 可能是对象 `{ County }`,偶发整段 JSON 字符串 */
+const readAreaCounty = (area: unknown): string => {
+  if (typeof area === "string") {
+    const raw = area.trim();
+    if (!raw) return "";
+    if (raw.includes("青浦")) return raw;
+    try {
+      return readAreaCounty(JSON.parse(raw));
+    } catch {
+      return raw;
+    }
+  }
+  const obj = asRecord(area);
+  return obj ? asText(obj.County) : "";
+};
+
+const profileDataOf = (companyInfo: unknown): Dict | null => {
+  const root = asRecord(companyInfo);
+  if (!root) return null;
+  const profile = asRecord(root.profile);
+  return profile ? asRecord(profile.data) : null;
+};
+
+const companyOf = (companyInfo: unknown): Dict | null => {
+  const root = asRecord(companyInfo);
+  return root ? asRecord(root.company) : null;
+};
+
+/** 从 company_info 取信用代码(profile 优先) */
+export const creditCodeFromCompanyInfo = (companyInfo: unknown): string => {
+  const profile = profileDataOf(companyInfo);
+  const company = companyOf(companyInfo);
+  return asText(profile?.CreditCode) || asText(company?.CreditCode);
+};
+
+/**
+ * 是否青浦区内企业。
+ * 主:Area.County 含「青浦」;次:AreaCode 以 310118 开头;
+ * 再:Address 含「青浦区」;末:信用代码第 3–8 位为 310118。
+ */
+export const isQingpuDistrictEnterprise = (companyInfo: unknown): boolean => {
+  const profile = profileDataOf(companyInfo);
+  const company = companyOf(companyInfo);
+  if (!profile && !company) return false;
+
+  const county = readAreaCounty(profile?.Area);
+  if (county.includes("青浦")) return true;
+
+  const areaCode = asText(profile?.AreaCode);
+  if (areaCode.startsWith(QINGPU_AREA_CODE)) return true;
+
+  const address = asText(profile?.Address) || asText(company?.Address);
+  if (address.includes("青浦区")) return true;
+
+  const creditCode = creditCodeFromCompanyInfo(companyInfo);
+  if (creditCode.length >= 8 && creditCode.slice(2, 8) === QINGPU_AREA_CODE) return true;
+
+  return false;
+};
+
+/** 未登录且识别为区内企业时弹出推荐登录气泡(AccountInfo 监听) */
+export const notifyQingpuEnterpriseLogin = (creditCode: string): void => {
+  const code = String(creditCode || "").trim();
+  if (!code || typeof document === "undefined") return;
+  document.dispatchEvent(
+    new CustomEvent(ENTERPRISE_BUBBLE_EVENT, { detail: { creditCode: code } }),
+  );
+};

+ 12 - 3
src/utils/runtime-config.ts

@@ -65,9 +65,18 @@ export function getGatewayApiBaseUrl() {
 }
 
 /**
- * NLS token 完整 URL——后端网关 `getALYToken`。
- * 前缀用 `VITE_GATEWAY_API`;路径 `/proxy/verify/getALYToken` 在此拼接(勿写进 env)。
+ * NLS token 的完整 URL。
+ *
+ * 2026-10-28 用户要求:**不再走 `/api` 反向代理**,浏览器直连该 HTTPS 地址。
+ * 该地址返回 `{code,message,content}` 且带 `Access-Control-Allow-Origin: *`,
+ * 不受同源/混合内容限制;可用 env / `globalThis.VITE_NLS_TOKEN_URL` 覆盖。
  */
+const NLS_TOKEN_URL_BUILTIN =
+  "https://kdyjs-proxy.metamaker.cn/proxy_proxy/proxy/verify/getALYToken";
+
 export function getNlsTokenApiUrl() {
-  return `${getGatewayApiBaseUrl()}/proxy/verify/getALYToken`;
+  const bootstrap = ((globalThis as any).VITE_NLS_TOKEN_URL || "") as string;
+  const fromEnv = (import.meta.env.VITE_NLS_TOKEN_URL || "") as string;
+  const value = bootstrap && bootstrap !== "%VITE_NLS_TOKEN_URL%" ? bootstrap : fromEnv;
+  return String(value || NLS_TOKEN_URL_BUILTIN).trim();
 }

+ 1 - 1
tsconfig.json

@@ -41,4 +41,4 @@
   "exclude": [
     "node_modules"
   ]
-}
+}

+ 3 - 3
vite.config.ts

@@ -22,8 +22,8 @@ const warnDmsTokenIfNeeded = (token: string): void => {
     dmsTokenWarnedFor = "missing";
     console.warn(
       `\n[dms] ⚠️ 没有 DMS token,DMS 读写(会话/问答记录/反馈)会失败,聊天本身不受影响。\n` +
-        `[dms]    最省事:在浏览器里复制 token,然后跑 \`npm run dms:token\`(从剪贴板读)。\n` +
-        `[dms]    文件位置:${DMS_TOKEN_FILE}\n`
+      `[dms]    最省事:在浏览器里复制 token,然后跑 \`npm run dms:token\`(从剪贴板读)。\n` +
+      `[dms]    文件位置:${DMS_TOKEN_FILE}\n`
     );
     return;
   }
@@ -105,7 +105,7 @@ export default defineConfig(() => {
         // 聊天后端(POST /api/chat,SSE):真实路径是 /api/chat,与前端前缀不同名 ⇒ 剥前缀。
         // 对应 .env.development 中 VITE_CHAT_API="/chat-api"。
         "/chat-api/": {
-          target: "http://192.168.2.23:8000",
+          target: "http://192.168.2.69:8001",
           changeOrigin: true,
           rewrite: (path) => path.replace(/^\/chat-api/, ""),
         },

Some files were not shown because too many files changed in this diff