Skip to content

Commit

Permalink
chore: 调整preload中函数顺序
Browse files Browse the repository at this point in the history
  • Loading branch information
Blore-lzn authored and GwokHiujin committed Jun 8, 2023
1 parent a822141 commit 1b4547a
Showing 1 changed file with 31 additions and 28 deletions.
59 changes: 31 additions & 28 deletions src/main/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,56 @@ import { isFileInDirectory, isMarkdownExtname } from './helper/path'
import { isOsx } from './config'

contextBridge.exposeInMainWorld('electronAPI', {
// Window
minWindow: () => ipcRenderer.send('window-min'),
maxWindow: () => ipcRenderer.send('window-max'),
closeWindow: () => ipcRenderer.send('window-close'),

newWindow: () => ipcRenderer.send('new-window'),
// DevTool
openDev: () => ipcRenderer.send('dev-open'),
closeDev: () => ipcRenderer.send('dev-close'),
// File
newFileFromDialog: () => ipcRenderer.invoke('newFileFromDialog'),
newFileFromSidebar: (filePath, fileName) => ipcRenderer.send('newFileFromSidebar', filePath, fileName),
newFolderFromSidebar: (folderPath, folderName) => ipcRenderer.send('newFolderFromSidebar', folderPath, folderName),

openFile: () => ipcRenderer.invoke('dialog:openFile'),
openFolder: () => ipcRenderer.send('open-folder'),
openFolderByPath: (path) => ipcRenderer.send('open-folder-by-path', path),
clearRecentlyUsedFiles: () => ipcRenderer.send('clear-recently-used-files'),
openFile: () => ipcRenderer.invoke('dialog:openFile'),
listenFileChanged: (callback) => ipcRenderer.on('file-changed', callback),

openFileTab: (callback) => ipcRenderer.on('open-file-tab', callback),

saveFile: (path, content) => ipcRenderer.send('save-file', path, content),
saveToAnotherFile: (content) => ipcRenderer.send('save-as', content),
exportPDF: (html) => ipcRenderer.invoke('exportPDF', html),

newFileFromDialog: () => ipcRenderer.invoke('newFileFromDialog'),
newFileFromSidebar: (filePath, fileName) => ipcRenderer.send('newFileFromSidebar', filePath, fileName),
newWindow: () => ipcRenderer.send('new-window'),

newFolderFromSidebar: (folderPath, folderName) => ipcRenderer.send('newFolderFromSidebar', folderPath, folderName),

changePath: (tarPath) => ipcRenderer.invoke('changePath', tarPath),

deleteFile: (filePath) => ipcRenderer.send('deleteFile', filePath),
deleteFolder: (folderPath) => ipcRenderer.send('deleteFolder', folderPath),

renameFileOrFolder: (newPath, oldPath) => ipcRenderer.send('renameFileOrFolder', newPath, oldPath),
linkToFile: (filePath, citingPath) => ipcRenderer.invoke('linkToFile', filePath, citingPath),
paste: (userSelect, tarPath) => ipcRenderer.send('paste', userSelect, tarPath),
handlePaste: () => ipcRenderer.invoke('handlePaste'),
setFilePathByMove: (callback) => ipcRenderer.on('set-file-path-by-move', callback),

refresh: (projPath) => ipcRenderer.invoke('refresh', projPath),
passiveRefresh: (callback) => ipcRenderer.on('ficus::passive-refresh', callback),

getLinksAndTags: (file) => ipcRenderer.invoke('getLinksAndTags', file),
readFile: (filePath) => ipcRenderer.invoke('readFile', filePath),

clearRecentlyUsedFiles: () => ipcRenderer.send('clear-recently-used-files'),
listenFileChanged: (callback) => ipcRenderer.on('file-changed', callback),
openFileTab: (callback) => ipcRenderer.on('open-file-tab', callback),
openInitFile: (callback) => ipcRenderer.on('ficus::open-init-file', callback),

changePath: (tarPath) => ipcRenderer.invoke('changePath', tarPath),

handlePaste: () => ipcRenderer.invoke('handlePaste'),
autoPathCompletion: (partialPath) => ipcRenderer.invoke('autoPathCompletion', partialPath),
// links
getLinksAndTags: (file) => ipcRenderer.invoke('getLinksAndTags', file),
getCites: (filePath) => ipcRenderer.invoke('ficus::getCites', filePath),
getTags: (tagName) => ipcRenderer.invoke('ficus::getTags', tagName),
findTags: (tagName, folderPath) => ipcRenderer.invoke('find_tags', tagName, folderPath),
getLinks: () => ipcRenderer.invoke('ficus::getLinks'),

tagToFolder: (tagname, dirPath, filepaths) => ipcRenderer.send('link::tag-to-folder', tagname, dirPath, filepaths),
folderToTag: (dirPath) => ipcRenderer.send('link::folder-to-tag', dirPath),
citeToTag: (srcFilepath, citeFilepaths) => ipcRenderer.send('link::cite-to-tag', srcFilepath, citeFilepaths),
Expand All @@ -55,31 +63,26 @@ contextBridge.exposeInMainWorld('electronAPI', {
getFileCiteTraverse: (filepath) => ipcRenderer.invoke('link::get-file-cite-traverse', filepath),
getFolderStatInGraph: (dirpath) => ipcRenderer.invoke('link::get-folder-stat-in-graph', dirpath),
getFilesByTag: (tagName) => ipcRenderer.invoke('link::get-files-by-tag', tagName),

// Forest
exportForest: (files, exportPath) => ipcRenderer.send('export-forest', files, exportPath),

aboutUs: () => ipcRenderer.invoke('main::about'),
autoPathCompletion: (partialPath) => ipcRenderer.invoke('autoPathCompletion', partialPath),

passiveRefresh: (callback) => ipcRenderer.on('ficus::passive-refresh', callback),
openInitFile: (callback) => ipcRenderer.on('ficus::open-init-file', callback),
keyboardEvent: (callback) => ipcRenderer.on('ficus::keyboard-event', callback),
setFilePathByMove: (callback) => ipcRenderer.on('set-file-path-by-move', callback),

// Preference
loadPreferences: (callback) => ipcRenderer.on('load-preferences', callback),
setPreferences: (preferences) => ipcRenderer.send('set-preferences', preferences),

// Search
globalSearch: (token) => ipcRenderer.invoke('search-token-globally', token),
// Graph
setFocusIdByName: (callback) => ipcRenderer.on('set-focus-id-by-name', callback),

// Keybinding
keyboardEvent: (callback) => ipcRenderer.on('ficus::keyboard-event', callback),
getKeybindingsMap: () => ipcRenderer.invoke('get-keybindings-map'),
loadKeybindingsMap: (callback) => ipcRenderer.on('load-keybindings-map', callback),
setKeybindingItem: (item) => ipcRenderer.send('set-keybinding-item', item),

disableAllKeybindings: () => ipcRenderer.send('disable-all-keybindings'),
enableAllKeybindings: () => ipcRenderer.send('enable-all-keybindings'),
clearUserKeybindings: () => ipcRenderer.send('clear-user-keybindings'),

aboutUs: () => ipcRenderer.invoke('main::about'),
getBuiltInDocumentsPath: () => ipcRenderer.invoke('get-built-in-documents-path'),

isOSx: () => isOsx
Expand Down

0 comments on commit 1b4547a

Please sign in to comment.