张恒

升级依赖,修正web打包失败

......@@ -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
......
......@@ -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.
......
......@@ -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.25",
"portfinder": "^1.0.26",
"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",
......
......@@ -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>
......
......@@ -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>
......
<!-- -->
<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 {
......
......@@ -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({
......