使用默认操作系统程序打开所有文件类型

是否可以通过默认的OS程序而不是Electron内部的链接来打开所有文件扩展名?

我的文件名是从JSON文件加载的。 (Value.url是在搜索过程中动态插入的文件名)

我在下面修改了我的代码,以将click事件链接到openBtnId,但现在我收到的是“电子未定义”。我有const shell = require('electron')。shell;在我的mainJS中。

import tarfile

with tarfile.open("test.tar.gz") as archive:
    for member in archive:
        file_obj = archive.extractfile(member)
        print(file_obj)
qiangjinding 回答:使用默认操作系统程序打开所有文件类型

您可以使用shell.openItem(fullPath)

const {shell} = require("electron");
shell.openItem("/path/to/my/file");

这必须在主进程中或在nodeIntegration设置为true的BrowserWindow中完成。

,

我将nodeIntegration设置为true并添加window。$ = window.jQuery = require('jquery');到我的mainWindow html。现在可以识别shell.openItem。

本文链接:https://www.f2er.com/2880572.html

大家都在问