Skip to content

Commit 1393dbe

Browse files
committed
update
1 parent c38ed98 commit 1393dbe

File tree

9 files changed

+98
-24
lines changed

9 files changed

+98
-24
lines changed

.github/electronrt.png

334 KB
Loading

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
> 一个开源的 Electron 开发环境脚手架,使用了 Electron + React + Typescript + Less + Webpack进行构建。
55
> 代码检查使用了 Eslint ,规则集采用的是 eslint-config-ali ,强制删除不必要的分号。
66
7+
## 界面预览
8+
9+
<img src=".github/electronrt.png" width="80%">
10+
711
## 食用方法
812

913
### 克隆代码

src/main/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ let mainWindow: BrowserWindow | null
88

99
function createMainWindow() {
1010
const window = new BrowserWindow({
11+
width: 1280,
12+
height: 730,
13+
frame: false,
1114
webPreferences: {
1215
nodeIntegration: true,
16+
enableRemoteModule: true,
1317
},
1418
})
1519

src/renderer/layouts/index.tsx

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,49 @@
11
import React, { useState } from 'react'
22
import { HashRouter, NavLink } from 'react-router-dom'
33
import useInterval from '@use-it/interval'
4-
// import _ from 'lodash'
4+
import { remote } from 'electron'
55

66
import Router from '../routes/router'
77

88
import './style.less'
99

10+
const isDev = process.env.NODE_ENV !== 'production'
11+
const winContent = remote.getCurrentWindow()
12+
1013
const Index = () => {
1114
const [hash, setHash] = useState<any>(window.location.hash)
1215

1316
useInterval(() => {
1417
setHash(() => window.location.hash)
1518
}, 100)
1619

20+
const close = () => {
21+
if (isDev) {
22+
winContent.destroy()
23+
} else {
24+
winContent.close()
25+
}
26+
}
27+
1728
return (
1829
<HashRouter>
1930
<div id="layout">
2031
<div className="layout-header">
2132
<div className="clearfix" />
22-
<span className="slg">Now you are at: {hash}</span>
33+
<h1 className="title">Electron RT Boilerplate</h1>
34+
<span className="slg">{hash}</span>
35+
<div className="control">
36+
<ul>
37+
<li className="close" onClick={() => { close() }}>
38+
<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="22" height="22">
39+
<path d="M816 816m-32 0a32 32 0 1 0 64 0 32 32 0 1 0-64 0Z" />
40+
<path d="M512 968a456 456 0 1 1 395.76-229.36 32 32 0 0 1-55.52-32 392 392 0 1 0-145.44 145.44 32 32 0 0 1 32 55.52A456 456 0 0 1 512 968z" />
41+
<path d="M376 680a32 32 0 0 1-22.64-54.64L625.12 353.6a32 32 0 1 1 45.28 45.28L398.88 670.4A32 32 0 0 1 376 680z" />
42+
<path d="M648 680a32 32 0 0 1-22.64-9.36L353.6 398.88a32 32 0 0 1 45.28-45.28L670.4 625.12A32 32 0 0 1 648 680z" />
43+
</svg>
44+
</li>
45+
</ul>
46+
</div>
2347
</div>
2448
<div className="layout-content">
2549
<div className="clearfix" />

src/renderer/layouts/style.less

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,62 @@
1-
@youmuGreen: rgb(47, 128, 55);
2-
31
#layout {
4-
.layout-header, .layout-footer {
5-
background-color: rgb(233, 233, 233);
6-
}
72
.layout-content {
83
min-height: calc(100vh - 58px);
94
}
105
.layout-header {
11-
.slg {
12-
margin-left: 4px;
6+
position: relative;
7+
height: 30px;
8+
background-color: rgb(20, 20, 20);
9+
color: white;
10+
-webkit-app-region: drag;
11+
.title {
12+
display: inline-block;
13+
margin: 0 8px;
1314
font-size: 13px;
15+
line-height: 30px;
16+
}
17+
.slg {
18+
display: inline-block;
19+
font-size: 10px;
20+
color: rgb(122, 122, 122);
21+
line-height: 30px;
22+
}
23+
.control {
24+
position: absolute;
25+
top: 0;
26+
right: 0;
27+
height: 30px;
28+
-webkit-app-region: no-drag;
29+
ul {
30+
margin: 0;
31+
height: 30px;
32+
li {
33+
display: inline-block;
34+
list-style: none;
35+
line-height: 30px;
36+
&.close {
37+
padding: 4px 6px;
38+
path {
39+
fill: rgb(216, 216, 216);
40+
}
41+
&:hover {
42+
background-color: rgb(213, 81, 45);
43+
}
44+
}
45+
}
46+
}
1447
}
1548
}
1649
.layout-footer {
50+
position: absolute;
51+
bottom: 0;
1752
.nav {
1853
margin-left: 8px;
1954
a {
2055
display: inline-block;
2156
font-size: 14px;
2257
padding: 2px;
2358
margin: 6px;
24-
color: @youmuGreen;
59+
color: rgb(255, 255, 255);
2560
text-decoration: none;
2661
&.active {
2762
text-decoration: underline;

src/renderer/pages/about/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const About = () => {
99
<h1 className="title">Electron RT Boilerplate</h1>
1010
<span>It seems you entered the about page.</span>
1111
<p>Author: YoumuKonpaku</p>
12-
<p>Website: <a href="#" onClick={() => { openExternal('https://youmukonpaku.com') }}>https://youmukonpaku.com</a></p>
12+
<p>Website: <a className="link" href="#" onClick={() => { openExternal('https://youmukonpaku.com') }}>https://youmukonpaku.com</a></p>
1313
</div>
1414
)
1515
}

src/renderer/pages/about/style.less

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
@gray: rgb(72, 82, 92);
2-
@youmuGreen: rgb(47, 128, 55);
3-
41
#about {
52
text-align: center;
6-
color: @gray;
3+
color: rgb(233, 233, 233);
74
.title {
8-
margin: 64px 0 12px 0;
5+
margin: 64px 0 24px 0;
96
font-size: 22px;
107
}
8+
.link {
9+
color: rgba(72, 72, 196);
10+
text-decoration: none;
11+
&:hover {
12+
color: rgba(92, 92, 216);
13+
}
14+
}
1115
}

src/renderer/pages/welcome/style.less

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
@gray: rgb(72, 82, 92);
2-
@youmuGreen: rgb(47, 128, 55);
3-
@youmuHoverGreen: rgb(47, 168, 55);
4-
51
#welcome {
62
text-align: center;
7-
color: @gray;
3+
color: rgb(233, 233, 233);
84
.title {
9-
margin: 64px 0 12px 0;
5+
margin: 64px 0 24px 0;
106
font-size: 22px;
117
}
128
.links {
@@ -20,7 +16,7 @@
2016
display: table-cell;
2117
width: 50%;
2218
padding: 4px 12px;
23-
color: @youmuGreen;
19+
color: rgba(72, 72, 196);
2420
text-decoration: none;
2521
&:first-child {
2622
text-align: right;
@@ -29,7 +25,7 @@
2925
text-align: left;
3026
}
3127
&:hover {
32-
color: @youmuHoverGreen
28+
color: rgba(92, 92, 216);
3329
}
3430
}
3531
}

src/renderer/style.less

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
* {
22
outline: none;
33
user-select: none;
4+
overflow: hidden;
45
}
56

67
html, body {
78
margin: 0;
9+
height: 100vh;
10+
}
11+
12+
body {
13+
position: relative;
14+
background-image: linear-gradient(135deg, rgb(61, 154, 188), rgb(55, 99, 146));
815
}
916

1017
.clearfix:before,.clearfix:after {

0 commit comments

Comments
 (0)