diff --git a/front/src/components/Search/index.jsx b/front/src/components/Search/index.jsx
index 10aa5ae..0d4ebfd 100644
--- a/front/src/components/Search/index.jsx
+++ b/front/src/components/Search/index.jsx
@@ -63,21 +63,35 @@ class Search extends React.Component {
this.setState({ resultList: [] });
return;
}
- httpUtil.get("/bookmark/searchUserBookmark?content=" + encodeURIComponent(content)).then(res => this.setState({ resultList: res }));
+ httpUtil
+ .get(
+ "/bookmark/searchUserBookmark?content=" + encodeURIComponent(content)
+ )
+ .then(res => this.setState({ resultList: res }));
}
/**
* 处理跳转到搜索引擎或者对应的书签
*/
enter() {
- const { currentIndex, currentOptionIndex, resultList, content } = this.state;
+ const {
+ currentIndex,
+ currentOptionIndex,
+ resultList,
+ content
+ } = this.state;
if (currentOptionIndex === 0 && resultList.length > 0) {
- window.open(resultList[currentIndex].url);
+ let url = resultList[currentIndex].url;
+ window.open(url.startsWith("http") ? url : "http://" + url);
}
if (currentOptionIndex === 1) {
- window.open("https://www.baidu.com/s?ie=UTF-8&wd=" + encodeURIComponent(content));
+ window.open(
+ "https://www.baidu.com/s?ie=UTF-8&wd=" + encodeURIComponent(content)
+ );
} else if (currentOptionIndex === 2) {
- window.open("https://www.google.com/search?q=" + encodeURIComponent(content));
+ window.open(
+ "https://www.google.com/search?q=" + encodeURIComponent(content)
+ );
}
}
@@ -123,7 +137,12 @@ class Search extends React.Component {
* 渲染结果列表
*/
renderResults() {
- const { resultList, currentIndex, currentOptionIndex, isFocus } = this.state;
+ const {
+ resultList,
+ currentIndex,
+ currentOptionIndex,
+ isFocus
+ } = this.state;
if (currentOptionIndex !== 0 || !isFocus) {
return;
}
@@ -132,25 +151,37 @@ class Search extends React.Component {
{resultList.map((item, index) => (
window.open(item.url)}
>
{item.name}
- {item.url}
+
+ {item.url}
+
))}
);
} else {
- return ;
+ return (
+
+ );
}
}
render() {
const { content, options, currentOptionIndex } = this.state;
const prefix = (
-