Browse Source

完成搜索

jwyu 1 year ago
parent
commit
540bce622e

+ 1 - 1
.env.development

@@ -1,5 +1,5 @@
 # 接口地址
-VITE_APP_API_URL="http://8.136.199.33:8602/adminapi"
+VITE_APP_API_URL="http://8.136.199.33:8610/v1"
 # 路由根地址
 VITE_APP_BASE_URL="/"
 # 打包输入文件名

+ 3 - 0
src/api/common.js

@@ -4,6 +4,9 @@
 
 import {get,post} from './index'
 
+/**
+ * 获取oss临时签名
+ */
 export function apiGetOSSSign(){
     return get('/resource/oss/get_sts_token',{})
 }

+ 10 - 0
src/api/index.js

@@ -77,6 +77,16 @@ _axios.interceptors.response.use(
     return data;
   },
   function (error) {
+    //关闭loading
+    LOADINGCOUNT--;
+    if (LOADINGCOUNT === 0) {
+      // closeToast()
+      LOADING.close()
+    }
+    console.log(error);
+    setTimeout(() => {
+      showToast(error.message)
+    }, 300);
     // Do something with response error
     return Promise.reject(error);
   }

+ 13 - 1
src/api/ppt.js

@@ -1,5 +1,5 @@
 /**
- * 中文ppt模块
+ * 中文/英文ppt模块
  */
 
 import {get,post} from './index'
@@ -128,4 +128,16 @@ export function apiPPTList(params) {
     }else{
         return get('/pptv2/group/ppt/list',params)
     }
+}
+
+/**
+ * ppt搜索
+ * @param Keyword
+ */
+export function apiPPTSearch(params){
+    if(window.location.pathname.startsWith('/ppten')){
+        return get('/ppt_english/ppt/list',params)
+    }else{
+        return get('/pptv2/ppt/list',params)
+    }
 }

+ 6 - 0
src/assets/styles/common.scss

@@ -37,4 +37,10 @@ P{
 ::-webkit-scrollbar-thumb {
     background: #7a7a7a;
     border-radius: 5PX;
+}
+
+// vant搜索框样式
+.van-search__content{
+    border: 1px solid $border-color;
+    background: #ffff !important;
 }

+ 7 - 2
src/layouts/Index.vue

@@ -63,7 +63,12 @@ function handleLoginOut(){
                 </template>
             </van-popover>
         </div>
-        <router-view />
+        <router-view v-slot="{ Component }">
+            <keep-alive>
+                <component :is="Component" :key="$route.name" v-if="$route.meta.keepAlive" />
+            </keep-alive>
+            <component :is="Component" :key="$route.name" v-if="!$route.meta.keepAlive" />
+        </router-view>
     </div>
 </template>
 
@@ -90,7 +95,7 @@ function handleLoginOut(){
     display: none;
 }
 
-@media screen and (min-width:650px){
+@media screen and (min-width:$media-width){
     .pad-header-box{
         display: block;
         height: 60px;

+ 2 - 1
src/router/ppt.js

@@ -12,7 +12,8 @@ export const pptRoutes=[
         component: () => import("@/views/ppt/Index.vue"),
         meta: { 
             title: "智能PPT",
-            hasBackHome:true
+            hasBackHome:true,
+            keepAlive:true
         },
     },
     {

+ 2 - 1
src/router/pptEn.js

@@ -12,7 +12,8 @@
         component: () => import("@/views/ppt/Index.vue"),
         meta: { 
             title: "智能PPT",
-            hasBackHome:true
+            hasBackHome:true,
+            keepAlive:true
         },
     },
     {

+ 1 - 1
src/views/Login.vue

@@ -120,7 +120,7 @@ const onSubmit = (values) => {
     display: none;
 }
 
-@media screen and (min-width:650px) {
+@media screen and (min-width:$media-width) {
     .login-page{
         margin-top: auto;
         padding: 30px;

+ 1 - 1
src/views/ppt/Index.vue

@@ -21,7 +21,7 @@ import PadPPTIndexWrap from './components/PadPPTIndexWrap.vue'
 .ppt-index-page_pad{
     display: none;
 }
-@media screen and (min-width:650px){
+@media screen and (min-width:$media-width){
     .ppt-index-page_mobile{
         display: none;
     }

+ 54 - 3
src/views/ppt/Search.vue

@@ -1,8 +1,53 @@
 <script setup>
 import {ref} from 'vue'
+import {apiPPTSearch} from '@/api/ppt'
+import { showToast } from 'vant'
+import { useRouter } from 'vue-router'
+
+const router=useRouter()
 
 const searchVal=ref('')
 
+let list=ref([])
+let finished=ref(false)
+async function handleSearch(){
+    finished.value=false
+    const res=await apiPPTSearch({
+        Keyword:searchVal.value
+    })
+    if(res.Ret===200){
+        list.value=res.Data.List||[]
+        finished.value=true
+    }
+}
+
+function onSearch(){
+    if(!searchVal.value){
+        showToast('请输入关键词')
+        return
+    }
+    handleSearch()
+}
+
+function goDetail(item){
+    if(window.location.pathname.startsWith('/ppten')){
+            router.push({
+                path:"/ppten/detail",
+                query:{
+                    id:item.PptId
+                }
+            })
+    }else{
+            router.push({
+                path:"/ppt/detail",
+                query:{
+                    id:item.PptId
+                }
+            })
+    }
+}
+
+
 </script>
 
 <template>
@@ -12,12 +57,14 @@ const searchVal=ref('')
                 v-model="searchVal"
                 shape="round"  
                 placeholder="请输入搜索关键词"
+                @search="onSearch"
             />
         </div>
+        <van-empty image="search" description="试试别的关键词吧~" v-if="list.length==0&&finished"/>
         <ul class="list-wrap">
-            <li class="item">
-                <div class="title">名称</div>
-                <div class="time">ccw 2023-01-16创建</div>
+            <li class="item" v-for="item in list" :key="item.PptId" @click="goDetail(item)">
+                <div class="title" v-html="item.Title"></div>
+                <div class="time">{{item.AdminRealName}} {{item.PptCreateTime.split(' ')[0]}}创建</div>
             </li>
         </ul>
     </div>
@@ -35,9 +82,13 @@ const searchVal=ref('')
     .item{
         padding: 30px 0 20px 0;
         border-bottom: 1px solid $border-color;
+        :deep(.color-light){
+            color: $theme-color;
+        }
         .time{
             color: $font-grey_999;
             margin-top: 10px;
+            font-size: 24px;
         }
     }
 }

+ 2 - 1
src/views/ppt/components/ChartWrap.vue

@@ -30,7 +30,8 @@ async function getChartInfo(){
             lang='en'
         }
         let showChartTitle=false
-        if((res.Data.ChartInfo.Source==1&&[2,7,10].includes(res.Data.ChartInfo.ChartType))||(res.Data.ChartInfo.Source==2&&res.Data.ChartInfo.ChartType==8)){
+        const {Source,ChartType}=res.Data.ChartInfo
+        if((Source==1&&[2,7,10].includes(ChartType))||(Source==2&&ChartType==8)){
             showChartTitle=true
         }
         chartRender({

+ 1 - 1
src/views/ppt/components/PadPPTIndexWrap.vue

@@ -258,7 +258,7 @@ function goMobileSearch(){
 .van-collapse-item__title--expanded:after{
     display: none;
 }
-@media screen and (min-width:650px){
+@media screen and (min-width:$media-width){
     .pad-classify-file-opt-box{
         border: 1px solid $border-color;
         padding: 10px 0;

+ 1 - 1
src/views/tabbar/Home.vue

@@ -52,7 +52,7 @@ function goNext(path){
     }
 }
 
-@media screen and (min-width:650px){
+@media screen and (min-width:$media-width){
     .home-page{
         padding: 30px 34px;
         .list{

+ 1 - 1
src/views/tabbar/Index.vue

@@ -44,7 +44,7 @@ const active = ref('home');
 </template>
 
 <style lang="scss" scoped>
-@media screen and (min-width:650px){
+@media screen and (min-width:$media-width){
     .tabbar-box{
         display: none;
     }

+ 0 - 1
vite.config.js

@@ -14,7 +14,6 @@ export default ({ mode }) =>
         resolvers: [VantResolver()],
       }),
     ],
-    // 本文相关配置
     css: {
       // css预处理器
       preprocessorOptions: {