Skip to content

Commit e2f3bce

Browse files
committed
详情页增加
1 parent 9445e2a commit e2f3bce

File tree

10 files changed

+278
-94
lines changed

10 files changed

+278
-94
lines changed

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<head>
55
<meta charset="utf-8">
6-
<title>v2ex-vue</title>
6+
<title>cnode-vue</title>
77
</head>
88

99
<body>

package.json

+75-75
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,76 @@
11
{
2-
"name": "v2ex-vue",
3-
"version": "1.0.0",
4-
"description": "A Vue.js project",
5-
"author": "chencoder <[email protected]>",
6-
"private": true,
7-
"scripts": {
8-
"dev": "node build/dev-server.js",
9-
"start": "node build/dev-server.js",
10-
"build": "node build/build.js",
11-
"lint": "eslint --ext .js,.vue src"
12-
},
13-
"dependencies": {
14-
"axios": "^0.16.2",
15-
"cookiesjs": "^1.4.2",
16-
"normalize.css": "^7.0.0",
17-
"vue": "^2.3.3",
18-
"vue-router": "^2.3.1",
19-
"vuex": "^2.3.1"
20-
},
21-
"devDependencies": {
22-
"autoprefixer": "^6.7.2",
23-
"babel-core": "^6.22.1",
24-
"babel-eslint": "^7.1.1",
25-
"babel-loader": "^6.2.10",
26-
"babel-plugin-transform-runtime": "^6.22.0",
27-
"babel-preset-env": "^1.3.2",
28-
"babel-preset-stage-2": "^6.22.0",
29-
"babel-register": "^6.22.0",
30-
"chalk": "^1.1.3",
31-
"connect-history-api-fallback": "^1.3.0",
32-
"copy-webpack-plugin": "^4.0.1",
33-
"css-loader": "^0.28.0",
34-
"eslint": "^3.19.0",
35-
"eslint-config-airbnb-base": "^11.1.3",
36-
"eslint-friendly-formatter": "^2.0.7",
37-
"eslint-import-resolver-webpack": "^0.8.1",
38-
"eslint-loader": "^1.7.1",
39-
"eslint-plugin-html": "^2.0.0",
40-
"eslint-plugin-import": "^2.2.0",
41-
"eventsource-polyfill": "^0.9.6",
42-
"express": "^4.14.1",
43-
"extract-text-webpack-plugin": "^2.0.0",
44-
"file-loader": "^0.11.1",
45-
"friendly-errors-webpack-plugin": "^1.1.3",
46-
"html-webpack-plugin": "^2.28.0",
47-
"http-proxy-middleware": "^0.17.3",
48-
"less": "^2.7.2",
49-
"less-loader": "^4.0.4",
50-
"opn": "^4.0.2",
51-
"optimize-css-assets-webpack-plugin": "^1.3.0",
52-
"ora": "^1.2.0",
53-
"rimraf": "^2.6.0",
54-
"semver": "^5.3.0",
55-
"shelljs": "^0.7.6",
56-
"style-loader": "^0.18.2",
57-
"url-loader": "^0.5.8",
58-
"vue-loader": "^12.1.0",
59-
"vue-style-loader": "^3.0.1",
60-
"vue-template-compiler": "^2.3.3",
61-
"webpack": "^2.6.1",
62-
"webpack-bundle-analyzer": "^2.2.1",
63-
"webpack-dev-middleware": "^1.10.0",
64-
"webpack-hot-middleware": "^2.18.0",
65-
"webpack-merge": "^4.1.0"
66-
},
67-
"engines": {
68-
"node": ">= 4.0.0",
69-
"npm": ">= 3.0.0"
70-
},
71-
"browserslist": [
72-
"> 1%",
73-
"last 2 versions",
74-
"not ie <= 8"
75-
]
76-
}
2+
"name": "cnode-vue",
3+
"version": "1.0.0",
4+
"description": "A Vue.js project",
5+
"author": "chencoder <[email protected]>",
6+
"private": true,
7+
"scripts": {
8+
"dev": "node build/dev-server.js",
9+
"start": "node build/dev-server.js",
10+
"build": "node build/build.js",
11+
"lint": "eslint --ext .js,.vue src"
12+
},
13+
"dependencies": {
14+
"axios": "^0.16.2",
15+
"cookiesjs": "^1.4.2",
16+
"normalize.css": "^7.0.0",
17+
"vue": "^2.3.3",
18+
"vue-router": "^2.3.1",
19+
"vuex": "^2.3.1"
20+
},
21+
"devDependencies": {
22+
"autoprefixer": "^6.7.2",
23+
"babel-core": "^6.22.1",
24+
"babel-eslint": "^7.1.1",
25+
"babel-loader": "^6.2.10",
26+
"babel-plugin-transform-runtime": "^6.22.0",
27+
"babel-preset-env": "^1.3.2",
28+
"babel-preset-stage-2": "^6.22.0",
29+
"babel-register": "^6.22.0",
30+
"chalk": "^1.1.3",
31+
"connect-history-api-fallback": "^1.3.0",
32+
"copy-webpack-plugin": "^4.0.1",
33+
"css-loader": "^0.28.0",
34+
"eslint": "^3.19.0",
35+
"eslint-config-airbnb-base": "^11.1.3",
36+
"eslint-friendly-formatter": "^2.0.7",
37+
"eslint-import-resolver-webpack": "^0.8.1",
38+
"eslint-loader": "^1.7.1",
39+
"eslint-plugin-html": "^2.0.0",
40+
"eslint-plugin-import": "^2.2.0",
41+
"eventsource-polyfill": "^0.9.6",
42+
"express": "^4.14.1",
43+
"extract-text-webpack-plugin": "^2.0.0",
44+
"file-loader": "^0.11.1",
45+
"friendly-errors-webpack-plugin": "^1.1.3",
46+
"html-webpack-plugin": "^2.28.0",
47+
"http-proxy-middleware": "^0.17.3",
48+
"less": "^2.7.2",
49+
"less-loader": "^4.0.4",
50+
"opn": "^4.0.2",
51+
"optimize-css-assets-webpack-plugin": "^1.3.0",
52+
"ora": "^1.2.0",
53+
"rimraf": "^2.6.0",
54+
"semver": "^5.3.0",
55+
"shelljs": "^0.7.6",
56+
"style-loader": "^0.18.2",
57+
"url-loader": "^0.5.8",
58+
"vue-loader": "^12.1.0",
59+
"vue-style-loader": "^3.0.1",
60+
"vue-template-compiler": "^2.3.3",
61+
"webpack": "^2.6.1",
62+
"webpack-bundle-analyzer": "^2.2.1",
63+
"webpack-dev-middleware": "^1.10.0",
64+
"webpack-hot-middleware": "^2.18.0",
65+
"webpack-merge": "^4.1.0"
66+
},
67+
"engines": {
68+
"node": ">= 4.0.0",
69+
"npm": ">= 3.0.0"
70+
},
71+
"browserslist": [
72+
"> 1%",
73+
"last 2 versions",
74+
"not ie <= 8"
75+
]
76+
}

src/api/api.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ export const getTopicsList = (data) => getData('topics', data);
3030
* 得到 主题详情
3131
* @param {any} data
3232
*/
33-
export const getTopicDetails = (data) => getData('topics/' + data);
33+
export const getTopicDetails = (data) => getData('topic/' + data);

src/components/listItemBox.vue

+13-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
<span class="last_active_time">{{formatDate(item.last_reply_at)}}</span>
1414
</a>
1515
<div class="topic-title-box">
16-
<span class="topiclist-tab">置顶</span>
17-
<a href="#" class="topic_title">{{item.title}}</a>
16+
<span class="topiclist-tab" v-if="!item.good && !item.top && item.tab!=='dev'">{{classify[item.tab]}}</span>
17+
<span class="topiclist-tab top" v-if="item.good || item.top">{{item.top ? '置顶':'精华'}}</span>
18+
<router-link :to="{ path: '/topic', query: { id: item.id }}">{{item.title}}</router-link>
1819
</div>
1920
</li>
2021
</ul>
@@ -32,6 +33,16 @@ export default {
3233
}
3334
}
3435
},
36+
data(){
37+
return {
38+
classify:{
39+
ask:'问答',
40+
good:'精华',
41+
share:'分享',
42+
job:'招聘'
43+
}
44+
}
45+
},
3546
methods:{
3647
formatDate:(time) => com.formatDate(time),
3748
}

src/components/pagination.vue

+8-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{{pager}}
88
</li>
99
<li v-if="showMoreNext" class="quicknext" @click="goNum(currentNum+5)">...</li>
10-
<li class="btn-prev" :class="{'disabled': currentNum === page}" @click="goNum(currentNum-1)">></li>
10+
<li class="btn-prev" :class="{'disabled': currentNum === page}" @click="goNum(currentNum+1)">></li>
1111
</ul>
1212
</div>
1313
</template>
@@ -70,13 +70,20 @@ export default {
7070
},
7171
methods:{
7272
goNum:function(num){
73+
document.body.scrollTop = 0
74+
document.documentElement.scrollTop = 0
7375
const pageNum = this.currentNum;
7476
this.currentNum = num;
7577
if(this.currentNum<1) this.currentNum=1;
7678
if(this.currentNum>this.page) this.currentNum = this.page;
7779
if(this.currentNum ==pageNum) return;
7880
this.$emit('updata', this.currentNum);
7981
}
82+
},
83+
watch:{
84+
currentPage: function (val, oldVal) {
85+
this.currentNum=val;
86+
}
8087
}
8188
}
8289
</script>

src/router/index.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ import Router from 'vue-router';
44
Vue.use(Router);
55

66
export default new Router({
7-
routes: [
8-
{
7+
routes: [{
98
path: '/',
10-
component : require('@/view/index/index'),
9+
component: require('@/view/index/index'),
1110
},
11+
{
12+
path: '/topic',
13+
component: require('@/view/articleDetails/index'),
14+
}
1215
],
1316
});

src/style/common.less

+11-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ a {
1010
color: #08c;
1111
text-decoration: none;
1212
}
13-
ul{
14-
list-style:none;
13+
ul,p{
1514
padding: 0;
1615
margin: 0;
1716
}
17+
ul{
18+
list-style:none;
19+
}
1820
.f-l {
1921
float: left;
2022
}
@@ -72,4 +74,11 @@ ul{
7274
background: #80bd01;
7375
color: #fff;
7476
}
77+
}
78+
.collect-btn{
79+
vertical-align: middle;
80+
display: inline-block;
81+
cursor: pointer;
82+
font-size: 14px;
83+
padding: 3px 10px;
7584
}

src/style/markdown.css

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
.markdown-text p,
2+
.preview p {
3+
white-space: pre-wrap;
4+
white-space: -moz-pre-wrap;
5+
white-space: -pre-wrap;
6+
white-space: -o-pre-wrap;
7+
word-wrap: break-word;
8+
line-height: 2em;
9+
margin: 1em 0
10+
}
11+
12+
.markdown-text>:last-child,
13+
.preview>:last-child,
14+
textarea#title {
15+
margin-bottom: 1em
16+
}
17+
18+
.markdown-text>:first-child,
19+
.preview>:first-child {
20+
margin-top: 0
21+
}
22+
23+
.markdown-text li,
24+
.preview li {
25+
font-size: 14px;
26+
line-height: 2em
27+
}
28+
29+
.markdown-text li code,
30+
.markdown-text p code,
31+
.preview li code,
32+
.preview p code {
33+
color: #000;
34+
background-color: #fcfafa;
35+
padding: 4px 6px
36+
}
37+
38+
.markdown-text img {
39+
cursor: pointer;
40+
max-width: 100%
41+
}
42+
43+
.markdown-text h1 code,
44+
.markdown-text h2 code,
45+
.markdown-text h3 code,
46+
.markdown-text h4 code,
47+
.markdown-text h5 code,
48+
.markdown-text h6 code {
49+
font-size: inherit;
50+
color: inherit
51+
}
52+
53+
.panel .markdown-text a {
54+
color: #08c
55+
}
56+
57+
.preview {
58+
padding: .5em;
59+
font-size: 15px;
60+
min-height: 200px;
61+
word-break: break-all
62+
}
63+
64+
.preview p>img {
65+
display: block;
66+
box-shadow: 0 0 4px rgba(0, 0, 0, .6)
67+
}
68+
69+
.markdown_editor .markdown_in_editor,
70+
.markdown_editor .markdown_in_preview {
71+
display: none
72+
}
73+
74+
.markdown_editor.in_editor .markdown_in_editor,
75+
.markdown_editor.in_preview .markdown_in_preview {
76+
display: block
77+
}

0 commit comments

Comments
 (0)