Skip to content

Commit

Permalink
Merge pull request #5 from chengdujs/develop
Browse files Browse the repository at this point in the history
update from develop
  • Loading branch information
MrTreasure authored Jan 23, 2017
2 parents 37c1b83 + 59027cc commit 2a016cb
Show file tree
Hide file tree
Showing 15 changed files with 406 additions and 82 deletions.
68 changes: 68 additions & 0 deletions docs/开发规范汇总.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# 0x0、版本描述

### 版本发布记录

v0.0.1 2017-1-22 13:30 初稿,根据现有代码进行归类,综合

### 开发规范贡献者

<a href="https://github.com/hstarorg" target="_black">
<img width="40" src="https://avatars0.githubusercontent.com/u/8816531" alt="hstarorg avator">
hstarorg
</a>

# 0x1、基本编码规范

1. 统一使用2个空格缩进。(项目已包含editorconfig配置文件,建议安装编辑器/IDE的editorconfig插件)
2. 文件末尾添加新行
3. 语句需要加分号
4. 使用ES6编码风格最佳
5. 使用常规的JS规范(如逗号之后加空格,一般使用VSC格式化即可)

# 0x2、文件命名规范

1. 页面命名统一大驼峰命名,可选加上Page后缀,如 `SearchPage`
2. 其他组件采用全小写命名,使用中横线风格,如 `job-item`


# 0x3、Vue编码约定

1. 省略 `style, template, script` 的默认值,如使用 `css` 来写 `style`,不需要设定 `lang`
2. Vue组件配置属性,请参考如下顺序:

大致是基本属性,钩子函数,其他常用配置这样的先后顺序

```
{
name: '',
props: {},
components: {},
filters: {},
data(){
},
created(),
...生命周期钩子,
computed: {},
watth: {},
methods: {}
}
```
3. 私有函数,请使用下划线开头

# 0x4、Github PR规范

1. 发起PR的时候,请务必注明编写的功能
2. 请务必提交可运行的代码
3. 如果有单元测试,请务必保证测试通过之后再提交
4. PR只允许提交的 `develop` 分支

# 0x5、单元测试规范

1. 尽可能的编写单元测试代码
2. 单元测试代码放置于 `test/unit` 目录下,根据页面创建目录,所有测试代码以 `<Page>_test` 结尾,组件同理。

# 0x6、vw-ui组件开发规范

1. 所有组件放置于 `vw-ui/components` 目录中,以组件名称为目录隔离
2. 组件不能有其他第三方依赖(不允许除weui之外的三方依赖)
2 changes: 1 addition & 1 deletion src/config/config.dev.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const conf = {
isDebug: true,
apiHost: 'http://chat.hstar.org:8601/api/v1/HkGhqLCUg'
apiHost: 'http://chat.hstar.org:8601/HkGhqLCUg'
};

window.AppConf = conf;
2 changes: 1 addition & 1 deletion src/config/config.prod.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const conf = {
isDebug: false,
apiHost: 'http://chat.hstar.org:8601/api/v1/HkGhqLCUg'
apiHost: 'http://chat.hstar.org:8601/HkGhqLCUg'
};

window.AppConf = conf;
6 changes: 6 additions & 0 deletions src/pages/LayoutPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@
</div>
</template>
<script>
import { eventBus } from 'common';
export default {
data() {
return {
pageName: 'home'
};
},
created() {
eventBus.on('set-current-page', pageName => {
this.pageName = pageName;
});
},
watch: {
pageName(newVal) {
if (newVal === 'home') {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/HomePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
};
},
created() {
ajax.get('http://chat.hstar.org:8601/e2607fcaf7fe/employmentList')
ajax.get(`${window.AppConf.apiHost}/recommendation_list`)
.then(data => {
if (data.state === 1) {
this.jobs = data.data;
Expand Down
12 changes: 12 additions & 0 deletions src/pages/message/MessagePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,15 @@
<h1>Message</h1>
</div>
</template>

<script>
import { eventBus } from 'common';
export default {
data() {
return {};
},
created() {
eventBus.emit('set-current-page', 'message');
}
};
</script>
120 changes: 56 additions & 64 deletions src/pages/search/SearchDetail.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
/*
author:成都-Treasure
email:[email protected]
version:0.0.1
bug:1.还是没有解决ajax获取的数据无法访问二级对象,把部分内容做成子组件后可以响应
2.没有设计图的图例,因此找不到部分图标,自己选了,也没有字体大小,padding等设置
3.预留了路由接口,方便后期整合后台
4.文字内容没有设置转换器,用了computed,后期可以直接修改
5.mock数据结构在mock部分
6.组件padding 12px 16px
*/
/* author:成都-Treasure email:[email protected] version:0.0.1 bug:1.还是没有解决ajax获取的数据无法访问二级对象,把部分内容做成子组件后可以响应 2.没有设计图的图例,因此找不到部分图标,自己选了,也没有字体大小,padding等设置
3.预留了路由接口,方便后期整合后台 4.文字内容没有设置转换器,用了computed,后期可以直接修改 5.mock数据结构在mock部分 6.组件padding 12px 16px */



Expand Down Expand Up @@ -36,7 +27,7 @@
<li class="item"><i class="ion-android-time"></i><span> {{tag.years}}</span></li>
</ul>
<div class="flag" @click="addMark">
<i :class="{'ion-ios-star-outline':markflag,'ion-star':!markflag}"></i>
<i :class="{'ion-ios-star-outline':markflag,'ion-star':!markflag}"></i>
<p> {{mark}}</p>
</div>
</div>
Expand All @@ -47,32 +38,32 @@
</div>
<job-split></job-split>
<div class="company-detail-wrapper">
<company-detail :companyModel="comDetail.companyName"></company-detail>
<company-detail :companyModel="comDetail.companyName"></company-detail>
</div>
<job-split></job-split>
<div class="company-detail-wrapper">
<company-detail :companyModel="comDetail.companyDetail"></company-detail>
</div>
<job-split></job-split>
<div class="push-wrapper">
<vw-button type="primary" @click="pushResume">投简历</vw-button>
<vw-button type="primary" @click="pushResume">投简历</vw-button>
</div>
<job-split></job-split>
</div>
</template>

<script>
// import '../../vw-ui';
// import '../../vw-ui';
import { jobSplit } from 'components';
import { ajax } from 'common';
import { ajax, eventBus } from 'common';
import searchNeeds from './search-needs.vue';
import companyDetail from './company-detail.vue';
export default {
name: 'search-detail',
data() {
return {
comDetail: {}, // companyDetail
url: 'http://chat.hstar.org:8601/99ed5748b6c1/companyDetail',
url: `${window.AppConf.apiHost}/comDetailTemplete`,
markflag: false,
money: {},
tag: {}
Expand All @@ -89,29 +80,30 @@
companyDetail
},
created() {
eventBus.emit('set-current-page', 'search');
this._getData();
},
methods: {
_getData() {
ajax.get(this.url)
.then(data => {
if (data.status === 1) {
return data.body;
} else {
throw new Error();
}
})
.then(data => {
this.comDetail = data;
this.money = data.money;
this.tag = data.tag;
})
.catch(() => {
this.$toast.msg('请求的数据未得到', {duration: 3000},
() => {
window.history.go(-1);
.then(data => {
if (data.status === 1) {
return data.body;
} else {
throw new Error();
}
})
.then(data => {
this.comDetail = data;
this.money = data.money;
this.tag = data.tag;
})
.catch(() => {
this.$toast.msg('请求的数据未得到', { duration: 3000 },
() => {
window.history.go(-1);
});
});
});
},
addMark() {
this.markflag = !this.markflag;
Expand All @@ -120,37 +112,37 @@
console.log('PushResume');
}
}
/* 使用路由钩子获取数据,后期对接后台接口使用
beforeRouteEnter(to, from, next) {
ajax.get('http://chat.hstar.org:8601/99ed5748b6c1/companyDetail')
.then(data => {
if (data.status === 1) {
console.log(data);
return data.body;
/* 使用路由钩子获取数据,后期对接后台接口使用
beforeRouteEnter(to, from, next) {
ajax.get('http://chat.hstar.org:8601/99ed5748b6c1/companyDetail')
.then(data => {
if (data.status === 1) {
console.log(data);
return data.body;
}
})
.then(data => {
next(vm => {
vm.comDetail = data;
vm.money = data.money;
console.log(data);
});
});
},
watch: {
$route () {
this.comDetail = null;
ajax.get('http://chat.hstar.org:8601/99ed5748b6c1/companyDetail')
.then(data => {
if (data.status === 1) {
return data.body;
}
})
.then(data => {
this.comDetail = data;
});
}
})
.then(data => {
next(vm => {
vm.comDetail = data;
vm.money = data.money;
console.log(data);
});
});
},
watch: {
$route () {
this.comDetail = null;
ajax.get('http://chat.hstar.org:8601/99ed5748b6c1/companyDetail')
.then(data => {
if (data.status === 1) {
return data.body;
}
})
.then(data => {
this.comDetail = data;
});
}
} */
} */
}
</script>

Expand Down
4 changes: 3 additions & 1 deletion src/pages/search/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import SearchPage from './SearchPage';
import SearchDetail from './SearchDetail';

export {
SearchPage
SearchPage,
SearchDetail
};
11 changes: 2 additions & 9 deletions src/router.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,18 @@ import Vue from 'vue';
import VueRouter from 'vue-router';

import LayoutPage from './pages/LayoutPage';

// System
import { NotFound } from './pages/system';

// Home
import { HomePage } from './pages/home';

// Search
import { SearchPage } from './pages/search';
// import SearchDetail from './pages/search/SearchDetail.vue'; // 调试搜索结果页面调用
import { SearchDetail } from './pages/search';
// Message
import { MessagePage } from './pages/message';

// My
import { MyPage } from './pages/my';

// Test Page
import TestPage from './pages/TestPage';

// 注册路由
Vue.use(VueRouter);

Expand All @@ -31,7 +24,7 @@ const routes = [
component: LayoutPage,
children: [
{ path: '', component: HomePage },
{ path: 'search', component: SearchPage },
{ path: 'search', component: SearchDetail },
// { path: 'search', component: SearchDetail },
{ path: 'message', component: MessagePage },
{ path: 'my', component: MyPage }
Expand Down
Loading

0 comments on commit 2a016cb

Please sign in to comment.