Skip to content

Commit

Permalink
refactor(create-electron): new hero
Browse files Browse the repository at this point in the history
  • Loading branch information
alex8088 committed Jan 25, 2024
1 parent 5a276c3 commit 8a9982b
Show file tree
Hide file tree
Showing 117 changed files with 3,021 additions and 3,503 deletions.
5 changes: 4 additions & 1 deletion packages/create-electron/template/react-ts/src/main/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { app, shell, BrowserWindow } from 'electron'
import { app, shell, BrowserWindow, ipcMain } from 'electron'
import { join } from 'path'
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
import icon from '../../resources/icon.png?asset'
Expand Down Expand Up @@ -49,6 +49,9 @@ app.whenReady().then(() => {
optimizer.watchWindowShortcuts(window)
})

// IPC test
ipcMain.on('ping', () => console.log('pong'))

createWindow()

app.on('activate', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta
http-equiv="Content-Security-Policy"
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'"
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:"
/>
</head>

Expand Down
148 changes: 19 additions & 129 deletions packages/create-electron/template/react-ts/src/renderer/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,144 +1,34 @@
import Versions from './components/Versions'
import icons from './assets/icons.svg'
import electronLogo from './assets/electron.svg'

function App(): JSX.Element {
return (
<div className="container">
<Versions></Versions>
const ipcHandle = (): void => window.electron.ipcRenderer.send('ping')

<svg className="hero-logo" viewBox="0 0 900 300">
<use xlinkHref={`${icons}#electron`} />
</svg>
<h2 className="hero-text">
You{"'"}ve successfully created an Electron project with React and TypeScript
</h2>
<p className="hero-tagline">
return (
<>
<img alt="logo" className="logo" src={electronLogo} />
<div className="creator">Powered by electron-vite</div>
<div className="text">
Build an Electron app with <span className="react">React</span>
&nbsp;and <span className="ts">TypeScript</span>
</div>
<p className="tip">
Please try pressing <code>F12</code> to open the devTool
</p>

<div className="links">
<div className="link-item">
<a target="_blank" href="https://electron-vite.org" rel="noopener noreferrer">
<div className="actions">
<div className="action">
<a href="https://electron-vite.org/" target="_blank" rel="noreferrer">
Documentation
</a>
</div>
<div className="link-item link-dot"></div>
<div className="link-item">
<a
target="_blank"
href="https://github.com/alex8088/electron-vite"
rel="noopener noreferrer"
>
Getting Help
</a>
</div>
<div className="link-item link-dot"></div>
<div className="link-item">
<a
target="_blank"
href="https://github.com/alex8088/quick-start/tree/master/packages/create-electron"
rel="noopener noreferrer"
>
create-electron
<div className="action">
<a target="_blank" rel="noreferrer" onClick={ipcHandle}>
Send IPC
</a>
</div>
</div>

<div className="features">
<div className="feature-item">
<article>
<h2 className="title">Configuring</h2>
<p className="detail">
Config with <span>electron.vite.config.ts</span> and refer to the{' '}
<a target="_blank" href="https://electron-vite.org/config" rel="noopener noreferrer">
config guide
</a>
.
</p>
</article>
</div>
<div className="feature-item">
<article>
<h2 className="title">HMR</h2>
<p className="detail">
Edit <span>src/renderer</span> files to test HMR. See{' '}
<a
target="_blank"
href="https://electron-vite.org/guide/hmr.html"
rel="noopener noreferrer"
>
docs
</a>
.
</p>
</article>
</div>
<div className="feature-item">
<article>
<h2 className="title">Hot Reloading</h2>
<p className="detail">
Run{' '}
<span>
{"'"}electron-vite dev --watch{"'"}
</span>{' '}
to enable. See{' '}
<a
target="_blank"
href="https://electron-vite.org/guide/hot-reloading.html"
rel="noopener noreferrer"
>
docs
</a>
.
</p>
</article>
</div>
<div className="feature-item">
<article>
<h2 className="title">Debugging</h2>
<p className="detail">
Check out <span>.vscode/launch.json</span>. See{' '}
<a
target="_blank"
href="https://electron-vite.org/guide/debugging.html"
rel="noopener noreferrer"
>
docs
</a>
.
</p>
</article>
</div>
<div className="feature-item">
<article>
<h2 className="title">Source Code Protection</h2>
<p className="detail">
Supported via built-in plugin <span>bytecodePlugin</span>. See{' '}
<a
target="_blank"
href="https://electron-vite.org/guide/source-code-protection.html"
rel="noopener noreferrer"
>
docs
</a>
.
</p>
</article>
</div>
<div className="feature-item">
<article>
<h2 className="title">Packaging</h2>
<p className="detail">
Use{' '}
<a target="_blank" href="https://www.electron.build" rel="noopener noreferrer">
electron-builder
</a>{' '}
and pre-configured to pack your app.
</p>
</article>
</div>
</div>
</div>
<Versions></Versions>
</>
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
:root {
--ev-c-white: #ffffff;
--ev-c-white-soft: #f8f8f8;
--ev-c-white-mute: #f2f2f2;

--ev-c-black: #1b1b1f;
--ev-c-black-soft: #222222;
--ev-c-black-mute: #282828;

--ev-c-gray-1: #515c67;
--ev-c-gray-2: #414853;
--ev-c-gray-3: #32363f;

--ev-c-text-1: rgba(255, 255, 245, 0.86);
--ev-c-text-2: rgba(235, 235, 245, 0.6);
--ev-c-text-3: rgba(235, 235, 245, 0.38);

--ev-button-alt-border: transparent;
--ev-button-alt-text: var(--ev-c-text-1);
--ev-button-alt-bg: var(--ev-c-gray-3);
--ev-button-alt-hover-border: transparent;
--ev-button-alt-hover-text: var(--ev-c-text-1);
--ev-button-alt-hover-bg: var(--ev-c-gray-2);
}

:root {
--color-background: var(--ev-c-black);
--color-background-soft: var(--ev-c-black-soft);
--color-background-mute: var(--ev-c-black-mute);

--color-text: var(--ev-c-text-1);
}

*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
font-weight: normal;
}

ul {
list-style: none;
}

body {
min-height: 100vh;
color: var(--color-text);
background: var(--color-background);
line-height: 1.6;
font-family:
Inter,
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
Roboto,
Oxygen,
Ubuntu,
Cantarell,
'Fira Sans',
'Droid Sans',
'Helvetica Neue',
sans-serif;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 8a9982b

Please sign in to comment.