Authored by 陈峰

package

.DS_Store
app/build/bundle
server/public/
node_modules/
.idea
... ...
import Vue from 'vue';
import VueCookie from 'vue-cookie';
import Router from 'vue-router';
import App from './pages/app';
import Routers from './pages';
... ... @@ -16,7 +15,6 @@ let router = new Router({routes: Routers});
Vue.use(yohoPluginCore, {router});
Vue.use(yohoPluginPurview);
Vue.use(yohoPluginUser);
Vue.use(VueCookie);
new Vue({
el: '#app',
... ...
const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const util = require('./util');
module.exports = {
entry: {
libs: ['./app.js', 'vue', 'vue-router', 'iview']
libs: ['vue', 'vue-router'],
view: ['iview'],
app: ['./app.js']
},
output: {
path: path.join(__dirname, '../bundle'),
path: util.resolve('../server/public'),
filename: '[name].[hash:7].js',
chunkFilename: '[name].[hash:7].js'
},
... ... @@ -50,7 +52,8 @@ module.exports = {
{
test: /\.js$/,
loader: 'babel-loader',
include: [util.resolve('/')]
include: [util.resolve('/')],
exclude: /node_modules/
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
... ... @@ -65,7 +68,7 @@ module.exports = {
loader: 'url-loader',
options: {
limit: 10000,
name: 'fonts/[name].[hash:7].[ext]'
name: 'fonts/[name].[ext]'
}
},
{
... ... @@ -96,12 +99,19 @@ module.exports = {
]
},
plugins: [
new ExtractTextPlugin('[name].[hash:7].css'),
new ExtractTextPlugin('style.[hash:7].css'),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true
}),
new webpack.optimize.CommonsChunkPlugin({
name: ['view', 'libs'],
}),
new CleanWebpackPlugin([util.resolve('../server/public')], {
verbose: true,
dry: false
})
]
};
... ...
... ... @@ -21,10 +21,12 @@ export default {
let that = this;
this.$router.beforeEach(function breadcrumb(to, from, next) {
that.showBreadcrumb = false;
that.$nextTick(() => { // Breadcrumb更新子组件的separator,如果不手动重建Breadcrumb周期,子组件separator不会得到更新
that.render(to);
});
if (to.name.indexOf('error.') < 0) {
that.showBreadcrumb = false;
that.$nextTick(() => { // Breadcrumb更新子组件的separator,如果不手动重建Breadcrumb周期,子组件separator不会得到更新
that.render(to);
});
}
return next();
});
this.render();
... ...
... ... @@ -41,14 +41,6 @@ let purviews = {
path: '/product/vips'
}
}
},
home: {
name: '',
subPurviews: {
overview: {
name: '默认页'
}
}
}
};
... ...
... ... @@ -46,7 +46,7 @@ export default {
},
login(username, password) {
Vue.passport.local(username, password).then((result) => {
this.$cookie.set('SHOP_ID', result.currentShop.id);
// this.$cookie.set('SHOP_ID', result.currentShop.id);
this.$router.push('/');
}, (error) => {
this.$Message.error(error.message);
... ...
<template>
<div>
<div class="err err-401" v-if="errType === '401'">没权限</div>
<div class="err err-404" v-if="errType === '404'">未找到</div>
<div class="err err-500" v-if="errType === '500'">服务器错误</div>
<div class="err err-401" v-if="errType === 'error.401'">没权限</div>
<div class="err err-404" v-if="errType === 'error.404'">404</div>
<div class="err err-500" v-if="errType === 'error.500'">服务器错误</div>
</div>
</template>
... ... @@ -16,7 +16,7 @@
errType: '500'
};
}
}
};
</script>
<style lang="scss" scoped>
... ...
... ... @@ -2,21 +2,21 @@ const page = r => require.ensure([], () => r(require('./error')), 'error');
const router = [{
path: '/401',
name: '401',
name: 'error.401',
component: page,
meta: {
authPass: true
}
}, {
path: '/404',
name: '404',
name: 'error.404',
component: page,
meta: {
authPass: true
}
}, {
path: '/500',
name: '500',
name: 'error.500',
component: page,
meta: {
authPass: true
... ...
... ... @@ -56,7 +56,7 @@
export default {
props: ['step', 'product'],
mounted : function() {
this.shopId = this.$cookie.get('SHOP_ID');
// this.shopId = this.$cookie.get('SHOP_ID');
this.getBrand();
},
data() {
... ...
... ... @@ -20,6 +20,12 @@ const plugin = {
}
if (options && options.router) {
Vue.$router = options.router;
options.router.beforeEach((to, from, next) => {
if (to.matched.length === 0) {
return next('/404');
}
return next();
});
}
Vue.$store = store;
Vue.prototype.$store = store;
... ... @@ -31,7 +37,7 @@ const plugin = {
});
// 设置axios默认参数
axios.defaults.baseURL = 'http://localhost:6008';
// axios.defaults.baseURL = '';
axios.defaults.responseType = 'json';
}
};
... ...
... ... @@ -20,7 +20,7 @@ const plugin = {
if (to.name === 'auth.login' && userInfo) {
return next('/');
}
if (!Vue.prototype.$user) {
if (!Vue.prototype.$user && userInfo) {
Vue.updateUser(userInfo);
}
}
... ...
... ... @@ -17,6 +17,7 @@
"babel-runtime": "^6.23.0",
"bluebird": "^3.5.0",
"body-parser": "^1.17.1",
"compression": "^1.6.2",
"cookie-parser": "^1.4.3",
"cookie-session": "^2.0.0-beta.1",
"express": "^4.15.2",
... ... @@ -47,6 +48,7 @@
"babel-preset-env": "^1.2.1",
"babel-preset-stage-2": "^6.22.0",
"babel-register": "^6.22.0",
"clean-webpack-plugin": "^0.1.16",
"css-loader": "^0.26.1",
"eslint": "^3.14.1",
"eslint-config-standard": "^6.2.1",
... ...
... ... @@ -7,6 +7,7 @@
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const compression = require('compression');
const Express = require('express');
// const session = require('express-session');
const cookieSession = require('cookie-session');
... ... @@ -37,6 +38,7 @@ app.use(cookieSession({
}
}));
app.use(compression());
app.use(favicon(path.join(__dirname, '/favicon.ico')));
app.use(Express.static(path.join(__dirname, 'public')));
app.use(bodyParser.json());
... ...
/**
* Created by TaoHuang on 2017/4/19.
*/
const _ = require('lodash');
module.exports = {
isAllowdShopId: (shopId, req) => {
return _.find(req.user.allowedShops, {shopsId: shopId}) ? true: false;
}
};
\ No newline at end of file