- 提取登录回跳、产品对比的路由匹配逻辑至独立的 match-route.uts 服务 - 修复登录页面导入对比服务的错误,改为导入新的 match-route 模块 - 保持原有的路由参数校验和跳转逻辑不变,仅重构代码结构
26 lines
1.5 KiB
Plaintext
26 lines
1.5 KiB
Plaintext
import { getSession } from '@/services/api.uts'
|
|
import { MatchDetail, MatchReason } from './matches.uts'
|
|
import { parseCompareIds } from '@/services/match-route.uts'
|
|
export { parseCompareIds, compareQuery, matchReturnPath } from '@/services/match-route.uts'
|
|
|
|
let scope = ''
|
|
let selected: string[] = []
|
|
|
|
// 只缓存少量选择ID,不持久化产品或个人事实;换账号、会话或评估后立即隔离。
|
|
export function compareSelection(assessmentId: string, revisionId: string = ''): string[] {
|
|
const session = getSession()
|
|
const key = session == null ? '' : (session.getString('userId') ?? '') + ':' + (session.getString('token') ?? '') + ':' + assessmentId + ':' + revisionId
|
|
if (key != scope || key.length == 0) { scope = key; selected = [] }
|
|
return selected.slice()
|
|
}
|
|
export function saveCompareSelection(assessmentId: string, ids: string[], revisionId: string = ''): void {
|
|
compareSelection(assessmentId, revisionId)
|
|
selected = parseCompareIds(ids.join(','))
|
|
}
|
|
export function sameMatchSnapshot(a: MatchDetail, b: MatchDetail): boolean {
|
|
return a.assessmentId == b.assessmentId && a.revisionId == b.revisionId && a.resultVersion == b.resultVersion && a.snapshotId == b.snapshotId && a.ruleVersion == b.ruleVersion && a.orderingVersion == b.orderingVersion
|
|
}
|
|
export function compareReasonText(reasons: MatchReason[], empty: string): string {
|
|
return reasons.length == 0 ? empty : reasons.map((r: MatchReason): string => r.text + '\n' + r.evidence.join('\n')).join('\n\n')
|
|
}
|