feat:增加RouteGo,统一路由跳转

This commit is contained in:
曾文豪
2022-05-20 15:32:42 +08:00
parent 54b9f48799
commit 90de4f6a84
6 changed files with 73 additions and 8 deletions

View File

@@ -10,7 +10,7 @@ export default defineConfig({
hash: true, hash: true,
title: false, title: false,
history: { history: {
type: "browser" type: "hash"
}, },
proxy proxy
}); });

View File

@@ -1,10 +1,14 @@
import less from "./index.less";
import PageContainer from "@/components/PageContainer"; import PageContainer from "@/components/PageContainer";
import {useEffect} from "react";
import RouteGo from "@/utils/RouteGo";
export default () => { export default () => {
useEffect(() => {
RouteGo.XYM.index();
}, [1])
return <PageContainer title={"浙科校园码"} loading={false}> ///////////////////////////////////////// 页面渲染
<h1 className={less.title}>Page index</h1>
</PageContainer> return <PageContainer title={"浙江科技学院"} loading/>
} }

View File

@@ -1,3 +0,0 @@
.title {
background: rgb(121, 242, 157);
}

13
src/pages/xym/index.jsx Normal file
View File

@@ -0,0 +1,13 @@
import PageContainer from "@/components/PageContainer";
import {useEffect} from "react";
export default () => {
useEffect(() => {
}, [1])
///////////////////////////////////////// 页面渲染
return <PageContainer title={"校园码"} loading/>
}

13
src/pages/xym/person.jsx Normal file
View File

@@ -0,0 +1,13 @@
import PageContainer from "@/components/PageContainer";
import {useEffect} from "react";
export default () => {
useEffect(() => {
}, [1])
///////////////////////////////////////// 页面渲染
return <PageContainer title={"个人信息"} loading/>
}

38
src/utils/RouteGo.js Normal file
View File

@@ -0,0 +1,38 @@
import {history} from "umi";
const XYM = {
/**
* 校园码首页
*/
index: () => {
history.push("/xym")
},
/**
* 个人信息
*/
person: () => {
history.push("/xym/person")
},
}
export default {
/**
* 返回上一页
* page 返回多少页,默认-1页
* @param page
*/
goBack: (page = -1) => {
history.go(page);
},
XYM,
}