本文整理匯總了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);
}
},