Skip to content

Commit

Permalink
fix: enter coder layout can not back
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanyxh committed May 18, 2024
1 parent 4f75437 commit c985f45
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
- 微信:hxy3130gbs
- Email:[email protected]

[博客站点]: https://yang-xianzhu.github.io/
[博客站点]: https://blog-kappa-seven-43.vercel.app/
[Hexo]: https://hexo.io/zh-cn/
[Vuepress]: https://vuepress.vuejs.org/zh/
[项目]: https://github.com/yuanyxh/illustrate
25 changes: 12 additions & 13 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/assets/svgs/typcn--arrow-back.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 12 additions & 2 deletions src/coder/Wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,15 @@ type FieldType = {
};

export default function Wrapper() {
const route = useRoutes();
const routes = useRoutes();
const location = useLocation();
const history = useHistory();

const [open, setOpen] = useState(false);
const [layoutId, setLayoutId] = useState(0);

const menu = useMemo(() => {
const codes = route?.[1].children || [];
const codes = routes?.[1].children || [];

const curr = location.path.replace('/coder/', '').split('/').shift()!;

Expand All @@ -179,6 +180,10 @@ export default function Wrapper() {
setLayoutId(e);
};

const handleBack = () => {
history.back();
};

return (
<Layout className={styles.wrapper}>
<Sider className={styles.sider} theme="dark">
Expand Down Expand Up @@ -222,6 +227,11 @@ export default function Wrapper() {
icon={<Icon icon="material-symbols:settings" />}
onClick={() => setOpen(true)}
/>
<FloatButton
aria-label="back"
icon={<Icon icon="typcn--arrow-back" />}
onClick={handleBack}
/>
</FloatButton.Group>
</Layout>
);
Expand Down
12 changes: 11 additions & 1 deletion src/router/hooks/useHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,24 @@ export function useHistory() {
);
}

function back() {
routerContext?.navigate(-1);
}

function forward() {
routerContext?.navigate(1);
}

function go(to: number) {
routerContext?.navigate(to);
}

return {
push,
replace,
go
go,
back,
forward
};
}, [routerContext]);

Expand Down
10 changes: 5 additions & 5 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import rehypePrism from '@mapbox/rehype-prism';
import viteRouteGenerator from './helpers/vite-route-generator';
import vitePrerender from './helpers/vite-prerender';
import viteGenerateSitemap from './helpers/vite-generate-sitemap';
import basicSsl from '@vitejs/plugin-basic-ssl';
// import basicSsl from '@vitejs/plugin-basic-ssl';

import type { ConfigEnv, UserConfig } from 'vite';

Expand Down Expand Up @@ -90,8 +90,8 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
iconDirs: [resolve('./src/assets/svgs')],
symbolId: 'icon-[dir]-[name]',
svgoOptions: true
}),
basicSsl()
})
// basicSsl()
],
resolve: {
alias: [
Expand Down Expand Up @@ -175,8 +175,8 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
changeOrigin: true,
rewrite: (path) => path.replace(/\/api/, 'issues')
}
},
https: {}
}
// https: {}
},
optimizeDeps: {
include: [],
Expand Down

0 comments on commit c985f45

Please sign in to comment.