refactor code

This commit is contained in:
MaysWind 2016-06-26 19:44:49 +08:00
parent e581a16724
commit 9c1d3b72f3
4 changed files with 6 additions and 5 deletions

View file

@ -151,7 +151,7 @@
}, },
"rpc": { "rpc": {
"error": { "error": {
"Unauthorized": "认证失败!" "unauthorized": "认证失败!"
} }
}, },
"options": { "options": {

View file

@ -8,7 +8,8 @@
rpcTokenPrefix: 'token:' rpcTokenPrefix: 'token:'
}).constant('aria2RpcErrors', { }).constant('aria2RpcErrors', {
Unauthorized: { Unauthorized: {
message: 'Unauthorized' message: 'Unauthorized',
tipTextKey: 'rpc.error.unauthorized'
} }
}); });
})(); })();

View file

@ -155,7 +155,7 @@
}, },
'rpc': { 'rpc': {
'error': { 'error': {
'Unauthorized': 'Authorization Failed!' 'unauthorized': 'Authorization Failed!'
} }
}, },
'options': { 'options': {

View file

@ -71,8 +71,8 @@
return false; return false;
} }
if (error.message == aria2RpcErrors.Unauthorized.message) { if (aria2RpcErrors[error.message] && aria2RpcErrors[error.message].tipTextKey) {
ariaNgCommonService.showError('rpc.error.' + error.message); ariaNgCommonService.showError(aria2RpcErrors[error.message].tipTextKey);
return true; return true;
} else { } else {
ariaNgCommonService.showError(error.message); ariaNgCommonService.showError(error.message);