diff --git a/bookmark_front/src/components/main/Search.vue b/bookmark_front/src/components/main/Search.vue index 02b74e4..c84b1c0 100644 --- a/bookmark_front/src/components/main/Search.vue +++ b/bookmark_front/src/components/main/Search.vue @@ -3,10 +3,17 @@
- - - - + + + + + + 谷歌 + bing + baidu + + +
@@ -24,7 +31,7 @@ {{ item.name }}
- + @@ -47,11 +54,11 @@ import HttpUtil from "@/util/HttpUtil"; import { mapState } from "vuex"; import ClipboardJS from "clipboard"; +import { GLOBAL_CONFIG, USER_INFO } from "@/store/modules/globalConfig"; export default { name: "Search", props: { - //是否显示定位等按钮 - showActions: Boolean, + showLocation: Boolean, //是否显示定位等按钮 }, data() { return { @@ -86,7 +93,7 @@ export default { ...mapState("treeData", ["totalTreeData"]), ...mapState("globalConfig", ["userInfo"]), searchIcon() { - let search = this.userInfo && this.userInfo.defaultSearchEngine ? this.userInfo.defaultSearchEngine : "baidu"; + let search = this.userInfo != null ? this.userInfo.defaultSearchEngine : "baidu"; return search === "baidu" ? "icon-baidu" : search === "bing" ? "icon-bing" : "icon-google"; }, searchUrl() { @@ -119,9 +126,9 @@ export default { this.submit(); }, //搜索或者跳转到书签 - submit() { + submit(forceSearch) { let url; - if (this.selectIndex == null) { + if (forceSearch || this.selectIndex == null) { //说明使用百度搜索 url = this.searchUrl + encodeURIComponent(this.value); } else { @@ -159,7 +166,6 @@ export default { * 键盘事件处理 */ keyPress(e) { - let stop = false; if (e.key === "Enter") { this.submit(); return this.stopDefault(); @@ -172,7 +178,17 @@ export default { return this.stopDefault(); } } - if (stop) { + }, + //修改默认搜索引擎 + async searchEngineChange(item) { + if (this.userInfo == null) { + this.$message.warning("未登录,请登录后操作"); + return; + } + if (item.key !== this.userInfo.defaultSearchEngine) { + await HttpUtil.post("/baseInfo/updateSearchEngine", null, { defaultSearchEngine: item.key }); + this.userInfo.defaultSearchEngine = item.key; + this.$store.commit(GLOBAL_CONFIG + "/" + USER_INFO, this.userInfo); } }, dealSearch(content) { @@ -217,6 +233,10 @@ export default { diff --git a/bookmark_front/src/layout/manage/Top.vue b/bookmark_front/src/layout/manage/Top.vue index e6746ec..dc179c0 100644 --- a/bookmark_front/src/layout/manage/Top.vue +++ b/bookmark_front/src/layout/manage/Top.vue @@ -20,6 +20,7 @@