Skip to content

Commit 0e69c17

Browse files
author
青椒
committed
electron
1 parent a9fd2c7 commit 0e69c17

File tree

14 files changed

+16085
-2420
lines changed

14 files changed

+16085
-2420
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
node_modules
2+
dist
13
.DS_Store
24
node_modules
35
/dist
@@ -21,3 +23,6 @@ pnpm-debug.log*
2123
*.njsproj
2224
*.sln
2325
*.sw?
26+
27+
#Electron-builder output
28+
/dist_electron

.prettierrc.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,25 @@
1-
<!-- @format -->
1+
# electron-vue3-ts
2+
electron9.0 + vue3.0 + typescript 示例项目
3+
4+
## Project setup
5+
```
6+
yarn install
7+
```
8+
9+
### Compiles and hot-reloads for development
10+
```
11+
yarn serve
12+
```
13+
14+
### Compiles and minifies for production
15+
```
16+
yarn build
17+
```
18+
19+
### Lints and fixes files
20+
```
21+
yarn lint
22+
```
23+
24+
### Customize configuration
25+
See [Configuration Reference](https://cli.vuejs.org/config/).

babel.config.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
module.exports = {
2-
presets: ["@vue/cli-plugin-babel/preset"]
3-
};
2+
presets: [
3+
'@vue/cli-plugin-babel/preset'
4+
]
5+
}

package-lock.json

Lines changed: 5757 additions & 2366 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
{
2-
"name": "b726_desktop",
3-
"version": "0.1.0",
2+
"name": "B726",
3+
"version": "0.0.1",
4+
"author": "bknds",
45
"private": true,
56
"scripts": {
6-
"dev": "vue-cli-service serve",
7+
"serve": "vue-cli-service serve",
78
"build": "vue-cli-service build",
8-
"lint": "vue-cli-service lint"
9+
"lint": "vue-cli-service lint",
10+
"electron:build": "vue-cli-service electron:build",
11+
"electron:serve": "vue-cli-service electron:serve",
12+
"postinstall": "electron-builder install-app-deps",
13+
"postuninstall": "electron-builder install-app-deps"
914
},
15+
"main": "background.js",
1016
"dependencies": {
11-
"axios": "^0.20.0",
1217
"core-js": "^3.6.5",
18+
"vue": "^3.0.0",
19+
"vue-class-component": "^8.0.0-0",
20+
"axios": "^0.20.0",
1321
"node-sass": "^4.14.1",
1422
"sass-loader": "^8.0.1",
1523
"vue-router": "^4.0.0-0",
16-
"vue": "^3.0.0-0",
17-
"vue-class-component": "^8.0.0-0",
1824
"vuex": "^4.0.0-0"
1925
},
2026
"devDependencies": {
@@ -23,16 +29,16 @@
2329
"@vue/cli-plugin-babel": "~4.5.0",
2430
"@vue/cli-plugin-eslint": "~4.5.0",
2531
"@vue/cli-plugin-typescript": "~4.5.0",
26-
"@vue/cli-plugin-router": "~4.5.0",
27-
"@vue/cli-plugin-vuex": "~4.5.0",
2832
"@vue/cli-service": "~4.5.0",
29-
"@vue/compiler-sfc": "^3.0.0-0",
30-
"@vue/eslint-config-prettier": "^6.0.0",
33+
"@vue/compiler-sfc": "^3.0.0",
3134
"@vue/eslint-config-typescript": "^5.0.2",
32-
"eslint-plugin-prettier": "^3.1.3",
35+
"babel-eslint": "^10.1.0",
36+
"electron": "^12.0.0",
37+
"electron-devtools-installer": "^3.1.0",
38+
"eslint": "^6.7.2",
3339
"eslint-plugin-vue": "^7.0.0-0",
34-
"prettier": "^1.19.1",
35-
"typescript": "~3.9.3"
40+
"typescript": "~3.9.3",
41+
"vue-cli-plugin-electron-builder": "~2.0.0-rc.5"
3642
},
3743
"eslintConfig": {
3844
"root": true,
@@ -42,12 +48,10 @@
4248
"extends": [
4349
"plugin:vue/vue3-essential",
4450
"eslint:recommended",
45-
"@vue/typescript/recommended",
46-
"@vue/prettier",
47-
"@vue/prettier/@typescript-eslint"
51+
"@vue/typescript"
4852
],
4953
"parserOptions": {
50-
"ecmaVersion": 2020
54+
"parser": "@typescript-eslint/parser"
5155
},
5256
"rules": {}
5357
},

public/favicon.ico

0 Bytes
Binary file not shown.

public/index.html

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
4-
<head>
5-
<meta charset="utf-8">
6-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7-
<meta name="viewport" content="width=device-width,initial-scale=1.0">
8-
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
9-
<title>听青</title>
10-
</head>
11-
12-
<body>
13-
<div id="app"></div>
14-
</body>
15-
16-
</html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7+
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
8+
<title><%= htmlWebpackPlugin.options.title %></title>
9+
</head>
10+
<body>
11+
<noscript>
12+
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
13+
</noscript>
14+
<div id="app"></div>
15+
<!-- built files will be auto injected -->
16+
</body>
17+
</html>

src/App.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ export default {
6060
}
6161
};
6262
63-
const mouseleave = (e: any) => {
63+
const mouseleave = () => {
6464
mouseDown.value = false;
6565
layoutFooter.value.rangeMouseleave()
6666
};
6767
68-
const mouseup = (e: any) => {
68+
const mouseup = () => {
6969
mouseDown.value = false;
7070
layoutFooter.value.rangeMouseup()
7171
};
@@ -94,6 +94,7 @@ export default {
9494
9595
body {
9696
background: rgb(121, 121, 121);
97+
overflow: hidden;
9798
}
9899
99100
.app-container {

src/background.ts

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
'use strict'
2+
3+
import { app, protocol, BrowserWindow, Menu } from 'electron'
4+
import { createProtocol } from 'vue-cli-plugin-electron-builder/lib'
5+
// import installExtension, { VUEJS_DEVTOOLS } from 'electron-devtools-installer'
6+
const isDevelopment = process.env.NODE_ENV !== 'production'
7+
8+
protocol.registerSchemesAsPrivileged([
9+
{ scheme: 'app', privileges: { secure: true, standard: true } }
10+
])
11+
12+
async function createWindow() {
13+
Menu.setApplicationMenu(null);
14+
// Create the browser window.
15+
const win = new BrowserWindow({
16+
width: isDevelopment ? 1500 : 1000,
17+
height: 660,
18+
fullscreenable: false, // 是否允许全屏
19+
backgroundColor: '#eee', // 背景颜色
20+
// titleBarStyle: 'customButtonsOnHover', // 标题栏的样式,有hidden、hiddenInset、customButtonsOnHover等
21+
resizable: false, // 是否允许拉伸大小
22+
transparent: false, // 是否是透明窗口(仅macOS)
23+
autoHideMenuBar: true,
24+
title: '听青',
25+
webPreferences: {
26+
webSecurity: false, //跨域限制
27+
contextIsolation: false,
28+
enableRemoteModule: true,
29+
nodeIntegration: (process.env
30+
.ELECTRON_NODE_INTEGRATION as unknown) as boolean,
31+
},
32+
})
33+
34+
if (process.env.WEBPACK_DEV_SERVER_URL) {
35+
// Load the url of the dev server if in development mode
36+
await win.loadURL(process.env.WEBPACK_DEV_SERVER_URL)
37+
if (!process.env.IS_TEST) win.webContents.openDevTools()
38+
} else {
39+
createProtocol('app')
40+
// Load the index.html when not in development
41+
win.loadURL('app://./index.html')
42+
}
43+
}
44+
45+
app.on('window-all-closed', () => {
46+
if (process.platform !== 'darwin') {
47+
app.quit()
48+
}
49+
})
50+
51+
app.on('activate', () => {
52+
if (BrowserWindow.getAllWindows().length === 0) createWindow()
53+
})
54+
55+
app.on('ready', async () => {
56+
if (isDevelopment && !process.env.IS_TEST) {
57+
// Install Vue Devtools
58+
// try {
59+
// await installExtension(VUEJS_DEVTOOLS)
60+
// } catch (e) {
61+
// console.error('Vue Devtools failed to install:', e.toString())
62+
// }
63+
}
64+
createWindow()
65+
})
66+
67+
if (isDevelopment) {
68+
if (process.platform === 'win32') {
69+
process.on('message', (data) => {
70+
if (data === 'graceful-exit') {
71+
app.quit()
72+
}
73+
})
74+
} else {
75+
process.on('SIGTERM', () => {
76+
app.quit()
77+
})
78+
}
79+
}

0 commit comments

Comments
 (0)