开启gzip

This commit is contained in:
wuhongjian 2022-10-20 16:15:59 +08:00
parent 56c4393f2e
commit 1f3116f402
6 changed files with 68 additions and 41 deletions

View File

@ -105,6 +105,7 @@ router.beforeEach((to, from, next) => {
return next({ name: 'login' })
}
window.SITE_CONFIG.menuList = res.data.filter(item => item.site === 0)
debugger
fnAddDynamicMenuRoutes(window.SITE_CONFIG.menuList)
next({ ...to, replace: true })
}).catch(() => {
@ -137,6 +138,7 @@ function fnCurrentRouteIsPageRoute (route, pageRoutes = []) {
*/
function fnAddDynamicMenuRoutes (menuList = [], routes = []) {
var temp = []
debugger
for (var i = 0; i < menuList.length; i++) {
if (menuList[i].children && menuList[i].children.length >= 1) {
temp = temp.concat(menuList[i].children)
@ -187,6 +189,7 @@ function fnAddDynamicMenuRoutes (menuList = [], routes = []) {
},
{ path: '*', redirect: { name: '404' } }
])
console.log('查询路由', routes)
window.SITE_CONFIG.dynamicMenuRoutes = routes
window.SITE_CONFIG.dynamicMenuRoutesHasAdded = true
}

View File

@ -1,8 +1,8 @@
<!--
* @Author: hisense.liangjunhua
* @Date: 2022-06-27 11:27:22
* @LastEditors: hisense.liangjunhua
* @LastEditTime: 2022-08-23 10:37:29
* @LastEditors: hisense.wuhongjian
* @LastEditTime: 2022-10-19 11:10:50
* @Description: 能力申请
-->
<template>
@ -168,7 +168,7 @@ export default {
created () {
bus.$off('competencyApplicationInit')
bus.$on('competencyApplicationInit', () => {
this.getDataList();
this.getDataList()
bus.$emit('updateTaskNum')
})
}

View File

@ -1,8 +1,8 @@
<!--
* @Author: hisense.liangjunhua
* @Date: 2022-06-29 15:59:51
* @LastEditors: hisense.liangjunhua
* @LastEditTime: 2022-08-04 14:34:45
* @LastEditors: hisense.wuhongjian
* @LastEditTime: 2022-10-19 11:18:43
* @Description: 告诉大家这是什么
-->
<!-- 流程业务表单 -->
@ -125,7 +125,7 @@ import bus from '@/views/bus.js'
export default {
//
mixins: [processModule],
data() {
data () {
return {
dialogVisible: false,
dialogType: '',
@ -154,7 +154,7 @@ export default {
agreeOrList: '同意'
}
},
created() {
created () {
// KEY
console.log('params=================>', this.$route, this.$route.params)
this.dataForm.taskId = this.$route.params.taskId
@ -188,7 +188,7 @@ export default {
RenProcessDetail
},
methods: {
init() {
init () {
// this.visible = true
this.$nextTick(() => {
// this.$refs.dataForm.resetFields()
@ -200,11 +200,11 @@ export default {
}
})
},
showDialog(title) {
showDialog (title) {
this.dialogVisible = true
this.dialogType = title
},
handleClose(done) {
handleClose (done) {
this.$confirm('确认关闭?')
.then((_) => {
this.input = ''
@ -212,11 +212,11 @@ export default {
})
.catch((_) => { })
},
handleClose2() {
handleClose2 () {
this.dialogVisible = false
this.input = ''
},
downloadFile2(url) {
downloadFile2 (url) {
console.log(window.SITE_CONFIG.previewUrl)
window.open(
window.SITE_CONFIG.previewUrl +
@ -225,7 +225,7 @@ export default {
)
},
//
getInfo() {
getInfo () {
let params = ''
if (this.dataForm.taskId) {
params = `taskId=${this.dataForm.taskId}`
@ -344,7 +344,7 @@ export default {
}
},
//
applyData() {
applyData () {
this.$http
.get(`/resource/select/${this.dataForm.instanceId}`)
.then(({ data: res }) => {
@ -436,7 +436,7 @@ export default {
1000,
{ leading: true, trailing: false }
),
tabRemoveHandle(tabName) {
tabRemoveHandle (tabName) {
console.log(tabName, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
if (tabName === 'home') {
return false
@ -463,19 +463,19 @@ export default {
}
},
//
startProcessErrorCallback(data) {
startProcessErrorCallback (data) {
console.log(data)
},
//
taskHandleErrorCallback(data) { },
download(data) {
taskHandleErrorCallback (data) { },
download (data) {
const alink = document.createElement('a')
alink.download = '附件' // ,,IE10
alink.href = data.attachment // url
alink.click() //
}
},
},
mounted() {
mounted () {
// this.applyData()
}
}

View File

@ -60,6 +60,7 @@
"body-parser": "^1.20.0",
"chalk": "^4.1.1",
"chokidar": "^3.5.2",
"compression-webpack-plugin": "^6.1.1",
"crypto-js": "^4.1.1",
"eslint": "^7.32.0",
"eslint-plugin-prettier": "^4.2.1",

View File

@ -2,7 +2,7 @@
* @Author: hisense.wuhongjian
* @Date: 2022-03-29 16:45:25
* @LastEditors: hisense.wuhongjian
* @LastEditTime: 2022-08-25 11:18:05
* @LastEditTime: 2022-10-19 17:44:14
* @Description: 告诉大家这是什么
-->
<!DOCTYPE html>

View File

@ -18,7 +18,19 @@ const {
donation,
} = require('./src/config')
const { webpackBarName, webpackBanner, donationConsole } = require('vab-config')
const CompressionWebpackPlugin = require('compression-webpack-plugin')
const productionGzipExtensions = [
'js',
'css',
'html',
'svg',
'json',
'txt',
'ico',
]
// gzip
const isPro = process.env.NODE_ENV === 'production'
// const isPro = false
if (donation) donationConsole()
const { version, author } = require('./package.json')
const Webpack = require('webpack')
@ -92,7 +104,6 @@ module.exports = {
chainWebpack(config) {
config.resolve.symlinks(true)
config.module.rule('svg').exclude.add(resolve('src/icon/remixIcon')).end()
config.module
.rule('remixIcon')
.test(/\.svg$/)
@ -110,21 +121,21 @@ module.exports = {
config.when(process.env.NODE_ENV !== 'development', (config) => {
config.performance.set('hints', false)
config.devtool('none')
config.optimization.splitChunks({
chunks: 'all',
cacheGroups: {
libs: {
name: 'vue-admin-beautiful-libs',
test: /[\\/]node_modules[\\/]/,
priority: 10,
chunks: 'initial',
},
},
})
config
.plugin('banner')
.use(Webpack.BannerPlugin, [`${webpackBanner}${time}`])
.end()
// config.optimization.splitChunks({
// chunks: 'all',
// cacheGroups: {
// libs: {
// name: 'vue-admin-beautiful-libs',
// test: /[\\/]node_modules[\\/]/,
// priority: 10,
// chunks: 'initial',
// },
// },
// })
// config
// .plugin('banner')
// .use(Webpack.BannerPlugin, [`${webpackBanner}${time}`])
// .end()
config.module
.rule('images')
.use('image-webpack-loader')
@ -134,7 +145,19 @@ module.exports = {
})
.end()
})
if (isPro) {
// 使gzip
config.plugin('compressionPlugin').use(
new CompressionWebpackPlugin({
// filename: '[path].gz[query]',
algorithm: 'gzip',
test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
threshold: 10240, // 10240
minRatio: 0.8, //
deleteOriginalAssets: false, //
})
)
}
if (build7z) {
config.when(process.env.NODE_ENV === 'production', (config) => {
config