Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuyihe committed Apr 23, 2019
2 parents 1306e1f + 800496d commit 65d8d21
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 11 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"vue2-editor": "^2.6.6",
"vuedraggable": "^2.20.0",
"vuex": "^3.0.1",
"vuex-persistedstate": "^2.5.4"
"vuex-persistedstate": "^2.5.4",
"webpack-cdn-plugin": "^3.0.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.4.0",
Expand Down
11 changes: 10 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>my_project</title>
<title>vue-admin-project</title>
<% if (process.env.NODE_ENV === 'production') { %>
<% for(var css of htmlWebpackPlugin.options.cdn.css) { %>
<link rel="stylesheet" href="<%=css%>" as="style">
<% } %>
<% for(var js of htmlWebpackPlugin.options.cdn.js) { %>
<script src="<%=js%>"></script>
<% } %>

<% } %>
</head>
<body>
<noscript>
Expand Down
8 changes: 6 additions & 2 deletions src/assets/scss/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ $base-pink:#E2918C;
$base-f8:#f8f8f8;
$base-666:#666;
// Aside
.el-scrollbar{
.el-scrollbar {
height: 100%;
border-right: solid 1px #e6e6e6;
.scrollbar-wrapper {
overflow-x: hidden !important;
.el-scrollbar__view{
.el-scrollbar__view {
// height: 100%;
overflow-x: hidden !important;
}
}
}
.el-menu {
border-right: 0;
}
4 changes: 3 additions & 1 deletion src/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ export default new Vuex.Store({
actions,
getters,
plugins: [createPersistedState({
storage: window.sessionStorage,
reducer(val) {
return {
// 只储存state中的token
token: val.token,
roles: val.roles
roles: val.roles,
tagsList: val.tagsList
}
}
})]
Expand Down
10 changes: 6 additions & 4 deletions src/views/layout/components/Tags.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,19 @@ export default {
}
},
closeTags(index, path) {
if (path === this.$route.fullPath) {
messages("warning", "不可关闭选中标签");
return;
}
if (this.tagsList.length == 1) {
messages("warning", "不可全都关闭");
} else {
//删除当前
let tags = this.tagsList.splice(index, 1);
this.$store.commit("TAGES_LIST", this.tagsList);
}
if (path === this.$route.fullPath) {
//如果关闭当前直接跳到下一个
this.$router.push(
this.$store.state.tagsList[this.$store.state.tagsList.length - 1]
);
}
}
}
};
Expand Down
46 changes: 44 additions & 2 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,63 @@ const CompressionWebpackPlugin = require('compression-webpack-plugin')
function resolve(dir) {
return path.join(__dirname, dir)
}
//对一些不经常改动的库,可以通过cdn引入,webpack不对他们打包
let externals = {
'vue': 'Vue',
'axios': 'axios',
'element-ui': 'ELEMENT',
'vue-router': 'VueRouter',
'vuex': 'Vuex'
}
const cdn={
css:[
//element-ui css
'https://unpkg.com/element-ui/lib/theme-chalk/index.css'
],
js:[
//vue
'https://unpkg.com/[email protected]/dist/vue.min.js',
//axios
'http://cdn.staticfile.org/axios/0.19.0-beta.1/axios.min.js',
//vuex
'https://unpkg.com/[email protected]/dist/vuex.min.js',
//vue-router
'https://unpkg.com/[email protected]/dist/vue-router.min.js',
//element
'https://unpkg.com/[email protected]/lib/index.js'
]
}
module.exports = {
//基本路径
publicPath: './',
//输出文件目录
outputDir: 'dist',
//放置生成的静态资源 (js、css、img、fonts) 的 (相对于 outputDir 的) 目录。
assetsDir: 'static',
//生产环境不需要生产map文件
productionSourceMap:false,
chainWebpack: config => {
//这里是对环境的配置,不同的环境对应不同的BASE_URL
config.plugin('define').tap(args => {
args[0]['process.env'].BASE_URL = JSON.stringify(process.env.BASE_URL)
return args;
});
//设置别名
config.resolve.alias
//代码分割
config.optimization.minimize(true);
config.optimization.splitChunks({
chunks: 'all'
})
//只在生产环境生效
if(process.env.NODE_ENV==='production'){
config.externals(externals)
config.plugin('html')
.tap(args=>{
args[0].cdn=cdn;
return args
})
}
//设置别名
config.resolve.alias
.set('@', resolve('src'))
},
// webpack插件配置
Expand Down

0 comments on commit 65d8d21

Please sign in to comment.