浏览代码

修改bug

Jing 1 周之前
父节点
当前提交
dfa8e30c8f

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

@@ -1 +1 @@
-{"id":"04949f4a-4b9c-4838-aa6b-ad9bd745da1f","timestamp":1747193175563}
+{"id":"638eeb66-e8b3-4e83-96ac-ae3451a2ba79","timestamp":1747706581432}

+ 0 - 1
.nuxt/manifest/meta/04949f4a-4b9c-4838-aa6b-ad9bd745da1f.json

@@ -1 +0,0 @@
-{"id":"04949f4a-4b9c-4838-aa6b-ad9bd745da1f","timestamp":1747193175563,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}

+ 1 - 0
.nuxt/manifest/meta/638eeb66-e8b3-4e83-96ac-ae3451a2ba79.json

@@ -0,0 +1 @@
+{"id":"638eeb66-e8b3-4e83-96ac-ae3451a2ba79","timestamp":1747706581432,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}

+ 1 - 1
.nuxt/nuxt.d.ts

@@ -1,6 +1,6 @@
 // Generated by nuxi
-/// <reference types="@nuxt/telemetry" />
 /// <reference types="@nuxt/devtools" />
+/// <reference types="@nuxt/telemetry" />
 /// <reference path="types/builder-env.d.ts" />
 /// <reference types="nuxt" />
 /// <reference path="types/app-defaults.d.ts" />

+ 1 - 1
.nuxt/tsconfig.json

@@ -102,7 +102,7 @@
         "./imports"
       ],
       "#app-manifest": [
-        "./manifest/meta/04949f4a-4b9c-4838-aa6b-ad9bd745da1f.json"
+        "./manifest/meta/638eeb66-e8b3-4e83-96ac-ae3451a2ba79.json"
       ],
       "#components": [
         "./components"

+ 14 - 13
middleware/setup.global.js

@@ -1,11 +1,11 @@
 export default async function (to, from) {
     //获得全局url
     const { $webUrl, $CwebUrl } = useNuxtApp();
-    if(getRouteWhiteList(to.path)){
+    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,17 +31,17 @@ 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 开头
@@ -83,12 +83,12 @@ function parseRoute(url) {
 }
 
 //获得路由白名单列表
-function getRouteWhiteList(path){
-    if(path=='/'){
+function getRouteWhiteList(path) {
+    if (path == '/') {
         console.log('白名单路由!允许访问!')
         //如果用户进入的是首页,直接返回true
         return true
-    }else{
+    } else {
         //如果用户进入的不是首页,则需要判断第一层路由是否在白名单
         const parts = path.split('/').filter(Boolean); // 分割并过滤空字符串
         console.log(parts[0])
@@ -99,12 +99,13 @@ function getRouteWhiteList(path){
             "topic",//商圈
             "advertising",//广告
             "about",//关于我们
+            "shukanyinxiangcheng",//书刊音像
         ]
 
-        if(whiteList.includes(parts[0])){
+        if (whiteList.includes(parts[0])) {
             console.log('白名单路由!允许访问!')
             return true
-        }else{
+        } else {
             return false
         }
     }