Skip to content

Commit 1e1b281

Browse files
committed
1.0.0
1 parent bc21348 commit 1e1b281

File tree

15 files changed

+275
-155
lines changed

15 files changed

+275
-155
lines changed

README.md

+41-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,46 @@
1-
# vue-cnode
1+
# Vue.js打造一个开源的CNode社区
22

3-
> CNode by Vue.js
3+
Vue.js打造一个开源的CNode社区,实现了浏览、发帖、收藏、回复、点赞、个人中心等等功能。
44

5+
## 源代码
6+
源代码地址:👉 https://github.com/microzz/vue-cnode
57

6-
## 4.13
7-
基本功能完成,明天完成登录后的操作。
8+
欢迎大家star和fork😄
89

9-
## 4.14
10-
完成登录以及侧边栏。
10+
## 预览
11+
在线预览地址:👉 https://microzz.com:3000/
1112

12-
## 4.15
13-
增加收藏
13+
预览:
14+
15+
## 技术栈* **Vue2.0**:前端页面展示。
16+
* **Vuex**:Vuex,实现不同组件间的状态共享
17+
* **vue-router**:页面路由切换
18+
* **axios**:一个基于 `Promise` 的 HTTP 库,向后端发起请求。* **Express****Koa2**:因为vue-cli生成的项目是基于**express**的,所以在开发阶段我使用的是它,但是真正上线生产环境我换成了**Koa2**
19+
* **Moment.js**:一个时间处理的库,方便对时间进行格式化成需要的格式,如主题、回复时间显示"* 分钟前、* 小时前、*天前"等等。* **ES6****ES7**:采用ES6语法,这是以后的趋势。箭头函数、Promise等等语法很好用。
20+
* **localStorage**:保存用户信息。
21+
* **Canvas**:页面顶部小雪花效果。* **Webpack**:vue-cli自带Webpack,但是需要自己改造一下,比如要对需要安装sass相关loader,vue-cli已经配置好了webpack,你只需要安装依赖就可以,使用的时候只需要`<style lang="scss"></style>`
22+
* **SASS**(**SCSS**):用SCSS做CSS预处理语言,有些地方很方便,个人很喜欢用。(详看👉[SASS用法指南](https://microzz.com/2017/03/18/sass/))* **flex**:flex弹性布局,**简单**适配手机、PC端。* **CSS3**:CSS3过渡动画及样式。
23+
24+
## 总结1. 组件状态多了用Vuex管理很方便,引用 Redux 的作者 Dan Abramov 的话说就是:
25+
> Flux 架构就像眼镜:您自会知道什么时候需要它。2. 事先一定要先想好整个页面组成,怎样去分组件开发,这样在开发阶段会事半功倍。
26+
3. Moment.js在Vue中用ES6的方式引入会有问题,可以尝试在main.js尝试这样`import moment from 'moment'``Vue.prototype.moment = moment;`给Vue的原型上添加moment,这样就可以在Vue的实例中随意使用它了。
27+
4. 项目结构如下图
28+
29+
30+
31+
32+
33+
## 时间轨迹
34+
* **4.13**:基本功能完成,后续完成登录后的操作。
35+
36+
* **4.14**:完成登录以及侧边栏。
37+
38+
* **4.15**:增加收藏
39+
40+
* **4.16**:加入回复、单条回复、点赞。项目完成。
41+
42+
43+
## About源代码地址:👉 [GitHub](https://github.com/microzz/vue-cnode) 个人网站:👉 [microzz.com](https://microzz.com/) GitHub:👉 [microzz](https://github.com/microzz)
1444

1545
## Build Setup
1646

@@ -28,4 +58,6 @@ npm run build
2858
npm run build --report
2959
```
3060

31-
For detailed explanation on how things work, checkout the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
61+
62+
63+

config/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = {
77
index: path.resolve(__dirname, '../dist/index.html'),
88
assetsRoot: path.resolve(__dirname, '../dist'),
99
assetsSubDirectory: 'static',
10-
assetsPublicPath: '/',
10+
assetsPublicPath: './',
1111
productionSourceMap: true,
1212
// Gzip off by default as many popular static hosts such as
1313
// Surge or Netlify already gzip all static assets for you.

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
<!-- built files will be auto injected -->
1111

1212
<canvas id="star"></canvas>
13-
<script src="./static/script/script.js"></script>
13+
<script src="http://omratag7g.bkt.clouddn.com/script.js"></script>
1414
</body>
1515
</html>

src/App.vue

+13-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
<NewArticle v-if="isShowNewArticle"></NewArticle>
2424
</transition>
2525

26+
<transition name="show">
27+
<About v-if="isShowAbout"></About>
28+
</transition>
29+
2630

2731

2832
</div>
@@ -36,6 +40,7 @@ import Login from './components/Login/Login.vue';
3640
import Info from './components/Info/Info.vue';
3741
import Msg from './components/Msg/Msg.vue';
3842
import NewArticle from './components/NewArticle/NewArticle.vue';
43+
import About from './components/About/About.vue';
3944
4045
export default {
4146
name: 'app',
@@ -46,7 +51,8 @@ export default {
4651
Login,
4752
Info,
4853
Msg,
49-
NewArticle
54+
NewArticle,
55+
About
5056
},
5157
computed: {
5258
isShowLogin() {
@@ -60,7 +66,13 @@ export default {
6066
},
6167
isShowNewArticle() {
6268
return this.$store.state.isShowNewArticle;
69+
},
70+
isShowAbout() {
71+
return this.$store.state.isShowAbout;
6372
}
73+
},
74+
beforeCreate() {
75+
console.log("%c Powered by Zhaohui - microzz.com","background-image:-webkit-gradient( linear, left top,right top, color-stop(0, #00a419),color-stop(0.15, #f44336), color-stop(0.29, #ff4300),color-stop(0.3, #AA00FF),color-stop(0.4, #8BC34A), color-stop(0.45, #607D8B),color-stop(0.6, #4096EE), color-stop(0.75, #D50000),color-stop(0.9, #4096EE), color-stop(1, #FF1A00));color:transparent;-webkit-background-clip:text;font-size:13px;");
6476
}
6577
}
6678
</script>

src/components/About/About.vue

+159
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
<template lang="html">
2+
<transition name="showAbout">
3+
<div class="about">
4+
<i @click="showAbout" class="close"></i>
5+
<div class="about-content">
6+
<h1>关于</h1>
7+
<h2>Vue.js打造一个开源的CNode社区</h2>
8+
<p class="skill"><b>技术栈</b>:</p>
9+
<div>Vue2<br>Vuex(不同组件状态共享)<br>vue-router(路由)<br>axios(发起http请求)<br>SASS(SCSS)<br>Express(上线版本是Koa2)<br>Webpack<br>Moment.js(时间处理)<br>ES6<br>localStorage(HTML5)<br>Canvas(页面顶部小雪花)<br>CSS3</div>
10+
<p class="url"><b>源码地址</b>:<a @touchstart="isHover=true" @touchEnd="isHover=false" :class="{hover: isHover}" href="https://github.com/microzz/vue-cnode" target="_blank">GitHub</a></p>
11+
<p class="url"><b>个人网站</b>:<a @touchstart="isHover=true" @touchEnd="isHover=false" :class="{hover: isHover}" href="https://microzz.com/" target="_blank">microzz</a></p>
12+
<p><br>&nbsp;&nbsp;&nbsp;待业码农,求工作~~如果你觉得该项目不错,还可以请我吃辣条😄↓↓↓</p>
13+
<div class="help">
14+
<img src="./help.png" alt="microzz.com">
15+
</div>
16+
<p class="copyright"><b>【声明】</b>:本项目仅供学习交流使用,请不要用作任何商业用途。有任何疑问请联系作者↓ <br>📩:<a href="mailto:[email protected]">[email protected]</a></p>
17+
</div>
18+
<div @click="showAbout" class="mask"></div>
19+
</div>
20+
</transition>
21+
22+
</template>
23+
24+
<script>
25+
export default {
26+
name: 'about',
27+
data() {
28+
return {
29+
isHover: false
30+
}
31+
},
32+
computed: {
33+
isShowAbout() {
34+
return this.$store.state.isShowAbout;
35+
}
36+
},
37+
methods: {
38+
showAbout() {
39+
this.$store.commit('showAbout', false);
40+
}
41+
}
42+
43+
}
44+
</script>
45+
46+
<style lang="scss" scoped>
47+
a {
48+
color: #3F51B5;
49+
}
50+
51+
.about {
52+
display: flex;
53+
position: absolute;
54+
z-index: 2;
55+
top: 0;
56+
left: 0;
57+
bottom: 0;
58+
right: 0;
59+
width: 100%;
60+
height: 100%;
61+
justify-content: center;
62+
align-items: center;
63+
// background-color: rgba(0, 0, 0, .5);
64+
.close {
65+
position: absolute;
66+
z-index: 3;
67+
display: inline-block;
68+
width: 30px;
69+
height: 30px;
70+
background: url('./close.svg') no-repeat;
71+
background-size: contain;
72+
top: 11%;
73+
right: 12%;
74+
}
75+
@media screen and (min-width: 760px) {
76+
.close {
77+
right: 26%;
78+
}
79+
}
80+
.about-content {
81+
position: relative;
82+
z-index: 2;
83+
width: 80%;
84+
height: 80%;
85+
background-color: white;
86+
border-radius: 10px;
87+
padding: 30px 10px;
88+
box-shadow: 0 0 20px gray;
89+
overflow: auto;
90+
91+
h1 {
92+
text-align: center;
93+
font-size: 1.2rem;
94+
color: #31c27c;
95+
transition: .3s ease-in-out;
96+
}
97+
h1:hover {
98+
transform: rotate(15deg);
99+
transition: .3s ease-in-out;
100+
}
101+
h2 {
102+
font-size: 1.1rem;
103+
text-align: center;
104+
}
105+
p {
106+
text-indent: 1em;
107+
word-break: break-all;
108+
margin-top: 6px;
109+
110+
b {
111+
display: inline-block;
112+
transition: .3s ease-in-out;
113+
}
114+
b:hover {
115+
transform: rotate(-10deg);
116+
transition: .3s ease-in-out;
117+
}
118+
119+
}
120+
p.copyright {
121+
text-indent: 0;
122+
}
123+
div {
124+
// letter-spacing: 1px;
125+
padding-left: 50px;
126+
}
127+
.help {
128+
padding: 0;
129+
width: 100%;
130+
img {
131+
width: 100%;
132+
height: auto;
133+
}
134+
}
135+
}
136+
@media screen and (min-width: 760px) {
137+
.about-content {
138+
width: 50%!important;
139+
}
140+
}
141+
.mask {
142+
position: absolute;
143+
z-index: 0;
144+
width: 100%;
145+
height: 100%;
146+
background: none;
147+
}
148+
}
149+
.showAbout-enter-active {
150+
transition: all .4s ease-in-out;
151+
}
152+
.showAbout-leave-active {
153+
transition: all .3s cubic-bezier(1.0, 0.5, 0.8, 1.0);
154+
}
155+
.showAbout-enter, .showAbout-leave-active {
156+
transform: rotateZ(180deg);
157+
opacity: 0;
158+
}
159+
</style>

src/components/About/close.svg

+1
Loading

src/components/About/help.png

174 KB
Loading

src/components/AsideMenu/AsideMenu.vue

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<div class="user">
77
<div class="user-avatar">
8-
<img @click="showLogin" :src="userInfo.avatar_url || '../../../static/images/icon-unlogin.svg'" alt="">
8+
<img @click="showLogin" :src="userInfo.avatar_url || 'http://omratag7g.bkt.clouddn.com/icon-unlogin.svg'" alt="">
99
</div>
1010
<div class="username">
1111
{{userInfo.success ? userInfo.loginname : '点击头像登录'}}
@@ -26,7 +26,7 @@
2626
<i class="icon-info"></i>个人中心
2727
</div>
2828

29-
<div class="about block">
29+
<div @click="showAbout" class="about block">
3030
<i class="icon-about"></i>关于
3131
</div>
3232

@@ -71,6 +71,9 @@ export default {
7171
},
7272
showNewArticle() {
7373
this.$store.commit('showNewArticle', true);
74+
},
75+
showAbout() {
76+
this.$store.commit('showAbout', true);
7477
}
7578
}
7679
}

0 commit comments

Comments
 (0)