Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add validators
  • Loading branch information
jackhutu committed Apr 24, 2017
1 parent 00d6474 commit e19354a
Show file tree
Hide file tree
Showing 43 changed files with 535 additions and 460 deletions.
48 changes: 24 additions & 24 deletions gulpfile.js
Expand Up @@ -9,25 +9,25 @@ var gulpSequence = require('gulp-sequence')
var nodemon = require('gulp-nodemon')
var open = require('open')

var DEV_PORT = 3000,PROD_PORT = 8400
var DEV_PORT = 3100, PROD_PORT = 8400
gulp.task('serve', function () {
var webpackConfig = require('./webpack.config')
var myConfig = Object.create(webpackConfig)
myConfig.entry.unshift('webpack/hot/only-dev-server')
myConfig.entry.unshift('webpack-dev-server/client?http://localhost:' + DEV_PORT)
new WebpackDevServer(webpack(myConfig), {
noInfo: false,
hot: true,
inline: true,
historyApiFallback: true,
publicPath: myConfig.output.publicPath,
stats: {
colors: true
}
noInfo: false,
hot: true,
inline: true,
historyApiFallback: true,
publicPath: myConfig.output.publicPath,
stats: {
colors: true
}
}).listen(DEV_PORT, 'localhost', function (err) {
if(err) throw new gutil.PluginError('webpack-dev-server', err)
gutil.log('[webpack-dev-server]', '==> 🌎 http://localhost:' + DEV_PORT)
open('http://localhost:' + DEV_PORT)
if (err) throw new gutil.PluginError('webpack-dev-server', err)
gutil.log('[webpack-dev-server]', '==> 🌎 http://localhost:' + DEV_PORT)
open('http://localhost:' + DEV_PORT)
})
})

Expand All @@ -38,35 +38,35 @@ gulp.task('clean', function () {
gulp.task('set-env-prod', function () {
env({
vars: {
'NODE_ENV':'production'
'NODE_ENV': 'production'
}
})
})

gulp.task('webpack', function (callback) {
var config = require('./webpack.config')
webpack(config, function(err, stats) {
if(err) throw new gutil.PluginError("webpack", err)
gutil.log("[webpack]", stats.toString({
// output options
webpack(config, function (err, stats) {
if (err) throw new gutil.PluginError('webpack', err)
gutil.log('[webpack]', stats.toString({
// output options
}))
callback()
})
})

gulp.task('webpack:dist',gulpSequence('set-env-prod','webpack'))
gulp.task('webpack:dist', gulpSequence('set-env-prod', 'webpack'))

gulp.task('build', gulpSequence('clean','webpack:dist'))
gulp.task('build', gulpSequence('clean', 'webpack:dist'))

gulp.task('nodemon', function () {
nodemon({
script: path.join(__dirname,'/server.js'),
script: path.join(__dirname, '/server.js'),
ext: 'js',
watch: [
path.join(__dirname,'/dist')
path.join(__dirname, '/dist')
],
env: { 'NODE_ENV': 'production','PORT':PROD_PORT }
})
env: { 'NODE_ENV': 'production', 'PORT': PROD_PORT }
})
})

gulp.task('serve:dist',gulpSequence('build','nodemon'))
gulp.task('serve:dist', gulpSequence('build', 'nodemon'))
61 changes: 32 additions & 29 deletions package.json
Expand Up @@ -14,6 +14,8 @@
},
"keywords": [
"vue",
"vue2",
"vuex",
"jackblog"
],
"author": "Jack Hu",
Expand All @@ -23,50 +25,51 @@
},
"homepage": "https://github.com/jackhutu/jackblog-vue#readme",
"devDependencies": {
"babel-core": "^6.17.0",
"babel-loader": "^6.2.5",
"babel-core": "6.24.1",
"babel-loader": "6.4.1",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-preset-es2015": "^6.16.0",
"babel-preset-stage-0": "^6.16.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"babel-runtime": "^6.11.6",
"bootstrap": "^3.3.7",
"css-loader": "^0.25.0",
"css-loader": "^0.28.0",
"del": "^2.2.2",
"eslint": "^3.7.0",
"eslint-loader": "^1.5.0",
"eslint-plugin-vue": "^0.1.1",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0",
"eslint": "^3.19.0",
"eslint-loader": "^1.7.1",
"eslint-plugin-vue": "^2.0.1",
"extract-text-webpack-plugin": "1.0.1",
"file-loader": "^0.11.1",
"font-awesome": "^4.6.3",
"gulp": "^3.9.1",
"gulp-env": "^0.4.0",
"gulp-nodemon": "^2.2.1",
"gulp-sequence": "^0.4.6",
"gulp-util": "^3.0.7",
"html-webpack-plugin": "^2.22.0",
"image-webpack-loader": "^2.0.0",
"html-webpack-plugin": "2.28.0",
"image-webpack-loader": "3.3.0",
"jackblog-sass": "^1.0.6",
"open": "0.0.5",
"react-cookie": "^0.4.8",
"style-loader": "^0.13.1",
"style-loader": "^0.16.1",
"universal-cookie": "^2.0.4",
"url-loader": "^0.5.7",
"vue": "^1.0.26",
"vue-hot-reload-api": "^1.3.3",
"vee-validate": "^2.0.0-beta.25",
"vue": "^2.2.6",
"vue-hot-reload-api": "^2.1.0",
"vue-html-loader": "^1.2.3",
"vue-loader": "^8.5.3",
"vue-resource": "^0.9.3",
"vue-router": "^0.7.13",
"vue-strap": "^1.1.26",
"vue-style-loader": "^1.0.0",
"vue-toast": "^2.0.3",
"vue-validator": "^2.1.7",
"vuex": "^0.8.2",
"vuex-router-sync": "^1.0.1",
"webpack": "^1.13.2",
"webpack-dev-server": "^1.16.1"
"vue-loader": "^11.3.4",
"vue-resource": "^1.3.1",
"vue-router": "^2.4.0",
"vue-strap": "github:wffranco/vue-strap",
"vue-style-loader": "^3.0.0",
"vue-template-compiler": "^2.2.6",
"vue-toast": "^3.0.0",
"vuex": "^2.3.1",
"vuex-router-sync": "^4.1.2",
"webpack": "1.14.0",
"webpack-dev-server": "1.16.3"
},
"dependencies": {
"express": "^4.14.0",
"serve-favicon": "^2.3.0"
"express": "^4.15.2",
"serve-favicon": "^2.4.2"
}
}
20 changes: 11 additions & 9 deletions server.js
@@ -1,21 +1,23 @@
var path = require('path');
var express = require('express');
var favicon = require('serve-favicon');
'use strict'

var app = new express();
var port = process.env.PORT || 8400;
var path = require('path')
var express = require('express')
var favicon = require('serve-favicon')

app.use(express.static(path.join(__dirname, 'dist')));
app.use(favicon(path.join(__dirname, 'dist', 'favicon.ico')));
var app = new express()
var port = process.env.PORT || 8400

app.get("/*", function(req, res) {
app.use(express.static(path.join(__dirname, 'dist')))
app.use(favicon(path.join(__dirname, 'dist', 'favicon.ico')))

app.get('/*', function(req, res) {
return res.sendFile(__dirname + '/dist/index.html')
})

app.listen(port, function(err) {
if (err) {
console.error(err)
} else {
console.info("==> 🌎 Listening on port %s. Open up http://localhost:%s/ in your browser.", port, port)
console.info('==> 🌎 Listening on port %s. Open up http://localhost:%s/ in your browser.', port, port)
}
})
7 changes: 3 additions & 4 deletions src/components/App.vue
Expand Up @@ -2,17 +2,16 @@
<div class="top-box">
<Navbar></Navbar>
<router-view></router-view>
<Toaster></Toaster>
</div>
</template>

<script>
import store from '../vuex/store'
import store from 'store'
import Navbar from './Navbar'
import Toaster from './Toaster'
// import Toaster from './Toaster'
export default {
store,
components: { Navbar,Toaster }
components:{Navbar}
}
</script>
23 changes: 11 additions & 12 deletions src/components/Apps/index.vue
Expand Up @@ -29,22 +29,21 @@
</div>
</template>
<script>
import { getApps } from '../../vuex/actions'
import { mapState,mapActions } from 'vuex'
export default {
vuex:{
getters:{
computed:{
...mapState({
apps: ({apps}) => apps.items
},
actions:{
getApps
}
})
},
route:{
activate ({ next }) {
this.getApps()
next()
}
methods:{
...mapActions([
'getApps'
])
},
created () {
this.getApps()
}
}
</script>
6 changes: 3 additions & 3 deletions src/components/Article/comment.vue
Expand Up @@ -5,7 +5,7 @@
<a href="javascript:;" @click.prevent="goComment" class="goto-comment pull-right"><i class="fa fa-pencil"></i>添加新评论</a>
</div>
<div id="comment_list">
<div class="comment-item" v-for="(i, comment) in commentList">
<div class="comment-item" v-for="(comment,i) in commentList">
<div class="content">
<div class="meta-top">
<a class="avatar">
Expand All @@ -23,9 +23,9 @@

<Reply v-show="comment.replys.length > 0" :replys="comment.replys" :k="i"></Reply>

<form id="replyForm{{i}}" class="new-reply hide" @submit.prevent="submitReply(i,comment._id)">
<form v-bind:id="'replyForm' + i" class="new-reply hide" @submit.prevent="submitReply(i,comment._id)">
<div class="comment-text">
<textarea id="replyContent{{i}}"
<textarea v-bind:id="'replyContent' + i"
required
maxLength="2000"
placeholder="写下你的回复…">
Expand Down
2 changes: 1 addition & 1 deletion src/components/Article/content.vue
Expand Up @@ -6,7 +6,7 @@
<span class="comments-count">评论{{articleDetail.comment_count}}</span>
<span class="likes-count">喜欢{{articleDetail.like_count}}</span>
</div>
<div class="markdown-content">{{{ articleDetail.content }}}</div>
<div class="markdown-content" v-html="articleDetail.content"></div>
</div>
</template>
<script>
Expand Down
40 changes: 22 additions & 18 deletions src/components/Article/index.vue
@@ -1,46 +1,50 @@
<template>
<div class="article-box">
<Content :article-detail="articleDetail"></Content>
<ArtickeContent :article-detail="articleDetail"></ArtickeContent>
<Like :like-count="articleDetail.like_count" :is-like="articleDetail.isLike"></Like>
<Prenext :prev-article="prevArticle" :next-article="nextArticle"></Prenext>
<Comment :comment-list="commentList" :user="user"></Comment>
<Loginmodal v-ref:modal></Loginmodal>
<Loginmodal ref='modal'></Loginmodal>
<Scrolltop></Scrolltop>
</div>
</template>
<script>
import { getArticleDetail,getPrenext,getCommentList,toggleLike,addComment,addReply } from '../../vuex/actions'
import Content from './content.vue'
import ArtickeContent from './content.vue'
import Comment from './comment.vue'
import Prenext from './prenext.vue'
import Like from './like.vue'
import Loginmodal from '../Login/modal.vue'
import Scrolltop from '../Scrolltop/index.vue'
import { mapState,mapActions } from 'vuex'
export default {
components: { Content,Like,Prenext,Comment,Loginmodal,Scrolltop },
vuex:{
getters:{
components: { ArtickeContent,Like,Prenext,Comment,Scrolltop,Loginmodal },
computed: {
...mapState({
articleDetail: ({articleDetail}) => articleDetail.item,
user: ({auth}) => auth.user,
nextArticle: ({prenextArticle}) => prenextArticle.next,
prevArticle: ({prenextArticle}) => prenextArticle.prev,
commentList: ({commentList}) => commentList.items,
options: ({options}) => options.item,
aid: ({route}) => route.params.aid
},
actions:{
getArticleDetail,getPrenext,getCommentList,toggleLike,addComment,addReply
}
aid: ({route}) => route.params.aid
})
},
route:{
data ({ to: { params: { aid }}}) {
this.getPrenext(aid)
this.getCommentList(aid)
this.getArticleDetail(aid, this.user)
}
created () {
const aid = this.$route.params.aid
this.getPrenext(aid)
this.getCommentList(aid)
this.getArticleDetail(aid, this.user)
},
methods:{
...mapActions([
'getArticleDetail',
'getPrenext',
'getCommentList',
'toggleLike',
'addComment',
'addReply'
]),
openLoginModal(){
this.$refs.modal.showModal()
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/Article/prenext.vue
@@ -1,10 +1,10 @@
<template>
<div class="prenext">
<div v-if="prevArticle._id" class="text-left prev">
<a v-link="{ name: 'article', params:{ aid: prevArticle._id } }" class="link-title"><span>上一篇:</span>{{prevArticle.title}} </a>
<router-link :to="{ name: 'article', params: { aid: prevArticle._id }}" class="link-title"><span>上一篇:</span> {{prevArticle.title}}</router-link>
</div>
<div v-if="nextArticle._id" class="text-right next">
<a v-link="{ name: 'article', params:{ aid: nextArticle._id } }" class="link-title"><span>下一篇:</span> {{nextArticle.title}}</a>
<router-link :to="{ name: 'article', params: { aid: nextArticle._id }}" class="link-title"><span>下一篇:</span> {{nextArticle.title}}</router-link>
</div>
</div>
</template>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Article/reply.vue
@@ -1,6 +1,6 @@
<template>
<div class="reply-list">
<div v-for="(i, reply) in replys" class="reply-item">
<div v-for="(reply, i) in replys" class="reply-item">
<p class="reply-content">
<a class="reply-user link-light">{{reply.user_info.nickname}}</a>:
{{reply.content}}
Expand Down

0 comments on commit e19354a

Please sign in to comment.