Skip to content

Commit

Permalink
Merge branch 'release/2.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ciqulover committed Nov 29, 2016
2 parents f4f3797 + a839f9b commit fe09243
Show file tree
Hide file tree
Showing 21 changed files with 167 additions and 124 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
@@ -0,0 +1,4 @@
.git
dist/
publish/
src/assets/js/
18 changes: 18 additions & 0 deletions .eslintrc.js
@@ -0,0 +1,18 @@
module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module'
},
plugins: [
'html'
],
extends: 'standard',
'rules': {
'arrow-parens': 0,
'generator-star-spacing': 0,
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
'no-console': process.env.NODE_ENV === 'production' ? 2 : 0,
'no-return-assign':0
}
}
17 changes: 9 additions & 8 deletions dist/main.js

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions dist/setup.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/styles.css

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions package.json
Expand Up @@ -6,34 +6,45 @@
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --inline --hot",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules",
"server": "node ./server/index"
"server": "node ./server/index",
"lint": "eslint --ext .js,.vue .",
"fix": "eslint --fix --ext .js,.vue ."
},
"dependencies": {
"babel-eslint": "^7.1.1",
"body-parser": "^1.15.2",
"cookie-parser": "^1.4.3",
"express": "^4.14.0",
"mongoose": "^4.6.4",
"serve-favicon": "^2.3.0"
},
"devDependencies": {
"autoprefixer": "^6.5.3",
"babel-core": "^6.0.0",
"babel-eslint": "^7.1.1",
"babel-loader": "^6.0.0",
"babel-plugin-transform-object-rest-spread": "^6.19.0",
"babel-preset-es2015": "^6.0.0",
"copy-webpack-plugin": "^4.0.0",
"cross-env": "^3.0.0",
"css-loader": "^0.25.0",
"eslint": "^3.11.1",
"eslint-config-standard": "^6.2.1",
"eslint-friendly-formatter": "^2.0.6",
"eslint-plugin-html": "^1.7.0",
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-standard": "^2.0.1",
"extract-text-webpack-plugin": "^2.0.0-beta",
"file-loader": "^0.9.0",
"node-sass": "^3.10.1",
"sass": "^0.5.0",
"sass-loader": "^4.0.2",
"url-loader": "^0.5.7",
"vue": "^2.0.1",
"vue-loader": "^9.7.0",
"vue-resource": "^1.0.3",
"vue-router": "^2.0.1",
"vuex": "^2.0.0",
"vue-loader": "^9.7.0",
"webpack": "^2.1.0-beta.25",
"webpack-dev-server": "^2.1.0-beta.0"
}
Expand Down
25 changes: 12 additions & 13 deletions server/api.js
@@ -1,11 +1,11 @@
const express = require('express')
const router = express.Router()
const db = require('./db')
const fn = ()=> {}
const fn = () => {}

router.get('/api/getArticle', (req, res)=> {
router.get('/api/getArticle', (req, res) => {
const _id = req.query.id
db.Article.findOne({_id}, (err, doc)=> {
db.Article.findOne({_id}, (err, doc) => {
if (err) {
console.log(err)
} else if (doc) {
Expand All @@ -14,7 +14,7 @@ router.get('/api/getArticle', (req, res)=> {
})
})

router.get('/api/getArticles', (req, res)=> {
router.get('/api/getArticles', (req, res) => {
db.Article.find(null, 'title date content', (err, doc) => {
if (err) {
console.log(err)
Expand Down Expand Up @@ -46,7 +46,7 @@ router.post('/api/login', (req, res) => {
})
})

router.post('/api/saveArticle', (req, res)=> {
router.post('/api/saveArticle', (req, res) => {
const id = req.body._id
const article = {
title: req.body.title,
Expand All @@ -61,14 +61,13 @@ router.post('/api/saveArticle', (req, res)=> {
res.status(200).end()
})


router.post('/api/deleteArticle', (req, res)=> {
router.post('/api/deleteArticle', (req, res) => {
db.Article.findByIdAndRemove(req.body.id, fn)
res.status(200).end()
})

router.post('/api/getLinks', (req, res) => {
db.Link.find(null, (err, doc)=> {
db.Link.find(null, (err, doc) => {
if (err) {
console.log(err)
} else if (doc) {
Expand All @@ -77,16 +76,16 @@ router.post('/api/getLinks', (req, res) => {
})
})

router.post('/api/saveLinks', (req, res)=> {
router.post('/api/saveLinks', (req, res) => {
const links = req.body || []
db.Link.remove(null, fn)
const promises = links.map(({name, href})=> new db.Link({name, href}).save())
const promises = links.map(({name, href}) => new db.Link({name, href}).save())
Promise.all(promises)
.then(()=>res.status(200).end())
.catch(()=>res.status(500).end())
.then(() => res.status(200).end())
.catch(() => res.status(500).end())
})

router.post('/api/savePwd', (req, res)=> {
router.post('/api/savePwd', (req, res) => {
const {name, pwd} = req.body
db.User.findOneAndUpdate({name}, {pwd}, fn)
res.status(200).end()
Expand Down
12 changes: 6 additions & 6 deletions server/db.js
Expand Up @@ -4,18 +4,18 @@ const Schema = mongoose.Schema

const userSchema = new Schema({
name: String,
pwd: String,
pwd: String
})

const articleSchema = new Schema({
title: String,
date: Date,
content: String,
content: String
})

const linkSchema = new Schema({
name: String,
href: String,
href: String
})

const Models = {
Expand All @@ -31,9 +31,9 @@ const initialize = function () {
console.log(err)
} else if (!doc.length) {
console.log('Database opens for the first time...')
Promise.all(init.map(item=>new Models[item.type](item).save()))
.then(()=>console.log('Initialize successfully.'))
.catch(()=>console.log('Something went wrong during initializing.'))
Promise.all(init.map(item => new Models[item.type](item).save()))
.then(() => console.log('Initialize successfully.'))
.catch(() => console.log('Something went wrong during initializing.'))
} else {
Models.initialized = true
}
Expand Down
6 changes: 3 additions & 3 deletions server/index.js
Expand Up @@ -5,7 +5,7 @@ const favicon = require('serve-favicon')
const bodyParser = require('body-parser')
const cookieParser = require('cookie-parser')
const db = require('./db')
const resolve = file=>path.resolve(__dirname, file)
const resolve = file => path.resolve(__dirname, file)
const api = require('./api')
const app = express()

Expand All @@ -22,11 +22,11 @@ app.use(api)
app.post('/api/setup', function (req, res) {
new db.User(req.body)
.save()
.then(()=> {
.then(() => {
res.status(200).end()
db.initialized = true
})
.catch(()=>res.status(500).end())
.catch(() => res.status(500).end())
})

app.get('*', function (req, res) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/back/Editor.vue
Expand Up @@ -22,7 +22,7 @@
</section>
</template>
<script>
import {mapState, mapActions, mapMutations} from 'vuex'
import {mapActions, mapMutations} from 'vuex'
import marked from '../../assets/js/marked.min'
import hljs from '../../assets/js/highlight.pack'
Expand Down
2 changes: 1 addition & 1 deletion src/components/back/Login.vue
Expand Up @@ -31,7 +31,7 @@
</template>
<script>
import {mapActions} from 'vuex'
import {get, set} from '../../assets/js/cookieUtil'
import {set} from '../../assets/js/cookieUtil'
export default{
data(){
Expand Down
2 changes: 1 addition & 1 deletion src/components/back/StatusBar.vue
Expand Up @@ -23,7 +23,7 @@
export default{
methods: {
logout() {
unset('user', '/', location.hostname)
unset('user', '/', window.location.hostname)
this.SET_USER({name: '', pwd: ''})
this.$router.push('/')
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/front/Archive.vue
Expand Up @@ -25,7 +25,7 @@
</main>
</template>
<script>
import {mapState, mapGetters,mapActions} from 'vuex'
import {mapState, mapGetters, mapActions} from 'vuex'
import MyHeader from './MyHeader.vue'
import MyFooter from './MyFooter.vue'
import Spinner from '../share/Spinner.vue'
Expand All @@ -38,7 +38,7 @@
...mapState(['articles']),
...mapGetters(['archive'])
},
methods:{...mapActions(['getArticles'])},
methods: {...mapActions(['getArticles'])},
components: {Spinner, MyHeader, MyFooter}
}
</script>
Expand Down
20 changes: 10 additions & 10 deletions src/main.js
@@ -1,18 +1,18 @@
import Vue from 'vue'
import VueResource from 'vue-resource'
import {mapState} from 'vuex'
import Vue from 'vue'
import VueResource from 'vue-resource'
import {mapState} from 'vuex'

import Spinner from './components/share/Spinner.vue'
import Toast from './components/share/Toast.vue'
import MyCanvas from './components/share/MyCanvas.vue'
import StyleInjector from './components/StyleInjector.vue'
import Spinner from './components/share/Spinner.vue'
import Toast from './components/share/Toast.vue'
import MyCanvas from './components/share/MyCanvas.vue'
import StyleInjector from './components/StyleInjector.vue'

import store from './store'
import router from './router'
import store from './store'
import router from './router'

Vue.use(VueResource)

Vue.filter('toDate', date=> {
Vue.filter('toDate', date => {
const d = new Date(date)
return d.getFullYear() + '年' +
(d.getMonth() + 1) + '月' +
Expand Down
19 changes: 9 additions & 10 deletions src/router/index.js
Expand Up @@ -3,21 +3,20 @@ import Router from 'vue-router'

Vue.use(Router)

import Archive from '../components/front/Archive.vue'
import Article from '../components/front/Article.vue'
import Console from '../components/back/Console.vue'
import Login from '../components/back/Login.vue'
import Archive from '../components/front/Archive.vue'
import Article from '../components/front/Article.vue'
import Console from '../components/back/Console.vue'
import Login from '../components/back/Login.vue'
import Articles from '../components/back/Articles.vue'
import Editor from '../components/back/Editor.vue'
import Links from '../components/back/Links.vue'
import Account from '../components/back/Account.vue'

import Editor from '../components/back/Editor.vue'
import Links from '../components/back/Links.vue'
import Account from '../components/back/Account.vue'

export default new Router({
mode: 'history',
routes: [
{path: '/archive', name: "archive", component: Archive},
{path: '/article', name: "article", component: Article},
{path: '/archive', name: 'archive', component: Archive},
{path: '/article', name: 'article', component: Article},
{path: '/', component: Login},
{
path: '/console',
Expand Down
12 changes: 6 additions & 6 deletions src/setup.js
@@ -1,5 +1,5 @@
import Vue from 'vue'
import VueResource from 'vue-resource'
import Vue from 'vue'
import VueResource from 'vue-resource'

Vue.use(VueResource)

Expand All @@ -11,24 +11,24 @@ new Vue({
pwdRepeat: ''
},
methods: {
submit(){
submit () {
if (!this.name.length) return this.info = '请输入合适的用户名'
if (this.pwd.length < 5) return this.info = '密码长度太短'
if (this.pwd !== this.pwdRepeat) return this.info = '两次输入的密码不一致'
this.$http.post('/api/setup', {name: this.name, pwd: this.pwd})
.then(() => {
this.info = '创建成功, 即将跳转到登陆...'
setTimeout(() => location.reload(), 2500)
setTimeout(() => window.location.reload(), 2500)
})
.catch(() => this.info = '创建失败')
},
clearInfo(){
clearInfo () {
this.info = ''
}
},
watch: {
name: 'clearInfo',
pwd: 'clearInfo',
pwd: 'clearInfo',
pwdRepeat: 'clearInfo'
}
}).$mount('#setup')

0 comments on commit fe09243

Please sign in to comment.