Showing
5 changed files
with
59 additions
and
4 deletions
@@ -72,11 +72,13 @@ | @@ -72,11 +72,13 @@ | ||
72 | "webpack": "^1.13.1", | 72 | "webpack": "^1.13.1", |
73 | "webpack-dev-server": "^1.14.1", | 73 | "webpack-dev-server": "^1.14.1", |
74 | "webpack-stream": "^3.1.0", | 74 | "webpack-stream": "^3.1.0", |
75 | + "yoho-cookie": "^1.2.0", | ||
75 | "yoho-fastclick": "^1.0.6", | 76 | "yoho-fastclick": "^1.0.6", |
76 | "yoho-iscroll": "^5.2.0", | 77 | "yoho-iscroll": "^5.2.0", |
77 | "yoho-jquery": "^2.2.4", | 78 | "yoho-jquery": "^2.2.4", |
78 | "yoho-jquery-lazyload": "^1.9.7", | 79 | "yoho-jquery-lazyload": "^1.9.7", |
79 | "yoho-mlellipsis": "0.0.3", | 80 | "yoho-mlellipsis": "0.0.3", |
81 | + "yoho-qs": "^1.0.1", | ||
80 | "yoho-swiper": "^3.3.1", | 82 | "yoho-swiper": "^3.3.1", |
81 | "yoho-vue": "^1.0.26", | 83 | "yoho-vue": "^1.0.26", |
82 | "yoho-vue-lazyload": "^0.4.3" | 84 | "yoho-vue-lazyload": "^0.4.3" |
public/js/common.js
0 → 100644
1 | +/** | ||
2 | + * 全局公有方法 | ||
3 | + */ | ||
4 | + | ||
5 | +/** | ||
6 | + * 请不要把原有 yohobuy 项目的代码复制过来! | ||
7 | + * 请不要把原有 yohobuy 项目的代码复制过来! | ||
8 | + * 请不要把原有 yohobuy 项目的代码复制过来! | ||
9 | + * | ||
10 | + * 所有与业务无关,复用多的代码尽量模块化 | ||
11 | + * 除非万不得已,不要声明全局变量 | ||
12 | + * 这一块的代码很少 | ||
13 | + * | ||
14 | + * 1. cookie 操作请使用 yoho-cookie 文档:https://github.com/florian/cookie.js | ||
15 | + * 2. 查询字符串读取 请使用 yoho-qs | ||
16 | + */ |
1 | var Vue = require('yoho-vue'); | 1 | var Vue = require('yoho-vue'); |
2 | 2 | ||
3 | -var App = require('example/home'); | 3 | +var app = require('example/home.vue'); |
4 | 4 | ||
5 | var vm = new Vue({ | 5 | var vm = new Vue({ |
6 | el: '#app', | 6 | el: '#app', |
7 | components: { | 7 | components: { |
8 | - app: App | 8 | + app: app |
9 | } | 9 | } |
10 | }); | 10 | }); |
11 | 11 | ||
12 | console.log(vm); | 12 | console.log(vm); |
13 | + | ||
14 | +/* eslint-disable */ | ||
15 | +// 私有包测试 | ||
16 | +var qs = require('yoho-qs'); | ||
17 | +console.log(qs); | ||
18 | + | ||
19 | +var parse = require('yoho-qs/parse'); // 提供解析函数 | ||
20 | +console.log(parse('q=w&e=r')); // { q: 'w', e: 'r' } | ||
21 | + | ||
22 | +var cookie = require('yoho-cookie'); | ||
23 | + | ||
24 | +console.log(cookie.all()); | ||
25 | +/* eslint-enable */ |
public/js/yoho.js
0 → 100644
1 | +/** | ||
2 | + * YOHO-SDK | ||
3 | + * | ||
4 | + * 与原生 APP 交互的代码 | ||
5 | + * 所有函数要做降级处理 | ||
6 | + * 假如不是 YOHO App,在浏览器实现对应的功能 | ||
7 | + * 浏览器不支持的功能,给出提示,控制台不能报错,不影响后续代码执行 | ||
8 | + * | ||
9 | + * 希望能与 微信 JS-SDK 一样方便 | ||
10 | + */ | ||
11 | + | ||
12 | +var yoho = { | ||
13 | + isApp: /yoho/.test((navigator.userAgent || '').toLowerCase()), | ||
14 | + goLogin: function() { | ||
15 | + if (this.isApp) { | ||
16 | + // ... | ||
17 | + } else { | ||
18 | + location.href = ''; | ||
19 | + } | ||
20 | + } | ||
21 | +}; | ||
22 | + | ||
23 | +module.exports = yoho; |
@@ -28,7 +28,9 @@ shelljs.ls(path.join(__dirname, 'js/**/*.page.js')).forEach((f) => { | @@ -28,7 +28,9 @@ shelljs.ls(path.join(__dirname, 'js/**/*.page.js')).forEach((f) => { | ||
28 | 'yoho-iscroll', | 28 | 'yoho-iscroll', |
29 | 'yoho-jquery-lazyload', | 29 | 'yoho-jquery-lazyload', |
30 | 'yoho-mlellipsis', | 30 | 'yoho-mlellipsis', |
31 | - 'yoho-swiper' | 31 | + 'yoho-swiper', |
32 | + 'yoho-qs', | ||
33 | + 'yoho-cookie' | ||
32 | ]; | 34 | ]; |
33 | }); | 35 | }); |
34 | 36 | ||
@@ -45,7 +47,6 @@ module.exports = { | @@ -45,7 +47,6 @@ module.exports = { | ||
45 | }] | 47 | }] |
46 | }, | 48 | }, |
47 | resolve: { | 49 | resolve: { |
48 | - extensions: ['', '.vue', '.json', '.js'], | ||
49 | modulesDirectories: ['node_modules', './vue'] | 50 | modulesDirectories: ['node_modules', './vue'] |
50 | }, | 51 | }, |
51 | plugins: [ | 52 | plugins: [ |
-
Please register or login to post a comment