Authored by 陈峰

commit

@@ -7,7 +7,7 @@ const apiMaps = require('../../config/api-map'); @@ -7,7 +7,7 @@ const apiMaps = require('../../config/api-map');
7 const checkApiMap = url => { 7 const checkApiMap = url => {
8 return apiMaps[url] ? apiMaps[url] : void 0; 8 return apiMaps[url] ? apiMaps[url] : void 0;
9 }; 9 };
10 -const request = async({url, method, reqParams, context}) => { 10 +const request = async({url, method, reqParams = {}, context}) => {
11 const apiInfo = checkApiMap(url); 11 const apiInfo = checkApiMap(url);
12 const {env, user} = context; 12 const {env, user} = context;
13 13
@@ -26,7 +26,6 @@ const request = async({url, method, reqParams, context}) => { @@ -26,7 +26,6 @@ const request = async({url, method, reqParams, context}) => {
26 method: apiInfo.api, 26 method: apiInfo.api,
27 }); 27 });
28 } 28 }
29 -  
30 const params = checkParams.getParams(reqParams, apiInfo); 29 const params = checkParams.getParams(reqParams, apiInfo);
31 const cache = method.toLowerCase() !== 'get' ? false : apiInfo.cache; 30 const cache = method.toLowerCase() !== 'get' ? false : apiInfo.cache;
32 const headers = { 31 const headers = {
1 <template> 1 <template>
2 - <img :src="currentSrc" :alt="alt"> 2 + <img v-lazy="currentSrc" :alt="alt">
3 </template> 3 </template>
4 4
5 <script> 5 <script>
@@ -17,8 +17,13 @@ export default { @@ -17,8 +17,13 @@ export default {
17 .replace('{width}', this.width) 17 .replace('{width}', this.width)
18 .replace('{height}', this.height); 18 .replace('{height}', this.height);
19 } 19 }
  20 + },
  21 + methods: {
  22 + onError() {
  23 + this.$el.src = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
  24 + }
20 } 25 }
21 -} 26 +};
22 </script> 27 </script>
23 28
24 <style> 29 <style>
@@ -5,6 +5,7 @@ import { @@ -5,6 +5,7 @@ import {
5 } from 'store/yoho/types'; 5 } from 'store/yoho/types';
6 import {createApp} from './app'; 6 import {createApp} from './app';
7 import {createApi} from 'create-api'; 7 import {createApi} from 'create-api';
  8 +import Lazy from 'vue-lazyload';
8 import 'statics/scss/common.scss'; 9 import 'statics/scss/common.scss';
9 import 'statics/font/iconfont.css'; 10 import 'statics/font/iconfont.css';
10 import 'statics/font/ufofont.css'; 11 import 'statics/font/ufofont.css';
@@ -17,6 +18,7 @@ if (window.__INITIAL_STATE__) { @@ -17,6 +18,7 @@ if (window.__INITIAL_STATE__) {
17 18
18 // Vue.prop('yoho', yoho); 19 // Vue.prop('yoho', yoho);
19 Vue.prop('api', createApi()); 20 Vue.prop('api', createApi());
  21 +Vue.use(Lazy);
20 22
21 router.onReady(() => { 23 router.onReady(() => {
22 router.beforeResolve((to, from, next) => { 24 router.beforeResolve((to, from, next) => {
@@ -7,8 +7,8 @@ import { @@ -7,8 +7,8 @@ import {
7 const sender = global.yoho.apmSender; 7 const sender = global.yoho.apmSender;
8 const logger = global.yoho.logger; 8 const logger = global.yoho.logger;
9 9
10 -const catchError = (err, context) => {  
11 - logger.error(err); 10 +const catchError = (err, message, context) => {
  11 + logger.error(message, err);
12 setImmediate(() => { 12 setImmediate(() => {
13 try { 13 try {
14 sender.addMessage({ 14 sender.addMessage({
@@ -48,7 +48,7 @@ export default context => { @@ -48,7 +48,7 @@ export default context => {
48 const matched = router.getMatchedComponents(); 48 const matched = router.getMatchedComponents();
49 49
50 if (matched.some(m => !m)) { 50 if (matched.some(m => !m)) {
51 - catchError(new Error('导航组件为空'), context); 51 + catchError(new Error('导航组件为空'), '[router.onReady]', context);
52 router.push({name: 'error.500'}); 52 router.push({name: 'error.500'});
53 return resolve(app); 53 return resolve(app);
54 } 54 }
@@ -62,13 +62,13 @@ export default context => { @@ -62,13 +62,13 @@ export default context => {
62 context.state = store.state; 62 context.state = store.state;
63 return resolve(app); 63 return resolve(app);
64 }).catch(e => { 64 }).catch(e => {
65 - catchError(e, context); 65 + catchError(e, '[asyncData]', context);
66 return resolve(app); 66 return resolve(app);
67 }); 67 });
68 }); 68 });
69 69
70 router.onError(e => { 70 router.onError(e => {
71 - catchError(e, context); 71 + catchError(e, 'router.onError', context);
72 router.push({name: 'error.500'}); 72 router.push({name: 'error.500'});
73 return resolve(app); 73 return resolve(app);
74 }); 74 });
@@ -11,9 +11,9 @@ const isTest = process.env.NODE_ENV === 'test3'; @@ -11,9 +11,9 @@ const isTest = process.env.NODE_ENV === 'test3';
11 11
12 const domains = { 12 const domains = {
13 13
14 - api: 'http://api.yoho.cn/',  
15 - service: 'http://service.yoho.cn/',  
16 - ufo: 'http://java-yohoufo-fore.test3.ingress.dev.yohocorp.com/ufo-gateway/', 14 + // api: 'http://api.yoho.cn/',
  15 + // service: 'http://service.yoho.cn/',
  16 + // ufo: 'http://java-yohoufo-fore.test3.ingress.dev.yohocorp.com/ufo-gateway/',
17 17
18 // liveApi: 'http://testapi.live.yohops.com:9999/', 18 // liveApi: 'http://testapi.live.yohops.com:9999/',
19 // singleApi: 'http://api-test3.yohops.com:9999/', 19 // singleApi: 'http://api-test3.yohops.com:9999/',
@@ -24,9 +24,9 @@ const domains = { @@ -24,9 +24,9 @@ const domains = {
24 24
25 // platformApi: 'http://172.16.6.210:8088/', 25 // platformApi: 'http://172.16.6.210:8088/',
26 26
27 - // api: 'http://api-test3.dev.yohocorp.com/',  
28 - // service: 'http://api-test3.dev.yohocorp.com/',  
29 - // ufo: 'http://java-yohoufo-fore.test3.ingress.dev.yohocorp.com/ufo-gateway/', 27 + api: 'http://api-test3.dev.yohocorp.com/',
  28 + service: 'http://api-test3.dev.yohocorp.com/',
  29 + ufo: 'http://java-yohoufo-fore.test3.ingress.dev.yohocorp.com/ufo-gateway/',
30 }; 30 };
31 31
32 module.exports = { 32 module.exports = {