提交 ca71dc91 编写于 作者: zcdtk's avatar zcdtk

update

上级 20ad17fb
流水线 #1173 已失败 ,包含阶段
import i18n from '@/locale'
/** /**
* Http请求状态文本信息 * Http请求状态文本信息
*/ */
export const StatusMessage = { export const StatusMessage = {
200: '服务器成功返回请求的数据。', 200: i18n.t('app.statusMessage.200'),
201: '新建或修改数据成功。', 201: i18n.t('app.statusMessage.201'),
202: '一个请求已经进入后台排队(异步任务)。', 202: i18n.t('app.statusMessage.202'),
204: '删除数据成功。', 204: i18n.t('app.statusMessage.204'),
400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。', 400: i18n.t('app.statusMessage.400'),
401: '用户没有权限(令牌、用户名、密码错误)。', 401: i18n.t('app.statusMessage.401'),
403: '用户得到授权,但是访问是被禁止的。', 403: i18n.t('app.statusMessage.403'),
404: '发出的请求针对的是不存在的记录,服务器没有进行操作。', 404: i18n.t('app.statusMessage.404'),
406: '请求的格式不可得。', 405: i18n.t('app.statusMessage.405'),
410: '请求的资源被永久删除,且不会再得到的。', 406: i18n.t('app.statusMessage.406'),
422: '当创建一个对象时,发生一个验证错误。', 410: i18n.t('app.statusMessage.410'),
500: '服务器发生错误,请检查服务器。', 422: i18n.t('app.statusMessage.422'),
502: '网关错误。', 500: i18n.t('app.statusMessage.500'),
503: '服务不可用,服务器暂时过载或维护。', 502: i18n.t('app.statusMessage.502'),
504: '网关超时。', 503: i18n.t('app.statusMessage.503'),
504: i18n.t('app.statusMessage.504'),
}; };
/** /**
* 请求错误状态码文本 * 请求错误状态码文本
*/ */
export const ErrorMessage = { export const ErrorMessage = {
100: '未知', 100: i18n.t('app.errorMessage.100'),
101: '请求发生错误', 101: i18n.t('app.errorMessage.101'),
5001: '数据不存在', 5001: i18n.t('app.errorMessage.5001'),
5002: '数据已存在,无法重复创建', 5002: i18n.t('app.errorMessage.5002'),
5003: '新建失败', 5003: i18n.t('app.errorMessage.5003'),
5004: '数据不存在,无法保存', 5004: i18n.t('app.errorMessage.5004'),
5005: '数据删除失败' 5005: i18n.t('app.errorMessage.5005'),
}; };
\ No newline at end of file
import i18n from '@/locale';
/** /**
* 全局加载动画工具类 * 全局加载动画工具类
* *
...@@ -14,16 +16,29 @@ export class Loading { ...@@ -14,16 +16,29 @@ export class Loading {
*/ */
protected static loadingCount: number = 0; protected static loadingCount: number = 0;
/**
* 加载对象
*
* @private
* @static
* @type {*}
* @memberof Loading
*/
private static loading: any = null;
/** /**
* 显示加载动画 * 显示加载动画
* *
* @static * @static
* @param {string} [message='加载中'] * @param {(any | string)} [message]
* @memberof Loading * @memberof Loading
*/ */
public static show(message: string = '加载中'): void { public static show(message?: any | string): void {
if (this.loadingCount === 0) { if (this.loadingCount === 0) {
console.warn('需自行实现加载动画开启功能'); this.loading = document.createElement('ion-loading');
this.loading.message = message ? message : i18n.t('app.loadding');;
document.body.appendChild(this.loading);
this.loading.present();
} }
this.loadingCount++; this.loadingCount++;
} }
...@@ -39,9 +54,10 @@ export class Loading { ...@@ -39,9 +54,10 @@ export class Loading {
this.loadingCount = 0; this.loadingCount = 0;
} }
if (this.loadingCount === 0) { if (this.loadingCount === 0) {
setTimeout(() => { if (this.loading) {
console.warn('需自行实现加载动画关闭功能'); this.loading.dismiss();
}, 50); this.loading = null;
}
} }
} }
} }
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册