mirror of
https://github.com/rubickCenter/rubick
synced 2025-06-10 13:20:28 +08:00
feat: 支持openDialog api
This commit is contained in:
parent
31d57fc404
commit
d0e489c36a
@ -1,4 +1,4 @@
|
||||
import {app, BrowserWindow} from 'electron';
|
||||
import {app, BrowserWindow, dialog} from 'electron';
|
||||
import {getlocalDataFile, saveData, getData} from './utils';
|
||||
import path from "path";
|
||||
|
||||
@ -25,6 +25,9 @@ export default {
|
||||
showMainWindow(arg, mainWindow) {
|
||||
mainWindow.show();
|
||||
},
|
||||
showOpenDialog({options}) {
|
||||
return JSON.parse(JSON.stringify(dialog.showOpenDialogSync(options)));
|
||||
},
|
||||
onPluginEnter(arg) {
|
||||
return arg
|
||||
},
|
||||
|
@ -63,7 +63,7 @@ export default function init(mainWindow) {
|
||||
fn = fn[op];
|
||||
});
|
||||
const data = await fn(arg, window);
|
||||
window.webContents.send(`msg-back-${arg.type}`, data);
|
||||
event.sender.send(`msg-back-${arg.type}`, data);
|
||||
});
|
||||
|
||||
ipcMain.on('new-window', (event, arg) => {
|
||||
|
@ -14,7 +14,10 @@ function getWindowHeight(searchList) {
|
||||
}
|
||||
|
||||
function searchKeyValues(lists, value){
|
||||
return lists.filter(item => item.indexOf(value) >= 0)
|
||||
return lists.filter(item => {
|
||||
if (typeof item === 'string') return item.indexOf(value) >= 0;
|
||||
return item.type.indexOf(value) >= 0;
|
||||
})
|
||||
}
|
||||
|
||||
function existOrNot(path) {
|
||||
|
@ -16,7 +16,7 @@ function getQueryVariable(variable) {
|
||||
if (location.href.indexOf('targetFile') > -1) {
|
||||
filePath = decodeURIComponent(getQueryVariable('targetFile'));
|
||||
} else {
|
||||
filePath = location.href.replace('file://', '');
|
||||
filePath = location.pathname.replace('file://', '');
|
||||
}
|
||||
const {ipcRenderer, nativeImage, clipboard, remote} = require('electron');
|
||||
|
||||
@ -105,7 +105,8 @@ window.utools = window.rubick = {
|
||||
name,
|
||||
});
|
||||
return new Promise((resolve, reject) => {
|
||||
ipcRenderer.once(`msg-back-getPath`, (e, result) => {
|
||||
ipcRenderer.on(`msg-back-getPath`, (e, result) => {
|
||||
console.log(result)
|
||||
result ? resolve(result) : reject();
|
||||
});
|
||||
})
|
||||
@ -118,6 +119,18 @@ window.utools = window.rubick = {
|
||||
return myNotification;
|
||||
// todo 实现 clickFeatureCode
|
||||
},
|
||||
showOpenDialog(options) {
|
||||
ipcRenderer.send('msg-trigger', {
|
||||
type: 'showOpenDialog',
|
||||
options: {...options},
|
||||
});
|
||||
return new Promise((resolve, reject) => {
|
||||
ipcRenderer.once(`msg-back-showOpenDialog`, (e, result) => {
|
||||
result ? resolve(result) : reject();
|
||||
});
|
||||
})
|
||||
},
|
||||
|
||||
copyImage(img) {
|
||||
convertImgToBase64(img,function(base64Image) {
|
||||
const image = nativeImage.createFromDataURL(base64Image)
|
||||
|
Loading…
x
Reference in New Issue
Block a user