trying stuff with electron forge but moving away
This commit is contained in:
+1
-1
@@ -2,6 +2,6 @@ import { API } from "./preload";
|
||||
export {};
|
||||
declare global {
|
||||
interface Window {
|
||||
API: typeof API;
|
||||
electron: typeof API;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,8 @@ import "./App.css";
|
||||
|
||||
import { HashRouter, Route, Routes } from "react-router-dom";
|
||||
|
||||
import { Button } from "@mui/material";
|
||||
import Home from "./pages/Home";
|
||||
import Login from "./pages/Login";
|
||||
import Logo from "./components/Logo";
|
||||
import React from "react";
|
||||
import logo from "./logo.svg";
|
||||
import testConnection from "@nirvana/core";
|
||||
|
||||
testConnection();
|
||||
|
||||
@@ -53,7 +53,10 @@
|
||||
{
|
||||
"html": "./src/index.html",
|
||||
"js": "./src/renderer.ts",
|
||||
"name": "main_window"
|
||||
"name": "main_window",
|
||||
"preload": {
|
||||
"js": "./src/preload.ts"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -87,6 +90,7 @@
|
||||
"dependencies": {
|
||||
"electron-squirrel-startup": "^1.0.0",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2"
|
||||
"react-dom": "^17.0.2",
|
||||
"react-router-dom": "^6.2.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,23 @@
|
||||
import * as React from "react";
|
||||
import * as ReactDOM from "react-dom";
|
||||
|
||||
import { HashRouter, Route, Routes } from "react-router-dom";
|
||||
|
||||
import Home from "./pages/Home";
|
||||
import Login from "./pages/Login";
|
||||
|
||||
function render() {
|
||||
ReactDOM.render(
|
||||
<>
|
||||
<Login />
|
||||
</>,
|
||||
<HashRouter>
|
||||
<div className="App">
|
||||
<Routes>
|
||||
<Route path="/" element={<Login />} />
|
||||
<Route path="/home" element={<Home />} />
|
||||
{/* <Route exact path="/profile/create" component={Sit} />
|
||||
<Route exact path="/profile/edit" component={Sit} /> */}
|
||||
</Routes>
|
||||
</div>
|
||||
</HashRouter>,
|
||||
document.body
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,40 @@
|
||||
export default function Logo({ className }: { className: string }) {
|
||||
export enum LogoType {
|
||||
primary = "primary",
|
||||
small = "small",
|
||||
}
|
||||
|
||||
export default function Logo({
|
||||
className,
|
||||
type,
|
||||
}: {
|
||||
className: string;
|
||||
type?: LogoType;
|
||||
}) {
|
||||
if (type === LogoType.small) {
|
||||
return (
|
||||
<svg
|
||||
width="85"
|
||||
height="107"
|
||||
viewBox="0 0 85 107"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
className={className}
|
||||
>
|
||||
<path
|
||||
d="M0.398438 25.9375C1.84375 26.9531 2.89453 27.6562 3.91016 28.4023C11.9258 34.2617 19.9336 40.125 27.9414 45.9961C32.8008 49.5391 37.1211 53.5898 40.1445 58.8867C42.6094 63.0898 44.1328 67.6172 44.7148 72.4648C44.9258 74.1797 45.0469 75.9062 45.0703 77.6367C45.1055 86.8281 45.0703 96.0156 45.0703 105.207V106.809C44.5742 106.562 44.0938 106.289 43.625 105.992C34.1094 99.043 24.5391 92.1523 15.1055 85.0859C6.83203 78.8672 1.97266 70.5273 0.734375 60.1484C0.527344 58.3633 0.421875 56.5703 0.414062 54.7734C0.398439 46.0312 0.398438 37.2891 0.398438 28.5508V25.9375Z"
|
||||
fill="#438E86"
|
||||
/>
|
||||
<path
|
||||
d="M84.2539 15.5039V23.0859C84.2539 28.0352 84.2851 32.9844 84.2539 37.9297C84.1875 46.7539 80.4922 53.875 73.6367 59.1641C66.6484 64.5703 59.4023 69.6328 52.2617 74.8477C52.0078 75.0352 51.7422 75.207 51.2695 75.5352C51.164 75.0273 51.0937 74.5117 51.0586 73.9922C51.0586 66.9883 50.9492 59.9805 51.0781 52.9805C51.2382 44.5977 54.539 37.5352 61.0937 32.3828C68.3945 26.6445 76.0117 21.3125 83.4961 15.8125C83.7422 15.6914 83.9961 15.5859 84.2539 15.5039Z"
|
||||
fill="#438E86"
|
||||
/>
|
||||
<path
|
||||
d="M44.957 44.9219L39.5781 40.9766C36.0156 38.3672 32.4336 35.7812 28.8828 33.1484C23.1992 28.9219 20.3281 23.2539 20.332 16.1367V2.45703C20.332 1.82813 20.332 1.20312 20.332 0.308594C20.8125 0.488281 21.2773 0.707031 21.7188 0.964844C26.6875 4.58203 31.6875 8.16016 36.5898 11.8672C41.1133 15.2852 44 19.7812 44.8516 25.4844C44.9648 26.0469 45.0352 26.6172 45.0625 27.1953C45.082 32.6562 45.0938 38.1172 45.0898 43.5742C45.0898 43.8828 45.0312 44.1914 44.957 44.9219Z"
|
||||
fill="#438E86"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<svg
|
||||
width="233"
|
||||
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
import { API } from "./preload";
|
||||
export {};
|
||||
declare global {
|
||||
interface Window {
|
||||
API: typeof API;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
import { app, BrowserWindow } from 'electron';
|
||||
import { BrowserWindow, app } from "electron";
|
||||
// This allows TypeScript to pick up the magic constant that's auto-generated by Forge's Webpack
|
||||
// plugin that tells the Electron app where to look for the Webpack-bundled app code (depending on
|
||||
// whether you're running in development or production).
|
||||
declare const MAIN_WINDOW_WEBPACK_ENTRY: string;
|
||||
|
||||
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
|
||||
if (require('electron-squirrel-startup')) {
|
||||
if (require("electron-squirrel-startup")) {
|
||||
// eslint-disable-line global-require
|
||||
app.quit();
|
||||
}
|
||||
@@ -15,6 +15,9 @@ const createWindow = (): void => {
|
||||
const mainWindow = new BrowserWindow({
|
||||
height: 600,
|
||||
width: 800,
|
||||
webPreferences: {
|
||||
preload: MAIN_WINDOW_WEBPACK_ENTRY,
|
||||
}, // use a preload script
|
||||
});
|
||||
|
||||
// and load the index.html of the app.
|
||||
@@ -27,18 +30,18 @@ const createWindow = (): void => {
|
||||
// This method will be called when Electron has finished
|
||||
// initialization and is ready to create browser windows.
|
||||
// Some APIs can only be used after this event occurs.
|
||||
app.on('ready', createWindow);
|
||||
app.on("ready", createWindow);
|
||||
|
||||
// Quit when all windows are closed, except on macOS. There, it's common
|
||||
// for applications and their menu bar to stay active until the user quits
|
||||
// explicitly with Cmd + Q.
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.on("window-all-closed", () => {
|
||||
if (process.platform !== "darwin") {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
app.on('activate', () => {
|
||||
app.on("activate", () => {
|
||||
// On OS X it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import {
|
||||
Add,
|
||||
CardGiftcardRounded,
|
||||
ContactsRounded,
|
||||
LinkRounded,
|
||||
PushPinRounded,
|
||||
} from "@mui/icons-material";
|
||||
import Logo, { LogoType } from "../../components/Logo";
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<div className="h-screen w-screen bg-slate-700">
|
||||
{/* header */}
|
||||
<div className="flex flex-row items-center bg-slate-800 h-20">
|
||||
<Logo type={LogoType.small} className="scale-[0.4]" />
|
||||
<input
|
||||
placeholder="type / to search"
|
||||
className="placeholder:text-slate-400 bg-transparent outline-none text-slate-100"
|
||||
/>
|
||||
|
||||
<button className="ml-auto hover:scale-110 bg-slate-600 text-teal-500 py-1 px-2 rounded-lg text-sm">
|
||||
flow state
|
||||
</button>
|
||||
|
||||
<span className="relative mx-5">
|
||||
<img
|
||||
src="https://lh3.googleusercontent.com/a-/AOh14Gjm29Sd1Wnm8NvZbXkosvf6SoID6kBP5OHRLVIOBQ=s96-c"
|
||||
className="rounded-lg h-8 hover:bg-slate-200 hover:cursor-pointer hover:scale-110"
|
||||
alt="cannot find"
|
||||
/>
|
||||
<span className="absolute bottom-0 -right-1.5 rounded-full bg-emerald-600 h-3 w-3"></span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* actions navbar */}
|
||||
<div className="flex justify-end mx-10 mt-5 space-x-3">
|
||||
<span className="hover:bg-slate-500 p-1 rounded-full cursor-pointer flex justify-center items-center">
|
||||
<ContactsRounded className="text-slate-100" fontSize="small" />
|
||||
</span>
|
||||
|
||||
<span className="hover:bg-slate-500 p-1 rounded-full cursor-pointer flex justify-center items-center">
|
||||
<LinkRounded className="text-slate-100" fontSize="small" />
|
||||
</span>
|
||||
|
||||
<span className="hover:bg-slate-500 p-1 rounded-full cursor-pointer flex justify-center items-center">
|
||||
<CardGiftcardRounded className="text-pink-100" fontSize="small" />
|
||||
</span>
|
||||
<span className="hover:bg-slate-500 p-1 rounded-full cursor-pointer flex justify-center items-center">
|
||||
<Add className="text-slate-100" fontSize="small" />
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* pinned conversations */}
|
||||
<div className="m-5 bg-slate-500 shadow-lg rounded">
|
||||
<span className="flex flex-row justify-start p-4 items-center">
|
||||
<PushPinRounded className="text-slate-100" />
|
||||
<span className="tracking-wider text-slate-100 uppercase text-sm font-semibold">
|
||||
Pinned
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,16 +1,44 @@
|
||||
import { Button } from "@mui/material";
|
||||
import Logo from "../../components/Logo";
|
||||
import { channels } from "../../shared/constants";
|
||||
import { Button, CircularProgress } from "@mui/material";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import Logo from "../../components/Logo";
|
||||
import { UserInfo } from "@nirvana/core/models";
|
||||
import { channels } from "../../shared/constants";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
export default function Login() {
|
||||
const navigate = useNavigate();
|
||||
|
||||
export default function () {
|
||||
const logIn = () => {
|
||||
// send to main process
|
||||
window.API.activateLogin();
|
||||
// window.API.send(channels.ACTIVATE_LOG_IN);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
// .API.receive(channels.AUTH_TOKEN, async (accessToken: string) => {
|
||||
// console.log(accessToken);
|
||||
// // get user info from access token
|
||||
// const userInfo: UserInfo = await (
|
||||
// await fetch(
|
||||
// `https://www.googleapis.com/oauth2/v1/userinfo?access_token=${accessToken}`
|
||||
// )
|
||||
// ).json();
|
||||
// console.log("user data: ");
|
||||
// console.log(userInfo);
|
||||
// // if user is a user, then continue to next route
|
||||
// navigate("/home");
|
||||
// // if user is not an existing user, then show create account page
|
||||
// });
|
||||
// return () => {
|
||||
// ipcRenderer.removeAllListeners(channels.AUTH_TOKEN);
|
||||
// };
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="container flex flex-col space-y-5 justify-center items-center h-screen bg-slate-900">
|
||||
<Logo className="scale-50" />
|
||||
<CircularProgress />
|
||||
|
||||
<Button onClick={logIn} variant="contained">
|
||||
Sign In
|
||||
</Button>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function Profile() {
|
||||
return <span>this is the profile page</span>;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { contextBridge, ipcRenderer } from "electron";
|
||||
|
||||
const API = {
|
||||
notificationApi: {
|
||||
sendNotification() {
|
||||
ipcRenderer.send("notify", "message");
|
||||
},
|
||||
},
|
||||
batteryApi: {},
|
||||
fileApi: {},
|
||||
};
|
||||
|
||||
contextBridge.exposeInMainWorld("electron", API);
|
||||
|
||||
export default API;
|
||||
@@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
channels: {
|
||||
ACTIVATE_LOG_IN: "ACTIVATE_LOG_IN",
|
||||
AUTH_TOKEN: "AUTH_TOKEN",
|
||||
},
|
||||
};
|
||||
@@ -13,7 +13,7 @@
|
||||
"paths": {
|
||||
"*": ["node_modules/*"]
|
||||
},
|
||||
"jsx": "react"
|
||||
"jsx": "react-jsx"
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
|
||||
@@ -9647,7 +9647,7 @@ react-refresh@^0.11.0:
|
||||
resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.11.0.tgz#77198b944733f0f1f1a90e791de4541f9f074046"
|
||||
integrity sha512-F27qZr8uUqwhWZboondsPx8tnC3Ct3SxZA3V5WyEvujRyyNv0VYPhoBg1gZ8/MV5tubQp76Trw8lTv9hzRBa+A==
|
||||
|
||||
react-router-dom@6:
|
||||
react-router-dom@6, react-router-dom@^6.2.2:
|
||||
version "6.2.2"
|
||||
resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-6.2.2.tgz#f1a2c88365593c76b9612ae80154a13fcb72e442"
|
||||
integrity sha512-AtYEsAST7bDD4dLSQHDnk/qxWLJdad5t1HFa1qJyUrCeGgEuCSw0VB/27ARbF9Fi/W5598ujvJOm3ujUCVzuYQ==
|
||||
|
||||
Reference in New Issue
Block a user