Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
update for webpack
  • Loading branch information
ciqulover committed Nov 19, 2016
1 parent fab2b4f commit 6c34339
Show file tree
Hide file tree
Showing 21 changed files with 177 additions and 214 deletions.
11 changes: 9 additions & 2 deletions .babelrc
@@ -1,6 +1,13 @@
{
"presets": [
["es2015", { "modules": false }]
// ["es2015","stage-0"]
[
"es2015",
{
"modules": false
}
]
],
"plugins": [
"transform-object-rest-spread"
]
}
7 changes: 3 additions & 4 deletions README.md
Expand Up @@ -38,7 +38,7 @@ server/ 后端
db.js 数据库
index.js 服务器入口
init.json 初始数据
src/
assets/ 外部引用文件
components/ vue组件
Expand All @@ -51,7 +51,7 @@ src/
style/ 全局样式
main.js 项目入口文件
setup.js 初始化账户
index.html 单页应用
setup.html 初始化账户页面
Expand All @@ -62,7 +62,7 @@ webpack.config.js webpack配置
```

## Setup
####环境
####环境
* Node.js **v6+**
* mongoDB [Download](https://www.mongodb.com/download-center?jmp=nav#community)mongoDB安装完成,建立数据库文件夹。以win平台为例,在C盘下新建data文件夹,进入data文件夹新建db文件夹(这是mongoDB启动时默认的数据存储目录,如果建立在其他盘上,需要在启动时通过--dbpath参数指定目录。注意mongoDB不会自动创建这个目录,如果没有目录启动时会错误)
进入mongoDB的安装目录,一般在C:\Program Files\MongoDB\Server\3.2\bin(因版本而异)
Expand Down Expand Up @@ -101,7 +101,6 @@ npm run server
* [x] 博客前台页面
* [ ] 博客内容管理
* [ ] Vue2.0服务端渲染(SSR)
* [ ]
* [ ] 博客内容相关
* [ ] 博客统计
* [ ] 主题设置
Expand Down
21 changes: 10 additions & 11 deletions dist/main.js

Large diffs are not rendered by default.

10 changes: 5 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.

2 changes: 1 addition & 1 deletion index.html
Expand Up @@ -7,7 +7,7 @@
<link rel="stylesheet" href="dist/styles.css">
</head>
<body>
<div id="CMS-Vue2" style="height: 100%">
<div id="CMS2" style="height: 100%">
<my-canvas></my-canvas>
<spinner v-show="isLoading"></spinner>
<Toast v-show="isToasting"></Toast>
Expand Down
19 changes: 7 additions & 12 deletions package.json
@@ -1,33 +1,25 @@
{
"name": "CMS2",
"description": "CMS of Blog V2.0.0, Powered by Vue2.0",
"version": "2.0.0",
"version": "2.1.0",
"author": "Lei Jiang <ycwalker@outlook.com>",
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --inline --hot",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules",
"watch": "webpack --progress --color --watch",
"server": "node ./server/index"
},
"dependencies": {
"babel-preset-stage-2": "^6.17.0",
"body-parser": "^1.15.2",
"cookie-parser": "^1.4.3",
"express": "^4.14.0",
"mongoose": "^4.6.4",
"serve-favicon": "^2.3.0",
"vue": "^2.0.1",
"vue-resource": "^1.0.3",
"vue-router": "^2.0.1",
"vue-validator": "^3.0.0-alpha.1",
"vuex": "^2.0.0",
"vuex-router-sync": "^2.1.1"
"serve-favicon": "^2.3.0"
},
"devDependencies": {
"babel-core": "^6.0.0",
"babel-loader": "^6.0.0",
"babel-plugin-transform-object-rest-spread": "^6.19.0",
"babel-preset-es2015": "^6.0.0",
"babel-preset-stage-0": "^6.16.0",
"copy-webpack-plugin": "^4.0.0",
"cross-env": "^3.0.0",
"css-loader": "^0.25.0",
Expand All @@ -36,8 +28,11 @@
"node-sass": "^3.10.1",
"sass": "^0.5.0",
"sass-loader": "^4.0.2",
"supervisor": "^0.11.0",
"url-loader": "^0.5.7",
"vue": "^2.0.1",
"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
32 changes: 12 additions & 20 deletions src/components/back/Articles.vue
@@ -1,29 +1,30 @@
<template>
<section class="articles">
<router-link :to="{path:'/console/editor'}"
<router-link :to="{name:'editor'}"
tag="button">新增文章
</router-link>
<table>
<tbody>
<tr>
<th @click="sort('title')">标题</th>
<th @click="sort('date')">日期</th>
<th>标题</th>
<th>日期</th>
<th>选项</th>
</tr>
<tr v-for="(article,index) in articles">
<router-link :to="{path:'/article',query:{id:article._id}}"
<router-link :to="{name:'article',query:{id:article._id}}"
tag="td">
{{article.title}}
</router-link>
<td>
{{article.date | toDate}}
</td>
<td>
<i class="fa fa-pencil-square-o"
@click="editArticle(article._id)">
</i>
<router-link class="fa fa-pencil-square-o"
:to="{name:'editor',query:{id:article._id}}"
tag="i">
</router-link>
<i class="fa fa-trash"
@click="deleteArticle(article._id,index)">
@click="deleteArticle(article._id)">
</i>
</td>
</tr>
Expand All @@ -32,25 +33,16 @@
</section>
</template>
<script>
import {mapState, mapGetters} from 'vuex'
import {mapState, mapActions} from 'vuex'
export default{
created(){
this.$store.dispatch('getArticles')
this.getArticles()
},
computed: mapState(['articles']),
methods: {
editArticle(id){
this.$router.push('/console/editor?id=' + id)
},
deleteArticle(id){
this.$store.dispatch('deleteArticle', id).then(()=> {
})
}
}
methods: mapActions(['getArticles', 'deleteArticle'])
}
</script>
<style lang="sass" rel="stylesheet/scss" scoped>
@import "../../style/variables.scss";
@import "../../style/mixins.scss";
section.articles {
Expand Down
15 changes: 7 additions & 8 deletions src/components/back/Console.vue
Expand Up @@ -32,20 +32,19 @@
</div>
</template>
<script>
import {mapState} from 'vuex'
import {get} from '../../assets/js/cookieUtil'
import StatusBar from './StatusBar.vue'
import {mapState, mapMutations} from 'vuex'
export default{
created(){
const userName = get('user')
if (!userName) {
this.$router.push('/')
} else if (userName && !this.user.name) {
this.$store.commit('SET_USER', {name: userName, pwd: ''})
}
const user = get('user')
if (!user) this.$router.push('/')
if (user && !this.user.name) this.SET_USER({name: user, pwd: ''})
},
components: {StatusBar},
computed: mapState(['user'])
computed: mapState(['user']),
methods: mapMutations(['SET_USER'])
}
</script>
<style lang="sass" rel="stylesheet/scss" scoped>
Expand Down
34 changes: 16 additions & 18 deletions src/components/back/Editor.vue
Expand Up @@ -16,15 +16,16 @@
</div>
<div class="panel">
<button class="saveArticle"
@click="saveArticle">保存
@click="save">保存
</button>
</div>
</section>
</template>
<script>
import {mapState} from 'vuex'
import {mapState, mapActions, mapMutations} from 'vuex'
import marked from '../../assets/js/marked.min'
import hljs from '../../assets/js/highlight.pack'
export default{
data(){
return {
Expand All @@ -34,27 +35,26 @@
},
created(){
const id = this.$route.query.id
if (id) {
this.$store.dispatch('getArticle', id)
} else {
this.$store.commit('SET_ARTICLE', {date: new Date()})
}
if (id) return this.getArticle(id)
this.SET_ARTICLE({date: new Date()})
},
updated(){
this.highlight()
},
methods: {
saveArticle(){
this.$store.dispatch('saveArticle')
.then(()=>this.$router.push({name: 'articles'}))
.catch(err=> console.log(err))
save(){
this.saveArticle()
.then(() => this.$router.push({name: 'articles'}))
.catch(err => console.log(err))
},
highlight(){
setTimeout(()=> {
setTimeout(() => {
hljs.initHighlighting.called = false
hljs.initHighlighting()
}, 0)
}
},
updated(){
this.highlight()
},
...mapActions(['getArticle', 'saveArticle']),
...mapMutations(['SET_ARTICLE'])
},
computed: {
content: {
Expand All @@ -79,11 +79,9 @@
}
}
}
}
</script>
<style lang="sass" rel="stylesheet/scss">
@import "../../style/variables";
@import "../../style/mixins.scss";
section.editor {
Expand Down
24 changes: 6 additions & 18 deletions src/components/back/Links.vue
Expand Up @@ -40,29 +40,17 @@
</template>

<script>
import {mapMutations, mapState} from 'vuex'
import {mapMutations, mapActions, mapState} from 'vuex'
export default{
created(){
this.$store.dispatch('getLinks')
this.getLinks()
},
computed: mapState(['links']),
methods: Object.assign(
{
saveLinks(){
this.$store.dispatch('saveLinks')
}
},
mapMutations([
'UPDATE_LINK_NAME',
'UPDATE_LINK_HREF',
'ADD_NEW_LINK',
'REMOVE_LINK'
])
)
methods: {
...mapActions(['saveLinks', 'getLinks']),
...mapMutations(['UPDATE_LINK_NAME', 'UPDATE_LINK_HREF', 'ADD_NEW_LINK', 'REMOVE_LINK'])
}
}
</script>

<style lang="sass" rel="stylesheet/scss" scoped>
Expand Down

0 comments on commit 6c34339

Please sign in to comment.