Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions apps/desktop/src/main/gateway/document-gateway-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import type {
CompleteExternalDocumentPatchInput,
ExternalDocumentProjectionBinding,
ImportRoomDocumentInput,
MoveRoomDocumentsResult,
MovedRoomDocument,
PreparedExternalDocumentPatch,
ExternalDocumentSourceKind,
PrepareExternalDocumentPatchInput,
Expand Down Expand Up @@ -297,6 +299,20 @@ export class DocumentGatewayBridge {
}, true)
}

move(documentId: string, fromRoomId: string, roomId: string): Promise<MovedRoomDocument> {
return this.request(`/v1/documents/${encodeURIComponent(documentId)}/move`, {
method: 'POST',
body: JSON.stringify({ fromRoomId, roomId }),
}, true)
}

moveMany(documentIds: string[], fromRoomId: string, roomId: string): Promise<MoveRoomDocumentsResult> {
return this.request('/v1/documents/move', {
method: 'POST',
body: JSON.stringify({ documentIds, fromRoomId, roomId }),
}, true)
}

delete(documentId: string): Promise<void> {
return this.request(`/v1/documents/${encodeURIComponent(documentId)}`, { method: 'DELETE' })
}
Expand Down
4 changes: 4 additions & 0 deletions apps/desktop/src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ const DOCUMENT_CHANNELS = {
import: 'documents:import',
save: 'documents:save',
delete: 'documents:delete',
move: 'documents:move',
moveMany: 'documents:move-many',
restore: 'documents:restore',
deletePermanently: 'documents:delete-permanently',
emptyTrash: 'documents:empty-trash',
Expand Down Expand Up @@ -2713,6 +2715,8 @@ function registerDocumentHandlers(
if (vaultSyncDeps) await trashDocumentInVault(vaultSyncDeps, documentId)
return deleted
},
move: (_event, documentId, fromRoomId, roomId) => bridge.move(documentId, fromRoomId, roomId),
moveMany: (_event, documentIds, fromRoomId, roomId) => bridge.moveMany(documentIds, fromRoomId, roomId),
restore: (_event, documentId) => bridge.restore(documentId),
deletePermanently: async (_event, documentId) => {
if (vaultSyncDeps) await trashDocumentInVault(vaultSyncDeps, documentId)
Expand Down
11 changes: 11 additions & 0 deletions apps/desktop/src/main/office/office-preview-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { BrowserWindow } from 'electron'
import { webContents } from 'electron'

import type { OfficeAgentFileEvent } from '../../shared/office'
import { logDesktop } from '../logging/desktop-logger'
import {
officePreviewKindForFileName,
type OfficePreviewKind,
Expand Down Expand Up @@ -160,6 +161,16 @@ export class OfficePreviewRegistry {
private wireDocsThesisHook(runtime: PreparedGenOfficeRuntime): void {
const bridge = this.thesisBridge
if (!bridge) return
// 运行时能力守卫:论文排版桥是 genoffice 后加的导出,带着旧运行时启动时它是 undefined。
// 缺了只跳过这个桥(AI 页签排版面板不可用),不能让 ensureRuntime 抛错——那会让
// 整条 open() 失败,Room 里的 Office 产物全部退回「用系统默认应用打开」。
if (typeof runtime.docs.setDocsThesisPanelHook !== 'function') {
logDesktop('office', 'warn', {
event: 'office.thesis-bridge-unavailable',
message: 'genoffice runtime 缺少 setDocsThesisPanelHook,跳过论文排版桥',
})
return
}
runtime.docs.setDocsThesisPanelHook(async (wcId, action) => {
const instance = this.findByWebContentsId(wcId)
const roomId = instance?.roomId ?? null
Expand Down
2 changes: 2 additions & 0 deletions apps/desktop/src/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,8 @@ const api: NxcoreDesktopApi = {
import: (input) => invoke('documents:import', input),
save: (documentId, input) => invoke('documents:save', documentId, input),
delete: (documentId) => invoke('documents:delete', documentId),
move: (documentId, fromRoomId, roomId) => invoke('documents:move', documentId, fromRoomId, roomId),
moveMany: (documentIds, fromRoomId, roomId) => invoke('documents:move-many', documentIds, fromRoomId, roomId),
restore: (documentId) => invoke('documents:restore', documentId),
deletePermanently: (documentId) => invoke('documents:delete-permanently', documentId),
emptyTrash: (roomId) => invoke('documents:empty-trash', roomId),
Expand Down
Loading
Loading