Skip to content

Commit 9b2563b

Browse files
committed
init
0 parents  commit 9b2563b

15 files changed

+7681
-0
lines changed

.eslintrc.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es6": true,
5+
"node": true
6+
},
7+
"extends": [
8+
"eslint:recommended",
9+
"plugin:@typescript-eslint/eslint-recommended",
10+
"plugin:@typescript-eslint/recommended",
11+
"plugin:import/errors",
12+
"plugin:import/warnings"
13+
],
14+
"parser": "@typescript-eslint/parser"
15+
}

.gitignore

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
.DS_Store
18+
19+
# Directory for instrumented libs generated by jscoverage/JSCover
20+
lib-cov
21+
22+
# Coverage directory used by tools like istanbul
23+
coverage
24+
*.lcov
25+
26+
# nyc test coverage
27+
.nyc_output
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (https://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
39+
# TypeScript v1 declaration files
40+
typings/
41+
42+
# TypeScript cache
43+
*.tsbuildinfo
44+
45+
# Optional npm cache directory
46+
.npm
47+
48+
# Optional eslint cache
49+
.eslintcache
50+
51+
# Optional REPL history
52+
.node_repl_history
53+
54+
# Output of 'npm pack'
55+
*.tgz
56+
57+
# Yarn Integrity file
58+
.yarn-integrity
59+
60+
# dotenv environment variables file
61+
.env
62+
.env.test
63+
64+
# parcel-bundler cache (https://parceljs.org/)
65+
.cache
66+
67+
# next.js build output
68+
.next
69+
70+
# nuxt.js build output
71+
.nuxt
72+
73+
# vuepress build output
74+
.vuepress/dist
75+
76+
# Serverless directories
77+
.serverless/
78+
79+
# FuseBox cache
80+
.fusebox/
81+
82+
# DynamoDB Local files
83+
.dynamodb/
84+
85+
# Webpack
86+
.webpack/
87+
88+
# Electron-Forge
89+
out/

package.json

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
{
2+
"name": "electron-demo-forge",
3+
"productName": "electron-demo-forge",
4+
"version": "1.0.0",
5+
"description": "My Electron application description",
6+
"main": ".webpack/main",
7+
"scripts": {
8+
"start": "electron-forge start",
9+
"package": "electron-forge package",
10+
"make": "electron-forge make",
11+
"publish": "electron-forge publish",
12+
"lint": "eslint --ext .ts ."
13+
},
14+
"keywords": [],
15+
"author": {
16+
"name": "李孝威",
17+
"email": "[email protected]"
18+
},
19+
"license": "MIT",
20+
"config": {
21+
"forge": {
22+
"packagerConfig": {},
23+
"makers": [
24+
{
25+
"name": "@electron-forge/maker-squirrel",
26+
"config": {
27+
"name": "electron_demo_forge"
28+
}
29+
},
30+
{
31+
"name": "@electron-forge/maker-zip",
32+
"platforms": [
33+
"darwin"
34+
]
35+
},
36+
{
37+
"name": "@electron-forge/maker-deb",
38+
"config": {}
39+
},
40+
{
41+
"name": "@electron-forge/maker-rpm",
42+
"config": {}
43+
}
44+
],
45+
"plugins": [
46+
[
47+
"@electron-forge/plugin-webpack",
48+
{
49+
"mainConfig": "./webpack.main.config.js",
50+
"renderer": {
51+
"config": "./webpack.renderer.config.js",
52+
"entryPoints": [
53+
{
54+
"html": "./src/renderer/index.html",
55+
"js": "./src/renderer/renderer.ts",
56+
"name": "main_window"
57+
}
58+
]
59+
}
60+
}
61+
]
62+
]
63+
}
64+
},
65+
"devDependencies": {
66+
"@electron-forge/cli": "6.0.0-beta.53",
67+
"@electron-forge/maker-deb": "6.0.0-beta.53",
68+
"@electron-forge/maker-rpm": "6.0.0-beta.53",
69+
"@electron-forge/maker-squirrel": "6.0.0-beta.53",
70+
"@electron-forge/maker-zip": "6.0.0-beta.53",
71+
"@electron-forge/plugin-webpack": "6.0.0-beta.53",
72+
"@marshallofsound/webpack-asset-relocator-loader": "^0.5.0",
73+
"@typescript-eslint/eslint-plugin": "^3.9.0",
74+
"@typescript-eslint/parser": "^3.9.0",
75+
"css-loader": "^4.2.1",
76+
"electron": "10.1.3",
77+
"eslint": "^7.6.0",
78+
"eslint-plugin-import": "^2.20.0",
79+
"fork-ts-checker-webpack-plugin": "^5.0.14",
80+
"node-loader": "^1.0.1",
81+
"style-loader": "^1.2.1",
82+
"ts-loader": "^8.0.2",
83+
"typescript": "^4.0.2",
84+
"vue-loader": "^15.9.3",
85+
"vue-style-loader": "^4.1.2",
86+
"vue-template-compiler": "^2.6.12"
87+
},
88+
"dependencies": {
89+
"electron-squirrel-startup": "^1.0.0",
90+
"vue": "^2.6.12",
91+
"vue-router": "^3.4.6"
92+
}
93+
}

src/index.ts

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { app, BrowserWindow } from "electron";
2+
declare const MAIN_WINDOW_WEBPACK_ENTRY: any;
3+
4+
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
5+
if (require("electron-squirrel-startup")) {
6+
// eslint-disable-line global-require
7+
app.quit();
8+
}
9+
10+
const createWindow = (): void => {
11+
// Create the browser window.
12+
const mainWindow = new BrowserWindow({
13+
height: 600,
14+
width: 800,
15+
});
16+
17+
// and load the index.html of the app.
18+
mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY);
19+
20+
// Open the DevTools.
21+
mainWindow.webContents.openDevTools();
22+
};
23+
24+
// This method will be called when Electron has finished
25+
// initialization and is ready to create browser windows.
26+
// Some APIs can only be used after this event occurs.
27+
app.on("ready", createWindow);
28+
29+
// Quit when all windows are closed, except on macOS. There, it's common
30+
// for applications and their menu bar to stay active until the user quits
31+
// explicitly with Cmd + Q.
32+
app.on("window-all-closed", () => {
33+
if (process.platform !== "darwin") {
34+
app.quit();
35+
}
36+
});
37+
38+
app.on("activate", () => {
39+
// On OS X it's common to re-create a window in the app when the
40+
// dock icon is clicked and there are no other windows open.
41+
if (BrowserWindow.getAllWindows().length === 0) {
42+
createWindow();
43+
}
44+
});
45+
46+
// In this file you can include the rest of your app's specific main process
47+
// code. You can also put them in separate files and import them here.

src/renderer/app.vue

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<template>
2+
<section>
3+
<h1>💖 Hello World!</h1>
4+
<p>Welcome to your Electron application.</p>
5+
<input type="file" @change="selectFileHandle" />
6+
</section>
7+
</template>
8+
9+
<script>
10+
export default {
11+
methods: {
12+
selectFileHandle(e) {
13+
console.log("file change", e.target);
14+
}
15+
}
16+
};
17+
</script>
18+
19+
<style></style>

src/renderer/index.css

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
body {
2+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
3+
margin: auto;
4+
max-width: 38rem;
5+
padding: 2rem;
6+
}

src/renderer/index.html

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>Hello World!</title>
6+
</head>
7+
<body>
8+
<section id="app"></section>
9+
</body>
10+
</html>

src/renderer/renderer.ts

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* This file will automatically be loaded by webpack and run in the "renderer" context.
3+
* To learn more about the differences between the "main" and the "renderer" context in
4+
* Electron, visit:
5+
*
6+
* https://electronjs.org/docs/tutorial/application-architecture#main-and-renderer-processes
7+
*
8+
* By default, Node.js integration in this file is disabled. When enabling Node.js integration
9+
* in a renderer process, please be aware of potential security implications. You can read
10+
* more about security risks here:
11+
*
12+
* https://electronjs.org/docs/tutorial/security
13+
*
14+
* To enable Node.js integration in this file, open up `main.js` and enable the `nodeIntegration`
15+
* flag:
16+
*
17+
* ```
18+
* // Create the browser window.
19+
* mainWindow = new BrowserWindow({
20+
* width: 800,
21+
* height: 600,
22+
* webPreferences: {
23+
* nodeIntegration: true
24+
* }
25+
* });
26+
* ```
27+
*/
28+
29+
import "./index.css";
30+
import Vue from "vue";
31+
import App from "./app.vue";
32+
33+
console.log(
34+
'👋 This message is being logged by "renderer.js", included via webpack'
35+
);
36+
37+
const app = new Vue({
38+
render: h => h(App)
39+
}).$mount("#app");
40+
console.log("vue app ", app);

src/renderer/shims-vue.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module "*.vue" {
2+
import Vue from "vue";
3+
export default Vue;
4+
}

tsconfig.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"compilerOptions": {
3+
"allowJs": true,
4+
"module": "commonjs",
5+
"skipLibCheck": true,
6+
"esModuleInterop": true,
7+
"noImplicitAny": true,
8+
"sourceMap": true,
9+
"baseUrl": ".",
10+
"outDir": "dist",
11+
"moduleResolution": "node",
12+
"resolveJsonModule": true,
13+
"paths": {
14+
"*": ["node_modules/*"]
15+
}
16+
},
17+
"include": [
18+
"src/**/*"
19+
]
20+
}

webpack.main.config.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
/**
3+
* This is the main entry point for your application, it's the first file
4+
* that runs in the main process.
5+
*/
6+
entry: './src/index.ts',
7+
// Put your normal webpack config below here
8+
module: {
9+
rules: require('./webpack.rules'),
10+
},
11+
resolve: {
12+
extensions: ['.js', '.ts', '.jsx', '.tsx', '.css', '.json']
13+
},
14+
};

webpack.plugins.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
2+
const VueLoadPlugin = require("vue-loader/lib/plugin");
3+
4+
module.exports = [
5+
new ForkTsCheckerWebpackPlugin(),
6+
new VueLoadPlugin()
7+
];

0 commit comments

Comments
 (0)