feat:搜索完成
This commit is contained in:
parent
a705cc76fb
commit
f968a41303
@ -11,11 +11,13 @@
|
|||||||
allowClear
|
allowClear
|
||||||
@blur.prevent="inputBlur"
|
@blur.prevent="inputBlur"
|
||||||
@focus="inputFocus"
|
@focus="inputFocus"
|
||||||
|
@keydown="keyPress"
|
||||||
/>
|
/>
|
||||||
<div v-if="focused" class="searchContent">
|
<div v-if="focused" class="searchContent">
|
||||||
<a-empty v-if="list.length == 0" />
|
<a-empty v-if="list.length == 0" />
|
||||||
<div
|
<div
|
||||||
class="listItem"
|
class="listItem"
|
||||||
|
:class="{ itemActive: index == hoverIndex || index == selectIndex }"
|
||||||
v-for="(item, index) in list"
|
v-for="(item, index) in list"
|
||||||
:key="item.bookmarkId"
|
:key="item.bookmarkId"
|
||||||
@mouseenter="mouseEnterOut(index, 'enter')"
|
@mouseenter="mouseEnterOut(index, 'enter')"
|
||||||
@ -23,7 +25,13 @@
|
|||||||
@mouseup="onMouse"
|
@mouseup="onMouse"
|
||||||
@click="itemClick(item)"
|
@click="itemClick(item)"
|
||||||
>
|
>
|
||||||
<a style="min-width: 4em" :href="item.url" target="_blank">
|
<a
|
||||||
|
class="listItemUrl"
|
||||||
|
style="padding-right: 1em; max-width: calc(100% - 2em)"
|
||||||
|
:id="'bookmark:' + item.bookmarkId"
|
||||||
|
:href="item.url"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
{{ item.name }}
|
{{ item.name }}
|
||||||
</a>
|
</a>
|
||||||
<a-tooltip v-if="showActions && hoverIndex === index" title="定位到书签树中">
|
<a-tooltip v-if="showActions && hoverIndex === index" title="定位到书签树中">
|
||||||
@ -31,6 +39,7 @@
|
|||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<a ref="targetA" style="left: 1000000px" target="_blank" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -50,7 +59,10 @@ export default {
|
|||||||
list: [],
|
list: [],
|
||||||
//计时器结束列表的显示
|
//计时器结束列表的显示
|
||||||
timer: null,
|
timer: null,
|
||||||
|
//鼠标悬浮选中
|
||||||
hoverIndex: null,
|
hoverIndex: null,
|
||||||
|
//上下选中
|
||||||
|
selectIndex: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -102,6 +114,26 @@ export default {
|
|||||||
location(item) {
|
location(item) {
|
||||||
this.$emit("location", item);
|
this.$emit("location", item);
|
||||||
},
|
},
|
||||||
|
//上下事件
|
||||||
|
keyPress(e) {
|
||||||
|
switch (e.key) {
|
||||||
|
case "ArrowUp":
|
||||||
|
this.selectIndex = this.selectIndex == null ? this.list.length - 1 : this.selectIndex == 0 ? null : this.selectIndex - 1;
|
||||||
|
break;
|
||||||
|
case "ArrowDown":
|
||||||
|
this.selectIndex = this.selectIndex == null ? 0 : this.selectIndex == this.list.length - 1 ? null : this.selectIndex + 1;
|
||||||
|
break;
|
||||||
|
case "Enter":
|
||||||
|
if (this.selectIndex == null) {
|
||||||
|
this.targetUrl = "https://www.baidu.com/s?ie=UTF-8&wd=" + encodeURIComponent(this.value);
|
||||||
|
} else {
|
||||||
|
this.targetUrl = this.list[this.selectIndex].url;
|
||||||
|
}
|
||||||
|
let a = this.$refs["targetA"];
|
||||||
|
a.href = this.targetUrl;
|
||||||
|
a.click();
|
||||||
|
}
|
||||||
|
},
|
||||||
dealSearch(content) {
|
dealSearch(content) {
|
||||||
let res = [];
|
let res = [];
|
||||||
let arrs = Object.values(this.totalTreeData);
|
let arrs = Object.values(this.totalTreeData);
|
||||||
@ -137,7 +169,16 @@ export default {
|
|||||||
font-size: 0.16rem;
|
font-size: 0.16rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
height: 0.3rem;
|
height: 0.3rem;
|
||||||
|
line-height: 0.3rem;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
.listItemUrl {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.itemActive {
|
||||||
|
background-color: #f8f8f8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,9 +69,9 @@ export default {
|
|||||||
created() {
|
created() {
|
||||||
console.log(this.isAdd, this.targetNode);
|
console.log(this.isAdd, this.targetNode);
|
||||||
if (!this.isAdd) {
|
if (!this.isAdd) {
|
||||||
this.form.type = this.targetNode.type;
|
this.form.type = this.targetNode.type.toString();
|
||||||
this.form.name = this.targetNode.name;
|
this.form.name = this.targetNode.name;
|
||||||
this.form.url = this.form.type === "bookmark" ? this.targetNode.url : "";
|
this.form.url = this.form.type === "0" ? this.targetNode.url : "";
|
||||||
}
|
}
|
||||||
this.token = window.token;
|
this.token = window.token;
|
||||||
this.form.path = this.targetNode == null ? "" : this.targetNode.path + (this.isAdd ? "." + this.targetNode.bookmarkId : "");
|
this.form.path = this.targetNode == null ? "" : this.targetNode.path + (this.isAdd ? "." + this.targetNode.bookmarkId : "");
|
||||||
|
@ -20,3 +20,15 @@
|
|||||||
* content配置
|
* content配置
|
||||||
*/
|
*/
|
||||||
@contentbgcolor: rgb(255, 255, 255); //公共背景色
|
@contentbgcolor: rgb(255, 255, 255); //公共背景色
|
||||||
|
|
||||||
|
.treeNodeItem {
|
||||||
|
span {
|
||||||
|
span {
|
||||||
|
display: inline-block;
|
||||||
|
width: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -77,7 +77,12 @@ const actions = {
|
|||||||
if (!treeData[""]) {
|
if (!treeData[""]) {
|
||||||
treeData[""] = [];
|
treeData[""] = [];
|
||||||
}
|
}
|
||||||
treeData[""].forEach(item => (item.isLeaf = item.type === 0));
|
Object.values(treeData).forEach(item =>
|
||||||
|
item.forEach(item1 => {
|
||||||
|
item1.isLeaf = item.type === 0;
|
||||||
|
item1.class = "treeNodeItem";
|
||||||
|
})
|
||||||
|
);
|
||||||
context.commit(TOTAL_TREE_DATA, treeData);
|
context.commit(TOTAL_TREE_DATA, treeData);
|
||||||
await localforage.setItem(TOTAL_TREE_DATA, treeData);
|
await localforage.setItem(TOTAL_TREE_DATA, treeData);
|
||||||
let userInfo = await httpUtil.get("/user/currentUserInfo");
|
let userInfo = await httpUtil.get("/user/currentUserInfo");
|
||||||
@ -94,7 +99,6 @@ const actions = {
|
|||||||
await localforage.removeItem(VERSION);
|
await localforage.removeItem(VERSION);
|
||||||
},
|
},
|
||||||
async moveNode(context, info) {
|
async moveNode(context, info) {
|
||||||
debugger;
|
|
||||||
let data = context.state[TOTAL_TREE_DATA];
|
let data = context.state[TOTAL_TREE_DATA];
|
||||||
const target = info.node.dataRef;
|
const target = info.node.dataRef;
|
||||||
const current = info.dragNode.dataRef;
|
const current = info.dragNode.dataRef;
|
||||||
|
@ -56,6 +56,7 @@
|
|||||||
checkStrictly
|
checkStrictly
|
||||||
:draggable="!isPhone"
|
:draggable="!isPhone"
|
||||||
@drop="onDrop"
|
@drop="onDrop"
|
||||||
|
@rightClick="rightClick"
|
||||||
/>
|
/>
|
||||||
<!-- 新增、修改 -->
|
<!-- 新增、修改 -->
|
||||||
<a-modal v-model="addModal.show" :title="addModal.isAdd ? '新增' : '编辑'" :footer="null">
|
<a-modal v-model="addModal.show" :title="addModal.isAdd ? '新增' : '编辑'" :footer="null">
|
||||||
@ -151,6 +152,13 @@ export default {
|
|||||||
this.expandedKeys.pop();
|
this.expandedKeys.pop();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
rightClick({ node }) {
|
||||||
|
if (this.currentSelect === node.dataRef) {
|
||||||
|
this.currentSelect = null;
|
||||||
|
} else {
|
||||||
|
this.currentSelect = node.dataRef;
|
||||||
|
}
|
||||||
|
},
|
||||||
check(key, { checked, node }) {
|
check(key, { checked, node }) {
|
||||||
let item = node.dataRef;
|
let item = node.dataRef;
|
||||||
if (checked) {
|
if (checked) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user