Pārlūkot izejas kodu

fix: 跌由都改为 # hash 模式

王晓东 2 mēneši atpakaļ
vecāks
revīzija
98363d82ac

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
build/assets/index-DiVtD1w9.js


+ 1 - 1
build/site.html

@@ -5,7 +5,7 @@
       <meta charset="UTF-8" />
       <meta name="viewport" content="width=device-width, initial-scale=1.0" />
       <title>Anycall App Landing Page</title>
-      <script type="module" crossorigin src="/fara/h5/assets/index-CIBPE-th.js"></script>
+      <script type="module" crossorigin src="/fara/h5/assets/index-DiVtD1w9.js"></script>
       <link rel="stylesheet" crossorigin href="/fara/h5/assets/index-1Br_J6GP.css">
     </head>
 

+ 8 - 3
src/App.tsx

@@ -14,8 +14,8 @@ import { FAQPage } from './components/pages/FAQPage';
 import { ContactPage } from './components/pages/ContactPage';
 
 function AppContent() {
-  const { currentPage } = useRouter();
-  
+  const { currentPage, navigateTo } = useRouter();
+  const _page = window.location.hash.split('#')?.[1] ?? currentPage
   // Ensure hash scrolling works even after page is fully loaded
   useEffect(() => {
     // Wait for all images and resources to load
@@ -38,9 +38,14 @@ function AppContent() {
       }
     }
   }, [currentPage]);
+
+  useEffect(()=> {
+    navigateTo(_page)
+  }, [])
   
   const renderPage = () => {
-    switch (currentPage) {
+    
+    switch (_page) {
       case 'home':
         return <Home />;
       case 'about':

+ 6 - 4
src/components/Header.tsx

@@ -17,10 +17,12 @@ export function Header() {
 
   const scrollToSection = (id: string) => {
     // Close mobile menu first for better UX
+    console.log(currentPage, id,3333)
     setMobileMenuOpen(false);
-    if (currentPage !== 'home') {
-      navigateTo('home', id);
-    } else {
+    navigateTo('home', id);
+    // if (currentPage !== 'home') {
+    //   navigateTo('home', id);
+    // } else {
       // Small delay to ensure mobile menu is closed
       setTimeout(() => {
         const element = document.getElementById(id);
@@ -29,7 +31,7 @@ export function Header() {
           window.history.pushState(null, '', `#${id}`);
         }
       }, 50);
-    }
+    // }
   };
 
   const handleNavigation = (page: 'faq' | 'contact') => {

+ 2 - 2
src/contexts/RouterContext.tsx

@@ -97,8 +97,8 @@ export function RouterProvider({ children }: { children: ReactNode }) {
     const url = hash ? `${path}#${hash}` : path;
     const BASE_PATH = VITE_BASE_PATH
     // Update browser URL without reloading
-    window.history.pushState({ page }, '', BASE_PATH + url);
-    
+    window.history.pushState(null, '', `#${page}`);
+    console.log(page, hash,3334)
     if (hash) {
       // If there's a hash, scroll to the section
       scrollToElement(hash, 150);

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels