{"id":30196516,"url":"https://github.com/guoguodad/react-app-template","last_synced_at":"2026-04-12T11:51:27.109Z","repository":{"id":109377630,"uuid":"496842040","full_name":"GuoguoDad/react-app-template","owner":"GuoguoDad","description":"webpack5 react 移动端 h5 项目模板","archived":false,"fork":false,"pushed_at":"2023-04-21T03:00:31.000Z","size":9761,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-13T05:38:40.393Z","etag":null,"topics":["ionic-react","react","redux","webpack5"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GuoguoDad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-05-27T02:54:42.000Z","updated_at":"2024-08-08T09:50:13.000Z","dependencies_parsed_at":"2023-03-08T10:15:24.567Z","dependency_job_id":null,"html_url":"https://github.com/GuoguoDad/react-app-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/GuoguoDad/react-app-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GuoguoDad%2Freact-app-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GuoguoDad%2Freact-app-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GuoguoDad%2Freact-app-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GuoguoDad%2Freact-app-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GuoguoDad","download_url":"https://codeload.github.com/GuoguoDad/react-app-template/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GuoguoDad%2Freact-app-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31713876,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-12T06:22:27.080Z","status":"ssl_error","status_checked_at":"2026-04-12T06:21:52.710Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ionic-react","react","redux","webpack5"],"created_at":"2025-08-13T05:26:17.597Z","updated_at":"2026-04-12T11:51:27.098Z","avatar_url":"https://github.com/GuoguoDad.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ccenter\u003e\u003ch1\u003e移动端h5项目，模拟移动端栈路由\u003ch1\u003e\u003c/center\u003e\n\n## 效果\n\u003cimg src=\"https://img-blog.csdnimg.cn/9879c9bf85db432e974481c93da02b77.gif#pic_center\"  alt=\"效果\" width=\"300\"/\u003e\u003cbr/\u003e\n\n## 为什么不用react-router\n移动端打开页面其实是栈的入栈操作，关闭页面是栈的出栈操作，而传统的h5路由，如react-router是不具备栈这个特性的，满足不了移动端的需求\n\n## 栈路由\n栈路由什么意思尼，其实app就是一个栈，栈遵循先进后出的原则，打开页面即入栈操作，关闭页面即出栈操作。\n\n\u003cimg src=\"https://img-blog.csdnimg.cn/2ed9e45c200e47e9a460a51cacddc014.png#pic_center\"  alt=\"效果\" width=\"400\"/\u003e\n\n- 打开A页面的时候，就是A入栈，A页面在栈顶，app就显示A页面\n- 又打开了B页面，B又入栈，B页面在栈顶，A页面在栈中并没有销毁，app显示B页面\n- 再打开C页面，C又入栈， C页面在栈顶，AB页面在栈中并没有销毁， app显示C页面\n\n\u003cbr/\u003e\n\n\u003cimg src=\"https://img-blog.csdnimg.cn/da263e35aad14468925438cfe865dfba.png#pic_center\"  alt=\"效果\" width=\"400\"/\u003e\n\n- C页面关闭(出栈), B页面成为栈顶， app显示B页面\n- B页面关闭(出栈), A页面成为栈顶，app显示A页面\n\n## 实现\n这里用的第三方的 @ionic/react-router 路由\n```\nimport React, { useEffect } from 'react'\nimport { IonApp, IonRouterOutlet, setupIonicReact } from '@ionic/react'\nimport { IonReactHashRouter } from '@ionic/react-router'\nimport { Route, Redirect } from 'react-router-dom'\nimport loadable from '@loadable/component'\n\nconst MainTabs = loadable(() =\u003e import('@pages/main' /* webpackChunkName: 'MainTabs', webpackPrefetch: true */))\nconst ImgList = loadable(() =\u003e import('@pages/imgList' /* webpackChunkName: 'ImgList', webpackPrefetch: true */))\nconst ImgDetail = loadable(() =\u003e import('@pages/imgDetail' /* webpackChunkName: 'ImgDetail', webpackPrefetch: true */))\n\nconst App = () =\u003e {\n  useEffect(() =\u003e {\n    setupIonicReact({\n      mode: 'ios'\n    })\n  }, [])\n\n  return (\n    \u003cIonApp\u003e\n      \u003cIonReactHashRouter\u003e\n        \u003cIonRouterOutlet\u003e\n          \u003cRoute exact={true} path=\"/\" render={() =\u003e \u003cRedirect to=\"/main\" /\u003e} /\u003e\n          \u003cRoute path={'/main'} exact component={MainTabs} /\u003e\n          \u003cRoute path={'/imgList'} exact component={ImgList} /\u003e\n          \u003cRoute path={'/imgDetail'} exact component={ImgDetail} /\u003e\n        \u003c/IonRouterOutlet\u003e\n      \u003c/IonReactHashRouter\u003e\n    \u003c/IonApp\u003e\n  )\n}\n\nexport default App\n\n```\n## 分析如何实现\n\u003cimg src=\"https://img-blog.csdnimg.cn/abaec81e64ec42c8b5b8c3fbb2bd093b.png#pic_center\"  alt=\"效果\" width=\"700\"/\u003e\u003cbr/\u003e\n\u003cimg src=\"https://img-blog.csdnimg.cn/3d4a9923884b4067bc6623f27c071102.png#pic_center\"  alt=\"效果\" width=\"700\"/\u003e\u003cbr/\u003e\n\u003cimg src=\"https://img-blog.csdnimg.cn/5016cadaeeca4e56ab8ff0570fc5c930.png#pic_center\"  alt=\"效果\" width=\"700\"/\u003e\u003cbr/\u003e\n\n- 打开第一个页面（入栈）document 增加一个class为ion-page的div，\n- 打开第二个页面document 增加一个class为ion-page-can-go-back的div，同时把第一个div的class增加 ion-page-hidden\n- 打开第三个页面document 增加一个class为ion-page-can-go-back的div, 同时把第二个页面的class增加 ion-page-hidden\n- 总结： 通过隐藏与显示来模拟栈路由的操作，思想简单，易于实现\n\n源码地址：\nhttp://github.com/GuoguoDad/react-app-template\n\n\n## 交个朋友\n* 如果对你有帮助，来个三连，谢谢\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguoguodad%2Freact-app-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguoguodad%2Freact-app-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguoguodad%2Freact-app-template/lists"}