From 52ace71f626ea2d9551ac56baaa15319e77ab814 Mon Sep 17 00:00:00 2001 From: maojindao55 Date: Sun, 20 Jul 2025 07:45:00 +0800 Subject: [PATCH] exclude confing.js fix --- package.json | 2 +- src/components/AuthGuard.jsx | 9 ++++++--- wrangler.toml | 5 ++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 62b2419..ebb38c5 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "dev": "vite", - "build": "vite build", + "build": "vite build && rm -f dist/config.js", "preview": "vite preview" }, "dependencies": { diff --git a/src/components/AuthGuard.jsx b/src/components/AuthGuard.jsx index ee6b532..144f7b0 100644 --- a/src/components/AuthGuard.jsx +++ b/src/components/AuthGuard.jsx @@ -3,9 +3,12 @@ import { Navigate, useLocation } from 'react-router-dom'; export default function AuthGuard({ children }) { //判断环境变量中的AUTH_ACCESS是否为1开启权限校验 //const authAccess = import.meta.env.AUTH_ACCESS; - const authAccess = window.APP_CONFIG?.AUTH_ACCESS || - import.meta.env.AUTH_ACCESS || - '0'; + let authAccess = window.APP_CONFIG?.AUTH_ACCESS || '0'; + const isCf = import.meta.env.IS_CF || '0'; + console.log(isCf, 'isCf'); + if (isCf === '1') { + authAccess = import.meta.env.AUTH_ACCESS || '0'; + } console.log(authAccess, 'authAccess'); if (authAccess === '1') { const location = useLocation(); diff --git a/wrangler.toml b/wrangler.toml index 7a1f2cc..9410af3 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -8,6 +8,5 @@ binding = "bgdb" # available in your Worker on env.DB database_name = "friends" database_id = "f68e9fa5-4aea-45db-9516-2d7052e936fa" -[site] -bucket = "./dist" -exclude = ["config.js"] \ No newline at end of file +[vars] +IS_CF = '1' \ No newline at end of file