feat:主页搜索完成
This commit is contained in:
parent
2e63b2706a
commit
92614c7344
@ -3,10 +3,17 @@
|
|||||||
<div :class="{ listShow: focused && list.length > 0 }" class="newSearch">
|
<div :class="{ listShow: focused && list.length > 0 }" class="newSearch">
|
||||||
<input ref="searchInput" class="input" type="text" v-model="value" @keydown="keyPress" @focus="inputFocus" @blur="inputBlur" />
|
<input ref="searchInput" class="input" type="text" v-model="value" @keydown="keyPress" @focus="inputFocus" @blur="inputBlur" />
|
||||||
<div class="action">
|
<div class="action">
|
||||||
|
<a-dropdown :trigger="['click']">
|
||||||
<a-tooltip title="点击切换网页搜索">
|
<a-tooltip title="点击切换网页搜索">
|
||||||
<my-icon style="color: white; font-size: 1.3em; margin-right: 0.5em" type="icon-google" @mousedown="location($event, item)" />
|
<my-icon class="icon" style="margin-right: 0.5em" :type="searchIcon" />
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-icon style="font-size: 1.2em; cursor: pointer" type="search" />
|
<a-menu slot="overlay" @click="searchEngineChange">
|
||||||
|
<a-menu-item key="google">谷歌</a-menu-item>
|
||||||
|
<a-menu-item key="bing">bing</a-menu-item>
|
||||||
|
<a-menu-item key="baidu">baidu</a-menu-item>
|
||||||
|
</a-menu>
|
||||||
|
</a-dropdown>
|
||||||
|
<a-icon class="icon" type="search" @click="submit(true)" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="focused && list.length > 0" class="searchContent">
|
<div v-if="focused && list.length > 0" class="searchContent">
|
||||||
@ -24,7 +31,7 @@
|
|||||||
{{ item.name }}
|
{{ item.name }}
|
||||||
</div>
|
</div>
|
||||||
<div class="icons" v-if="hoverIndex === index">
|
<div class="icons" v-if="hoverIndex === index">
|
||||||
<a-tooltip title="定位到书签树中" v-if="showActions">
|
<a-tooltip title="定位到书签树中" v-if="showLocation">
|
||||||
<my-icon style="color: white; font-size: 1.3em" type="icon-et-location" @mousedown="location($event, item)" />
|
<my-icon style="color: white; font-size: 1.3em" type="icon-et-location" @mousedown="location($event, item)" />
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip :title="'复制链接:' + item.url">
|
<a-tooltip :title="'复制链接:' + item.url">
|
||||||
@ -47,11 +54,11 @@
|
|||||||
import HttpUtil from "@/util/HttpUtil";
|
import HttpUtil from "@/util/HttpUtil";
|
||||||
import { mapState } from "vuex";
|
import { mapState } from "vuex";
|
||||||
import ClipboardJS from "clipboard";
|
import ClipboardJS from "clipboard";
|
||||||
|
import { GLOBAL_CONFIG, USER_INFO } from "@/store/modules/globalConfig";
|
||||||
export default {
|
export default {
|
||||||
name: "Search",
|
name: "Search",
|
||||||
props: {
|
props: {
|
||||||
//是否显示定位等按钮
|
showLocation: Boolean, //是否显示定位等按钮
|
||||||
showActions: Boolean,
|
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -86,7 +93,7 @@ export default {
|
|||||||
...mapState("treeData", ["totalTreeData"]),
|
...mapState("treeData", ["totalTreeData"]),
|
||||||
...mapState("globalConfig", ["userInfo"]),
|
...mapState("globalConfig", ["userInfo"]),
|
||||||
searchIcon() {
|
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";
|
return search === "baidu" ? "icon-baidu" : search === "bing" ? "icon-bing" : "icon-google";
|
||||||
},
|
},
|
||||||
searchUrl() {
|
searchUrl() {
|
||||||
@ -119,9 +126,9 @@ export default {
|
|||||||
this.submit();
|
this.submit();
|
||||||
},
|
},
|
||||||
//搜索或者跳转到书签
|
//搜索或者跳转到书签
|
||||||
submit() {
|
submit(forceSearch) {
|
||||||
let url;
|
let url;
|
||||||
if (this.selectIndex == null) {
|
if (forceSearch || this.selectIndex == null) {
|
||||||
//说明使用百度搜索
|
//说明使用百度搜索
|
||||||
url = this.searchUrl + encodeURIComponent(this.value);
|
url = this.searchUrl + encodeURIComponent(this.value);
|
||||||
} else {
|
} else {
|
||||||
@ -159,7 +166,6 @@ export default {
|
|||||||
* 键盘事件处理
|
* 键盘事件处理
|
||||||
*/
|
*/
|
||||||
keyPress(e) {
|
keyPress(e) {
|
||||||
let stop = false;
|
|
||||||
if (e.key === "Enter") {
|
if (e.key === "Enter") {
|
||||||
this.submit();
|
this.submit();
|
||||||
return this.stopDefault();
|
return this.stopDefault();
|
||||||
@ -172,7 +178,17 @@ export default {
|
|||||||
return this.stopDefault();
|
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) {
|
dealSearch(content) {
|
||||||
@ -217,6 +233,10 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
@inputBgColor: rgb(74, 74, 74);
|
||||||
|
@listBgColor: #2b2b2b;
|
||||||
|
@textColor: white;
|
||||||
|
@listActiveBgColor: #454545;
|
||||||
.search {
|
.search {
|
||||||
position: relative;
|
position: relative;
|
||||||
.listShow {
|
.listShow {
|
||||||
@ -226,15 +246,15 @@ export default {
|
|||||||
.newSearch {
|
.newSearch {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
background-color: rgb(74, 74, 74);
|
background-color: @inputBgColor;
|
||||||
border-radius: 0.18rem;
|
border-radius: 0.18rem;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
font-size: 1.2em;
|
font-size: 1.2em;
|
||||||
color: white;
|
color: @textColor;
|
||||||
.input {
|
.input {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
border: 0;
|
border: 0;
|
||||||
background-color: rgb(74, 74, 74);
|
background-color: @inputBgColor;
|
||||||
padding: 0.1rem;
|
padding: 0.1rem;
|
||||||
padding-left: 0.19rem;
|
padding-left: 0.19rem;
|
||||||
outline: none;
|
outline: none;
|
||||||
@ -244,13 +264,18 @@ export default {
|
|||||||
padding-right: 0.19rem;
|
padding-right: 0.19rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
.icon {
|
||||||
|
color: @textColor;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 1.3em;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.searchContent {
|
.searchContent {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background: #2b2b2b;
|
background: @listBgColor;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
border-top: 1px solid white;
|
border-top: 1px solid white;
|
||||||
border-bottom-left-radius: 0.18rem;
|
border-bottom-left-radius: 0.18rem;
|
||||||
@ -262,7 +287,7 @@ export default {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
height: 0.3rem;
|
height: 0.3rem;
|
||||||
line-height: 0.3rem;
|
line-height: 0.3rem;
|
||||||
color: white;
|
color: @textColor;
|
||||||
margin: 0.05rem 0 0.05rem 0;
|
margin: 0.05rem 0 0.05rem 0;
|
||||||
padding: 0 0.19rem 0 0.19rem;
|
padding: 0 0.19rem 0 0.19rem;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@ -279,7 +304,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.itemActive {
|
.itemActive {
|
||||||
background-color: #454545;
|
background-color: @listActiveBgColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,32 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="top">
|
<div class="top">
|
||||||
<div>应用</div>
|
<div></div>
|
||||||
<div>头像</div>
|
<div v-if="userInfo == null">
|
||||||
|
<router-link to="/public/login">登陆</router-link>
|
||||||
|
/
|
||||||
|
<router-link to="/public/register">注册</router-link>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<a-dropdown>
|
||||||
|
<div class="user">
|
||||||
|
<img :src="userInfo.icon" class="userIcon" />
|
||||||
|
</div>
|
||||||
|
<a-menu slot="overlay" :trigger="['hover', 'click']" @click="menuClick">
|
||||||
|
<a-menu-item key="personSpace">
|
||||||
|
<router-link to="manage">管理</router-link>
|
||||||
|
</a-menu-item>
|
||||||
|
<a-menu-item key="logout">
|
||||||
|
<a href="javascript:;">退出</a>
|
||||||
|
</a-menu-item>
|
||||||
|
</a-menu>
|
||||||
|
</a-dropdown>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapState } from "vuex";
|
import { mapState } from "vuex";
|
||||||
|
import { logoutClear } from "@/store/index";
|
||||||
export default {
|
export default {
|
||||||
name: "homeTop",
|
name: "homeTop",
|
||||||
data() {
|
data() {
|
||||||
@ -15,6 +35,14 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
...mapState("globalConfig", ["userInfo"]),
|
...mapState("globalConfig", ["userInfo"]),
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
async menuClick(item) {
|
||||||
|
if (item.key == "logout") {
|
||||||
|
await logoutClear();
|
||||||
|
this.$router.replace("/public/login");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -27,5 +55,9 @@ export default {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
padding-left: 0.4rem;
|
padding-left: 0.4rem;
|
||||||
padding-right: 0.4rem;
|
padding-right: 0.4rem;
|
||||||
|
|
||||||
|
.userIcon {
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapState } from "vuex";
|
import { mapState } from "vuex";
|
||||||
|
import { logoutClear } from "@/store/index";
|
||||||
export default {
|
export default {
|
||||||
name: "Top",
|
name: "Top",
|
||||||
computed: {
|
computed: {
|
||||||
@ -28,9 +29,7 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
async menuClick({ key }) {
|
async menuClick({ key }) {
|
||||||
if (key === "logout") {
|
if (key === "logout") {
|
||||||
//推出登录清理缓存
|
await logoutClear();
|
||||||
await this.$store.dispatch("treeData/clear");
|
|
||||||
await this.$store.dispatch("globalConfig/clear");
|
|
||||||
this.$router.replace("/public/login");
|
this.$router.replace("/public/login");
|
||||||
} else if (key === "personSpace") {
|
} else if (key === "personSpace") {
|
||||||
this.$router.push("/manage/personSpace/userInfo");
|
this.$router.push("/manage/personSpace/userInfo");
|
||||||
|
@ -40,6 +40,17 @@ export async function loginInit () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推出登陆时需要清理的
|
||||||
|
*/
|
||||||
|
export async function logoutClear () {
|
||||||
|
await store.dispatch(globalConfig.GLOBAL_CONFIG + "/" + globalConfig.clear);
|
||||||
|
await store.dispatch(treeData.TREE_DATA + "/" + treeData.clear);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 确保未登录前要初始化的初始化完了
|
||||||
|
*/
|
||||||
async function finishNoLogin () {
|
async function finishNoLogin () {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
let timer = setInterval(() => {
|
let timer = setInterval(() => {
|
||||||
|
@ -10,6 +10,7 @@ export const IS_INIT = "isInit";
|
|||||||
|
|
||||||
export const noLoginInit = "noLoginInit";
|
export const noLoginInit = "noLoginInit";
|
||||||
export const loginInit = "loginInit";
|
export const loginInit = "loginInit";
|
||||||
|
export const clear = "clear";
|
||||||
/**
|
/**
|
||||||
* 存储全局配置
|
* 存储全局配置
|
||||||
*/
|
*/
|
||||||
@ -67,7 +68,7 @@ const actions = {
|
|||||||
commit(TOKEN, token);
|
commit(TOKEN, token);
|
||||||
},
|
},
|
||||||
//登出清除数据
|
//登出清除数据
|
||||||
async clear (context) {
|
async [clear] (context) {
|
||||||
await localforage.removeItem(TOKEN);
|
await localforage.removeItem(TOKEN);
|
||||||
context.commit(USER_INFO, null);
|
context.commit(USER_INFO, null);
|
||||||
context.commit(TOKEN, null);
|
context.commit(TOKEN, null);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import localforage from "localforage";
|
import localforage from "localforage";
|
||||||
import { } from "ant-design-vue";
|
import { checkJwtValid } from "@/util/UserUtil";
|
||||||
import HttpUtil from "../../util/HttpUtil";
|
import HttpUtil from "../../util/HttpUtil";
|
||||||
|
|
||||||
export const TREE_DATA = "treeData";
|
export const TREE_DATA = "treeData";
|
||||||
@ -13,6 +13,7 @@ export const IS_INITING = "isIniting";
|
|||||||
export const noLoginInit = "noLoginInit";
|
export const noLoginInit = "noLoginInit";
|
||||||
export const loginInit = "loginInit";
|
export const loginInit = "loginInit";
|
||||||
export const refresh = "refresh";
|
export const refresh = "refresh";
|
||||||
|
export const clear = "clear";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 版本检查定时调度
|
* 版本检查定时调度
|
||||||
@ -109,7 +110,7 @@ const actions = {
|
|||||||
await localforage.setItem(TOTAL_TREE_DATA, treeData);
|
await localforage.setItem(TOTAL_TREE_DATA, treeData);
|
||||||
},
|
},
|
||||||
//清除缓存数据
|
//清除缓存数据
|
||||||
async clear (context) {
|
async [clear] (context) {
|
||||||
context.commit(TOTAL_TREE_DATA, null);
|
context.commit(TOTAL_TREE_DATA, null);
|
||||||
context.commit(VERSION, null);
|
context.commit(VERSION, null);
|
||||||
context.commit(SHOW_REFRESH_TOAST, false);
|
context.commit(SHOW_REFRESH_TOAST, false);
|
||||||
@ -282,7 +283,7 @@ const mutations = {
|
|||||||
|
|
||||||
|
|
||||||
async function treeDataCheck (context, isFirst) {
|
async function treeDataCheck (context, isFirst) {
|
||||||
if (toastShow) {
|
if (toastShow || !checkJwtValid(context.rootState.globalConfig.token)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let realVersion = await HttpUtil.get("/user/version");
|
let realVersion = await HttpUtil.get("/user/version");
|
||||||
|
0
bookmark_front/src/views/home/PinBookmark.vue
Normal file
0
bookmark_front/src/views/home/PinBookmark.vue
Normal file
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<a-spin :spinning="loading" :delay="300">
|
<a-spin :spinning="loading" :delay="300">
|
||||||
<div class="search">
|
<div class="search">
|
||||||
<search :showActions="true" @location="location" />
|
<search :showLocation="true" @location="location" />
|
||||||
</div>
|
</div>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<div class="left">
|
<div class="left">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user