刘光辉
119 分钟以前 cf11e63b659afcc9792ab3e395f1b45d844431a8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import type { DmsApiResult } from './fileCenter';
 
import { defHttp } from '#/api/request';
 
export interface DmsCompareSession {
  config: Record<string, any>;
  expiresAt: number;
  title: string;
}
 
export async function createDmsCompareSession(data: { currentVersionId: string; documentId: string; historicalVersionId: string; operationId: string }) {
  const options = { errorMessageMode: 'none' as const };
  const ticket = await defHttp.post<DmsApiResult<{ ticket: string }>>({ url: '/api/dms/file-compare-tickets', data }, options);
  if (!ticket.data?.ticket) throw new Error('未能创建版本比较会话');
  const response = await defHttp.post<DmsApiResult<DmsCompareSession>>(
    { url: '/api/biz/onlyoffice/compare/config', timeout: 120_000, data: { ticket: ticket.data.ticket } },
    options,
  );
  if (!response.data?.config || response.data.config.editorConfig?.mode !== 'view' || response.data.config.document?.permissions?.edit !== false)
    throw new Error('版本比较配置不完整');
  return response.data;
}