Skip to content

Commit 3126521

Browse files
committed
先提交一下,(*^__^*) 嘻嘻……
1 parent ce6ab96 commit 3126521

File tree

105 files changed

+7007
-610
lines changed

Some content is hidden

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

105 files changed

+7007
-610
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# vue-rust-cn
22

33
> 未完成,路由在 src/main.js 里面
4+
> do 提醒组件 message.vue 与 点赞成功的提醒功能
5+
> 几天不写,突然发现这么简单的逻辑都不会了,留坑,以后做。
46
57
## Build Setup
68

build/superagent-mock-config.js

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
module.exports = [
2+
{
3+
/**
4+
* regular expression of URL
5+
*/
6+
pattern: 'https://api.local(.*)',
7+
8+
/**
9+
* returns the data
10+
*
11+
* @param match array Result of the resolution of the regular expression
12+
* @param params object sent by 'send' function
13+
* @param headers object set by 'set' function
14+
*/
15+
fixtures: function (match, params, headers) {
16+
/**
17+
* Returning error codes example:
18+
* request.get('https://domain.example/404').end(function(err, res){
19+
* console.log(err); // 404
20+
* console.log(res.notFound); // true
21+
* })
22+
*/
23+
if (match[1] === '/404') {
24+
throw new Error(404);
25+
}
26+
27+
if (match[1] === '/support/up') {
28+
return {
29+
ok: 1
30+
};
31+
}
32+
33+
if (match[1] === '/article/up') {
34+
return {
35+
ok: 1
36+
};
37+
}
38+
39+
if (match[1] === '/favourite') {
40+
return {
41+
up: true,
42+
down: false
43+
};
44+
}
45+
46+
if (match[1] === '/enshrine_status') {
47+
return true;
48+
}
49+
50+
if (match[1] === '/enshrine') {
51+
return {
52+
ok: 1
53+
};
54+
}
55+
56+
57+
58+
if (match[1] == '/article') {
59+
if(params['article_id']) {
60+
let date = new Date()
61+
let content = `<article>
62+
<h2 id="我们是谁?">我们是谁?</h2>
63+
<p>我们是幻腾智能,中国最专注于智能家居的互联网公司。<br>
64+
我们的梦想是通过将照明,门窗,燃气报警,窗帘等等设备智能化,来拉近亲人之间的距离,带来更多幸福感,让中国的普通百姓能够享受到前所未有的舒适生活。</p>
65+
66+
<p>说的简单一点,我们的产品是这样的:通过幻腾的手机App,用户可以在手机上看到家人的状态,能够知道什么时候需要开始做饭了。在出差的时候,可以随时知道家里有没有小偷进入。老人晚上上厕所的时候,灯光可以自动点亮,等等。</p>
67+
68+
<h2 id="为什么你应该加入?">为什么你应该加入?</h2><h4 id="超浓的技术氛围让你不会孤独">超浓的技术氛围让你不会孤独</h4>
69+
70+
<p>加分项:</p>
71+
72+
<ul>
73+
<li>完成以下测试,并获得1万分以上
74+
<a href="http://pg.wutj.info/tom-home/" target="_blank">猜猜Tom几点到家?</a>
75+
By CTO 吴天际</li>
76+
</ul>
77+
<h2 id="联系方式">联系方式</h2>
78+
<ul>
79+
<li>公司地址: 北京市海淀区双清路3号33025</li>
80+
<li>电话:13911339910</li>
81+
<li>邮箱:hr@huantengsmart.com</li>
82+
</ul>
83+
</article>`
84+
85+
return {
86+
id: params['article_id'],
87+
title: '[北京] 幻腾科技寻找 Ruby 后端工程师',
88+
category: '招聘',
89+
author: {
90+
face_img: 'https://ruby-china-files.b0.upaiyun.com/user/large_avatar/21472.jpg',
91+
name: 'Tiny',
92+
id: 30
93+
},
94+
viewCount: 39,
95+
favourite: {
96+
up: 12,
97+
down: 0
98+
},
99+
release_time: '11分钟前',
100+
last_comment: {
101+
user_id: 90,
102+
user_name:'飘雪',
103+
last_time: '2分钟前'
104+
},
105+
now_time: date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate(),
106+
content: content,
107+
comments: [
108+
{
109+
id:2,
110+
user_id:3,
111+
username:'十八岁的蜀黍',
112+
face_img:'https://cdn.v2ex.co/avatar/1c3e/364c/43832_normal.png?m=1401411063',
113+
time: '5 分钟前',
114+
up_count: 2,
115+
content: '寒蝉凄切,对长亭晚,骤雨初歇。都门帐饮无绪,留恋处,兰舟催发。执手相看泪眼,竟无语凝噎。念去去,千里烟波,暮霭沉沉楚天阔。 多情自古伤离别,更那堪冷落清秋节!今宵酒醒何处?杨柳岸,晓风残月。此去经年,应是良辰好景虚设。便纵有千种风情,更与何人说?'
116+
},
117+
118+
{
119+
id:3,
120+
user_id:78,
121+
username:'飘雪',
122+
face_img:'https://avatars3.githubusercontent.com/u/12268276?v=3&s=80',
123+
time: '2分钟前',
124+
up_count: 0,
125+
content: '<p>北方有佳人。绝世而独立。一顾倾人城。再顾倾人国。宁不知倾城与倾国。佳人难再得。</p>'
126+
127+
}
128+
129+
],
130+
131+
}
132+
}
133+
}
134+
135+
/**
136+
* Checking on parameters example:
137+
* request.get('https://domain.example/hero').send({superhero: "superman"}).end(function(err, res){
138+
* console.log(res.body); // "Your hero: superman"
139+
* })
140+
*/
141+
142+
if (match[1] === '/hero') {
143+
if(params['superhero']) {
144+
return 'Your hero:' + params['superhero'];
145+
} else {
146+
return 'You didnt chose a hero';
147+
}
148+
}
149+
150+
151+
/**
152+
* Checking on headers example:
153+
* request.get('https://domain.example/authorized_endpoint').set({Authorization: "9382hfih1834h"}).end(function(err, res){
154+
* console.log(res.body); // "Authenticated!"
155+
* })
156+
*/
157+
158+
if (match[1] === '/authorized_endpoint') {
159+
if(headers['Authorization']) {
160+
return 'Authenticated!';
161+
} else {
162+
throw new Error(401); // Unauthorized
163+
}
164+
}
165+
166+
167+
},
168+
169+
/**
170+
* returns the result of the GET request
171+
*
172+
* @param match array Result of the resolution of the regular expression
173+
* @param data mixed Data returns by `fixtures` attribute
174+
*/
175+
get: function (match, data) {
176+
177+
return {
178+
body: data
179+
};
180+
},
181+
182+
/**
183+
* returns the result of the POST request
184+
*
185+
* @param match array Result of the resolution of the regular expression
186+
* @param data mixed Data returns by `fixtures` attribute
187+
*/
188+
post: function (match, data) {
189+
190+
if (match[1] === '/comment') {
191+
return {
192+
comment_id: 3
193+
};
194+
}
195+
196+
if (match[1] === '/register') {
197+
return {
198+
user_id: 3,
199+
username: 'yugo',
200+
face_img: 'http://temp.im/150x150/007AFF/fff'
201+
};
202+
}
203+
204+
return {
205+
code: 201
206+
};
207+
},
208+
delete: function(match, data){
209+
if (match[1] === '/comment') {
210+
return {
211+
ok: 1
212+
}
213+
}
214+
},
215+
put: function(match, data){
216+
if (match[1] === '/comment') {
217+
return {
218+
ok: 1
219+
}
220+
}
221+
},
222+
}
223+
];

build/webpack.dev.conf.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ module.exports = merge(baseWebpackConfig, {
2929
filename: 'index.html',
3030
template: 'index.html',
3131
inject: true
32-
})
33-
]
32+
}),
33+
new webpack.DefinePlugin({ "global.GENTLY": false }),
34+
],
35+
node: {
36+
__dirname: true,
37+
},
3438
})

index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<link href="//cdn.bootcss.com/ionicons/2.0.1/css/ionicons.min.css" rel="stylesheet">
1212
<link href="//cdn.bootcss.com/animate.css/3.5.2/animate.min.css" rel="stylesheet">
1313
<link href="//cdn.bootcss.com/wangeditor/2.1.10/css/wangEditor.min.css" rel="stylesheet">
14+
<link href="//cdn.bootcss.com/highlight.js/9.5.0/styles/atelier-forest.dark.min.css" rel="stylesheet">
1415
</head>
1516
<body>
1617
<app></app>
@@ -23,5 +24,6 @@
2324

2425
<script src="//cdn.bootcss.com/mixitup/2.1.10/jquery.mixitup.min.js"></script>
2526
<script src="//cdn.bootcss.com/wangeditor/2.1.10/js/wangEditor.min.js"></script>
27+
<script src="//cdn.bootcss.com/highlight.js/9.5.0/highlight.min.js"></script>
2628
</body>
2729
</html>

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111
},
1212
"dependencies": {
1313
"babel-runtime": "^6.0.0",
14+
"highlight.js": "^9.5.0",
15+
"superagent": "^2.0.0",
1416
"vue": "^1.0.21",
15-
"vue-router": "^0.7.13"
17+
"vue-router": "^0.7.13",
18+
"xss": "^0.2.13"
1619
},
1720
"devDependencies": {
1821
"babel-core": "^6.0.0",
@@ -33,6 +36,7 @@
3336
"ora": "^0.2.0",
3437
"shelljs": "^0.6.0",
3538
"stylus-loader": "^2.1.0",
39+
"superagent-mock": "^1.10.0",
3640
"url-loader": "^0.5.7",
3741
"vue-hot-reload-api": "^1.2.0",
3842
"vue-html-loader": "^1.0.0",

0 commit comments

Comments
 (0)