|
@@ -0,0 +1,77 @@
|
|
|
+<template>
|
|
|
+ <div class="page-search-docs">
|
|
|
+ <history-list
|
|
|
+ v-show="type === 'history' && isLogin"
|
|
|
+ :list="docsSearchHistory"
|
|
|
+ @click="goPage"
|
|
|
+ @delete="deleteList"
|
|
|
+ ></history-list>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { HistoryList } from '@/ui'
|
|
|
+import { mapActions, mapGetters } from 'vuex'
|
|
|
+import { openLinkOfOther } from '@/utils'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'SearchMiddleDocs',
|
|
|
+ components: {
|
|
|
+ [HistoryList.name]: HistoryList
|
|
|
+ },
|
|
|
+ inject: {
|
|
|
+ topSearch: {
|
|
|
+ default: () => {}
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ cacheSearch: '',
|
|
|
+ type: 'history',
|
|
|
+ list: []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapGetters('user', ['isLogin']),
|
|
|
+ ...mapGetters('search', ['docsSearchHistory']),
|
|
|
+ getKeys() {
|
|
|
+ return this.topSearch.input.split(' ').filter((v) => v.trim())
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...mapActions('search', ['removeHistory', 'setHistory']),
|
|
|
+ clear() {
|
|
|
+ this.type = 'history'
|
|
|
+ this.cacheSearch = ''
|
|
|
+ this.list = []
|
|
|
+ },
|
|
|
+ deleteList() {
|
|
|
+ this.removeHistory({
|
|
|
+ type: 'docs'
|
|
|
+ })
|
|
|
+ },
|
|
|
+ submit() {
|
|
|
+ // 历史记录新增
|
|
|
+ this.setHistory({
|
|
|
+ type: 'docs',
|
|
|
+ item: {
|
|
|
+ label: this.topSearch.input
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (this.topSearch.input) {
|
|
|
+ return openLinkOfOther(`/page_docs_mobile/search?text=${this.topSearch.input}`)
|
|
|
+ } else {
|
|
|
+ return openLinkOfOther('/page_docs_mobile/home')
|
|
|
+ }
|
|
|
+ },
|
|
|
+ goPage(data) {
|
|
|
+ // 历史记录新增
|
|
|
+ this.setHistory({
|
|
|
+ type: 'docs',
|
|
|
+ item: data
|
|
|
+ })
|
|
|
+ openLinkOfOther(`/page_docs_mobile/search?text=${data.label}`)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|