From a5c42c74c09c73bde818991789f9eb56a5a73c5f Mon Sep 17 00:00:00 2001 From: "Jay.M.Hu" Date: Sun, 22 Jan 2017 12:58:32 +0800 Subject: [PATCH 1/5] Adjust pages for preview --- src/config/config.dev.js | 2 +- src/config/config.prod.js | 2 +- src/pages/LayoutPage.vue | 6 ++ src/pages/home/HomePage.vue | 2 +- src/pages/message/MessagePage.vue | 12 +++ src/pages/search/SearchDetail.vue | 120 ++++++++++++++---------------- src/pages/search/index.js | 4 +- src/router.config.js | 11 +-- 8 files changed, 82 insertions(+), 77 deletions(-) diff --git a/src/config/config.dev.js b/src/config/config.dev.js index ab482b4..a66bb7f 100644 --- a/src/config/config.dev.js +++ b/src/config/config.dev.js @@ -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; diff --git a/src/config/config.prod.js b/src/config/config.prod.js index e4a579c..ccd6137 100644 --- a/src/config/config.prod.js +++ b/src/config/config.prod.js @@ -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; diff --git a/src/pages/LayoutPage.vue b/src/pages/LayoutPage.vue index ba387a5..07022db 100644 --- a/src/pages/LayoutPage.vue +++ b/src/pages/LayoutPage.vue @@ -18,12 +18,18 @@ diff --git a/src/pages/search/SearchDetail.vue b/src/pages/search/SearchDetail.vue index abaaa1f..2837634 100644 --- a/src/pages/search/SearchDetail.vue +++ b/src/pages/search/SearchDetail.vue @@ -1,14 +1,5 @@ -/* - author:成都-Treasure - email:treasurewmj@foxmail.com - version:0.0.1 - bug:1.还是没有解决ajax获取的数据无法访问二级对象,把部分内容做成子组件后可以响应 - 2.没有设计图的图例,因此找不到部分图标,自己选了,也没有字体大小,padding等设置 - 3.预留了路由接口,方便后期整合后台 - 4.文字内容没有设置转换器,用了computed,后期可以直接修改 - 5.mock数据结构在mock部分 - 6.组件padding 12px 16px -*/ +/* author:成都-Treasure email:treasurewmj@foxmail.com version:0.0.1 bug:1.还是没有解决ajax获取的数据无法访问二级对象,把部分内容做成子组件后可以响应 2.没有设计图的图例,因此找不到部分图标,自己选了,也没有字体大小,padding等设置 +3.预留了路由接口,方便后期整合后台 4.文字内容没有设置转换器,用了computed,后期可以直接修改 5.mock数据结构在mock部分 6.组件padding 12px 16px */ @@ -36,7 +27,7 @@
  • {{tag.years}}
  • - +

    {{mark}}

    @@ -47,7 +38,7 @@
    - +
    @@ -55,16 +46,16 @@
    - 投简历 + 投简历
    diff --git a/src/pages/search/index.js b/src/pages/search/index.js index 7df9952..b31afc1 100644 --- a/src/pages/search/index.js +++ b/src/pages/search/index.js @@ -1,5 +1,7 @@ import SearchPage from './SearchPage'; +import SearchDetail from './SearchDetail'; export { - SearchPage + SearchPage, + SearchDetail }; diff --git a/src/router.config.js b/src/router.config.js index a859a6a..3607bf1 100644 --- a/src/router.config.js +++ b/src/router.config.js @@ -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); @@ -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 } From 2ce42f9ef42419f582a66546f8ca563be7e66d29 Mon Sep 17 00:00:00 2001 From: "Jay.M.Hu" Date: Sun, 22 Jan 2017 13:31:07 +0800 Subject: [PATCH 2/5] Add develop rules --- ...04\350\214\203\346\261\207\346\200\273.md" | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 "docs/\345\274\200\345\217\221\350\247\204\350\214\203\346\261\207\346\200\273.md" diff --git "a/docs/\345\274\200\345\217\221\350\247\204\350\214\203\346\261\207\346\200\273.md" "b/docs/\345\274\200\345\217\221\350\247\204\350\214\203\346\261\207\346\200\273.md" new file mode 100644 index 0000000..75e7af2 --- /dev/null +++ "b/docs/\345\274\200\345\217\221\350\247\204\350\214\203\346\261\207\346\200\273.md" @@ -0,0 +1,68 @@ +# 0x0、版本描述 + +### 版本发布记录 + +v0.0.1 2017-1-22 13:30 初稿,根据现有代码进行归类,综合 + +### 开发规范贡献者 + + +hstarorg avator +hstarorg + + +# 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` 目录下,根据页面创建目录,所有测试代码以 `_test` 结尾,组件同理。 + +# 0x6、vw-ui组件开发规范 + +1. 所有组件放置于 `vw-ui/components` 目录中,以组件名称为目录隔离 +2. 组件不能有其他第三方依赖(不允许除weui之外的三方依赖) From e01815676502828ca482db84bc0887184462b9ab Mon Sep 17 00:00:00 2001 From: "Jay.M.Hu" Date: Sun, 22 Jan 2017 16:36:18 +0800 Subject: [PATCH 3/5] vw-ui update, add slider component. --- src/vw-ui/components/slider/slider.vue | 76 +++++++++++++++++++ .../tabbar/{TabItem.vue => tab-item.vue} | 0 src/vw-ui/index.js | 12 ++- src/vw-ui/utils/dom.js | 75 ++++++++++++++++++ 4 files changed, 159 insertions(+), 4 deletions(-) create mode 100644 src/vw-ui/components/slider/slider.vue rename src/vw-ui/components/tabbar/{TabItem.vue => tab-item.vue} (100%) create mode 100644 src/vw-ui/utils/dom.js diff --git a/src/vw-ui/components/slider/slider.vue b/src/vw-ui/components/slider/slider.vue new file mode 100644 index 0000000..eb3252a --- /dev/null +++ b/src/vw-ui/components/slider/slider.vue @@ -0,0 +1,76 @@ + + diff --git a/src/vw-ui/components/tabbar/TabItem.vue b/src/vw-ui/components/tabbar/tab-item.vue similarity index 100% rename from src/vw-ui/components/tabbar/TabItem.vue rename to src/vw-ui/components/tabbar/tab-item.vue diff --git a/src/vw-ui/index.js b/src/vw-ui/index.js index 4f2ca19..ada4ad5 100644 --- a/src/vw-ui/index.js +++ b/src/vw-ui/index.js @@ -1,6 +1,9 @@ -import Button from './components/button/Button'; -import Tabbar from './components/tabbar/Tabbar'; -import TabItem from './components/tabbar/TabItem'; +import Button from './components/button/button'; + +import Tabbar from './components/tabbar/tabbar'; +import TabItem from './components/tabbar/tab-item'; + +import Slider from './components/slider/slider'; import Toast from './components/toast/toast.js'; @@ -8,7 +11,8 @@ import Toast from './components/toast/toast.js'; const COMPONENTS = [ Button, Tabbar, - TabItem + TabItem, + Slider ]; const SERVICES = [ diff --git a/src/vw-ui/utils/dom.js b/src/vw-ui/utils/dom.js new file mode 100644 index 0000000..e2ea300 --- /dev/null +++ b/src/vw-ui/utils/dom.js @@ -0,0 +1,75 @@ +class LiteQuery { + constructor(selector, doc = window.document) { + this._nodeList = []; + if (typeof selector === 'string') { + this._nodeList = [].slice.call(doc.querySelectorAll(selector)); + } else if (selector instanceof window.Node) { + this._nodeList = [selector]; + } else { + throw new Error('arguments error'); + } + } + + on(eventName, eventHandler, eventPropagation = false) { + this._nodeList.forEach(el => { + el.addEventListener(eventName, eventHandler, eventPropagation); + }); + return this; + } + + off(eventName, eventHandler = null) { + this._nodeList.forEach(el => { + el.removeEventListener(eventName, eventHandler); + }); + return this; + } + + getStyle(key) { + if (this._nodeList.length !== 1) { + throw new Error('getStyle must be called by one element.'); + } + let el = this._nodeList[0]; + let elStyleObj = window.getComputedStyle(el); + if (key) { + return elStyleObj[key]; + } + return elStyleObj; + } + + addClass(className) { + this._nodeList.forEach(el => { + if (el.classList.indexOf(className) < 0) { + el.classList.add(...className.split(' ')); + } + }); + return this; + } + + removeClass(className) { + this._nodeList.forEach(el => { + if (el.classList.indexOf(className) >= 0) { + el.classList.remove(...className.split(' ')); + } + }); + } + + css(key, value) { + let styleObj; + if (typeof key === 'string') { + styleObj = { [key]: value }; + } else { + styleObj = key; + } + let keys = Object.keys(styleObj); + this._nodeList.forEach(el => { + keys.forEach(styleProp => { + el.style[styleProp] = styleObj[styleProp]; + }); + }); + return this; + } +} + +export const $$ = function (selector, doc) { + return new LiteQuery(selector, doc); +}; From 6d8c97b4cf59e5f60d60300db319579e73003876 Mon Sep 17 00:00:00 2001 From: "Jay.M.Hu" Date: Sun, 22 Jan 2017 17:04:27 +0800 Subject: [PATCH 4/5] update vw-ui, add toptip --- src/vw-ui/components/toptip/toptip.js | 70 ++++++++++++++++++++++++++ src/vw-ui/components/toptip/toptip.vue | 24 +++++++++ src/vw-ui/index.js | 4 +- 3 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 src/vw-ui/components/toptip/toptip.js create mode 100644 src/vw-ui/components/toptip/toptip.vue diff --git a/src/vw-ui/components/toptip/toptip.js b/src/vw-ui/components/toptip/toptip.js new file mode 100644 index 0000000..0b30104 --- /dev/null +++ b/src/vw-ui/components/toptip/toptip.js @@ -0,0 +1,70 @@ +import Vue from 'vue'; + +const ToptipConstructor = Vue.extend(require('./toptip.vue')); +const toptipPool = []; + +const getAnInstance = () => { + if (toptipPool.length > 0) { + let instance = toptipPool[0]; + toptipPool.splice(0, 1); + return instance; + } + return new ToptipConstructor({ + el: document.createElement('div') + }); +}; + +const returnAnInstance = instance => { + if (instance) { + toptipPool.push(instance); + } +}; + +const removeDom = event => { + if (event.target.parentNode) { + event.target.parentNode.removeChild(event.target); + } +}; + +ToptipConstructor.prototype.close = function () { + this.$el.addEventListener('transitionend', removeDom); + this.opacity = 0; + this.closeCallback(); + returnAnInstance(this); +}; + +const showToptip = (options) => { + let duration = options.duration || 3000; + let instance = getAnInstance(); + + clearTimeout(instance.timer); + instance.content = options.content; + instance.closeCallback = options.callback; + document.body.appendChild(instance.$el); + + Vue.nextTick(function () { + instance.opacity = 1; + instance.$el.removeEventListener('transitionend', removeDom); + ~duration && (instance.timer = setTimeout(() => { + instance.close(); + }, duration)); + }); + + return instance; +}; + +const noop = function () { }; + +const Toptip = { + name: '$toptip', + tip(message, options, callback) { + options = options || {}; + showToptip({ + content: message, + duration: options.duration || 3000, + callback: callback || noop + }); + } +}; + +export default Toptip; diff --git a/src/vw-ui/components/toptip/toptip.vue b/src/vw-ui/components/toptip/toptip.vue new file mode 100644 index 0000000..54a0949 --- /dev/null +++ b/src/vw-ui/components/toptip/toptip.vue @@ -0,0 +1,24 @@ + + + diff --git a/src/vw-ui/index.js b/src/vw-ui/index.js index ada4ad5..4ef9e0d 100644 --- a/src/vw-ui/index.js +++ b/src/vw-ui/index.js @@ -6,6 +6,7 @@ import TabItem from './components/tabbar/tab-item'; import Slider from './components/slider/slider'; import Toast from './components/toast/toast.js'; +import Toptip from './components/toptip/toptip.js'; // All components. const COMPONENTS = [ @@ -16,7 +17,8 @@ const COMPONENTS = [ ]; const SERVICES = [ - Toast + Toast, + Toptip ]; const install = Vue => { From 59027ccfdb5a73857876151b16d4b3be314b95e6 Mon Sep 17 00:00:00 2001 From: "Jay.M.Hu" Date: Sun, 22 Jan 2017 17:04:49 +0800 Subject: [PATCH 5/5] add root class name for slider --- src/vw-ui/components/slider/slider.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vw-ui/components/slider/slider.vue b/src/vw-ui/components/slider/slider.vue index eb3252a..13442b4 100644 --- a/src/vw-ui/components/slider/slider.vue +++ b/src/vw-ui/components/slider/slider.vue @@ -1,5 +1,5 @@