feat(chat): 完善固资预览与下载权限
This commit is contained in:
1 parent
6ce0942fef
commit
bf18a7ef1d
19 files changed
+1163
-86
No files matched your search
@@ -16,6 +16,21 @@ interface UseChatAssetHistoryOptions {
|
||||
warn: (message: string) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把后端返回的技术性错误翻译成用户可理解的提示。
|
||||
* AI 触发时机:当资产履历查询失败,但原始错误包含英文配置名、共享盘术语等技术细节时调用。
|
||||
* 核心逻辑:优先识别已知的履历共享盘配置异常,返回面向业务用户的中文说明;其他错误保持原文,避免吞掉真实上下文。
|
||||
* 参数约束:仅处理展示文案,不改变错误对象本身;返回值必须适合作为 toast/警告弹窗直接展示。
|
||||
*/
|
||||
function normalizeAssetHistoryErrorMessage(message: string): string {
|
||||
const normalizedMessage = String(message || '').trim();
|
||||
const lowerCaseMessage = normalizedMessage.toLowerCase();
|
||||
if (lowerCaseMessage.includes('asset history share is not configured')) {
|
||||
return '当前系统暂未配置资产履历文件目录,暂时无法查看履历,请联系管理员处理。';
|
||||
}
|
||||
return normalizedMessage || '检索资产履历失败';
|
||||
}
|
||||
|
||||
export function useChatAssetHistory(options: UseChatAssetHistoryOptions) {
|
||||
const open = ref(false);
|
||||
const loading = ref(false);
|
||||
@@ -35,7 +50,7 @@ export function useChatAssetHistory(options: UseChatAssetHistoryOptions) {
|
||||
* 检索资产履历并直接打开最佳预览结果。
|
||||
* AI 触发时机:当用户点击聊天表格中的“资产编号”,希望直接查看该资产履历时调用。
|
||||
* 核心逻辑:点击后先切入“检索中”状态,再按“资产编号 + 资产名称”查询共享盘候选文件,命中后默认取排序最优的第一条直接预览;
|
||||
* 未命中或查询失败时,仅给用户展示友好提示,不再弹出中间候选列表。
|
||||
* 未命中或查询失败时,仅给用户展示友好提示,不再弹出中间候选列表;若后端返回技术性英文报错,会先转换成业务可读提示。
|
||||
* 参数约束:至少要提供资产编号或资产名称之一;候选文件排序由后端负责,本方法默认信任第一条结果。
|
||||
*/
|
||||
const openHistory = async (nextAssetId: string, nextAssetName = '') => {
|
||||
@@ -69,7 +84,8 @@ export function useChatAssetHistory(options: UseChatAssetHistoryOptions) {
|
||||
}
|
||||
await openHistoryFilePreview(bestMatch);
|
||||
} catch (err: unknown) {
|
||||
const message = err instanceof Error ? err.message : '检索资产履历失败';
|
||||
const rawMessage = err instanceof Error ? err.message : '检索资产履历失败';
|
||||
const message = normalizeAssetHistoryErrorMessage(rawMessage);
|
||||
error.value = message;
|
||||
options.warn(`履历查询失败:${message}`);
|
||||
} finally {
|
||||
|
||||
Reference in new issue
Block a user