feat: init

This commit is contained in:
2025-09-05 18:20:53 +08:00
parent c9c9c8fa67
commit f46a851ee5
6 changed files with 54 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
import { Route, Routes } from "react-router-dom";
import { Route, RouterProvider, Routes } from "react-router-dom";
import { routes, AppRoute } from "./routes";
import AuthRoute from "./auth.tsx";
import { Suspense } from "react";
@@ -35,7 +35,7 @@ export const RenderRoutes = () => {
display: "flex",
alignItems: "center",
justifyContent: "center",
fontSize: "12px",
fontSize: "24px",
}}
>
<DotLoading />

View File

@@ -1,5 +1,6 @@
import { Navigate } from "react-router-dom";
import { createBrowserRouter, Navigate } from "react-router-dom";
import { lazy } from "react";
import { type Router } from "react-router-dom";
export interface AppRoute {
path: string;

View File

@@ -1,16 +1,26 @@
import MainLayout from "@/layout/main/mainLayout";
import { useState } from "react";
import { useEffect, useState } from "react";
import { Divider, Space } from "antd-mobile";
import Translate from "./translate/index";
import { Electrocardiogram, Filter, GithubOne } from "@icon-park/react";
import { Electrocardiogram, Filter, GithubOne, HamburgerButton } from "@icon-park/react";
import { useNavigate } from "react-router-dom";
import { useSafeNavigate } from "@workspace/hooks";
import "./index.less";
function Index() {
const [visible, setVisible] = useState<boolean>(false);
const safeNavigate = useSafeNavigate();
const navigate = useNavigate();
useEffect(() => {
if (window.history) {
// // 往历史记录里面添加一条新的当前页面的url
// // 给 popstate 绑定一个方法监听页面返回
window.addEventListener("popstate", () => onLink(""), false); //false阻止默认事件
}
}, []);
const onLink = (link: string) => {
// safeNavigate(link);
navigate(link);
};
return (
@@ -35,6 +45,13 @@ function Index() {
strokeLinecap="butt"
onClick={() => onLink("/translate/archives")}
/>
<HamburgerButton
theme="outline"
size="24"
fill="#333"
strokeWidth={3}
strokeLinecap="butt"
/>
</Space>
</div>
<Translate searchVisible={visible} />