Browse Source

服务不可用提示

pull/18425/head
天可 5 years ago
parent
commit
e912048168
  1. 2
      site/theme/en-US.js
  2. 8
      site/theme/template/IconDisplay/IconPicSearcher.tsx
  3. 1
      site/theme/zh-CN.js

2
site/theme/en-US.js

@ -114,5 +114,7 @@ module.exports = {
'app.docs.components.icon.pic-searcher.title': 'Search by image',
'app.docs.components.icon.pic-searcher.placeholder':
'Click or drag or paste file to this area to upload',
'app.docs.components.icon.pic-searcher.server-error':
'Predict service is temporarily unavailable',
},
};

8
site/theme/template/IconDisplay/IconPicSearcher.tsx

@ -68,7 +68,11 @@ class PicSearcher extends Component<PicSearcherProps, PicSearcherState> {
};
predict = async (imageBase64: any) => {
const {
intl: { messages },
} = this.props;
this.setState(() => ({ loading: true }));
try {
const res = await fetch(
'//1647796581073291.cn-shanghai.fc.aliyuncs.com/2016-08-15/proxy/cr-sh.cr-fc-predict__stable/cr-fc-predict/',
{
@ -83,6 +87,10 @@ class PicSearcher extends Component<PicSearcherProps, PicSearcherState> {
let icons = await res.json();
icons = icons.map((i: any) => ({ score: i.score, type: i.class_name.replace(/\s/g, '-') }));
this.setState(() => ({ icons, loading: false }));
} catch (err) {
message.error(messages['app.docs.components.icon.pic-searcher.server-error']);
this.setState(() => ({ loading: false }));
}
};
toggleModal = () => {

1
site/theme/zh-CN.js

@ -110,5 +110,6 @@ module.exports = {
'app.docs.components.icon.category.logo': '品牌和标识',
'app.docs.components.icon.pic-searcher.title': '按图片搜索',
'app.docs.components.icon.pic-searcher.placeholder': '点击/拖拽/粘贴上传',
'app.docs.components.icon.pic-searcher.server-error': '识别服务暂不可用',
},
};

Loading…
Cancel
Save