Canvas analysis previously sent every page. Add a Magic Notes setting for 1-8 canvas pages, defaulting to 1 for new and historical settings. Select the first N pages in current canvas order before capture and use the same text/image range for saved entries, drafts and canvas-source todos. Keep full 50-page saving/export, expose the same setting through config tools, and use the shared settings select with an inline help icon. Include pagination, persistence, production IPC and isolated Electron regressions, including text-only input and scaled page boundaries. Validation: focused feature tests and isolated Electron regressions passed; the final compact UI passed 14 tests. Typecheck and lint were reported passing by the coordinating agent. No full-suite pass is claimed because the completed full test command exposed no summary. No live model calls were made for this commit preparation. Release note: 魔法笔记新增“发送画布页数”设置,可选 1~8 页,默认 1 页,按当前画布顺序发送前 N 页的文字和图片;标题旁问号可查看说明,保存和导出完整画布不受影响。
44 lines
2.5 KiB
TypeScript
44 lines
2.5 KiB
TypeScript
import { app, BrowserWindow } from 'electron'
|
|
import { writeFileSync } from 'node:fs'
|
|
import { join } from 'node:path'
|
|
import { registerIpcHandlers } from '../../src/main/ipc'
|
|
import { AssistantDatabase } from '../../src/main/assistant/assistant-database'
|
|
import { ApplicationSettingsStore } from '../../src/main/application-settings-store'
|
|
|
|
const directory = process.env.GB_NOTES_PROBE_DIRECTORY!
|
|
const url = process.env.GB_NOTES_PROBE_URL!
|
|
const preload = join(directory, 'preload.cjs')
|
|
app.setPath('userData', join(directory, 'profile'))
|
|
app.whenReady().then(async () => {
|
|
const win = new BrowserWindow({ show: false, width: 1400, height: 1000, webPreferences: {
|
|
sandbox: true, contextIsolation: true, nodeIntegration: false, backgroundThrottling: false, preload
|
|
} })
|
|
const database = new AssistantDatabase(join(directory, 'assistant.sqlite'))
|
|
database.initialize(directory)
|
|
const supportsImageInput = process.env.GB_NOTES_PROBE_VISION === 'true'
|
|
const runtimeSettings = { workspacePath: directory, supportsImageInput,
|
|
defaultModelProfileId: 'vision', modelProfiles: [{ id: 'vision', supportsImageInput }] }
|
|
const applicationSettings = new ApplicationSettingsStore(join(directory, 'application.json'))
|
|
await applicationSettings.update({ magicNoteCommentMode: 'after-save-auto', magicNoteCommentFormat: 'structured' })
|
|
const dispose = registerIpcHandlers(win, { capability: 'text' } as never, 'CommandOrControl+Shift+Space',
|
|
{ getResolvedSettings: async () => runtimeSettings, getPublicSettings: async () => runtimeSettings } as never,
|
|
{} as never, { clear() {}, cancelImport() {} } as never, {} as never, database,
|
|
{ clear() {} } as never, {} as never, async () => {}, undefined, undefined, undefined, undefined,
|
|
applicationSettings)
|
|
win.webContents.on('console-message', event => console.log(event.message))
|
|
try {
|
|
await win.loadURL(url)
|
|
for (let i = 0; i < 400; i++) {
|
|
if (await win.webContents.executeJavaScript('typeof window.notesAnalysisRegression === "function"')) break
|
|
await new Promise(resolve => setTimeout(resolve, 50))
|
|
}
|
|
const result = await win.webContents.executeJavaScript('window.notesAnalysisRegression().catch(error => ({ error: error.stack, body: document.body.innerText }))')
|
|
writeFileSync(join(directory, 'result.json'), JSON.stringify({ ...result, requests: (globalThis as typeof globalThis & { analysisRequests: unknown[] }).analysisRequests }))
|
|
} finally {
|
|
await dispose()
|
|
database.close()
|
|
win.destroy()
|
|
}
|
|
app.exit(0)
|
|
}).catch(error => { console.error(error); app.exit(1) })
|