CzRger 7 månader sedan
förälder
incheckning
9954fd0d6d
3 ändrade filer med 19 tillägg och 8 borttagningar
  1. 7 0
      src/api/modules/web/list.ts
  2. 3 2
      src/router/index.ts
  3. 9 6
      src/views/web/home/index.vue

+ 7 - 0
src/api/modules/web/list.ts

@@ -14,3 +14,10 @@ export const frontGetIndexAndFieldInfo = (params: any) => handle({
   method: 'get',
   params
 })
+
+// 搜索记录
+export const searchLogsGetKeyWordByUserId = (params: any) => handle({
+  url: `/${suffix}/search-logs/getKeyWordByUserId`,
+  method: 'get',
+  params
+})

+ 3 - 2
src/router/index.ts

@@ -47,7 +47,8 @@ router.beforeEach((to, from , next) => {
     }
 })
 let userInfo = {
-    isAdmin: true
+    isAdmin: true,
+    id: 1
 }
 let themeConfig = null
 export const initMainRouter = async () => {
@@ -80,7 +81,7 @@ export const initMainRouter = async () => {
             subTitle: 'HAI NAN SHE GUAN ZHI HUI SOU SUO PING TAI',
             // titleLogo: 'https://element-plus.org/images/element-plus-logo.svg',
             // webBgImg: 'https://element-plus.org/images/element-plus-logo.svg',
-            loginImg: 'https://element-plus.org/images/element-plus-logo.svg',
+            // loginImg: 'https://element-plus.org/images/element-plus-logo.svg',
         }
         initRootVar(themeConfig)
     } else if (location.pathname !== '/login') {

+ 9 - 6
src/views/web/home/index.vue

@@ -40,7 +40,7 @@
       <div class="label">搜索记录</div>
       <div class="result">
         <template v-for="(item, index) in state.historyList">
-          <span class="__hover" @click="toList(item, true)">{{index + 1}}.{{item}}</span>
+          <span class="__hover" @click="toList(item.keyword, true)">{{index + 1}}.{{item.keyword}}</span>
         </template>
       </div>
     </div>
@@ -74,10 +74,12 @@
 import {computed, getCurrentInstance, onMounted, reactive} from "vue";
 import router from "@/router";
 import {ElMessage} from "element-plus";
-import {useThemeStore, useWebStore} from "@/stores";
+import {useAppStore, useThemeStore, useWebStore} from "@/stores";
 import {mockGetSearchHistory} from "@/api/modules/mock/mock";
+import {searchLogsGetKeyWordByUserId} from "@/api/modules/web/list";
 
 const {proxy} = getCurrentInstance()
+const AppStore = useAppStore()
 const WebStore = useWebStore()
 const ThemeStore = useThemeStore()
 const state: any = reactive({
@@ -119,7 +121,10 @@ const noAreaCpt = computed(() => {
   return !(state.areaList.length > 0)
 })
 const initHistory = () => {
-  mockGetSearchHistory().then(res => {
+  searchLogsGetKeyWordByUserId(proxy.$util.formatGetParam({
+    userId: AppStore.userInfo?.id,
+    size: 10
+  })).then(res => {
     state.historyList = res.data
   })
 }
@@ -136,8 +141,6 @@ const onIndexTabAll = () => {
   })
 }
 const toList = (text, isAll = false) => {
-  console.log(searchAreaCpt.value.arr)
-
   if (text) {
     const routerUrl = router.resolve({
       name: '4f6dd2ea-7c0a-4923-9a57-932ef42235f6',
@@ -156,7 +159,7 @@ const toList = (text, isAll = false) => {
   }
 }
 onMounted(() => {
-  // initHistory()
+  initHistory()
   initArea()
 })
 </script>