切换导航条
切换导航条
当前项目
正在载入...
登录
术习电报
/
electron-vue-template
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
构建
提交
问题看板
文件
提交
网络
比较
分支
标签
作者
张恒
2020-04-29 16:16:35 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
提交
e8217f96dc9997ade4ecea4846be7e9a1629edd9
e8217f96
1 个父辈
3d6d797c
升级依赖,修正web打包失败
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
134 行增加
和
80 行删除
.electron-vue/webpack.web.config.js
README_ZH.md
package-lock.json
package.json
src/renderer/components/LandingPage.vue
src/renderer/components/LandingPage/SystemInformation.vue
src/renderer/components/title/index.vue
src/renderer/main.js
.electron-vue/webpack.web.config.js
查看文件 @
e8217f9
...
...
@@ -9,6 +9,7 @@ const MinifyPlugin = require("babel-minify-webpack-plugin");
const
CopyWebpackPlugin
=
require
(
'copy-webpack-plugin'
)
const
MiniCssExtractPlugin
=
require
(
'mini-css-extract-plugin'
)
const
HtmlWebpackPlugin
=
require
(
'html-webpack-plugin'
)
const
TerserPlugin
=
require
(
'terser-webpack-plugin'
);
const
{
VueLoaderPlugin
}
=
require
(
'vue-loader'
)
function
resolve
(
dir
)
{
...
...
@@ -87,6 +88,7 @@ let webConfig = {
use
:
{
loader
:
'url-loader'
,
query
:
{
esModule
:
false
,
limit
:
10000
,
name
:
'imgs/[name].[ext]'
}
...
...
@@ -97,6 +99,7 @@ let webConfig = {
use
:
{
loader
:
'url-loader'
,
query
:
{
esModule
:
false
,
limit
:
10000
,
name
:
'fonts/[name].[ext]'
}
...
...
@@ -159,6 +162,50 @@ if (process.env.NODE_ENV === 'production') {
minimize
:
true
})
)
webConfig
.
optimization
=
{
splitChunks
:
{
chunks
:
"async"
,
cacheGroups
:
{
vendor
:
{
// 将第三方模块提取出来
minSize
:
30000
,
minChunks
:
1
,
test
:
/node_modules/
,
chunks
:
'initial'
,
name
:
'vendor'
,
priority
:
1
},
commons
:
{
test
:
/
[\\/]
src
[\\/]
common
[\\/]
/
,
name
:
'commons'
,
minSize
:
30000
,
minChunks
:
3
,
chunks
:
'initial'
,
priority
:
-
1
,
reuseExistingChunk
:
true
// 这个配置允许我们使用已经存在的代码块
}
}
},
runtimeChunk
:
{
name
:
'runtime'
},
minimizer
:
[
new
TerserPlugin
({
test
:
/
\.
js
(\?
.*
)?
$/i
,
extractComments
:
false
,
cache
:
false
,
sourceMap
:
false
,
terserOptions
:
{
warnings
:
false
,
compress
:
{
warnings
:
false
,
drop_console
:
true
,
drop_debugger
:
true
,
pure_funcs
:
[
'console.log'
]
},
output
:
{
comments
:
false
,
},
}
})]
}
}
module
.
exports
=
webConfig
...
...
README_ZH.md
查看文件 @
e8217f9
...
...
@@ -50,6 +50,7 @@ npm config edit
这是花裤衩大大原本的
[
地址
](
https://github.com/PanJiaChen/electron-vue-admin
)
# 更新日志
-
2020年04月29日:修复web打包失败,提升依赖;文档待完善
-
2020年02月09日:添加
[
中文在线文档
](
https://umbrella22.github.io/electron-vue-template-doc/
)
,
[
国内访问地址
](
https://zh-sky.gitee.io/electron-vue-template-doc/
)
-
剔除win打包依赖,因为太大了,将它放到码云的额外仓库中,
[
地址
](
https://gitee.com/Zh-Sky/HardToDownloadLib
)
-
2020年02月06日更新:激进分支更新至8.0.0.
...
...
package-lock.json
查看文件 @
e8217f9
此文件的差异被折叠,
点击展开。
package.json
查看文件 @
e8217f9
...
...
@@ -72,7 +72,7 @@
"dependencies"
:
{
"axios"
:
"^0.19.2"
,
"date-fns"
:
"^2.12.0"
,
"electron-updater"
:
"^4.
2.5
"
,
"electron-updater"
:
"^4.
3.1
"
,
"element-ui"
:
"^2.13.1"
,
"express"
:
"^4.17.1"
,
"fs-extra"
:
"^9.0.0"
,
...
...
@@ -138,11 +138,11 @@
"multispinner"
:
"^0.2.1"
,
"node-loader"
:
"^0.6.0"
,
"node-sass"
:
"^4.14.0"
,
"portfinder"
:
"^1.0.2
5
"
,
"portfinder"
:
"^1.0.2
6
"
,
"sass-loader"
:
"^8.0.2"
,
"split2"
:
"^3.1.1"
,
"style-loader"
:
"^1.2.
0
"
,
"svg-sprite-loader"
:
"^4.2.
6
"
,
"style-loader"
:
"^1.2.
1
"
,
"svg-sprite-loader"
:
"^4.2.
7
"
,
"terser-webpack-plugin"
:
"^2.3.6"
,
"through2-filter"
:
"^3.0.0"
,
"url-loader"
:
"^4.1.0"
,
...
...
src/renderer/components/LandingPage.vue
查看文件 @
e8217f9
...
...
@@ -53,7 +53,6 @@
<script>
import SystemInformation from "./LandingPage/SystemInformation";
import ipcApi from "../utils/ipcRenderer";
import { message } from "@/api/login";
export default {
name: "landing-page",
...
...
@@ -90,8 +89,8 @@ export default {
});
},
StartServer() {
ipcApi.send("statr-server");
ipcApi.on("confirm-start", (event, arg) => {
this.$
ipcApi.send("statr-server");
this.$
ipcApi.on("confirm-start", (event, arg) => {
console.log(arg);
this.$message({
type: "success",
...
...
@@ -130,8 +129,8 @@ export default {
noLink: true,
message: "此操作会清空本地数据库中的所有数据,是否继续?"
};
ipcApi.send("open-messagebox", data);
ipcApi.on("confirm-message", (event, arg) => {
this.$
ipcApi.send("open-messagebox", data);
this.$
ipcApi.on("confirm-message", (event, arg) => {
console.log(arg);
if (arg.response === 0) {
this.$db.deleall({ name: "yyy" }).then(res => {
...
...
@@ -147,7 +146,7 @@ export default {
title: "错误",
message: "已经没有数据可以被删除!"
};
ipcApi.send("open-errorbox", errormsg);
this.$
ipcApi.send("open-errorbox", errormsg);
}
});
}
...
...
@@ -157,9 +156,9 @@ export default {
switch (data) {
case "one":
const dialog = this.$electron.remote.dialog;
ipcApi.send("check-update");
this.$
ipcApi.send("check-update");
console.log("启动检查");
ipcApi.on("UpdateMsg", (event, data) => {
this.$
ipcApi.on("UpdateMsg", (event, data) => {
console.log(data);
switch (data.state) {
case -1:
...
...
@@ -189,7 +188,7 @@ export default {
this.$alert("更新下载完成!", "提示", {
confirmButtonText: "确定",
callback: action => {
ipcApi.send("confirm-update");
this.$
ipcApi.send("confirm-update");
}
});
break;
...
...
@@ -201,34 +200,34 @@ export default {
break;
case "two":
console.log(111);
ipcApi.send("start-download");
ipcApi.on("confirm-download", (event, arg) => {
this.$
ipcApi.send("start-download");
this.$
ipcApi.on("confirm-download", (event, arg) => {
if (arg) {
this.dialogVisible = true;
}
});
ipcApi.on("download-progress", (event, arg) => {
this.$
ipcApi.on("download-progress", (event, arg) => {
this.percentage = Number(arg);
});
ipcApi.on("download-error", (event, arg) => {
this.$
ipcApi.on("download-error", (event, arg) => {
if (arg) {
this.progressStaus = "exception";
this.percentage = 40;
this.colors = "#d81e06";
}
});
ipcApi.on("download-paused", (event, arg) => {
this.$
ipcApi.on("download-paused", (event, arg) => {
if (arg) {
this.progressStaus = "warning";
this.$alert("下载由于未知原因被中断!", "提示", {
confirmButtonText: "重试",
callback: action => {
ipcApi.send("satrt-download");
this.$
ipcApi.send("satrt-download");
}
});
}
});
ipcApi.on("download-done", (event, age) => {
this.$
ipcApi.on("download-done", (event, age) => {
this.filePath = age.filePath;
this.progressStaus = "success";
this.$alert("更新下载完成!", "提示", {
...
...
@@ -249,12 +248,12 @@ export default {
}
},
destroyed() {
ipcApi.remove("confirm-message");
ipcApi.remove("download-done");
ipcApi.remove("download-paused");
ipcApi.remove("confirm-download");
ipcApi.remove("download-progress");
ipcApi.remove("download-error");
this.$
ipcApi.remove("confirm-message");
this.$
ipcApi.remove("download-done");
this.$
ipcApi.remove("download-paused");
this.$
ipcApi.remove("confirm-download");
this.$
ipcApi.remove("download-progress");
this.$
ipcApi.remove("download-error");
}
};
</script>
...
...
src/renderer/components/LandingPage/SystemInformation.vue
查看文件 @
e8217f9
...
...
@@ -35,49 +35,51 @@
</template>
<script>
export default {
data () {
return {
electron: process.versions.electron,
name: this.$route.name,
node: process.versions.node,
path: this.$route.path,
platform: require('os').platform(),
arch:require('os').arch(),
vue: require('vue/package.json').version
}
},
mounted(){
console.log(this.$route)
}
export default {
data() {
return {
electron: process.versions.electron || "浏览器环境",
name: this.$route.name,
node: process.versions.node || "浏览器环境",
path: this.$route.path,
platform: require("os").platform(),
arch: require("os").arch(),
vue: require("vue/package.json").version
};
},
mounted() {
console.log(this.$route);
}
};
</script>
<style scoped>
.title {
color: #888;
font-size: 18px;
font-weight: initial;
letter-spacing:
.25px;
margin-top: 10px;
}
.title {
color: #888;
font-size: 18px;
font-weight: initial;
letter-spacing: 0
.25px;
margin-top: 10px;
}
.items { margin-top: 8px; }
.items {
margin-top: 8px;
}
.item {
display: flex;
align-items: center;
margin-bottom: 6px;
line-height: 24px;
}
.item {
display: flex;
align-items: center;
margin-bottom: 6px;
line-height: 24px;
}
.item .name {
color: #6a6a6a;
margin-right: 6px;
}
.item .name {
color: #6a6a6a;
margin-right: 6px;
}
.item .value {
color: #35495e;
font-weight: bold;
}
.item .value {
color: #35495e;
font-weight: bold;
}
</style>
...
...
src/renderer/components/title/index.vue
查看文件 @
e8217f9
<!-- -->
<template>
<div class="window-title" v-if="!IsUseSysTitle&&isMac">
<div class="window-title" v-if="!IsUseSysTitle&&isMac
&&!IsWeb
">
<!-- 软件logo预留位置 -->
<div style="-webkit-app-region: drag;" class="logo">
<svg-icon icon-class="electron-logo"></svg-icon>
...
...
@@ -25,32 +25,35 @@
</template>
<script>
import ipcApi from "@/utils/ipcRenderer";
export default {
data: () => ({
mix: false,
IsUseSysTitle: false,
isMac:process.platform !== 'darwin'
isMac: process.platform !== "darwin",
IsWeb: process.env.IS_WEB
}),
components: {},
created() {
ipcApi.send("IsUseSysTitle");
ipcApi.on("CisUseSysTitle", (event, arg) => (this.IsUseSysTitle = arg));
this.$ipcApi.send("IsUseSysTitle");
this.$ipcApi.on(
"CisUseSysTitle",
(event, arg) => (this.IsUseSysTitle = arg)
);
},
mounted() {},
methods: {
Mini() {
ipcApi.send("windows-mini");
this.$
ipcApi.send("windows-mini");
},
MixOrReduction() {
ipcApi.send("window-max");
ipcApi.on("window-confirm", (event, arg) => (this.mix = arg));
this.$
ipcApi.send("window-max");
this.$
ipcApi.on("window-confirm", (event, arg) => (this.mix = arg));
},
Close() {
ipcApi.send("window-close");
this.$
ipcApi.send("window-close");
}
}
};
...
...
@@ -69,7 +72,7 @@ export default {
.title {
text-align: center;
}
.logo{
.logo
{
margin-left: 20px;
}
.controls-container {
...
...
src/renderer/main.js
查看文件 @
e8217f9
...
...
@@ -3,8 +3,6 @@ import Vue from 'vue'
import
App
from
'./App'
import
router
from
'./router'
import
store
from
'./store'
// 导入数据操作库
import
db
from
'./api/operationalData'
// 引用element
import
ElementUI
from
'element-ui'
import
'element-ui/lib/theme-chalk/index.css'
...
...
@@ -14,14 +12,18 @@ import './error'
import
'./icons'
import
'@/styles/index.scss'
if
(
!
require
(
'../../config'
).
IsUseSysTitle
)
require
(
'@/styles/custom-title.scss'
)
if
(
!
process
.
env
.
IS_WEB
)
Vue
.
use
(
require
(
'vue-electron'
))
if
(
!
process
.
env
.
IS_WEB
)
{
Vue
.
use
(
require
(
'vue-electron'
))
if
(
!
require
(
'../../config'
).
IsUseSysTitle
)
{
require
(
'@/styles/custom-title.scss'
)
}
// 当处于electron状态下才引用db
Vue
.
prototype
.
$db
=
require
(
'./api/operationalData'
).
default
Vue
.
prototype
.
$ipcApi
=
require
(
'./utils/ipcRenderer'
).
default
}
Vue
.
use
(
ElementUI
)
Vue
.
prototype
.
$db
=
db
Vue
.
config
.
productionTip
=
false
/* eslint-disable no-new */
const
vue
=
new
Vue
({
...
...
请
注册
或
登录
后发表评论