umbrella22

添加nedb数据库操作,去除eslint

...@@ -17,17 +17,17 @@ let mainConfig = { ...@@ -17,17 +17,17 @@ let mainConfig = {
17 ], 17 ],
18 module: { 18 module: {
19 rules: [ 19 rules: [
20 - { 20 + // {
21 - test: /\.(js)$/, 21 + // test: /\.(js)$/,
22 - enforce: 'pre', 22 + // enforce: 'pre',
23 - exclude: /node_modules/, 23 + // exclude: /node_modules/,
24 - use: { 24 + // use: {
25 - loader: 'eslint-loader', 25 + // loader: 'eslint-loader',
26 - options: { 26 + // options: {
27 - formatter: require('eslint-friendly-formatter') 27 + // formatter: require('eslint-friendly-formatter')
28 - } 28 + // }
29 - } 29 + // }
30 - }, 30 + // },
31 { 31 {
32 test: /\.js$/, 32 test: /\.js$/,
33 use: 'babel-loader', 33 use: 'babel-loader',
......
...@@ -31,17 +31,17 @@ let rendererConfig = { ...@@ -31,17 +31,17 @@ let rendererConfig = {
31 ], 31 ],
32 module: { 32 module: {
33 rules: [ 33 rules: [
34 - { 34 + // {
35 - test: /\.(js|vue)$/, 35 + // test: /\.(js|vue)$/,
36 - enforce: 'pre', 36 + // enforce: 'pre',
37 - exclude: /node_modules/, 37 + // exclude: /node_modules/,
38 - use: { 38 + // use: {
39 - loader: 'eslint-loader', 39 + // loader: 'eslint-loader',
40 - options: { 40 + // options: {
41 - formatter: require('eslint-friendly-formatter') 41 + // formatter: require('eslint-friendly-formatter')
42 - } 42 + // }
43 - } 43 + // }
44 - }, 44 + // },
45 { 45 {
46 test: /\.scss$/, 46 test: /\.scss$/,
47 use: ['vue-style-loader', 'css-loader', 'sass-loader'] 47 use: ['vue-style-loader', 'css-loader', 'sass-loader']
......
...@@ -18,17 +18,17 @@ let webConfig = { ...@@ -18,17 +18,17 @@ let webConfig = {
18 }, 18 },
19 module: { 19 module: {
20 rules: [ 20 rules: [
21 - { 21 + // {
22 - test: /\.(js|vue)$/, 22 + // test: /\.(js|vue)$/,
23 - enforce: 'pre', 23 + // enforce: 'pre',
24 - exclude: /node_modules/, 24 + // exclude: /node_modules/,
25 - use: { 25 + // use: {
26 - loader: 'eslint-loader', 26 + // loader: 'eslint-loader',
27 - options: { 27 + // options: {
28 - formatter: require('eslint-friendly-formatter') 28 + // formatter: require('eslint-friendly-formatter')
29 - } 29 + // }
30 - } 30 + // }
31 - }, 31 + // },
32 { 32 {
33 test: /\.scss$/, 33 test: /\.scss$/,
34 use: ['vue-style-loader', 'css-loader', 'sass-loader'] 34 use: ['vue-style-loader', 'css-loader', 'sass-loader']
......
...@@ -12,14 +12,11 @@ ...@@ -12,14 +12,11 @@
12 "build:web": "cross-env BUILD_TARGET=web node .electron-vue/build.js", 12 "build:web": "cross-env BUILD_TARGET=web node .electron-vue/build.js",
13 "dev": "node .electron-vue/dev-runner.js", 13 "dev": "node .electron-vue/dev-runner.js",
14 "e2e": "npm run pack && mocha test/e2e", 14 "e2e": "npm run pack && mocha test/e2e",
15 - "lint": "eslint --ext .js,.vue -f ./node_modules/eslint-friendly-formatter src test",
16 - "lint:fix": "eslint --ext .js,.vue -f ./node_modules/eslint-friendly-formatter --fix src test",
17 "pack": "npm run pack:main && npm run pack:renderer", 15 "pack": "npm run pack:main && npm run pack:renderer",
18 "pack:main": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.main.config.js", 16 "pack:main": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.main.config.js",
19 "pack:renderer": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.renderer.config.js", 17 "pack:renderer": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.renderer.config.js",
20 "test": "npm run unit && npm run e2e", 18 "test": "npm run unit && npm run e2e",
21 - "unit": "karma start test/unit/karma.conf.js", 19 + "unit": "karma start test/unit/karma.conf.js"
22 - "postinstall": "npm run lint:fix"
23 }, 20 },
24 "build": { 21 "build": {
25 "productName": "my-project", 22 "productName": "my-project",
......
1 // 这里是定义菜单的地方,详情请查看 https://electronjs.org/docs/api/menu 1 // 这里是定义菜单的地方,详情请查看 https://electronjs.org/docs/api/menu
2 +const { dialog } = require('electron')
2 const menu = [{ 3 const menu = [{
3 label: '文档操作', 4 label: '文档操作',
4 submenu: [{ 5 submenu: [{
...@@ -22,5 +23,22 @@ const menu = [{ ...@@ -22,5 +23,22 @@ const menu = [{
22 accelerator: 'CmdOrCtrl+F4', 23 accelerator: 'CmdOrCtrl+F4',
23 role: 'close' 24 role: 'close'
24 }] 25 }]
26 +}, {
27 + label: '帮助',
28 + submenu: [{
29 + label: '切换到开发者模式',
30 + accelerator: 'CmdOrCtrl+I',
31 + role: 'toggledevtools'
32 + }, {
33 + label: '关于',
34 + role: 'about',
35 + click: function () {
36 + dialog.showMessageBox({
37 + title: '关于',
38 + type: 'info',
39 + message: '程序使用electron搭建,程序制作Sky'
40 + })
41 + }
42 + }]
25 }] 43 }]
26 export default menu 44 export default menu
......
1 +import db from '../utils/db'
2 +
3 +export default {
4 + adddata (data) {
5 + return new Promise((resolve, reject) => {
6 + db.insert(data, (err, newdoc) => {
7 + if (err) {
8 + reject(err)
9 + return false
10 + }
11 + resolve(newdoc)
12 + })
13 + })
14 + },
15 + finddata (query) {
16 + return new Promise((resolve, reject) => {
17 + db.find(query, (err, res) => {
18 + if (err) {
19 + reject(err)
20 + return false
21 + }
22 + resolve(res)
23 + })
24 + })
25 + },
26 + findone (query) {
27 + return new Promise((resolve, reject) => {
28 + db.findOne(query, (err, res) => {
29 + if (err) {
30 + reject(err)
31 + return false
32 + }
33 + resolve(res)
34 + })
35 + })
36 + }
37 +}
...@@ -3,17 +3,17 @@ ...@@ -3,17 +3,17 @@
3 <img id="logo" src="~@/assets/logo.png" alt="electron-vue"> 3 <img id="logo" src="~@/assets/logo.png" alt="electron-vue">
4 <main> 4 <main>
5 <div class="left-side"> 5 <div class="left-side">
6 - <span class="title"> 6 + <span class="title">Welcome to your new project!</span>
7 - Welcome to your new project!
8 - </span>
9 <system-information></system-information> 7 <system-information></system-information>
8 + <span>{{text}}</span>
10 </div> 9 </div>
11 10
12 <div class="right-side"> 11 <div class="right-side">
13 <div class="doc"> 12 <div class="doc">
14 <div class="title alt">Other Documentation</div> 13 <div class="title alt">Other Documentation</div>
15 <el-button type="primary" round @click="open()">控制台打印</el-button> 14 <el-button type="primary" round @click="open()">控制台打印</el-button>
16 - <el-button type="primary" round>element按钮示例</el-button> 15 + <el-button type="primary" round @click="setdata">写入数据</el-button>
16 + <el-button type="primary" round @click="getdata">读取数据</el-button>
17 </div> 17 </div>
18 </div> 18 </div>
19 </main> 19 </main>
...@@ -21,79 +21,100 @@ ...@@ -21,79 +21,100 @@
21 </template> 21 </template>
22 22
23 <script> 23 <script>
24 - import SystemInformation from './LandingPage/SystemInformation' 24 +import SystemInformation from "./LandingPage/SystemInformation";
25 25
26 - export default { 26 +export default {
27 - name: 'landing-page', 27 + name: "landing-page",
28 components: { SystemInformation }, 28 components: { SystemInformation },
29 - methods: { 29 + data: () => ({
30 - open (link) { 30 + text: "等待数据读取",
31 - console.log(this.$electron) 31 + newdata: {
32 + name: "yyy",
33 + age: "12"
32 } 34 }
35 + }),
36 + methods: {
37 + open(link) {
38 + console.log(this.$electron);
39 + },
40 + setdata() {
41 + this.$db
42 + .adddata(this.newdata)
43 + .then(res => console.log(res))
44 + .catch(err => console.log(err));
45 + },
46 + getdata() {
47 + this.$db
48 + .finddata()
49 + .then(res => console.log(res))
50 + .catch(err => console.log(err));
33 } 51 }
34 } 52 }
53 +};
35 </script> 54 </script>
36 55
37 <style> 56 <style>
38 - 57 +* {
39 - * {
40 box-sizing: border-box; 58 box-sizing: border-box;
41 margin: 0; 59 margin: 0;
42 padding: 0; 60 padding: 0;
43 - } 61 +}
44 62
45 - body { font-family: 'Source Sans Pro', sans-serif; } 63 +body {
64 + font-family: "Source Sans Pro", sans-serif;
65 +}
46 66
47 - #wrapper { 67 +#wrapper {
48 - background: 68 + background: radial-gradient(
49 - radial-gradient(
50 ellipse at top left, 69 ellipse at top left,
51 rgba(255, 255, 255, 1) 40%, 70 rgba(255, 255, 255, 1) 40%,
52 - rgba(229, 229, 229, .9) 100% 71 + rgba(229, 229, 229, 0.9) 100%
53 ); 72 );
54 height: 100vh; 73 height: 100vh;
55 padding: 60px 80px; 74 padding: 60px 80px;
56 width: 100vw; 75 width: 100vw;
57 - } 76 +}
58 77
59 - #logo { 78 +#logo {
60 height: auto; 79 height: auto;
61 margin-bottom: 20px; 80 margin-bottom: 20px;
62 width: 420px; 81 width: 420px;
63 - } 82 +}
64 83
65 - main { 84 +main {
66 display: flex; 85 display: flex;
67 justify-content: space-between; 86 justify-content: space-between;
68 - } 87 +}
69 88
70 - main > div { flex-basis: 50%; } 89 +main > div {
90 + flex-basis: 50%;
91 +}
71 92
72 - .left-side { 93 +.left-side {
73 display: flex; 94 display: flex;
74 flex-direction: column; 95 flex-direction: column;
75 - } 96 +}
76 97
77 - .welcome { 98 +.welcome {
78 color: #555; 99 color: #555;
79 font-size: 23px; 100 font-size: 23px;
80 margin-bottom: 10px; 101 margin-bottom: 10px;
81 - } 102 +}
82 103
83 - .title { 104 +.title {
84 color: #2c3e50; 105 color: #2c3e50;
85 font-size: 20px; 106 font-size: 20px;
86 font-weight: bold; 107 font-weight: bold;
87 margin-bottom: 6px; 108 margin-bottom: 6px;
88 - } 109 +}
89 110
90 - .title.alt { 111 +.title.alt {
91 font-size: 18px; 112 font-size: 18px;
92 margin-bottom: 10px; 113 margin-bottom: 10px;
93 - } 114 +}
94 115
95 - .doc p { 116 +.doc p {
96 color: black; 117 color: black;
97 margin-bottom: 10px; 118 margin-bottom: 10px;
98 - } 119 +}
99 </style> 120 </style>
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -3,8 +3,8 @@ import Vue from 'vue' ...@@ -3,8 +3,8 @@ import Vue from 'vue'
3 import App from './App' 3 import App from './App'
4 import router from './router' 4 import router from './router'
5 import store from './store' 5 import store from './store'
6 -// 引用nedb做本地存储 6 +// 导入数据操作库
7 -import db from './utils/db' 7 +import db from './api/operationalData'
8 // 引用element 8 // 引用element
9 import ElementUI from 'element-ui' 9 import ElementUI from 'element-ui'
10 import 'element-ui/lib/theme-chalk/index.css' 10 import 'element-ui/lib/theme-chalk/index.css'
...@@ -13,8 +13,9 @@ if (!process.env.IS_WEB) Vue.use(require('vue-electron')) ...@@ -13,8 +13,9 @@ if (!process.env.IS_WEB) Vue.use(require('vue-electron'))
13 13
14 Vue.use(ElementUI) 14 Vue.use(ElementUI)
15 15
16 -Vue.config.productionTip = false
17 Vue.prototype.$db = db 16 Vue.prototype.$db = db
17 +
18 +Vue.config.productionTip = false
18 /* eslint-disable no-new */ 19 /* eslint-disable no-new */
19 new Vue({ 20 new Vue({
20 components: { 21 components: {
......