Skip to content

Commit af18835

Browse files
author
zanjs
committed
🐱 init
0 parents  commit af18835

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+13143
-0
lines changed

.babelrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"presets": ["es2015", "stage-3"],
3+
"plugins": ["transform-runtime", "kneden"],
4+
"comments": false
5+
}

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.DS_Store
2+
node_modules/
3+
#dist/
4+
npm-debug.log

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2013-2016 Julian
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# cnode-vue
2+
3+
> Vue版 cnodejs.org社区 WebApp
4+
5+
## Build Setup
6+
7+
``` bash
8+
# clone repo
9+
git clone [email protected]:vuecn/cnode-vuecn.git
10+
11+
# install dependencies
12+
npm install
13+
14+
# build for production
15+
npm run build
16+
```
17+
# Screenshots
18+

favicon.ico

264 KB
Binary file not shown.

index.html

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html lang="zh-CN">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
6+
<link rel="shortcut icon" href="/favicon.ico" />
7+
<link rel="stylesheet" href="/build/app.css"></head>
8+
<title>cnode - vuecn</title>
9+
10+
<body>
11+
<div id="app"></div>
12+
<script src="/static/vue.js"></script>
13+
<script src="/build/app.js"></script></body>
14+
</html>

package.json

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"name": "cnode-vuecn",
3+
"version": "0.0.1",
4+
"description": "Vue.js版 cnodejs.org WebApp",
5+
"main": "index.js",
6+
"scripts": {
7+
"start": "node server",
8+
"dev": "webpack-dev-server --hot --inline --colors --progress",
9+
"build": "webpack --colors --progress --config webpack.prod.conf.js",
10+
"test": "echo \"Error: no test specified\" && exit 1"
11+
},
12+
"repository": {
13+
"type": "git",
14+
"url": "git+https://github.com/vuecn/cnode-vuecn.git"
15+
},
16+
"keywords": [
17+
"cnode",
18+
"vue"
19+
],
20+
"author": "julian",
21+
"engines": {
22+
"node": ">= 0.10.0"
23+
},
24+
"license": "MIT",
25+
"bugs": {
26+
"url": "https://github.com/vuecn/cnode-vuecn/issues"
27+
},
28+
"homepage": "https://github.com/vuecn/cnode-vuecn#readme",
29+
"dependencies": {
30+
"express": "^4.13.4",
31+
"mime": "^1.3.4",
32+
"vue": "^1.0.17",
33+
"vue-router": "^0.7.11"
34+
},
35+
"devDependencies": {
36+
"autoprefixer": "^6.3.3",
37+
"babel-core": "^6.6.5",
38+
"babel-loader": "^6.2.4",
39+
"babel-plugin-transform-runtime": "^6.6.0",
40+
"babel-preset-es2015": "^6.6.0",
41+
"babel-preset-stage-3": "^6.3.13",
42+
"babel-runtime": "^5.8.35",
43+
"css-loader": "^0.23.1",
44+
"es6-promise": "^3.1.2",
45+
"extract-text-webpack-plugin": "^1.0.1",
46+
"file-loader": "^0.8.5",
47+
"html-webpack-plugin": "^2.10.0",
48+
"kneden": "^1.0.2",
49+
"postcss": "^5.0.19",
50+
"postcss-loader": "^0.8.1",
51+
"precss": "^1.4.0",
52+
"style-loader": "^0.13.0",
53+
"url-loader": "^0.5.7",
54+
"vue-hot-reload-api": "^1.3.2",
55+
"vue-html-loader": "^1.2.0",
56+
"vue-loader": "^8.2.0",
57+
"vue-style-loader": "^1.0.0",
58+
"webpack": "^1.12.14",
59+
"webpack-dev-server": "^1.14.1",
60+
"whatwg-fetch": "^0.11.0"
61+
}
62+
}

server.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var express = require("express")
2+
var app = express()
3+
4+
app.use(express.static(__dirname))
5+
6+
// app.use(function (req, res, next) {
7+
// if (req.path !== "/" || ! req.path.includes("build")) {
8+
// res.sendFile(path.join(__dirname, "/index.html"))
9+
// }
10+
11+
// next()
12+
// })
13+
14+
app.listen(process.env.PORT || 8080)

src/api.js

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
import promise from "es6-promise"
2+
import "whatwg-fetch"
3+
4+
export let getList = async (page, tag) => {
5+
let response = await fetch(`https://cnodejs.org/api/v1/topics?page=${page}&limit=20&tab=${tag}`, {
6+
mode: "cors"
7+
}).catch((error) => {
8+
console.log(error)
9+
})
10+
11+
return await response.json().catch((error) => {
12+
console.log(error)
13+
})
14+
}
15+
16+
export let getTopic = async (topicId) => {
17+
let response = await fetch(`https://cnodejs.org/api/v1/topic/${topicId}`, {
18+
mode: "cors"
19+
}).catch((error) => {
20+
console.log(error)
21+
})
22+
23+
return await response.json().catch((error) => {
24+
console.log(error)
25+
})
26+
}
27+
28+
export let login = async (token) => {
29+
let response = await fetch(`https://cnodejs.org/api/v1/accesstoken `, {
30+
method: "POST",
31+
mode: "cors",
32+
headers: {
33+
"Content-Type": "application/x-www-form-urlencoded"
34+
},
35+
body: `accesstoken=${token}`
36+
}).catch((error) => {
37+
console.log(error)
38+
})
39+
40+
return await response.json().catch((error) => {
41+
console.log(error)
42+
})
43+
}
44+
45+
export let like = async (id, token) => {
46+
let response = await fetch(`https://cnodejs.org/api/v1/reply/${id}/ups`, {
47+
method: "POST",
48+
mode: "cors",
49+
headers: {
50+
"Content-Type": "application/x-www-form-urlencoded"
51+
},
52+
body: `accesstoken=${token}`
53+
}).catch((error) => {
54+
console.log(error)
55+
})
56+
57+
return await response.json().catch((error) => {
58+
console.log(error)
59+
})
60+
}
61+
62+
export let reply = async (token, topicId, content, replyId) => {
63+
let body = replyId ? `accesstoken=${token}&content=${content}&reply_id=${replyId}` : `accesstoken=${token}&content=${content}`
64+
65+
let response = await fetch(`https://cnodejs.org/api/v1/topic/${topicId}/replies`, {
66+
method: "POST",
67+
mode: "cors",
68+
headers: {
69+
"Content-Type": "application/x-www-form-urlencoded"
70+
},
71+
body: body
72+
}).catch((error) => {
73+
console.log(error)
74+
})
75+
76+
return await response.json().catch((error) => {
77+
console.log(error)
78+
})
79+
}
80+
81+
export let getProfile = async (nickname) => {
82+
let response = await fetch(`https://cnodejs.org/api/v1/user/${nickname}`, {
83+
mode: "cors"
84+
}).catch((error) => {
85+
console.log(error)
86+
})
87+
88+
return await response.json().catch((error) => {
89+
console.log(error)
90+
})
91+
}
92+
93+
export let getMessages = async (token) => {
94+
let response = await fetch(`https://cnodejs.org/api/v1/messages?accesstoken=${token}`, {
95+
mode: "cors"
96+
}).catch((error) => {
97+
console.log(error)
98+
})
99+
100+
return await response.json().catch((error) => {
101+
console.log(error)
102+
})
103+
}
104+
105+
export let getMessageCount = async (token) => {
106+
let response = await fetch(`https://cnodejs.org/api/v1/message/count?accesstoken=${token}`, {
107+
mode: "cors"
108+
}).catch((error) => {
109+
console.log(error)
110+
})
111+
112+
return await response.json().catch((error) => {
113+
console.log(error)
114+
})
115+
}
116+
117+
export let post = async ({token, title, tab, content}) => {
118+
let response = await fetch("https://cnodejs.org/api/v1/topics", {
119+
method: "POST",
120+
headers: {
121+
"Content-Type": "application/x-www-form-urlencoded"
122+
},
123+
mode: "cors",
124+
body: `accesstoken=${token}&title=${title}&tab=${tab}&content=${content}`
125+
}).catch((error) => {
126+
console.log(error)
127+
})
128+
129+
return await response.json().catch((error) => {
130+
console.log(error)
131+
})
132+
}

src/app.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require("./css/normalize.css")
2+
require("./css/common.css")
3+
require("./css/app.css")
4+
require("./css/home.css")
5+
require("./css/topic.css")
6+
require("./css/layout-box.css")
7+
require("./css/message.css")
8+
9+
import router from "./router"
10+
import APP from "./app.vue"
11+
12+
router.start(APP, "#app")

src/app.vue

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<template>
2+
<div :class="{show: show}">
3+
<router-view></router-view>
4+
<tips :message.sync="message"></tips>
5+
</div>
6+
</template>
7+
8+
<script>
9+
import directives from "./directives"
10+
import tips from "./components/tips.vue"
11+
12+
Vue.directive("touch", directives)
13+
14+
export default {
15+
data() {
16+
return {
17+
tag: "全部",
18+
show: false,
19+
slide: false,
20+
message: ""
21+
}
22+
},
23+
components: {
24+
tips
25+
},
26+
created() {
27+
let deviceWidth = Math.min(640, document.documentElement.clientWidth)
28+
29+
document.documentElement.style.fontSize = `${deviceWidth / 6.4}px`
30+
},
31+
events: {
32+
// loaded() {
33+
// this.loading = false
34+
// },
35+
// loading() {
36+
// this.loading = true
37+
// },
38+
showNav() {
39+
this.showNav = true
40+
},
41+
hideNav() {
42+
this.showNav = false
43+
},
44+
// login(data) {
45+
// this.user = data
46+
// },
47+
showSlideNav() {
48+
this.show = true
49+
50+
document.body.classList.add("show")
51+
},
52+
// hideSlideNav() {
53+
// this.show = false
54+
55+
// document.body.classList.remove("show")
56+
// },
57+
closeLoading() {
58+
this.loading = false
59+
},
60+
tailChanged(message) {
61+
this.message = message
62+
},
63+
addBgClass() {
64+
document.body.classList.add("bg")
65+
},
66+
removeBgClass() {
67+
document.body.classList.remove("bg")
68+
},
69+
postError(message) {
70+
this.message = message
71+
}
72+
}
73+
}
74+
</script>

src/components/loading.vue

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<template>
2+
<div class="loading-cover" v-if="loading" transition="loading">
3+
<div class="loading-text">(´・ω・`)正在加载...</div>
4+
</div>
5+
</template>
6+
7+
<script>
8+
export default {
9+
props: ["loading"]
10+
}
11+
</script>

0 commit comments

Comments
 (0)