diff --git a/.github/electronrt.png b/.github/electronrt.png new file mode 100644 index 0000000..8fbadd1 Binary files /dev/null and b/.github/electronrt.png differ diff --git a/README.md b/README.md index 0862cc4..6eb00de 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ > 一个开源的 Electron 开发环境脚手架,使用了 Electron + React + Typescript + Less + Webpack进行构建。 > 代码检查使用了 Eslint ,规则集采用的是 eslint-config-ali ,强制删除不必要的分号。 +## 界面预览 + + + ## 食用方法 ### 克隆代码 diff --git a/src/main/index.ts b/src/main/index.ts index 322851a..dda25bd 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -8,8 +8,12 @@ let mainWindow: BrowserWindow | null function createMainWindow() { const window = new BrowserWindow({ + width: 1280, + height: 730, + frame: false, webPreferences: { nodeIntegration: true, + enableRemoteModule: true, }, }) diff --git a/src/renderer/layouts/index.tsx b/src/renderer/layouts/index.tsx index 55430a3..bced72b 100644 --- a/src/renderer/layouts/index.tsx +++ b/src/renderer/layouts/index.tsx @@ -1,12 +1,15 @@ import React, { useState } from 'react' import { HashRouter, NavLink } from 'react-router-dom' import useInterval from '@use-it/interval' -// import _ from 'lodash' +import { remote } from 'electron' import Router from '../routes/router' import './style.less' +const isDev = process.env.NODE_ENV !== 'production' +const winContent = remote.getCurrentWindow() + const Index = () => { const [hash, setHash] = useState(window.location.hash) @@ -14,12 +17,33 @@ const Index = () => { setHash(() => window.location.hash) }, 100) + const close = () => { + if (isDev) { + winContent.destroy() + } else { + winContent.close() + } + } + return (
- Now you are at: {hash} +

Electron RT Boilerplate

+ {hash} +
+
    +
  • { close() }}> + + + + + + +
  • +
+
diff --git a/src/renderer/layouts/style.less b/src/renderer/layouts/style.less index c9abf98..2d42cd5 100644 --- a/src/renderer/layouts/style.less +++ b/src/renderer/layouts/style.less @@ -1,19 +1,54 @@ -@youmuGreen: rgb(47, 128, 55); - #layout { - .layout-header, .layout-footer { - background-color: rgb(233, 233, 233); - } .layout-content { min-height: calc(100vh - 58px); } .layout-header { - .slg { - margin-left: 4px; + position: relative; + height: 30px; + background-color: rgb(20, 20, 20); + color: white; + -webkit-app-region: drag; + .title { + display: inline-block; + margin: 0 8px; font-size: 13px; + line-height: 30px; + } + .slg { + display: inline-block; + font-size: 10px; + color: rgb(122, 122, 122); + line-height: 30px; + } + .control { + position: absolute; + top: 0; + right: 0; + height: 30px; + -webkit-app-region: no-drag; + ul { + margin: 0; + height: 30px; + li { + display: inline-block; + list-style: none; + line-height: 30px; + &.close { + padding: 4px 6px; + path { + fill: rgb(216, 216, 216); + } + &:hover { + background-color: rgb(213, 81, 45); + } + } + } + } } } .layout-footer { + position: absolute; + bottom: 0; .nav { margin-left: 8px; a { @@ -21,7 +56,7 @@ font-size: 14px; padding: 2px; margin: 6px; - color: @youmuGreen; + color: rgb(255, 255, 255); text-decoration: none; &.active { text-decoration: underline; diff --git a/src/renderer/pages/about/index.tsx b/src/renderer/pages/about/index.tsx index 947f0af..ddfd0eb 100644 --- a/src/renderer/pages/about/index.tsx +++ b/src/renderer/pages/about/index.tsx @@ -9,7 +9,7 @@ const About = () => {

Electron RT Boilerplate

It seems you entered the about page.

Author: YoumuKonpaku

-

Website: { openExternal('https://youmukonpaku.com') }}>https://youmukonpaku.com

+

Website: { openExternal('https://youmukonpaku.com') }}>https://youmukonpaku.com

) } diff --git a/src/renderer/pages/about/style.less b/src/renderer/pages/about/style.less index c26d2bf..c8b05ff 100644 --- a/src/renderer/pages/about/style.less +++ b/src/renderer/pages/about/style.less @@ -1,11 +1,15 @@ -@gray: rgb(72, 82, 92); -@youmuGreen: rgb(47, 128, 55); - #about { text-align: center; - color: @gray; + color: rgb(233, 233, 233); .title { - margin: 64px 0 12px 0; + margin: 64px 0 24px 0; font-size: 22px; } + .link { + color: rgba(72, 72, 196); + text-decoration: none; + &:hover { + color: rgba(92, 92, 216); + } + } } \ No newline at end of file diff --git a/src/renderer/pages/welcome/style.less b/src/renderer/pages/welcome/style.less index 6f87398..861b1f6 100644 --- a/src/renderer/pages/welcome/style.less +++ b/src/renderer/pages/welcome/style.less @@ -1,12 +1,8 @@ -@gray: rgb(72, 82, 92); -@youmuGreen: rgb(47, 128, 55); -@youmuHoverGreen: rgb(47, 168, 55); - #welcome { text-align: center; - color: @gray; + color: rgb(233, 233, 233); .title { - margin: 64px 0 12px 0; + margin: 64px 0 24px 0; font-size: 22px; } .links { @@ -20,7 +16,7 @@ display: table-cell; width: 50%; padding: 4px 12px; - color: @youmuGreen; + color: rgba(72, 72, 196); text-decoration: none; &:first-child { text-align: right; @@ -29,7 +25,7 @@ text-align: left; } &:hover { - color: @youmuHoverGreen + color: rgba(92, 92, 216); } } } diff --git a/src/renderer/style.less b/src/renderer/style.less index ab5efc6..77b9316 100644 --- a/src/renderer/style.less +++ b/src/renderer/style.less @@ -1,10 +1,17 @@ * { outline: none; user-select: none; + overflow: hidden; } html, body { margin: 0; + height: 100vh; +} + +body { + position: relative; + background-image: linear-gradient(135deg, rgb(61, 154, 188), rgb(55, 99, 146)); } .clearfix:before,.clearfix:after {