Explorar el Código

dev正常,ssr数据同步异常

13127578837 hace 1 año
padre
commit
269571a832

+ 3 - 4
index.html

@@ -3,11 +3,10 @@
 
 <head>
     <meta charset="UTF-8" />
-    <link rel="icon" type="image/svg+xml" href="/vite.svg" />
-    <title>永天官网</title>
+    <link rel="icon" type="image/svg+xml" href="/favicon.ico" />
+    <title></title>
     <meta name="keywords" content="">
     <meta name="description" content="">
-    <link rel="icon" href="assets/img/favicon.ico">
     <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
     <!--preload-links-->
 </head>
@@ -15,7 +14,7 @@
     <div id="app" style="width:100%;padding:0;margin:0"><!--ssr-outlet--></div>
     <script type="module" src="/src/entry-client.ts"></script>
     <script>
-        // window.__INITIAL_STATE__ = '<!--vuex-state-->' 
+        window.__INITIAL_STATE__ = '<!--vuex-state-->' 
     </script>
 </body>
 

+ 19 - 17
package-lock.json

@@ -14,8 +14,8 @@
                 "vue": "^3.4.19",
                 "vue-i18n": "^9.9.0",
                 "vue-router": "^4.0.13",
-                "vuex": "^4.0.2",
-                "vuex-router-sync": "^5.0.0"
+                "vue3-lazy": "^1.0.0-alpha.1",
+                "vuex": "^4.0.2"
             },
             "devDependencies": {
                 "@typescript-eslint/eslint-plugin": "^6.21.0",
@@ -5080,6 +5080,17 @@
                 "typescript": "*"
             }
         },
+        "node_modules/vue3-lazy": {
+            "version": "1.0.0-alpha.1",
+            "resolved": "https://registry.npmmirror.com/vue3-lazy/-/vue3-lazy-1.0.0-alpha.1.tgz",
+            "integrity": "sha512-dpjpKK4DC5q+wZVtS/VY3X6pYBJHxRmYanr20s39RB6o6fvbneQ/DNuz37bipYfEdrEvbSZ95Y2SCexuznQNrQ==",
+            "engines": {
+                "node": ">=6.0.0"
+            },
+            "peerDependencies": {
+                "vue": "^3.0.0-alpha.9"
+            }
+        },
         "node_modules/vuex": {
             "version": "4.0.2",
             "resolved": "https://registry.npmmirror.com/vuex/-/vuex-4.0.2.tgz",
@@ -5091,15 +5102,6 @@
                 "vue": "^3.0.2"
             }
         },
-        "node_modules/vuex-router-sync": {
-            "version": "5.0.0",
-            "resolved": "https://registry.npmmirror.com/vuex-router-sync/-/vuex-router-sync-5.0.0.tgz",
-            "integrity": "sha512-Mry2sO4kiAG64714X1CFpTA/shUH1DmkZ26DFDtwoM/yyx6OtMrc+MxrU+7vvbNLO9LSpgwkiJ8W+rlmRtsM+w==",
-            "peerDependencies": {
-                "vue-router": "^3.0.0",
-                "vuex": "^3.0.0"
-            }
-        },
         "node_modules/webpack-sources": {
             "version": "3.2.3",
             "resolved": "https://registry.npmmirror.com/webpack-sources/-/webpack-sources-3.2.3.tgz",
@@ -8983,6 +8985,12 @@
                 "semver": "^7.5.4"
             }
         },
+        "vue3-lazy": {
+            "version": "1.0.0-alpha.1",
+            "resolved": "https://registry.npmmirror.com/vue3-lazy/-/vue3-lazy-1.0.0-alpha.1.tgz",
+            "integrity": "sha512-dpjpKK4DC5q+wZVtS/VY3X6pYBJHxRmYanr20s39RB6o6fvbneQ/DNuz37bipYfEdrEvbSZ95Y2SCexuznQNrQ==",
+            "requires": {}
+        },
         "vuex": {
             "version": "4.0.2",
             "resolved": "https://registry.npmmirror.com/vuex/-/vuex-4.0.2.tgz",
@@ -8991,12 +8999,6 @@
                 "@vue/devtools-api": "^6.0.0-beta.11"
             }
         },
-        "vuex-router-sync": {
-            "version": "5.0.0",
-            "resolved": "https://registry.npmmirror.com/vuex-router-sync/-/vuex-router-sync-5.0.0.tgz",
-            "integrity": "sha512-Mry2sO4kiAG64714X1CFpTA/shUH1DmkZ26DFDtwoM/yyx6OtMrc+MxrU+7vvbNLO9LSpgwkiJ8W+rlmRtsM+w==",
-            "requires": {}
-        },
         "webpack-sources": {
             "version": "3.2.3",
             "resolved": "https://registry.npmmirror.com/webpack-sources/-/webpack-sources-3.2.3.tgz",

+ 2 - 2
package.json

@@ -20,8 +20,8 @@
         "vue": "^3.4.19",
         "vue-i18n": "^9.9.0",
         "vue-router": "^4.0.13",
-        "vuex": "^4.0.2",
-        "vuex-router-sync": "^5.0.0"
+        "vue3-lazy": "^1.0.0-alpha.1",
+        "vuex": "^4.0.2"
     },
     "devDependencies": {
         "@typescript-eslint/eslint-plugin": "^6.21.0",

BIN
public/error.gif


BIN
public/error.png


+ 0 - 0
src/assets/img/favicon.ico → public/favicon.ico


BIN
public/loading.gif


+ 0 - 1
public/vite.svg

@@ -1 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>

+ 6 - 2
src/App.vue

@@ -3,10 +3,14 @@ import headerCommon  from '@/components/layout/header.vue'
 import footerCommon  from '@/components/layout/footer.vue'
 import feedFix from '@/components/layout/feedFix.vue'
 // import dialogCom from '@/components/layout/dialogCom.vue'
+// globalThis.scrollTo({
+//     top: globalThis.innerHeight,
+//     behavior: "smooth"
+// })
 </script>
-<template>
+<template >
   <headerCommon />
-  <router-view />
+  <router-view  />
   <feedFix />
   <footerCommon />
 </template>

+ 1 - 1
src/assets/styles/common/style.css

@@ -4143,7 +4143,7 @@
                 background-repeat: no-repeat;
                 background-size: cover;
                 background: #ccc;
-                height: 600px
+                height: 600px;
             }
             
             @media (max-width: 1200px) {

+ 13 - 13
src/components/layout/banner.vue

@@ -3,31 +3,31 @@ import { ref, watch } from 'vue'
 import { useStore  } from 'vuex'
 import poster from '@/assets/img/banner/poster.jpg'
 const store = useStore()
-const modelType  =ref()
-const columnImage  =ref()
+const modelType = ref(1)
+const columnImage  = ref("")
 const posterImg = ref(poster)//视频封面图
+console.log(222,store.state)
 watch(
-    () => store.state.menuList,
+    () => store.state.currentPagePath || store.state.sub || !store.state.currentPagePath && !store.state.sub || store.state.recomMendation,
     () => {
-        setTimeout(()=>{
-            modelType.value = store.state.menuList[store.state.sub]?.modelType //图片或视频类型
-            columnImage.value =store.state.menuList[store.state.sub]?.imagePath//图片或视频地址
-        },300)
+        console.log(3333333,store.state)
+        modelType.value = store.state.menuList[store.state.sub]?.modelType //图片或视频类型
+        columnImage.value =store.state.menuList[store.state.sub]?.imagePath//图片或视频地址
+        console.log(modelType.value)
     },
-    { deep: true, immediate: true }
+    { deep:true }
 );
-
 </script>
 <template>
-        <div v-if="modelType==1"
-            style="width:100%;height:100%;background-size:cover;background-position:center center;background-repeat:no-repeat;"
-            v-bind:style="{backgroundImage:'url('+columnImage+')'}">
+        <div v-if="modelType==1" style="width:100%;height:100%;background-size:cover;background-position:center center;background-repeat:no-repeat; "
+        :style="{backgroundImage:`url(${columnImage})`}">
         </div>
 
-        <video webkit-playsinline="webkit-playsinline" playsinline v-else id="videoPlay" autoplay loop muted preload="auto" :poster="posterImg"
+        <video v-if="modelType ==2" webkit-playsinline="webkit-playsinline" playsinline  id="videoPlay" autoplay loop muted preload="auto" :poster="posterImg"
             style="width:100%;height:100%;object-fit:fill;" :src="columnImage">
             <source type="video/mp4">
         </video>
+    
 </template>
 <style lang="scss">
 .common-bradcrumb-section{

+ 23 - 306
src/components/layout/feedFix.vue

@@ -1,314 +1,31 @@
 <script setup lang="ts">
-import { useStore  } from 'vuex'
-// import $ from 'jquery'
-// $(window).on('scroll', function() {
-//     // Sticky Header
-//     var scroll = $(window).scrollTop();
-//     if (scroll < 110) {
-//         $('header.sticky-header').removeClass('sticky');
-//     } else {
-//         $('header.sticky-header').addClass('sticky');
-//     }
-
-//     //返回顶部按钮的显示与隐藏
-//     if (scroll > 700){
-//         $('#scroll-up').css({'visibility': 'visible','opacity':'1'});
-//     }else{
-//         $('#scroll-up').css({'visibility': 'hidden','opacity':'0'});
-//     }
-// })
+import { watch } from 'vue'
+// console.log(process.env.NODE_ENV)
+// // (客户端)监听返回顶部状态
+// if(process.env.NODE_ENV == "development"){
+//     globalThis.addEventListener('scroll', function() {
+//         var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
+//         var element:any = document.getElementById("scroll-up")
+//         if(scrollTop > 770){
+//             element.style.opacity = 1
+//         }else{
+//             element.style.opacity = 0
+//         }
+//     });
+// }
 //返回顶部
 function scrollToTop() {
-    globalThis.scrollTo({
-        top: 0,
-        behavior: "smooth"
-    })
+    // globalThis.scrollTo({
+    //     top: 0,
+    //     behavior: "smooth"
+    // })
 }
-const store = useStore()
-// if(process.env.NODE_ENV == "development"){
-//     setTimeout(()=>{
-//     let seoTitle = store.state.menuList[store.state.sub]
-//     $('title').text(seoTitle?.categoryName);
-//     $('meta[name="description"]').attr('content', seoTitle?.metadescription);
-//     $('meta[name="keywords"]').attr('content', seoTitle?.metakeywords);
-// },500)
-
-// //视频上拉操作
-// $('.go_down').click(function () {
-//     $('html,body').animate({
-//         scrollTop: $(window).height()
-//     }, 700);
-// });
-// //移动端菜单操作
-// $.fn.meanmenu = function(e) {
-// var n = {
-//     meanMenuTarget: $(this),
-//     meanMenuContainer: 'body',
-//     meanMenuClose: '<span ></span ><span ></span ><span ></span >',
-//     meanMenuCloseSize: '18px',
-//     meanMenuOpen: '<span ></span ><span ></span ><span ></span >',
-//     meanRevealPosition: 'right',
-//     meanRevealPositionDistance: '0',
-//     meanRevealColour: '',
-//     meanScreenWidth: '480',
-//     meanNavPush: '',
-//     meanShowChildren: !0,
-//     meanExpandableChildren: !0,
-//     meanExpand: '+',
-//     meanContract: '-',
-//     meanRemoveAttrs: !1,
-//     onePage: !1,
-//     meanDisplay: 'block',
-//     removeElements: '',
-// };
-// e = $.extend(n, e);
-// var a = window.innerWidth || document.documentElement.clientWidth;
-// return this.each(function() {
-//     var n = e.meanMenuTarget,
-//         t = e.meanMenuContainer,
-//         r = e.meanMenuClose,
-//         i = e.meanMenuCloseSize,
-//         s = e.meanMenuOpen,
-//         u = e.meanRevealPosition,
-//         m = e.meanRevealPositionDistance,
-//         l = e.meanRevealColour,
-//         o = e.meanScreenWidth,
-//         c = e.meanNavPush,
-//         v = '.meanmenu-reveal',
-//         h = e.meanShowChildren,
-//         d = e.meanExpandableChildren,
-//         y = e.meanExpand,
-//         j = e.meanContract,
-//         Q = e.meanRemoveAttrs,
-//         f = e.onePage,
-//         g = e.meanDisplay,
-//         p = e.removeElements,
-//         C = !1;
-//     (navigator.userAgent.match(/iPhone/i) ||
-//         navigator.userAgent.match(/iPod/i) ||
-//         navigator.userAgent.match(/iPad/i) ||
-//         navigator.userAgent.match(/Android/i) ||
-//         navigator.userAgent.match(/Blackberry/i) ||
-//         navigator.userAgent.match(/windows Phone/i)) &&
-//     (C = !0),
-//     (navigator.userAgent.match(/MSIE 8/i) ||
-//         navigator.userAgent.match(/MSIE 7/i)) &&
-//     $('html').css('overflow-y', 'scroll');
-//     var w = '',
-//         x = function() {
-//             if ('center' === u) {
-//                 var e =
-//                     window.innerWidth ||
-//                     document.documentElement.clientWidth,
-//                     n = e / 2 - 22 + 'px';
-//                 (w = 'left:' + n + ';right:auto;'),
-//                 C
-//                     ?
-//                     $('.meanmenu-reveal').animate({
-//                         left: n,
-//                     }) :
-//                     $('.meanmenu-reveal').css('left', n);
-//             }
-//         },
-//         A = !1,
-//         E = !1;
-//     'right' === u && (w = 'right:' + m + ';left:auto;'),
-//         'left' === u && (w = 'left:' + m + ';right:auto;'),
-//         x();
-//     var M = '',
-//         W = function() {
-//             $('.mean-bar,.mean-push').remove(),
-//                 $(t).removeClass('mean-container'),
-//                 $(n).css('display', g),
-//                 (A = !1),
-//                 (E = !1),
-//                 $(p).removeClass('mean-remove');
-//         },
-//         b = function() {
-            
-//                 var e = 'background:' + l + ';color:' + l + ';' + w;
-//             if (o >= a) {
-//                 $(p).addClass('mean-remove'),
-//                     (E = !0),
-//                     $(t).addClass('mean-container'),
-//                     $('.mean-container').prepend(
-//                         '<div class="mean-bar"><a href="#nav" class="meanmenu-reveal" style="' +
-//                         e +
-//                         '">Show Navigation</a><nav class="mean-nav"></nav></div>'
-//                     );
-// $(v).html(s),
-
-//                     setTimeout(function(){
-//                 var r = $(n).html();
-//                 $('.mean-nav').html(r),
-//                     Q &&
-//                     $(
-//                         'nav.mean-nav ul, nav.mean-nav ul *'
-//                     ).each(function() {
-//                         $(this).is('.mean-remove') ?
-//                             $(this).attr(
-//                                 'class',
-//                                 'mean-remove'
-//                             ) :
-//                             $(this).removeAttr('class'),
-//                             $(this).removeAttr('id');
-//                     }),
-//                     $(n).before('<div class="mean-push" />'),
-//                     $('.mean-push').css('margin-top', c),
-//                     $(n).hide(),
-//                     $('.meanmenu-reveal').show(),
-                    
-//                     (M = $(v)),
-//                     $('.mean-nav ul').hide(),
-//                     h ?
-//                     d ?
-//                     ($('.mean-nav ul ul').each(
-//                             function() {
-//                                 $(this).children()
-//                                     .length &&
-//                                     $(this, 'li:first')
-//                                     .parent()
-//                                     .append(
-//                                         '<a class="mean-expand" href="#" style="font-size: ' +
-//                                         i +
-//                                         '">' +
-//                                         y +
-//                                         '</a>'
-//                                     );
-//                             }
-//                         ),
-//                         $('.mean-expand').on(
-//                             'click',
-//                             function(e) {
-//                                 e.preventDefault(),
-//                                     $(this).hasClass(
-//                                         'mean-clicked'
-//                                     ) ?
-//                                     ($(this).text(y),
-//                                         $(this)
-//                                         .prev('ul')
-//                                         .slideUp(
-//                                             300,
-//                                             function() {}
-//                                         )) :
-//                                     ($(this).text(j),
-//                                         $(this)
-//                                         .prev('ul')
-//                                         .slideDown(
-//                                             300,
-//                                             function() {}
-//                                         )),
-//                                     $(this).toggleClass(
-//                                         'mean-clicked'
-//                                     );
-//                             }
-//                         )) :
-//                     $('.mean-nav ul ul').show() :
-//                     $('.mean-nav ul ul').hide(),
-//                     $('.mean-nav ul li')
-//                     .last()
-//                     .addClass('mean-last'),
-//                     M.removeClass('meanclose'),
-//                     $(M).on('click',function(e) {
-//                         e.preventDefault(),
-//                             A === !1 ?
-//                             (M.css('text-align', 'center'),
-//                                 M.css('text-indent', '0'),
-//                                 M.css('font-size', i),
-//                                 $(
-//                                     '.mean-nav ul:first'
-//                                 ).slideDown(),
-//                                 (A = !0)) :
-//                             ($(
-//                                     '.mean-nav ul:first'
-//                                 ).slideUp(),
-//                                 (A = !1)),
-//                             M.toggleClass('meanclose'),
-//                             $(p).addClass('mean-remove');
-//                     }),
-//                     f &&
-//                     $('.mean-nav ul > li > a:first-child').on(
-//                         'click',
-//                         function() {
-//                             $('.mean-nav ul:first').slideUp(),
-//                                 (A = !1),
-//                                 $(M)
-//                                 .toggleClass('meanclose')
-//                                 .html(s);
-//                         }
-//                     );
-
 
-//                     },300)
-                
-                
-//             } else W();
-
-            
-            
-//         };
-//     C ||
-//         $(window).resize(function() {
-//             (a =
-//                 window.innerWidth ||
-//                 document.documentElement.clientWidth),
-//             a > o,
-//                 W(),
-//                 o >= a ? (b(), x()) : W();
-//         }),
-//         $(window).resize(function() {
-//             (a =
-//                 window.innerWidth ||
-//                 document.documentElement.clientWidth),
-//             C
-//                 ?
-//                 (x(), o >= a ? E === !1 && b() : W()) :
-//                 (W(), o >= a && (b(), x()));
-//         }),
-//         b();
-// });
-// };
-// var onitirDoc = {
-//     init: function() {
-//         this.mobileMenu();
-//         this.productGird();
-//     },
-
-//     // Mobile Menu
-//     mobileMenu: function() {
-//         $('.mainmenu-area .main-menu .menu-items').meanmenu({
-//             meanMenuContainer: '.mobile-menu',
-//             meanScreenWidth: '991',
-//             meanRevealPosition: 'right',
-//         });
-//     },
-
-//     // Porduct Grid
-//     productGird: function() {
-//         var grid = $('.grid-isotope');
-//         if (!grid.length) {
-//             return;
-//         }
-
-//         grid.isotope();
-
-//         $('.grid-filter ul').on('click', 'li', function() {
-//             var filterValue = $(this).attr('data-filter');
-//             grid.isotope({ filter: filterValue });
-//         });
-
-//         $('.grid-filter ul li').on('click', function(event) {
-//             $(this).siblings('.active').removeClass('active');
-//             $(this).addClass('active');
-//             event.preventDefault();
-//         });
+// watch(()=>store.state.scrollUp.scrollTo,
+//     ()=>{
+        
 //     }
-// };
-// $(document).ready(function() {
-//         onitirDoc.init();
-// })
-// }
-
+// )
 </script>
 <template>
 <div class="feedBackBox">
@@ -342,7 +59,7 @@ const store = useStore()
             <img src="@/assets/img/qr_codeF1.png" alt="">
         </div>
     </div>
-    <div @click="scrollToTop" id="scroll-up" style="opacity:1">
+    <div @click="scrollToTop" id="scroll-up" style="opacity:0">
         <img src="@/assets/img/home/f_top.png" alt="">
     </div>
 </div>

+ 11 - 4
src/components/layout/footer.vue

@@ -1,10 +1,15 @@
 <script setup lang="ts">
-import { useStore  } from 'vuex'
+import { ref } from 'vue'
+import { useStore } from 'vuex'
 const store = useStore()
+const status = ref(false)
+setTimeout(()=>{
+    status.value = true
+},200)
 </script>
 <template>
-    <footer>
-        <div class="footer-widget-area">
+    <footer v-if="status">
+        <div class="footer-widget-area" style="position: relative;clear: both;">
             <div class="container">
                 <div class="row footerOne">
                     <div class="col-lg-2 col-md-6 col-sm-6 footerWidth">
@@ -54,5 +59,7 @@ const store = useStore()
     </footer>
 </template>
 <style lang="scss" scoped>
-
+.a{
+    clear: both;
+}
 </style>

+ 16 - 2
src/components/layout/header.vue

@@ -5,19 +5,33 @@ import { useRoute } from "vue-router"
 const store = useStore()
 const route = useRoute()
 const currentPagePath = ref(route.path)//当前页面路径
+if(route.path.indexOf("_")){
+    currentPagePath.value = route.path.split("_")[0]
+}
 const pathTemplateQuery = ref()//页面模版复用参数
 if(route.query && route.query.dup){
     pathTemplateQuery.value = route.query.dup
 }
 //获取菜单列表
-store.dispatch('getMenuList')
+store.dispatch('getMenuList').then(()=>{
+    let data = store.state.menuList
+    for(let i=0;i<data.length;i++){
+        if(!data[i].sname && data[i].path == route.path){
+            console.log(data[i])
+            // document.getElementsByName('keywords')[0].content = data[i].metakeywords
+            // document.getElementsByName('description')[0].content = data[i].metadescription
+            // document.getElementsByTagName("title")[0].innerHTML = data[i].categoryName
+        }
+    }
+ 
+})
 </script>
 <template>
         <header class="header-absolute sticky-header">
             <div class="custom-container-one">
                 <div class="mainmenu-area  d-flex align-items-center justify-content-center">
                     <div class="logo">
-                        <a href="/"><img src="@/assets/img/logo-white.png" alt="uskylogo"></a>
+                        <a href="/index"><img src="@/assets/img/logo-white.png" alt="uskylogo"></a>
                     </div>
                     <div class="d-flex align-items-center ">
                         <nav class="main-menu">

+ 4 - 3
src/entry-client.ts

@@ -1,8 +1,8 @@
 import { createApp } from './main'
 const { app, router, store } = createApp()
-// if(window.__INITIAL_STATE__){
-//     store.replaceState(window.__INITIAL_STATE__)
-// }
+if(window.__INITIAL_STATE__){
+    store.replaceState(window.__INITIAL_STATE__)
+}
 // router.beforeEach((to,from,next)=>{
 //     const uskyDb = new indexedDb("uskyDb") //创建或连接DB数据库
 //     uskyDb.openStore("menu","id",['list']).then((res:any)=>{
@@ -13,6 +13,7 @@ router.isReady().then(() => {
     //比较to、from不同时执行数据预取
     router.beforeResolve((to,from,next)=>{
         console.log("跳转")
+
         let toComponent = router.resolve(to).matched.flatMap(record=>Object.values(record.components))
         let fromComponent = router.resolve(from).matched.flatMap(record=>Object.values(record.components))
         let actived = toComponent.filter((c,i)=>{

+ 5 - 0
src/main.ts

@@ -5,6 +5,7 @@ import { createSSRRouter } from './router'
 import ElementPlus from 'element-plus'
 import 'element-plus/dist/index.css'
 import { store } from './store'
+import lazyPlugin from 'vue3-lazy'
 // import { scrollToTop } from './assets/js/common.js'
 // import { sync } from 'vuex-router-sync'
 const router = createSSRRouter()
@@ -17,5 +18,9 @@ export function createApp() {
     app.use(router)
     app.use(store)
     app.use(ElementPlus)
+    app.use(lazyPlugin, {
+        loading: 'loading.gif',
+        error: 'error.png',
+    })
     return { app, router , store}
 }

+ 10 - 29
src/router/index.ts

@@ -1,4 +1,5 @@
 const index = () => import('@/views/index/index.vue')
+// const index2 = () => import('@/views/index/index.vue')
 const cases = () => import('@/views/cases/index.vue')
 const cases_Read = () => import('@/views/cases/read.vue')
 const services = () => import('@/views/services/index.vue')
@@ -9,32 +10,21 @@ const about = () => import('@/views/about/index.vue')
 import { createRouter, createMemoryHistory, createWebHistory } from 'vue-router'
 
 const routes = [
-    
     {
         path: "/index",
         name: "首页",
         component: index,
-        redirect:"/",
         meta: {
-            title: "",
+            title: "首页",
             keepAlive: false
         }
     },
-    // {
-    //     path: "",
-    //     name: "首页",
-    //     component: index,
-    //     meta: {
-    //         title: "",
-    //         keepAlive: false
-    //     }
-    // },
     {
         path: "/cases",
         name: "客户案例",
         component: cases,
         meta: {
-            title: "",
+            title: "客户案例",
             keepAlive: false
         }
     },
@@ -43,7 +33,7 @@ const routes = [
         name: "案例详情页",
         component: cases_Read,
         meta: {
-            title: "",
+            title: "案例详情页",
             keepAlive: false
         }
     },
@@ -54,7 +44,7 @@ const routes = [
         name: "产品服务",
         component: services,
         meta: {
-            title: "",
+            title: "产品服务",
             keepAlive: false
         }
     },
@@ -63,7 +53,7 @@ const routes = [
         name: "产品详情页",
         component: services_Read,
         meta: {
-            title: "",
+            title: "产品详情页",
             keepAlive: false
         }
     },
@@ -73,7 +63,7 @@ const routes = [
         name: "新闻动态",
         component: news,
         meta: {
-            title: "",
+            title: "新闻动态",
             keepAlive: false
         }
     },
@@ -82,7 +72,7 @@ const routes = [
         name: "新闻详情",
         component: news_Read,
         meta: {
-            title: "",
+            title: "新闻详情",
             keepAlive: false
         }
     },
@@ -91,19 +81,10 @@ const routes = [
         name: "关于永天",
         component: about,
         meta: {
-            title: "",
-            keepAlive: false
-        }
-    },
-    {
-        path: "/cases",
-        name: "客户案例",
-        component: cases,
-        meta: {
-            title: "",
+            title: "关于永天",
             keepAlive: false
         }
-    },
+    }
 
 ]
 

+ 6 - 1
src/store/index.ts

@@ -14,6 +14,11 @@ export const store = createStore({
         currentPagePath:'',//当前页名称
         acitveId:0,//客户案例类型切换活动id
         sub:0,//当前页下标
+        scrollUp:{ //返回顶部
+            opacity:0,
+            visibility:"hidden",
+            scrollTo:0
+        },
         //分页数据
         pagination:{
             total:0,
@@ -123,7 +128,7 @@ export const store = createStore({
          * @param data.sub 页面下标
          * @returns 
          */
-        getPageData({ commit },data:any){
+        getPageData({ commit }:any,data:any){
             return new Promise(resolve=>{
                 //当前页
                 if(data.index || data.sub){

+ 5 - 5
src/style.css

@@ -24,8 +24,8 @@ a:hover {
 
 body {
   margin: 0;
-  display: flex;
-  place-items: center;
+  /* display: flex;
+  place-items: center; */
   min-width: 320px;
   min-height: 100vh;
 }
@@ -59,10 +59,10 @@ button:focus-visible {
 }
 
 #app {
-  max-width: 1280px;
+  /* max-width: 1280px; */
   margin: 0 auto;
-  padding: 2rem;
-  text-align: center;
+  /* padding: 2rem; */
+  /* text-align: center; */
 }
 
 @media (prefers-color-scheme: light) {

+ 4 - 4
src/views/about/index.vue

@@ -84,10 +84,10 @@ import pagination from '@/components/layout/pagination.vue'
         paramsData.value.params.pageNum = val
         store.dispatch('getPageData',paramsData.value).then(()=>{
             articalArray.value = store.state.pageContent
-            globalThis.scrollTo({
-                top: 0,
-                behavior: "smooth"
-            })
+            // globalThis.scrollTo({
+            //     top: 0,
+            //     behavior: "smooth"
+            // })
         })
     }
     onMounted(() => {

+ 105 - 99
src/views/cases/index.vue

@@ -1,130 +1,136 @@
 <script setup lang="ts">
-import { ref, onMounted } from 'vue'
-import { useStore  } from 'vuex'
+import { ref, watch } from 'vue'
+import { useStore } from 'vuex'
 import { useRouter, useRoute } from "vue-router";
 import banner from '@/components/layout/banner.vue'
-    const store = useStore()
-    const router = useRouter()
-    const route = useRoute()
-    const columnTypes = ref([]) //类型
-    const requestParams = ref({})//active类型
-    setTimeout(()=>{
-        columnTypes.value = store.state.menuList[store.state.sub].children
-    },500)
-    const paramsData = ref({})
-    let oldCategoryId= ref()
-    //类型切换
-    function facilityClick(item:Object){
-        //防抖
-        if(item.id != oldCategoryId.value){
-            requestParams.value = item
+const store = useStore()
+const router = useRouter()
+const route = useRoute()
+const columnTypes = ref([]) //类型
+const requestParams = ref({})//active类型
+const paramsData = ref({})
+let oldCategoryId = ref()
+//类型切换
+function facilityClick(item: Object) {
+    //防抖
+    if (item.id != oldCategoryId.value) {
+        requestParams.value = item
+        paramsData.value = {
+            params: {
+                categoryid: item.id,
+                pageNum: 1,
+                pageSize: 100,
+                order: "sortindex",
+            },
+            index: store.state.currentPagePath,
+            sub: store.state.sub
+        }
+        oldCategoryId.value = item.id
+        store.dispatch('getPageData', paramsData.value)
+    }
+}
+//详情页
+function details(item: Object) {
+    router.push(
+        {
+            path: `cases_Read`,
+            query: {
+                categoryid: item.categoryid,
+                id: item.id,
+                isUrlId: 1
+            }
+        }
+    )
+    // globalThis.scrollTo(0, 0)
+}
+//数据初始化
+function init() {
+    const data = store.state.menuList
+    const paramsData = ref({})//页面主题内容请求参数
+    for (let i = 0; i < data.length; i++) {
+        if (!data[i].sname && route.path == data[i].path) {
             paramsData.value = {
-                params:{
-                    categoryid: item.id,
-                    pageNum:1,
-                    pageSize:100,
-                    order:"sortindex",
+                params: {
+                    categoryid: data[i].id,
+                    pageNum: 1,
+                    pageSize: 100,
+                    order: "sortindex",
                 },
-                index:store.state.currentPagePath,
-                sub:store.state.sub
+                index: route.path,
+                sub: i
+            }
+            if (!route.query?.categoryid) {
+                paramsData.value.params.categoryid = data[i].children[0].id
+            } else {
+                paramsData.value.params.categoryid = route.query.categoryid
             }
-            oldCategoryId.value = item.id
-            store.dispatch('getPageData',paramsData.value)
+            store.dispatch('getPageData', paramsData.value)
         }
     }
-    //详情页
-    function details(item:Object){
-        router.push(
-            { 
-                path: `cases_Read` , 
-                query: { 
-                    categoryid: item.categoryid,
-                    id:item.id,
-                    isUrlId:1
-                } 
-            }
-        )
-        globalThis.scrollTo(0,0)
+}
+watch(() => store.state.menuList.length > 0,
+    () => {
+        init()
     }
-    //数据初始化
-    function init(){
-      const data = store.state.menuList
-      const paramsData = ref({})//页面主题内容请求参数
-      for(let i=0;i<data.length;i++){
-              //模板 主页
-              if(!data[i].sname && route.path == data[i].path){
-                  paramsData.value = {
-                      params:{
-                          categoryid: data[i].id,
-                          pageNum:1,
-                          pageSize:100,
-                          order:"sortindex",
-                      },
-                      index:route.path,
-                      sub:i
-                  }
-                  if(!route.query?.categoryid){
-                    paramsData.value.params.categoryid = data[i].children[0].id
-                  }else{
-                    paramsData.value.params.categoryid = route.query.categoryid
-                  }
-                  store.dispatch('getPageData',paramsData.value)
-              }
-      }
+)
+watch(
+    () => store.state.currentPagePath || store.state.sub || !store.state.currentPagePath && !store.state.sub,
+    () => {
+        columnTypes.value = store.state.menuList[store.state.sub].children
     }
-    onMounted(() => {
-        setTimeout(()=>{
-            init()
-        },300)
-    });
+);
 </script>
 <template>
     <div class="pageContain">
         <section class="common-bradcrumb-section">
-                <banner />
-            </section>
-            <section style="background:#F4F8FD" class="solutionType">
-                <div class="container pc" style="text-align:center">
-                    <div class="solutionTypeOne" v-for="(item,i) in columnTypes" :class="item.id == store.state.acitveId ? 'active' : ''" @mouseover="facilityClick(item)"  :style="{'width':(1/columnTypes.length*100)+'%' }">
-                        <div style="width:40px;height:40px;;overflow:hidden;margin:0 auto" >
-                            <img class="img" :src="item.imagePath" alt=""  >
-                        </div>
-                        <p>{{item.categoryName}}</p>
+            <banner />
+        </section>
+        <section style="background:#F4F8FD" class="solutionType">
+            <div class="container pc" style="text-align:center">
+                <div class="solutionTypeOne" v-for="(item, i) in columnTypes"
+                    :class="item.id == store.state.acitveId ? 'active' : ''" @mouseover="facilityClick(item)"
+                    :style="{ 'width': (1 / columnTypes.length * 100) + '%' }">
+                    <div style="width:40px;height:40px;;overflow:hidden;margin:0 auto">
+                        <img class="img" v-lazy="item.imagePath" alt="">
                     </div>
+                    <p>{{ item.categoryName }}</p>
                 </div>
-                <div class="container mobile" style="text-align:center">
-                    <div class=" solutionTypeOne" v-for="(item,i) in columnTypes" :class="item.id == requestParams.categoryid ? 'active' : ''"
-                    v-on:mouseover="facilityClick(i, item)"  :style="{'width':(1.5/columnTypes.length*100)+'%' }">
-                        <div style="width:40px;height:40px;;overflow:hidden;margin:0 auto">
-                            <img class="img" :src="item.imagePath" alt="" >
-                        </div>
-                        <p>{{item.categoryName}}</p>
+            </div>
+            <div class="container mobile" style="text-align:center">
+                <div class=" solutionTypeOne" v-for="(item, i) in columnTypes"
+                    :class="item.id == store.state.acitveId ? 'active' : ''" v-on:mouseover="facilityClick(item)"
+                    :style="{ 'width': (1.5 / columnTypes.length * 100) + '%' }">
+                    <div style="width:40px;height:40px;;overflow:hidden;margin:0 auto">
+                        <img class="img" v-lazy="item.imagePath" alt="">
                     </div>
+                    <p>{{ item.categoryName }}</p>
                 </div>
-            </section>
-            <section class="solution-section lazyContainer">
-                <div v-for="(item,index) in store.state.pageContent" :key="item.id" :style="{background:(index % 2 == 1?'#F4F8FD':'#fff')}" style="padding:40px 0" >
-                    <div class="container"  @click="details(item)">
-                        <div  class="solutionItem" >
+            </div>
+        </section>
+        <section class="solution-section lazyContainer">
+            <div v-for="(item, index) in store.state.pageContent" :key="item.id"
+                :style="{ background: (index % 2 == 1 ? '#F4F8FD' : '#fff') }" style="padding:40px 0">
+                <div class="container">
+                    <a :href="`cases_Read?categoryid=${item.categoryid}&id=${item.id}&=isUrlId=1`" style="color:#000">
+                        <div class="solutionItem">
                             <div class="solutionTitle text-left">
-                                {{item.title}}
+                                {{ item.title }}
                             </div>
                             <div class="row solutionInner">
                                 <div class="col-md-7">
                                     <p v-html="item.lmtitle" class="text-left"></p>
-                                    <div class="pt-40 mb-20 text-left">{{item.zhaiyao}}</div>
+                                    <div class="pt-40 mb-20 text-left">{{ item.zhaiyao }}</div>
                                 </div>
                                 <div class="col-md-5 text-center">
-                                    <img :src="item.image" alt="" :data-src="item.image">
+                                    <img v-lazy="item.image" alt="" :data-src="item.image">
                                 </div>
                             </div>
                         </div>
-                    </div>
+                    </a>
                 </div>
-            </section>
+            </div>
+        </section>
     </div>
-            
-</template>
-<style lang="scss" scoped>
 
-</style>
+</template>
+<style lang="scss" scoped></style>

+ 17 - 11
src/views/cases/read.vue

@@ -1,15 +1,12 @@
 <script setup lang="ts">
-    import { ref, onMounted } from 'vue'
+    import { ref, watch } from 'vue'
     import { useStore  } from 'vuex'
     import { useRoute } from "vue-router"
     import banner from '@/components/layout/banner.vue'
     import recomMendation from '@/components/layout/recomMendation.vue'
     const store = useStore()
     const route = useRoute()
-    const recomMendationList = ref([]) //推荐内容
-    setTimeout(()=>{
-        recomMendationList.value = recomMendationFilter(store.state.recomMendation)
-    },1000)
+    const recomMendationList:any = ref([]) //推荐内容
     //推荐内容过滤
     function recomMendationFilter(data:any){
         let array = []
@@ -30,8 +27,8 @@
             str.value = route.path.split("_")[0]
         }
         for(let i=0;i<data.value.length;i++){
-            if( route.path == data.value[i].path || str == data.value[i].path){
-                if(route.query?.categoryid  && !route.query.dup){
+            if(route.path == data.value[i].path || str.value == data.value[i].path){
+                if(route.query?.categoryid  && !data.value[i].sname){
                     sub.value = i
                 }
             }
@@ -48,14 +45,23 @@
                     details:true
                 },
                 index:route.path,
-                sub:sub
+                sub:sub.value
             }
         }
         store.dispatch('getPageData',paramsData.value)
     }
-    onMounted(() => {
-        init()
-    });
+    watch(() => store.state.menuList || route.path,
+        () => {
+            init()
+        }
+    )
+    watch(
+        () => store.state.recomMendation,
+        () => {
+            recomMendationList.value = recomMendationFilter(store.state.recomMendation)
+        },
+        { deep:true  }
+    );
     </script>
     <template>
             <div class="pageContain">

+ 45 - 42
src/views/index/index.vue

@@ -1,6 +1,6 @@
 
 <script setup lang="ts">
-import { ref, onMounted } from 'vue'
+import { onMounted, ref, watch } from 'vue'
 import { useStore  } from 'vuex'
 import { useRoute } from "vue-router";
 import banner from '@/components/layout/banner.vue'
@@ -8,51 +8,54 @@ const store = useStore()
 const route = useRoute()
 // 首页箭头下拉
 function go_down(){
-    globalThis.scrollTo({
-        top: globalThis.innerHeight,
-        behavior: "smooth"
-    })
+    // globalThis.scrollTo({
+    //     top: globalThis.innerHeight,
+    //     behavior: "smooth"
+    // })
 }
  //数据初始化
  function init(){
-      const data = store.state.menuList
-      const paramsData = ref({
-        params:{
-            categoryid: 0,
-            pageNum:1,
-            pageSize:100,
-            order:"sortindex",
-        },
-        index:"",
-        sub:0
-      })//页面主题内容请求参数
-      for(let i=0;i<data.length;i++){
-        //主页
-        console.log(data[i].sname , data[i].path)
-        if(!data[i].sname && route.path == data[i].path || !data[i].sname && data[i].path =="/index"){
-            paramsData.value = {
-                params:{
-                    categoryid: data[i].id,
-                    pageNum:1,
-                    pageSize:100,
-                    order:"sortindex",
-                },
-                index:route.path,
-                sub:i
-            }
-            console.log(data[i])
-            if(route.path == "/index" || route.path == "/"){
-            paramsData.value.params.categoryid = data[i].id
-            }
-            store.dispatch('getPageData',paramsData.value)
+    const data = store.state.menuList
+    const paramsData = ref({
+    params:{
+        categoryid: 0,
+        pageNum:1,
+        pageSize:100,
+        order:"sortindex",
+    },
+    index:"",
+    sub:0
+    })//页面主题内容请求参数
+    for(let i=0;i<data.length;i++){
+    //主页
+    if(!data[i].sname && route.path == data[i].path || !data[i].sname && data[i].path =="/index"){
+        paramsData.value = {
+            params:{
+                categoryid: data[i].id,
+                pageNum:1,
+                pageSize:100,
+                order:"sortindex",
+            },
+            index:route.path,
+            sub:i
         }
-      }
+        if(route.path == "/index" || route.path == "/"){
+        paramsData.value.params.categoryid = data[i].id
+        }
+        store.dispatch('getPageData',paramsData.value)
+    }
+    }
+}
+watch(()=>store.state.menuList.length>0,
+    ()=>{
+    init()
     }
-    onMounted(() => {
-        setTimeout(()=>{
-            init()
-        },300)
-    });
+)
+onMounted(()=>{
+    setTimeout(()=>{
+        init()
+    },1000)
+})
 </script>
 <template>
     <div class="pageContain">
@@ -95,7 +98,7 @@ function go_down(){
                         :style="{padding:(index % 2 == 1?'40px 25px':' 40px 25px')}"
                         style="background-color: #ffff;    box-shadow: 0px 10px 20px 10px rgb(179 202 216 / 20%); align-items:center">
                         <div class="col-md-6  pr-40 aboutImg text-center ">
-                            <img :src="arr.image" alt="">
+                            <img v-lazy="arr.image + 1111" alt="">
                         </div>
                         <div class="col-md-6" v-html="arr.content">
                         </div>

+ 44 - 39
src/views/news/index.vue

@@ -1,5 +1,5 @@
 <script setup lang="ts">
-import { ref, onMounted } from 'vue'
+import { ref, watch } from 'vue'
 import { useStore  } from 'vuex'
 import { useRouter, useRoute } from "vue-router";
 import banner from '@/components/layout/banner.vue'
@@ -11,9 +11,6 @@ import pagination from '@/components/layout/pagination.vue'
     const columnTypes = ref([]) //类型
     const requestParams = ref({})//active类型
     const articalArray = ref([])
-    setTimeout(()=>{
-        columnTypes.value = store.state.menuList[store.state.sub].children
-    },1000)
     const paramsData = ref({})
     let oldCategoryId= ref()
     //类型切换
@@ -56,27 +53,27 @@ import pagination from '@/components/layout/pagination.vue'
       const data = store.state.menuList
       const paramsData = ref({})//页面主题内容请求参数
       for(let i=0;i<data.length;i++){
-              //模板 主页
-              if(!data[i].sname && route.path == data[i].path){
-                  paramsData.value = {
-                      params:{
-                          categoryid: data[i].id,
-                          pageNum:1,
-                          pageSize:100,
-                        //   order:"sortindex",
-                      },
-                      index:route.path,
-                      sub:i
-                  }
-                  if(!route.query?.categoryid){
-                    paramsData.value.params.categoryid = data[i].children[0].id
-                  }else{
-                    paramsData.value.params.categoryid = route.query.categoryid
-                  }
-                  store.dispatch('getPageData',paramsData.value).then(()=>{
-                    articalArray.value = store.state.pageContent
-                  })
-              }
+        if(!data[i].sname && route.path == data[i].path){
+            console.log(111,data[i])
+            paramsData.value = {
+                params:{
+                    categoryid: data[i].id,
+                    pageNum:1,
+                    pageSize:100,
+                //   order:"sortindex",
+                },
+                index:route.path,
+                sub:i
+            }
+            if(!route.query?.categoryid){
+            paramsData.value.params.categoryid = data[i].children[0].id
+            }else{
+            paramsData.value.params.categoryid = route.query.categoryid
+            }
+            store.dispatch('getPageData',paramsData.value).then(()=>{
+            articalArray.value = store.state.pageContent
+            })
+        }
       }
     }
     //分页
@@ -84,17 +81,23 @@ import pagination from '@/components/layout/pagination.vue'
         paramsData.value.params.pageNum = val
         store.dispatch('getPageData',paramsData.value).then(()=>{
             articalArray.value = store.state.pageContent
-            globalThis.scrollTo({
-                top: 0,
-                behavior: "smooth"
-            })
+            // globalThis.scrollTo({
+            //     top: 0,
+            //     behavior: "smooth"
+            // })
         })
     }
-    onMounted(() => {
-        setTimeout(()=>{
+    watch(() => store.state.menuList.length > 0,
+        () => {
             init()
-        },300)
-    });
+        }
+    )
+    watch(
+        () => store.state.currentPagePath || store.state.sub || !store.state.currentPagePath && !store.state.sub,
+        () => {
+            columnTypes.value = store.state.menuList[store.state.sub].children
+        }
+    );
 </script>
 <template>
     <div class="pageContain">
@@ -118,12 +121,14 @@ import pagination from '@/components/layout/pagination.vue'
                                 <!-- 新闻列表主题start -->
                                 <div class="row">
                                     <div class="col-md-4 newItemOne lazyContainer" v-for="(item,index) in articalArray" :key="index" >
-                                        <div class="oneInnerBox" @click="details(item)">
-                                            <div class="img" style="overflow:hidden">
-                                                    <el-image  :src="item.image" alt="" :data-src="item.image" fit="contain"  style="display:block"  />   
-                                            </div>
-                                            <a class="line-two">{{item.title}}</a>
-                                            <span>{{ item.createdate }}</span>
+                                        <div class="oneInnerBox">
+                                            <a :href="`news_Read?categoryid=${item.categoryid}&id=${item.id}&=isUrlId=1`" style="color:#000">
+                                                <div class="img" style="overflow:hidden">
+                                                        <el-image  :src="item.image" alt="" :data-src="item.image" fit="contain"  style="display:block"  />   
+                                                </div>
+                                                <a class="line-two">{{item.title}}</a>
+                                                <span>{{ item.createdate }}</span>
+                                            </a>
                                         </div>
                                     </div>
                                 </div>

+ 17 - 12
src/views/news/read.vue

@@ -1,16 +1,12 @@
 <script setup lang="ts">
-    import { ref, onMounted } from 'vue'
+    import { ref, watch } from 'vue'
     import { useStore  } from 'vuex'
     import { useRoute } from "vue-router"
     import banner from '@/components/layout/banner.vue'
     import recomMendation from '@/components/layout/recomMendation.vue'
-    
     const store = useStore()
     const route = useRoute()
-    const recomMendationList = ref([]) //推荐内容
-    setTimeout(()=>{
-        recomMendationList.value = recomMendationFilter(store.state.recomMendation)
-    },30)
+    const recomMendationList:any = ref([]) //推荐内容
     //推荐内容过滤
     function recomMendationFilter(data:any){
         let array = []
@@ -31,8 +27,8 @@
             str.value = route.path.split("_")[0]
         }
         for(let i=0;i<data.value.length;i++){
-            if( route.path == data.value[i].path || str == data.value[i].path){
-                if(route.query?.categoryid  && !route.query.dup){
+            if(route.path == data.value[i].path || str.value == data.value[i].path){
+                if(route.query?.categoryid  && !data.value[i].sname){
                     sub.value = i
                 }
             }
@@ -49,14 +45,23 @@
                     details:true
                 },
                 index:route.path,
-                sub:sub
+                sub:sub.value
             }
         }
         store.dispatch('getPageData',paramsData.value)
     }
-    onMounted(() => {
-        init()
-    });
+    watch(() => store.state.menuList || route.path,
+        () => {
+            init()
+        }
+    )
+    watch(
+        () => store.state.recomMendation,
+        () => {
+            recomMendationList.value = recomMendationFilter(store.state.recomMendation)
+        },
+        { deep:true  }
+    );
     </script>
     <template>
             <div class="pageContain">

+ 35 - 30
src/views/services/index.vue

@@ -1,5 +1,5 @@
 <script setup lang="ts">
-import { ref, onMounted } from 'vue'
+import { ref, watch } from 'vue'
 import { useStore  } from 'vuex'
 import { useRouter, useRoute } from "vue-router";
 import banner from '@/components/layout/banner.vue'
@@ -11,9 +11,6 @@ import pagination from '@/components/layout/pagination.vue'
     const columnTypes = ref([]) //类型
     const requestParams = ref({})//active类型
     const articalArray = ref([])
-    setTimeout(()=>{
-        columnTypes.value = store.state.menuList[store.state.sub].children
-    },500)
     const paramsData = ref({})
     let oldCategoryId= ref()
     //类型切换
@@ -38,19 +35,19 @@ import pagination from '@/components/layout/pagination.vue'
         }
     }
     //详情页
-    function details(item:Object){
-        router.push(
-            { 
-                path: `services_Read` , 
-                query: { 
-                    categoryid: item.categoryid,
-                    id:item.id,
-                    isUrlId:1
-                } 
-            }
-        )
+    // function details(item:Object){
+    //     router.push(
+    //         { 
+    //             path: `services_Read` , 
+    //             query: { 
+    //                 categoryid: item.categoryid,
+    //                 id:item.id,
+    //                 isUrlId:1
+    //             } 
+    //         }
+    //     )
 
-    }
+    // }
     //数据初始化
     function init(){
       const data = store.state.menuList
@@ -84,17 +81,23 @@ import pagination from '@/components/layout/pagination.vue'
         paramsData.value.params.pageNum = val
         store.dispatch('getPageData',paramsData.value).then(()=>{
             articalArray.value = store.state.pageContent
-            globalThis.scrollTo({
-                top: 0,
-                behavior: "smooth"
-            })
+            // globalThis.scrollTo({
+            //     top: 0,
+            //     behavior: "smooth"
+            // })
         })
     }
-    onMounted(() => {
-        setTimeout(()=>{
+    watch(() => store.state.menuList.length > 0,
+        () => {
             init()
-        },300)
-    });
+        }
+    )
+    watch(
+        () => store.state.currentPagePath || store.state.sub || !store.state.currentPagePath && !store.state.sub,
+        () => {
+            columnTypes.value = store.state.menuList[store.state.sub].children
+        }
+    );
 </script>
 <template>
     <div class="pageContain">
@@ -110,12 +113,14 @@ import pagination from '@/components/layout/pagination.vue'
             <section class="product-grid-section  container pt-20 pb-60 lazyContainer" >
                     <div class="row pt-80 content"  >
                         <div class="col-md-4 newItemOne "  v-for="item in articalArray" :key="item.id">
-                            <div class="oneInnerBox" @click="details(item)">
-                                <div class="img">
-                                    <img :src="item.image" alt="" :data-src="item.image">
-                                </div>
-                                <a class="line-two">{{item.title}}</a>
-                                <span class="line-two">{{item.zhaiyao}}</span>
+                            <div class="oneInnerBox">
+                                <a :href="`services_Read?categoryid=${item.categoryid}&id=${item.id}&=isUrlId=1`" style="color:#000">
+                                    <div class="img">
+                                        <img :src="item.image" alt="" :data-src="item.image">
+                                    </div>
+                                    <a class="line-two">{{item.title}}</a>
+                                    <span class="line-two">{{item.zhaiyao}}</span>
+                                </a>
                             </div>
                         </div>
                     </div>

+ 18 - 11
src/views/services/read.vue

@@ -1,5 +1,5 @@
 <script setup lang="ts">
-    import { ref, onMounted } from 'vue'
+    import { ref, watch } from 'vue'
     import { useStore  } from 'vuex'
     import { useRoute } from "vue-router"
     import banner from '@/components/layout/banner.vue'
@@ -7,10 +7,7 @@
     
     const store = useStore()
     const route = useRoute()
-    const recomMendationList = ref([]) //推荐内容
-    setTimeout(()=>{
-        recomMendationList.value = recomMendationFilter(store.state.recomMendation)
-    },30)
+    const recomMendationList:any = ref([]) //推荐内容
     //推荐内容过滤
     function recomMendationFilter(data:any){
         let array = []
@@ -31,9 +28,10 @@
             str.value = route.path.split("_")[0]
         }
         for(let i=0;i<data.value.length;i++){
-            if( route.path == data.value[i].path || str == data.value[i].path){
-                if(route.query?.categoryid  && !route.query.dup){
+            if( route.path == data.value[i].path || str.value == data.value[i].path){
+                if(route.query?.categoryid  && !data.value[i].sname){
                     sub.value = i
+                    console.log(1111,sub.value)
                 }
             }
         }
@@ -49,14 +47,23 @@
                     details:true
                 },
                 index:route.path,
-                sub:sub
+                sub:sub.value
             }
         }
         store.dispatch('getPageData',paramsData.value)
     }
-    onMounted(() => {
-        init()
-    });
+    watch(() => store.state.menuList || route.path,
+        () => {
+            init()
+        }
+    )
+    watch(
+        () => store.state.recomMendation,
+        () => {
+            recomMendationList.value = recomMendationFilter(store.state.recomMendation)
+        },
+        { deep:true  }
+    );
     </script>
     <template>
             <div class="pageContain">