Jing 2 сар өмнө
parent
commit
dcf2ae1e35

+ 1 - 1
.nuxt/manifest/latest.json

@@ -1 +1 @@
-{"id":"6ba24ed3-4f8e-4edc-9702-28921b7a8448","timestamp":1747043886868}
+{"id":"85f876db-5d64-40ec-a0b3-78675fb2d686","timestamp":1747644748037}

+ 0 - 1
.nuxt/manifest/meta/6ba24ed3-4f8e-4edc-9702-28921b7a8448.json

@@ -1 +0,0 @@
-{"id":"6ba24ed3-4f8e-4edc-9702-28921b7a8448","timestamp":1747043886868,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}

+ 1 - 0
.nuxt/manifest/meta/85f876db-5d64-40ec-a0b3-78675fb2d686.json

@@ -0,0 +1 @@
+{"id":"85f876db-5d64-40ec-a0b3-78675fb2d686","timestamp":1747644748037,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}

+ 1 - 1
.nuxt/tsconfig.json

@@ -102,7 +102,7 @@
         "./imports"
       ],
       "#app-manifest": [
-        "./manifest/meta/6ba24ed3-4f8e-4edc-9702-28921b7a8448.json"
+        "./manifest/meta/85f876db-5d64-40ec-a0b3-78675fb2d686.json"
       ],
       "#components": [
         "./components"

+ 2 - 2
assets/css/class.less

@@ -748,8 +748,8 @@ section {
     }
 }
 .boxheight1 {
-    height: 650px;
+    height: 590px;
 }
 .boxheight2 {
-    height: 325px;
+    height: 249px;
 }

+ 64 - 32
middleware/setup.global.js

@@ -1,11 +1,11 @@
 export default async function (to, from) {
     //获得全局url
     const { $webUrl, $CwebUrl } = useNuxtApp();
-    if(to.path == '/' || to.path == '/404'){
+    if (getRouteWhiteList(to.path)) {
         //如果目标路由是/,或者/404 无需验证
-    }else{
+    } else {
         // to是目标路由对象,from是来源路由对象
-        console.log('进入路由中间件,目标路由:', to.path,"当前路由:",from.path);
+        console.log('进入路由中间件,目标路由:', to.path, "当前路由:", from.path);
         //拆分目标路由
         let parts = parseRoute(to.path)
         console.log(parts)
@@ -19,9 +19,9 @@ export default async function (to, from) {
             query: parts
         })
         console.log(responseRoute)
-        if(responseRoute.code == 200){
+        if (responseRoute.code == 200) {
             //如果路由存在,不做任何操作
-        }else{
+        } else {
             return navigateTo('/404')
         }
     }
@@ -31,42 +31,46 @@ export default async function (to, from) {
 function parseRoute(url) {
     const parts = url.split('/').filter(Boolean); // 分割并过滤空字符串
     const lastPart = parts[parts.length - 1];
-    
+
     // 提取 id(数字.html 的数字部分)
     const idMatch = lastPart.match(/^(\d+)\.html$/);
     const id = idMatch ? idMatch[1] : undefined;
-    
+
     // 如果最后是数字.html、index.html 或 list-数字.html,则去掉它
     const isSpecialRoute = idMatch || lastPart === "index.html" || lastPart.startsWith("list-");
     if (isSpecialRoute) {
         parts.pop();
     }
-    
+
     let all_route, last_route;
-    
+
     // 如果路径以 xiangcunshangcheng 开头
-    if (parts[0] === "xiangcunshangcheng") {
-        if( parts.length > 1){
-            if(parts[parts.length - 1] != 'gongying' && parts[parts.length - 1] != 'qiugou'){
-                // 否则按原逻辑处理
-                all_route = parts.join('/');
-                last_route = parts.length > 0 ? parts[parts.length - 1] : null;
-            }else{
-                // all_route = 去掉最后一层
-                all_route = parts.slice(0, -1).join('/');
-                // last_route = 新的最后一层
-                last_route = parts.length > 1 ? parts[parts.length - 2] : null;
-            }
-        }else{
-            // 否则按原逻辑处理
-            all_route = parts.join('/');
-            last_route = parts.length > 0 ? parts[parts.length - 1] : null;
-        }
-    } else {
-        // 否则按原逻辑处理
-        all_route = parts.join('/');
-        last_route = parts.length > 0 ? parts[parts.length - 1] : null;
-    }
+    // if (parts[0] === "xiangcunshangcheng") {
+    //     if( parts.length > 1){
+    //         if(parts[parts.length - 1] != 'gongying' && parts[parts.length - 1] != 'qiugou'){
+    //             // 否则按原逻辑处理
+    //             all_route = parts.join('/');
+    //             last_route = parts.length > 0 ? parts[parts.length - 1] : null;
+    //         }else{
+    //             // all_route = 去掉最后一层
+    //             all_route = parts.slice(0, -1).join('/');
+    //             // last_route = 新的最后一层
+    //             last_route = parts.length > 1 ? parts[parts.length - 2] : null;
+    //         }
+    //     }else{
+    //         // 否则按原逻辑处理
+    //         all_route = parts.join('/');
+    //         last_route = parts.length > 0 ? parts[parts.length - 1] : null;
+    //     }
+    // } else {
+    //     // 否则按原逻辑处理
+    //     all_route = parts.join('/');
+    //     last_route = parts.length > 0 ? parts[parts.length - 1] : null;
+    // }
+
+    all_route = parts.join('/');
+    last_route = parts.length > 0 ? parts[parts.length - 1] : null;
+
     // 返回结果(只有数字.html 时才包含 id)
     const result = {
         all_route,
@@ -76,4 +80,32 @@ function parseRoute(url) {
         result.id = id;
     }
     return result;
-}
+}
+
+//获得路由白名单列表
+function getRouteWhiteList(path) {
+    if (path == '/') {
+        console.log('白名单路由!允许访问!')
+        //如果用户进入的是首页,直接返回true
+        return true
+    } else {
+        //如果用户进入的不是首页,则需要判断第一层路由是否在白名单
+        const parts = path.split('/').filter(Boolean); // 分割并过滤空字符串
+        console.log(parts[0])
+        let whiteList = [
+            "404",
+            "search",//搜索页
+            "xiangcunshangcheng",//乡村商城搜索页
+            "topic",//商圈
+            "advertising",//广告
+            "about",//关于我们
+        ]
+
+        if (whiteList.includes(parts[0])) {
+            console.log('白名单路由!允许访问!')
+            return true
+        } else {
+            return false
+        }
+    }
+}

+ 2 - 2
plugins/category.ts

@@ -37,7 +37,7 @@ const navPre: number[] = [
 
 export default defineNuxtPlugin((nuxtApp) => {
     //master 环境
-    // nuxtApp.provide('pageNav', navMaster)
+    nuxtApp.provide('pageNav', navMaster)
     //pre 环境
-    nuxtApp.provide('pageNav', navPre)
+    // nuxtApp.provide('pageNav', navPre)
 })

+ 10 - 10
plugins/globals.ts

@@ -1,16 +1,16 @@
 export default defineNuxtPlugin((nuxtApp) => {
   //Pre环境
-  nuxtApp.provide('webUrl', 'http://apipre1.bjzxtw.org.cn:29501')
-  nuxtApp.provide('CwebUrl', 'http://pre.nzgx.org')
-  nuxtApp.provide('BwebUrl', 'http://adminpre.bjzxtw.org.cn')
-  nuxtApp.provide('LoginWebUrl', 'http://adminpre.bjzxtw.org.cn/adminapi')
-  nuxtApp.provide('userUrl', 'http://localhost:3006')
+  // nuxtApp.provide('webUrl', 'http://apipre1.bjzxtw.org.cn:29501')
+  // nuxtApp.provide('CwebUrl', 'http://pre.nzgx.org')
+  // nuxtApp.provide('BwebUrl', 'http://adminpre.bjzxtw.org.cn')
+  // nuxtApp.provide('LoginWebUrl', 'http://adminpre.bjzxtw.org.cn/adminapi')
+  // nuxtApp.provide('userUrl', 'http://localhost:3006')
 
   //正式环境
-  // nuxtApp.provide('webUrl', 'https://flzxw.bjzxtw.org.cn')
-  // nuxtApp.provide('CwebUrl', 'http://nw.nzgx.org')
-  // nuxtApp.provide('BwebUrl', 'https://admin.bjzxtw.org.cn')
-  // nuxtApp.provide('LoginWebUrl', 'http://admin.bjzxtw.org.cn/adminapi')
-  // nuxtApp.provide('userUrl', 'http://localhost:3006')
+  nuxtApp.provide('webUrl', 'https://flzxw.bjzxtw.org.cn')
+  nuxtApp.provide('CwebUrl', 'http://nw.nzgx.org')
+  nuxtApp.provide('BwebUrl', 'https://admin.bjzxtw.org.cn')
+  nuxtApp.provide('LoginWebUrl', 'http://admin.bjzxtw.org.cn/adminapi')
+  nuxtApp.provide('userUrl', 'http://localhost:3006')
   
 })

+ 4 - 4
plugins/request.ts

@@ -6,11 +6,11 @@ export default defineNuxtPlugin(() => {
 
     let Url = {
         //正式环境
-        // webUrl: 'https://flzxw.bjzxtw.org.cn', //接口地址
-        // CwebUrl: 'nw.nzgx.org' //页面地址
+        webUrl: 'https://flzxw.bjzxtw.org.cn', //接口地址
+        CwebUrl: 'nw.nzgx.org' //页面地址
         //pre环境
-        webUrl: 'http://apipre1.bjzxtw.org.cn:29501', //pre接口地址
-        CwebUrl: 'pre.nzgx.org' //页面地址
+        // webUrl: 'http://apipre1.bjzxtw.org.cn:29501', //pre接口地址
+        // CwebUrl: 'pre.nzgx.org' //页面地址
     }
 
     const service = axios.create({