mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-24 10:40:07 +08:00
feat(export): add image export options to markdown settings
This commit is contained in:
parent
13093bb821
commit
d521a88d30
@ -191,6 +191,11 @@ export enum IpcChannel {
|
||||
File_StartWatcher = 'file:startWatcher',
|
||||
File_StopWatcher = 'file:stopWatcher',
|
||||
File_ShowInFolder = 'file:showInFolder',
|
||||
// Image export specific channels
|
||||
File_ReadBinary = 'file:readBinary',
|
||||
File_WriteBinary = 'file:writeBinary',
|
||||
File_CopyFile = 'file:copyFile',
|
||||
File_CreateDirectory = 'file:createDirectory',
|
||||
|
||||
// file service
|
||||
FileService_Upload = 'file-service:upload',
|
||||
|
||||
@ -531,6 +531,23 @@ export function registerIpc(mainWindow: BrowserWindow, app: Electron.App) {
|
||||
ipcMain.handle(IpcChannel.File_StopWatcher, fileManager.stopFileWatcher.bind(fileManager))
|
||||
ipcMain.handle(IpcChannel.File_ShowInFolder, fileManager.showInFolder.bind(fileManager))
|
||||
|
||||
// Image export specific handlers
|
||||
ipcMain.handle(IpcChannel.File_ReadBinary, async (_, filePath: string) => {
|
||||
return fs.promises.readFile(filePath)
|
||||
})
|
||||
|
||||
ipcMain.handle(IpcChannel.File_WriteBinary, async (_, filePath: string, buffer: Buffer) => {
|
||||
return fs.promises.writeFile(filePath, buffer)
|
||||
})
|
||||
|
||||
ipcMain.handle(IpcChannel.File_CopyFile, async (_, sourcePath: string, destPath: string) => {
|
||||
return fs.promises.copyFile(sourcePath, destPath)
|
||||
})
|
||||
|
||||
ipcMain.handle(IpcChannel.File_CreateDirectory, async (_, dirPath: string) => {
|
||||
return fs.promises.mkdir(dirPath, { recursive: true })
|
||||
})
|
||||
|
||||
// file service
|
||||
ipcMain.handle(IpcChannel.FileService_Upload, async (_, provider: Provider, file: FileMetadata) => {
|
||||
const service = FileServiceManager.getInstance().getService(provider)
|
||||
|
||||
@ -151,6 +151,10 @@ export interface SettingsState {
|
||||
notionExportReasoning: boolean
|
||||
excludeCitationsInExport: boolean
|
||||
standardizeCitationsInExport: boolean
|
||||
// Image export settings
|
||||
imageExportMode: 'base64' | 'folder' | 'none'
|
||||
imageExportQuality: number
|
||||
imageExportMaxSize: number
|
||||
yuqueToken: string | null
|
||||
yuqueUrl: string | null
|
||||
yuqueRepoId: string | null
|
||||
@ -333,6 +337,10 @@ export const initialState: SettingsState = {
|
||||
notionExportReasoning: false,
|
||||
excludeCitationsInExport: false,
|
||||
standardizeCitationsInExport: false,
|
||||
// Image export settings
|
||||
imageExportMode: 'none',
|
||||
imageExportQuality: 85,
|
||||
imageExportMaxSize: 2048,
|
||||
yuqueToken: '',
|
||||
yuqueUrl: '',
|
||||
yuqueRepoId: '',
|
||||
@ -716,6 +724,16 @@ const settingsSlice = createSlice({
|
||||
setStandardizeCitationsInExport: (state, action: PayloadAction<boolean>) => {
|
||||
state.standardizeCitationsInExport = action.payload
|
||||
},
|
||||
// Image export settings actions
|
||||
setImageExportMode: (state, action: PayloadAction<'base64' | 'folder' | 'none'>) => {
|
||||
state.imageExportMode = action.payload
|
||||
},
|
||||
setImageExportQuality: (state, action: PayloadAction<number>) => {
|
||||
state.imageExportQuality = action.payload
|
||||
},
|
||||
setImageExportMaxSize: (state, action: PayloadAction<number>) => {
|
||||
state.imageExportMaxSize = action.payload
|
||||
},
|
||||
setYuqueToken: (state, action: PayloadAction<string>) => {
|
||||
state.yuqueToken = action.payload
|
||||
},
|
||||
@ -940,6 +958,9 @@ export const {
|
||||
setNotionExportReasoning,
|
||||
setExcludeCitationsInExport,
|
||||
setStandardizeCitationsInExport,
|
||||
setImageExportMode,
|
||||
setImageExportQuality,
|
||||
setImageExportMaxSize,
|
||||
setYuqueToken,
|
||||
setYuqueRepoId,
|
||||
setYuqueUrl,
|
||||
|
||||
@ -17,6 +17,8 @@ import dayjs from 'dayjs'
|
||||
import DOMPurify from 'dompurify'
|
||||
import { appendBlocks } from 'notion-helper'
|
||||
|
||||
import { createExportFolderStructure, processImageBlocks } from './exportImages'
|
||||
|
||||
const logger = loggerService.withContext('Utils:export')
|
||||
|
||||
// 全局的导出状态获取函数
|
||||
|
||||
Loading…
Reference in New Issue
Block a user