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;
|
}
|