mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-15 15:37:33 +08:00
code refactor
This commit is contained in:
@@ -3,16 +3,150 @@ const baseApiUrlPath = '/api';
|
||||
const baseQrcodePath = '/qrcode';
|
||||
const baseProxyUrlPath = '/proxy';
|
||||
const baseAmapApiProxyUrlPath = '/_AMapService';
|
||||
const apiNotFoundErrorCode = 100001;
|
||||
const validatorErrorCode = 200000;
|
||||
const googleMapJavascriptUrl = 'https://maps.googleapis.com/maps/api/js';
|
||||
const baiduMapJavascriptUrl = 'https://api.map.baidu.com/api?v=3.0';
|
||||
const amapJavascriptUrl = 'https://webapi.amap.com/maps?v=2.0';
|
||||
|
||||
const specifiedApiNotFoundErrors = {
|
||||
'/api/register.json': {
|
||||
message: 'User registration is disabled'
|
||||
}
|
||||
};
|
||||
|
||||
const parameterizedErrors = [
|
||||
{
|
||||
localeKey: 'parameter invalid',
|
||||
regex: /^parameter "(\w+)" is invalid$/,
|
||||
parameters: [{
|
||||
field: 'parameter',
|
||||
localized: true
|
||||
}]
|
||||
},
|
||||
{
|
||||
localeKey: 'parameter required',
|
||||
regex: /^parameter "(\w+)" is required$/,
|
||||
parameters: [{
|
||||
field: 'parameter',
|
||||
localized: true
|
||||
}]
|
||||
},
|
||||
{
|
||||
localeKey: 'parameter too large',
|
||||
regex: /^parameter "(\w+)" must be less than (\d+)$/,
|
||||
parameters: [{
|
||||
field: 'parameter',
|
||||
localized: true
|
||||
}, {
|
||||
field: 'number',
|
||||
localized: false
|
||||
}]
|
||||
},
|
||||
{
|
||||
localeKey: 'parameter too long',
|
||||
regex: /^parameter "(\w+)" must be less than (\d+) characters$/,
|
||||
parameters: [{
|
||||
field: 'parameter',
|
||||
localized: true
|
||||
}, {
|
||||
field: 'length',
|
||||
localized: false
|
||||
}]
|
||||
},
|
||||
{
|
||||
localeKey: 'parameter too small',
|
||||
regex: /^parameter "(\w+)" must be more than (\d+)$/,
|
||||
parameters: [{
|
||||
field: 'parameter',
|
||||
localized: true
|
||||
}, {
|
||||
field: 'number',
|
||||
localized: false
|
||||
}]
|
||||
},
|
||||
{
|
||||
localeKey: 'parameter too short',
|
||||
regex: /^parameter "(\w+)" must be more than (\d+) characters$/,
|
||||
parameters: [{
|
||||
field: 'parameter',
|
||||
localized: true
|
||||
}, {
|
||||
field: 'length',
|
||||
localized: false
|
||||
}]
|
||||
},
|
||||
{
|
||||
localeKey: 'parameter length not equal',
|
||||
regex: /^parameter "(\w+)" length is not equal to (\d+)$/,
|
||||
parameters: [{
|
||||
field: 'parameter',
|
||||
localized: true
|
||||
}, {
|
||||
field: 'length',
|
||||
localized: false
|
||||
}]
|
||||
},
|
||||
{
|
||||
localeKey: 'parameter cannot be blank',
|
||||
regex: /^parameter "(\w+)" cannot be blank$/,
|
||||
parameters: [{
|
||||
field: 'parameter',
|
||||
localized: true
|
||||
}]
|
||||
},
|
||||
{
|
||||
localeKey: 'parameter invalid username format',
|
||||
regex: /^parameter "(\w+)" is invalid username format$/,
|
||||
parameters: [{
|
||||
field: 'parameter',
|
||||
localized: true
|
||||
}]
|
||||
},
|
||||
{
|
||||
localeKey: 'parameter invalid email format',
|
||||
regex: /^parameter "(\w+)" is invalid email format$/,
|
||||
parameters: [{
|
||||
field: 'parameter',
|
||||
localized: true
|
||||
}]
|
||||
},
|
||||
{
|
||||
localeKey: 'parameter invalid currency',
|
||||
regex: /^parameter "(\w+)" is invalid currency$/,
|
||||
parameters: [{
|
||||
field: 'parameter',
|
||||
localized: true
|
||||
}]
|
||||
},
|
||||
{
|
||||
localeKey: 'parameter invalid color',
|
||||
regex: /^parameter "(\w+)" is invalid color$/,
|
||||
parameters: [{
|
||||
field: 'parameter',
|
||||
localized: true
|
||||
}]
|
||||
},
|
||||
{
|
||||
localeKey: 'parameter invalid amount filter',
|
||||
regex: /^parameter "(\w+)" is invalid amount filter$/,
|
||||
parameters: [{
|
||||
field: 'parameter',
|
||||
localized: true
|
||||
}]
|
||||
}
|
||||
];
|
||||
|
||||
export default {
|
||||
defaultTimeout: defaultTimeout,
|
||||
baseApiUrlPath: baseApiUrlPath,
|
||||
baseQrcodePath: baseQrcodePath,
|
||||
baseProxyUrlPath: baseProxyUrlPath,
|
||||
baseAmapApiProxyUrlPath: baseAmapApiProxyUrlPath,
|
||||
apiNotFoundErrorCode: apiNotFoundErrorCode,
|
||||
validatorErrorCode: validatorErrorCode,
|
||||
specifiedApiNotFoundErrors: specifiedApiNotFoundErrors,
|
||||
parameterizedErrors: parameterizedErrors,
|
||||
googleMapJavascriptUrl: googleMapJavascriptUrl,
|
||||
baiduMapJavascriptUrl: baiduMapJavascriptUrl,
|
||||
amapJavascriptUrl: amapJavascriptUrl
|
||||
|
||||
Reference in New Issue
Block a user