This commit is contained in:
parent
63badb1c74
commit
9cc9a2862a
2 changed files with 9 additions and 2 deletions
|
@ -230,6 +230,9 @@ export const initWindow = async (app: App) => {
|
|||
});
|
||||
}
|
||||
ipcRenderer.on(Constants.SIYUAN_OPEN_FILE, (event, data) => {
|
||||
if (!data.app) {
|
||||
data.app = app;
|
||||
}
|
||||
openFile(data);
|
||||
});
|
||||
ipcRenderer.on(Constants.SIYUAN_SAVE_CLOSE, (event, close) => {
|
||||
|
|
|
@ -198,8 +198,12 @@ export const openFile = async (options: IOpenFileOptions) => {
|
|||
// https://github.com/siyuan-note/siyuan/issues/7491
|
||||
if (!options.position) {
|
||||
let hasMatch = false;
|
||||
const optionsClone = Object.assign({}, options);
|
||||
delete optionsClone.app; // 防止 JSON.stringify 时产生递归
|
||||
const optionsClone: IObject = {};
|
||||
Object.keys(options).forEach((key: keyof IOpenFileOptions) => {
|
||||
if (key !== "app" && options[key] && typeof options[key] !== "function") {
|
||||
optionsClone[key] = JSON.parse(JSON.stringify(options[key]));
|
||||
}
|
||||
});
|
||||
hasMatch = await ipcRenderer.invoke(Constants.SIYUAN_GET, {
|
||||
cmd: Constants.SIYUAN_OPEN_FILE,
|
||||
options: JSON.stringify(optionsClone),
|
||||
|
|
Loading…
Add table
Reference in a new issue