Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ixinyi server #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<link href="http://cdn.bootcss.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="http://taoxindeblog.oss-cn-shanghai.aliyuncs.com/theme.css">
<link href="http://iamhades.oss-cn-shanghai.aliyuncs.com/line-icons.min.css" rel="stylesheet" type="text/css" media="all"/>
<script src="https://cdn1.lncld.net/static/js/av-min-1.0.0.js"></script>
<!-- <script src="https://cdn1.lncld.net/static/js/av-min-1.0.0.js"></script> -->
<!-- showdown cdn -->
<script type="text/javascript" src="http://taoxindeblog.oss-cn-shanghai.aliyuncs.com/showdown.js"></script>
<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
Expand Down
45 changes: 22 additions & 23 deletions public/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<template>
<div>
<toplayout>
<div slot="top_menu" class="top-nav">
<menu></menu>
</div>
</toplayout>
<router-view slot="top_container" class="view" transition="expand" transition-mode="out-in"></router-view>
<div slot="top_footer" class="top-foot">
<span id="busuanzi_container_site_pv">
访问量<span id="busuanzi_value_site_pv"></span>
</span>|
<span id="busuanzi_container_site_uv">
访客数<span id="busuanzi_value_site_uv"></span>
</span>
</div>
<toplayout>
<div slot="top_menu" class="top-nav">
<menu></menu>
</div>
</toplayout>
<router-view slot="top_container" class="view" transition="expand" transition-mode="out-in"></router-view>
<div slot="top_footer" class="top-foot">
<span id="busuanzi_container_site_pv">
访问量<span id="busuanzi_value_site_pv"></span>
</span>|
<span id="busuanzi_container_site_uv">
访客数<span id="busuanzi_value_site_uv"></span>
</span>
</div>
</div>
</template>

Expand All @@ -23,14 +23,13 @@
import store from './vuex/store';
module.exports = {
components:{
toplayout,
menu
},
store,
ready(){
this.$AVInit();
}
};
toplayout,
menu
},
store,
ready(){
}
};
</script>
<style type="text/css">
.top-foot{
Expand Down Expand Up @@ -82,7 +81,7 @@
}

@keyframes expand-out {
0% {
0% {
opacity: 1;
}
25% {
Expand Down
12 changes: 2 additions & 10 deletions public/src/ext/vue_ext.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,6 @@ exports.install = function install (Vue) {
return format;
};

function AVInit(){
const X_CC_Id = 'yourappid';
const X_CC_Key = 'yourappkey';
AV.init({ appId:X_CC_Id, appKey:X_CC_Key });
}


// 处理leadcloud中查询出的数据
function transDataFromLc(oldObject){
const newObject = [];
Expand Down Expand Up @@ -325,10 +318,9 @@ exports.install = function install (Vue) {
// 拦截器
Vue.http.interceptors.push({
request(request) {
window.showLoading = true;
// TODO
window.showLoading = true;
if (!request.url.match('http')) {
request.url = 'https://api.leancloud.cn/1.1/classes/' + request.url;
request.url = 'http://localhost:8113' + request.url;
}
return request;
},
Expand Down
123 changes: 53 additions & 70 deletions public/src/service/article.js
Original file line number Diff line number Diff line change
@@ -1,80 +1,63 @@
/*
* @Author: iMocco
* @Date: 2017-03-17 14:41:23
* @Last Modified by: iMocco
* @Last Modified time: 2017-03-21 09:51:20
*/
export const getArticles = ({
dispatch
}, data) => {
const query = new AV.Query('Articles');
query.descending('createdAt');
query.limit(data.limit); // 最多返回 10 条结果
query.skip(data.start);
query.find().then(function(results) {
dispatch('getArticles', results);
}, function(error) {});
};
Vue.http.get('/articles', data).then((err) => {
}, (result) => {
dispatch('getArticles', result.data);
});
};

export const addArticle = ({
dispatch
}, data) => {
const Article = AV.Object.extend('Articles');
const addarticle = new Article();
addarticle.save({
title: data.title,
content: data.content,
tag: data.tag,
state: data.state
}).then(function(object) {
dispatch('addArticle', object);
});
};
// export const addArticle = ({
// dispatch
// }, data) => {
// const Article = AV.Object.extend('Articles');
// const addarticle = new Article();
// addarticle.save({
// title: data.title,
// content: data.content,
// tag: data.tag,
// state: data.state
// }).then(function(object) {
// dispatch('addArticle', object);
// });
// };

export const getArticleById = ({
dispatch
}, id) => {
var query = new AV.Query('Articles');
query.get(id).then(function(result) {
// 成功获得实例
const data = {};
data.title = result.get('title');
data.content = result.get('content');
data.tag = result.get('tag');
data.state = result.get('state');
data.id = result.id;
data.createdAt = result.createdAt;
data.updatedAt = result.updatedAt;
dispatch('getArticleById', data);
}, function(error) {
console.log(error);
});
};
export const getArticleById = ({
dispatch
}, data) => {
Vue.http.get('/articleById', data).then((err) => {
}, (result) => {
dispatch('getArticleById', result.data);
});
};

export const getArticleCount = ({
dispatch
}, data) => {
const query = new AV.Query('Articles');
// query.equalTo('state', 1);
query.count().then(function (count) {
dispatch('getArticleCount', count);
}, function (error) {
});
};
export const searchArticles = ({
export const getArticleCount = ({
dispatch
}, data) => {
const query = new AV.Query('Articles');
query.descending('createdAt');
query.limit(data.limit); // 最多返回 10 条结果
query.skip(data.start);
query.contains('title',data.title);
query.find().then(function(results) {
dispatch('searchArticles', results);
}, function(error) {});
};
export const getReadInfos = ({
Vue.http.get('/articlesCount', data).then((err) => {
}, (result) => {
dispatch('getArticleCount', result.data);
});
};
export const searchArticles = ({
dispatch
}, data) => {
const query = new AV.Query('ReadInfo');
query.descending('createdAt');
// query.limit(data.limit); // 最多返回 10 条结果
// query.skip(data.start);
query.find().then(function(results) {
dispatch('getReadInfos', results);
}, function(error) {});
};
Vue.http.get('/queryArticles', data).then((err) => {
}, (result) => {
dispatch('searchArticles', result);
});
};
export const getReadInfos = ({
dispatch
}) => {
Vue.http.get('/readInfo').then((err) => {
}, (result) => {
dispatch('getReadInfos', result.data);
});
};
4 changes: 3 additions & 1 deletion public/src/views/blog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@
},
attached(){
const id = this.$route.params.aid;
const data = {};
data.id = id;
console.info(id);
this.getArticleById(id);
this.getArticleById(data);
},
watch:{
result(val){
Expand Down
6 changes: 3 additions & 3 deletions public/src/views/blogs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</div>
<div class="blog" v-if="articles" v-for="article in articles">
<div class="title">
<p><a @click="goDetail(article.id, $index, article.createdAt)">{{article.title}}</a></p>
<p><a @click="goDetail(article.objectId, $index, article.createdAt)">{{article.title}}</a></p>
<span>发布时间:{{this.$formatDate(article.createdAt, 'yyyy-MM-dd hh:mm')}}</span>
</div>
<div class="tags">
Expand All @@ -20,7 +20,7 @@
<div v-html="article.content"></div>
</div>
<div class="read">
<a @click="goDetail(article.id, $index, article.createdAt)">阅读全文</a>
<a @click="goDetail(article.objectId, $index, article.createdAt)">阅读全文</a>
</div>
</div>
</div>
Expand Down Expand Up @@ -57,7 +57,7 @@ export default{
return{
articles:[],
start:0,
limit:5,
limit:5,
currentStart:0,
show:true,
};
Expand Down
4 changes: 2 additions & 2 deletions public/src/views/readLine.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
<div v-if="$index%2===0" class="col-sm-6 col-md-pull-6" >
<p>
<ul>
<li v-for="read in historys[time]"><a href="{{read._serverData.url}}" target="_blank">{{read._serverData.title}}</a></li>
<li v-for="read in historys[time]"><a href="{{read.url}}" target="_blank">{{read.title}}</a></li>
</ul>
</p>
</div>
<div v-else class="col-sm-6" style="text-align:left">
<p>
<ul>
<li v-for="read in historys[time]"><a href="{{read._serverData.url}}" target="_blank">{{read._serverData.title}}</a></li>
<li v-for="read in historys[time]"><a href="{{read.url}}" target="_blank">{{read.title}}</a></li>
</ul>
</p>
</div>
Expand Down
7 changes: 2 additions & 5 deletions public/src/vuex/modules/article.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const state = {
// mutations
const mutations = {
getArticles(allState, articles) {
allState.articles = Vue.prototype.$transDataFromLc(articles);
allState.articles = articles;
},
addArticle(allState, result) {
allState.addArticleResult = result;
Expand All @@ -23,12 +23,9 @@ const mutations = {
allState.articleCount = result;
},
searchArticles(allState, result) {
allState.serArticleResult = Vue.prototype.$transDataFromLc(result);
allState.serArticleResult = result.data;
},
getReadInfos(allState, result){
// for(let i in result){
// const date = Vue.prototype.$formatDate(result[i].createdAt, 'yyyy-MM-dd');
// }
const keys = {};
const dates = [];
const values = {};
Expand Down