mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-21 10:27:44 +08:00
客户端:附件支持选择文件夹
This commit is contained in:
parent
b438385cd6
commit
cabb37c5b9
@ -128,9 +128,14 @@ export const bindFileHandleEvent = ({ mainWindow }) => {
|
||||
})
|
||||
|
||||
// 选择本地文件
|
||||
ipcMain.handle('selectFile', event => {
|
||||
ipcMain.handle('selectFile', (event, openDirectory = false) => {
|
||||
const properties = []
|
||||
if (openDirectory) {
|
||||
properties.push('openDirectory')
|
||||
}
|
||||
const res = dialog.showOpenDialogSync({
|
||||
title: '选择'
|
||||
title: '选择',
|
||||
properties
|
||||
})
|
||||
if (res && res[0]) {
|
||||
console.log(111, res[0])
|
||||
@ -229,8 +234,8 @@ export const bindFileHandleEvent = ({ mainWindow }) => {
|
||||
shell.showItemInFolder(file)
|
||||
})
|
||||
|
||||
// 打开指定文件
|
||||
ipcMain.handle('openPath', (event, file) => {
|
||||
// 打开指定文件
|
||||
ipcMain.handle('openPath', (event, file) => {
|
||||
const exist = fs.existsSync(file)
|
||||
if (!exist) {
|
||||
return '文件不存在'
|
||||
|
||||
@ -25,7 +25,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
||||
openFile: file => ipcRenderer.invoke('openFile', file),
|
||||
selectOpenFile: () => ipcRenderer.send('selectOpenFile'),
|
||||
copyFile: file => ipcRenderer.invoke('copyFile', file),
|
||||
selectFile: () => ipcRenderer.invoke('selectFile'),
|
||||
selectFile: openDirectory => ipcRenderer.invoke('selectFile', openDirectory),
|
||||
openPath: path => ipcRenderer.invoke('openPath', path),
|
||||
saveClientConfig: config => ipcRenderer.invoke('saveClientConfig', config),
|
||||
getClientConfig: () => ipcRenderer.invoke('getClientConfig')
|
||||
|
||||
@ -70,7 +70,7 @@ export default {
|
||||
// activeNodes.forEach(node => {
|
||||
// node.setAttachment('/test.md', '我去')
|
||||
// })
|
||||
const file = await window.electronAPI.selectFile()
|
||||
const file = await window.electronAPI.selectFile(true)
|
||||
if (file) {
|
||||
activeNodes.forEach(node => {
|
||||
node.setAttachment(file.file, file.name)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user