本文整理汇总了TypeScript中antd.message类的典型用法代码示例。如果您正苦于以下问题:TypeScript message类的具体用法?TypeScript message怎么用?TypeScript message使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了message类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: loadModels
function* loadModels({ payload: { name, models } }: LoadModelsParams) {
const { token } = yield select((state: RootState) => state.auth);
if (token) {
try {
const {
[name]: { extras },
} = models;
logger.debug('[loadModels]', 'loading content', { name, extras });
message.loading(`loading content '${name}'...`);
const response = yield call(AppContext.adapters.models.loadModels, name, extras);
message.success(`load content '${name}' success`);
logger.log('[loadModels]', 'loaded content', { name, response });
yield put(
contentActions.loadModelsSuccess({
[name]: { data: response.data, loading: false },
}),
);
} catch (e) {
logger.warn('[loadModels]', { e });
message.error(toErrorMessage(e));
}
}
}
示例2: loginSaga
function* loginSaga({ payload: { username, password }, callback }) {
const auth: AuthState = yield select((state: RootState) => state.auth);
try {
const response = yield call(authProxy.login, username, password);
logger.log('[loginSaga]', 'response is', response);
// 切换用户时更新操作区域,如果未来需要保存当前页面配置的话,应该将切换操作提出为单独的 Saga
if (auth.username !== username) {
yield put(panesActions.closeAll());
}
if (callback) callback({ response });
const token = yield call(authProxy.extractToken, response.data);
yield put(authActions.loginSuccess(username, token));
message.info(`'${username}' login success`);
yield put(routerActions.toIndex());
} catch (error) {
logger.error('[loginSaga]', { error });
try {
if (callback != null) callback({ error });
} catch (e) {
logger.warn('[upsert] callback error', e, { e });
}
if (error.response) {
yield put(authActions.loginFailed(error.response));
message.error(toErrorMessage(error));
}
}
}
示例3: state
(dispatch: Redux.Dispatch, state: ()=>any)=> {
let _state: QueryInterface = state().query_list;
if (_state.start && !_state.end) {
message.error("当指定开始时间时,必须同时指定结束时间");
return
}
if (_state.end && !_state.start) {
message.error("当指定结束时间时,必须同时指定开始时间");
return
}
if (_state.end < _state.start) {
message.error("结束时间不能小于开始时间");
return
}
const url = `/api/query/query-call-over/?${parse_data(_state.start, 'start')}${parse_data(_state.end, 'end')}department=${_state.current_department}`;
fetch(url, {
credentials: 'include',
method: 'get',
}).then(response=> {
if (response.status == 200) {
response.json().then((json)=> {
dispatch(UpdateListData(json))
})
} else {
response.json().then(json=>message.error(JSON.stringify(json)))
}
});
return
}
示例4:
response.json().then(json => {
try {
message.error("错误," + json['error'])
}catch(e){
message.error("发生错误")
}
})
示例5: Promise
return new Promise((resolve, reject) => {
if (/^20\d$/.test(response.status as any)) {
message.success('upload successfully.');
resolve(response.data);
} else {
message.error('upload failed.');
reject(response);
}
});
示例6: getState
}).then(response => {
if (response.status != 202) {
message.error("替换失败")
} else {
let state = getState();
dispatch(GetData((state.manage_check as manage_check_store).selectDate, (state.manage_check as manage_check_store).selectClassName));
message.success("替换成功");
dispatch(showModal(false))
}
}
示例7: validateFile
export function validateFile(file: { type: string; size: number }): boolean {
// console.log(file);
const isImage = ['image/jpeg', 'image/png', 'image/gif'].indexOf(file.type) > -1;
const isLt20M = file.size / 1024 / 1024 < 20;
logger.log('[validateFile]', file, { isImage, isLt20M });
if (!isImage) {
message.error('You can only upload JPG/PNG/GIF file!');
}
if (!isLt20M) {
message.error('Image must smaller than 20MB!');
}
return isImage && isLt20M;
}
示例8: fetch
(dispatch:Redux.Dispatch, getState:()=>any)=> {
if(username.length>0 && password.length>0){
fetch('/api/scrapy/about-password/', {
credentials: 'include',
method: 'post',
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ password: password, username: username })
}).then(response => {
if (response.status == 200) {
message.success("成功更改了密码")
dispatch(actions.change_password_modal(false))
} else {
response.json().then(json => {
try {
message.error("错误," + json['error'])
}catch(e){
message.error("发生错误")
}
})
}
})
}else{
message.error("用户名或密码字段不能为空")
}
}
示例9:
.then((resp: any) => {
message.success('Add todo success');
if (action.meta && action.meta.closeFn) {
action.meta.closeFn();
}
return Actions.ADD_TODO.success(resp);
})
示例10:
UPDATE_DATE_RANGE: (state,
action: ActionMeta<{ end: moment.Moment, start: moment.Moment}, {}>) => {
if (action.error) {
message.error(`Error updating date range.`);
} else {
return Object.assign({}, state, action.payload);
}
},