Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.disposer = intercept(this.style, 'color', change => {
if (!change.newValue) {
// 忽略取消设置背景颜色
notification.error({message: '错误提示', description: '颜色值不能为空'});
return null;
}
if (change.newValue.length === 6) {
// 补全缺少的 '#' 前缀
change.newValue = '#' + change.newValue;
notification.warn({message: '警告提示', description: '缺少#前缀'});
return change;
}
if (change.newValue.length === 7) {
return change;
}
if (change.newValue.length > 10) this.disposer(); // 不再拦截今后的任何变化
notification.error({message: '错误提示', description: change.newValue + ' 不是一个合法的颜色值'});
});
export async function handleErr (res) {
log.debug(res)
let text = res.message || res.statusText
if (!_.isString(text)) {
try {
text = _.isFunction(res.text)
? await res.text()
: _.isFunction(res.json) ? await res.json() : ''
} catch (e) {
log.error('fetch response parse fails', e)
}
}
log.debug(text, 'fetch err info')
notification.error({
message: 'error',
description: (
<div>
{text}
</div>
),
duration: 55
})
}
.catch(error => {
if (error.status === 401) {
notification.error({
message: "MyMoments",
description:
"Username or Password is incorrect. Please try again!"
});
} else {
notification.error({
message: "MyMoments",
description:
error.message ||
"Sorry! Something went wrong. Please try again!"
});
}
});
}
resps.forEach((data, index) => {
if (data === "") {
notification.error({
message: "Could not download from subscription",
description: urls[index]
})
return
}
let yml = {}
try {
yml = ymlParse(data)
} catch{ }
const { 'Proxy': p = [] } = yml
proxies = proxies.concat(p)
})
setSubProxies(proxies)
const errorHandler = (error: ResponseError) => {
const { response = {} as Response } = error;
const errortext = codeMessage[response.status] || response.statusText;
const { status, url } = response;
notification.error({
message: `请求错误 ${status}: ${url}`,
description: errortext,
});
};
callback: data => {
data
? notification.success({ message: data.msg_show || "编辑成功" })
: notification.error({ message: "编辑失败" });
this.setState({
TcpDrawerVisible: false,
editInfo: false
});
this.load();
}
});
onItemEdit (item) {
const value = this.state[item.id] === null ? null : (this.state[item.id] || this.props.account[item.id])
if (!value) {
notification.error({
message: 'Missing username',
description: `${'Add your username before moving on to the next step'}`
})
return
}
this.props.onClaimAction &&
this.props.onClaimAction(item, { [item.id]: value })
}
.then((result) => {
this.handleCancel();
if (result.success) {
notification.success({
message: intl.formatMessage({ id: 'success' }),
description: intl.formatMessage({ id: 'success_revoke_app_tokens' }),
});
} else {
notification.error({
message: intl.formatMessage({ id: 'error' }),
description: intl.formatMessage({ id: 'general_error_short' }),
});
}
});
}
const getSetting = (params: { key: string; disableNotification?: boolean }): ISetting => {
const settingByEerrorTips: ISetting = {
name: '',
slug: '',
value: '',
};
const settingsByEmpty: ISetting[] = [settingByEerrorTips];
const settingsByLs = localStorage.getItem('settings');
const settings = settingsByLs ? (JSON.parse(settingsByLs) as ISetting[]) : settingsByEmpty;
const setting = settings.find(t => t.slug === params.key);
if (!setting) {
if (!params.disableNotification) {
notification.error({ message: `setting ${params.key} not found` });
}
return settingByEerrorTips;
}
return setting;
};
notify: action((state, { message, description, error }) => {
const options = {
placement: 'bottomRight',
bottom: 50,
} as ArgsProps;
if (!error) {
notification.success({
...options,
message: message,
description,
});
} else {
notification.error({
...options,
duration: 10,
message: message,
description: description || error.message,
});
}
}),
navigateTo: thunk((actions, route, { dispatch }) => {