Skip to content

Commit

Permalink
feat(admin): admin main component
Browse files Browse the repository at this point in the history
  • Loading branch information
DomonJi committed Jan 17, 2017
1 parent c04405a commit 85d0149
Show file tree
Hide file tree
Showing 12 changed files with 403 additions and 70 deletions.
32 changes: 18 additions & 14 deletions admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@
},
"dependencies": {
"marked": "^0.3.6",
"md5": "^2.2.1",
"simplemde": "^1.11.2",
"vue": "^2.0.1",
"vue-router": "^2.0.0",
"vuex": "^2.0.0"
"vue": "^2.1.9",
"vue-msgbox": "^0.2.14",
"vue-router": "^2.1.1",
"vue-template-compiler": "^2.1.9",
"vuex": "^2.1.1"
},
"devDependencies": {
"autoprefixer": "^6.4.0",
Expand All @@ -28,13 +31,16 @@
"babel-preset-es2015": "^6.0.0",
"babel-preset-stage-2": "^6.0.0",
"babel-register": "^6.0.0",
"chai": "^3.5.0",
"chromedriver": "^2.21.2",
"connect-history-api-fallback": "^1.1.0",
"cross-spawn": "^4.0.2",
"css-loader": "^0.25.0",
"eslint": "^3.6.1",
"eslint-config-standard": "^6.1.0",
"eslint-friendly-formatter": "^2.0.5",
"eslint-loader": "^1.5.0",
"eslint-plugin-html": "^1.3.0",
"eslint-config-standard": "^6.1.0",
"eslint-plugin-promise": "^2.0.1",
"eslint-plugin-standard": "^2.0.1",
"eventsource-polyfill": "^0.9.6",
Expand All @@ -44,6 +50,8 @@
"function-bind": "^1.0.2",
"html-webpack-plugin": "^2.8.1",
"http-proxy-middleware": "^0.17.2",
"inject-loader": "^2.0.1",
"isparta-loader": "^2.0.0",
"json-loader": "^0.5.4",
"karma": "^1.3.0",
"karma-coverage": "^1.1.1",
Expand All @@ -55,21 +63,17 @@
"karma-webpack": "^1.7.0",
"lolex": "^1.4.0",
"mocha": "^3.1.0",
"chai": "^3.5.0",
"sinon": "^1.17.3",
"sinon-chai": "^2.8.0",
"inject-loader": "^2.0.1",
"isparta-loader": "^2.0.0",
"phantomjs-prebuilt": "^2.1.3",
"chromedriver": "^2.21.2",
"cross-spawn": "^4.0.2",
"nightwatch": "^0.9.8",
"selenium-server": "2.53.1",
"opn": "^4.0.2",
"ora": "^0.3.0",
"phantomjs-prebuilt": "^2.1.3",
"selenium-server": "2.53.1",
"shelljs": "^0.7.4",
"sinon": "^1.17.3",
"sinon-chai": "^2.8.0",
"stylus-loader": "^2.4.0",
"url-loader": "^0.5.7",
"vue-loader": "^9.4.0",
"vue-loader": "^10.0.0",
"vue-style-loader": "^1.0.0",
"webpack": "^1.13.2",
"webpack-dev-middleware": "^1.8.3",
Expand Down
2 changes: 1 addition & 1 deletion admin/src/components/common/DraftEditor.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template lang="html">
<section :class="{'editor-active':!saved}">
<div :class="'title-active':!titleSaved">
<div :class="{'title-active':!titleSaved}">
<input type="text" class="form-control big only-border-bottom" :value="draftTitle" @input="updateTitle">
</div>
<div class="clearfix">
Expand Down
2 changes: 1 addition & 1 deletion admin/src/components/common/NavAside.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template lang="html">
<aside class="sidebar">
<img src="../../assets/image/logo.png" alt="" class="sidebar-logo">
<!-- <img src="../../assets/image/logo.png" alt="" class="sidebar-logo"> -->
<nav class="aside-nav">
<ul class="aside-nav-list">
<li class="aside-nav-item"><router-link class="aside-nav-button" to="/drafts"><i class="icon-wenzhang iconfont"></i></router-link></li>
Expand Down
71 changes: 71 additions & 0 deletions admin/src/components/drafts.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<template lang="html">
<div class="container-with-aside">
<nav-aside></nav-aside>
<section class="draft-list-column">
<h3 class="page-title">
<i class="icon-wenzhang iconfont"></i>
Draft List
<i class="iconfont icon-jiahao draft-add" @click="newDraft"></i>
</h3>
<draft-list></draft-list>
</section>
<div class="draft-edit">
<draft-editor v-if="currentId"></draft-editor>
</div>
</div>
</template>

<script>
import DraftEditor from 'components/common/DraftEditor'
import DraftList from 'components/common/DraftList'
import NavAside from 'components/common/NavAside'
import {
mapGetters,
mapActions
} from 'vuex'
import api from 'src/api'
export default {
components: {
NavAside,
DraftEditor,
DraftList
},
computed: { ...mapGetters(['saved', 'titleSaved', 'currentId'])
},
methods: { ...mapActions(['getDraftList', 'createDraft']),
newDraft() {
if (this.saved && this.titleSaved) this.createDraft()
else window.alert('Current draft is saving, please try again')
}
},
watch: {
'$route': 'getDraftList'
}
}
</script>

<style lang="stylus">
@import '../stylus/simplemde.styl'
@import '../stylus/_settings.styl'
.container-with-aside
margin-left 70px
height 100%
.draft-list-column
float left
border-right 1px solid $border
height 100%
width 300px
overflow-y auto
.draft-add
cursor pointer
float right
margin-right 10px
margin-top 2px
.page-title
color $light
padding-left 25px
font-weight 400
.draft-edit
overflow auto
height 100%
</style>
146 changes: 146 additions & 0 deletions admin/src/components/login.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<template lang="html">
<div>
<header class="banner">
<!-- <img src="../assets/img/logo.png" class="banner-logo" alt="logo"> -->
</header>
<div class="center-box">
<div class="flash-bar danger" v-show="loginErr">Loging Failed {{loginErrMsg}}</div>
<section class="login-box">
<div class="login-header">
<h3>
Blog Login
</h3>
</div>
<div class="login-body">
<input type="text" class="form-control top" placeholder="username" v-model="username">
<input type="password" class="form-control bottom" placeholder="password" v-model="password" @keyup.13="login">
</div>
<div class="login-footer">
<div class="login-button-Container">
<button class="btn btn-save btn-block" @click="login">
Login
</button>
</div>
</div>
</section>
</div>
</div>
</template>

<script>
import {
mapActions
} from 'vuex'
import api from 'src/api'
import md5 from 'md5'
export default {
data() {
return {
username: '',
password: '',
loginErr: false,
loginErrMsg: ''
}
},
methods: { ...mapActions(['createToken']),
login() {
this.createToken(this.username, md5(this.password).toUpperCase()).catch(err => {
console.log(err)
this.loginErr = true
this.loginErrMsg = err.error_message.error
})
}
}
}
</script>

<style lang="stylus">
@import '../stylus/_settings.styl'
.banner
padding 10px 0
text-align center
border-bottom 1px solid #EEE
margin-bottom 20px
.banner-logo
height 35px
.center-box
max-width 400px
margin 0 auto
padding 32px 15px
.login-box
background #fafafa
border-radius 10px
box-shadow 0 0px 2px #CCC
padding 15px
.login-header
text-align center
line-height 1.5
margin 0 0 10px 0
.login-button-Container
width 200px
margin 0 auto
.flash-bar
box-sizing border-box
width 100%
padding 15px
color #fff
border 1px solid transparent
border-radius: 6px;
margin-bottom: 10px;
&.success
background-color $blue
border-color $blue
&.danger
background-color $red
border-color $red
&.info
background-color $darkGrey
border-color $darkGrey
text-align center
.btn
cursor pointer
border 1px solid transparent
border-radius 3px
padding 6px 10px
text-align center
vertical-align middle
outline 0
&.btn-save
color #fff
background-color $green
border-color $green
&.btn-info
color #fff
background-color $grey
border-color $grey
&.btn-border
color $dark
background-color white
border-color $grey
&:hover
border-color $green
&.btn-cancel
color #fff
background-color $red
border-color $red
&.btn-block
width 100%
box-sizing border-box
.form-control
color $black
box-sizing border-box
padding 10px 8px
width 100%
height auto
box-shadow none
border 1px solid $border
background-color #fff
outline 0
&.top
border-radius 5px 5px 0 0
margin-bottom 0
&.bottom
border-radius 0 0 5px 5px
border-top 0
margin-bottom 20px
</style>
Loading

0 comments on commit 85d0149

Please sign in to comment.