working version with js electron set up sending data to channel and stuff through to the main process
This commit is contained in:
@@ -3,8 +3,9 @@ const ElectronGoogleOAuth2 =
|
||||
|
||||
const path = require("path");
|
||||
|
||||
const { app, BrowserWindow } = require("electron");
|
||||
const { app, BrowserWindow, session, ipcMain } = require("electron");
|
||||
const isDev = require("electron-is-dev");
|
||||
const { channels } = require("../src/shared/constants");
|
||||
|
||||
function createWindow() {
|
||||
// Create the browser window.
|
||||
@@ -13,6 +14,7 @@ function createWindow() {
|
||||
height: 800,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
preload: path.resolve(path.join(__dirname, "./preload.js")),
|
||||
},
|
||||
});
|
||||
|
||||
@@ -51,15 +53,33 @@ app.on("activate", () => {
|
||||
|
||||
app.on("ready", () => {
|
||||
console.log(process.env);
|
||||
const myApiOauth = new ElectronGoogleOAuth2(
|
||||
"423533244953-banligobgbof8hg89i6cr1l7u0p7c2pk.apps.googleusercontent.com",
|
||||
"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",
|
||||
[""],
|
||||
{ successRedirectURL: "http://localhost:3000" }
|
||||
);
|
||||
// const myApiOauth = new ElectronGoogleOAuth2(
|
||||
// "423533244953-banligobgbof8hg89i6cr1l7u0p7c2pk.apps.googleusercontent.com",
|
||||
// "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",
|
||||
// [""],
|
||||
// { successRedirectURL: "https://usenirvana.com" }
|
||||
// );
|
||||
|
||||
myApiOauth.openAuthWindowAndGetTokens().then((token) => {
|
||||
// use your token.access_token
|
||||
console.log(`got the user's authentication: ${token}`);
|
||||
});
|
||||
// myApiOauth.openAuthWindowAndGetTokens().then((token) => {
|
||||
// // use your token.access_token
|
||||
// const cookie = {
|
||||
// name: "access_token",
|
||||
// value: token,
|
||||
// };
|
||||
|
||||
// // session.defaultSession.cookies.set(cookie).then(
|
||||
// // () => {
|
||||
// // // success
|
||||
// // console.log("stored auth token in cookies");
|
||||
// // },
|
||||
// // (error) => {
|
||||
// // console.error(error);
|
||||
// // }
|
||||
// // );
|
||||
// });
|
||||
});
|
||||
|
||||
// End of the file
|
||||
ipcMain.on(channels.ACTIVATE_LOG_IN, (event, arg) => {
|
||||
console.log("activated log in channel");
|
||||
});
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { API } from "./preload";
|
||||
export {};
|
||||
declare global {
|
||||
interface Window {
|
||||
API: typeof API;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
const { contextBridge, ipcRenderer } = require("electron");
|
||||
const { channels } = require("../src/shared/constants");
|
||||
|
||||
const API = {
|
||||
activateLogin: () => ipcRenderer.send(channels.ACTIVATE_LOG_IN),
|
||||
};
|
||||
|
||||
contextBridge.exposeInMainWorld("API", API);
|
||||
Generated
-24540
File diff suppressed because it is too large
Load Diff
@@ -22,13 +22,13 @@
|
||||
"typescript": "^4.6.2",
|
||||
"web-vitals": "^2.1.4"
|
||||
},
|
||||
"main": "public/electron.js",
|
||||
"main": "electron/electron.js",
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject",
|
||||
"dev": "concurrently -k \"BROWSER=none npm start\" \"npm:electron\"",
|
||||
"dev": "concurrently -k \"BROWSER=none yarn start\" \"yarn electron\"",
|
||||
"electron": "wait-on tcp:3000 && electron ."
|
||||
},
|
||||
"eslintConfig": {
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
import { Button } from "@mui/material";
|
||||
import ElectronGoogleOAuth2 from "@getstation/electron-google-oauth2";
|
||||
import Logo from "../../components/Logo";
|
||||
import { channels } from "../../shared/constants";
|
||||
|
||||
export default function () {
|
||||
const signIn = () => {};
|
||||
const logIn = () => {
|
||||
// send to main process
|
||||
window.API.activateLogin();
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="container flex flex-col space-y-5 justify-center items-center h-screen bg-slate-900">
|
||||
<Logo className="scale-50" />
|
||||
<Button onClick={signIn} variant="contained">
|
||||
<Button onClick={logIn} variant="contained">
|
||||
Sign In
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
channels: {
|
||||
ACTIVATE_LOG_IN: "ACTIVATE_LOG_IN",
|
||||
AUTH_TOKEN: "AUTH_TOKEN",
|
||||
},
|
||||
};
|
||||
@@ -1,12 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext",
|
||||
"es6"
|
||||
],
|
||||
"lib": ["dom", "dom.iterable", "esnext", "es6"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
@@ -24,7 +19,5 @@
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
]
|
||||
"include": ["src", "electron/global.d.ts"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user