如何解决在树莓派上找不到electronjs相机
所以我创建了一个电子应用程序,可以打开相机并扫描二维码,这是我使用的插件https://github.com/schmich/instascan。 html 文件是使用 Vue 完成的并测试了输出,我可以看到相机正在工作,但是当在 raspberry pi 3 b+ 上传输并编译电子应用程序 "npm run start"
时,现在它找不到任何相机,(RPi相机正在 html 部分工作和测试),下面的代码是我对主进程的尝试
'use strict';
const path = require('path');
const { app,BrowserWindow,Menu,globalShortcut} = require('electron');
const unhandled = require('electron-unhandled');
const debug = require('electron-debug');
const {is} = require('electron-util');
unhandled();
debug();
contextMenu();
// Note: Must match `build.appId` in package.json
app.setAppUserModelId('com.pixzeldigital.attrfidqrcode');
// Prevent window from being garbage collected
let mainWindow;
const createMainWindow = async () => {
const win = new BrowserWindow({
title: app.name,show: false,width: 1024,height: 768,frame: false
});
win.on('ready-to-show',() => {
win.maximize();
win.show();
});
win.on('closed',() => {
// Dereference the window
// For multiple windows store them in an array
mainWindow = undefined;
});
await win.loadFile(path.join(__dirname,'vue/dist/index.html'));
return win;
};
// Prevent multiple instances of the app
if (!app.requestSingleInstanceLock()) {
app.quit();
}
app.on('second-instance',() => {
if (mainWindow) {
if (mainWindow.isMinimized()) {
mainWindow.restore();
}
mainWindow.show();
}
});
app.on('window-all-closed',() => {
if (!is.macos) {
app.quit();
}
});
app.on('activate',async () => {
if (!mainWindow) {
mainWindow = await createMainWindow();
}
});
app.on('ready',() => {
// Register a shortcut listener for Ctrl + Shift + I
globalShortcut.register('Control+Shift+I',() => {
// When the user presses Ctrl + Shift + I,this function will get called
// You can modify this function to do other things,but if you just want
// to disable the shortcut,you can just return false
return false;
});
});
(async () => {
await app.whenReady();
Menu.setApplicationMenu(null);
mainWindow = await createMainWindow();
})();
非常感谢任何帮助、想法和建议。提前致谢。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。