Skip to content

Commit

Permalink
feat: add NProgress bar (#67)
Browse files Browse the repository at this point in the history
* feat: add n progress bar

* chore: bump version
  • Loading branch information
fu050409 authored Nov 30, 2024
1 parent 539e48f commit 3cf98fb
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changes/n-progress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"algohub": patch:feat
---

Add `NProgress` loading bar to the whole frontend.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"axios": "^1.7.7",
"md-editor-v3": "^5.0.2",
"monaco-editor": "^0.52.0",
"nprogress": "^0.2.0",
"pinia": "^2.2.6",
"pinia-plugin-persistedstate": "^4.1.3",
"postcss": "^8.4.49",
Expand All @@ -43,6 +44,7 @@
"@primevue/auto-import-resolver": "^4.2.2",
"@tauri-apps/cli": "^2.1.0",
"@types/node": "^22.9.0",
"@types/nprogress": "^0.2.3",
"@types/path-browserify": "^1.0.3",
"@vitejs/plugin-vue": "^5.2.0",
"archons": "^0.2.5",
Expand Down
16 changes: 16 additions & 0 deletions pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

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

23 changes: 22 additions & 1 deletion src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import {
createWebHashHistory,
type RouteRecordRaw,
} from "vue-router";
import NProgress from "nprogress";
import "nprogress/nprogress.css";

const views = import.meta.glob([
"./views/**/*.vue",
Expand All @@ -27,7 +29,26 @@ const routes: RouteRecordRaw[] = Object.entries(views).map(
}
);

export default createRouter({
const router = createRouter({
history: createWebHashHistory(import.meta.env.BASE_URL),
routes: [...routes],
});

NProgress.configure({
easing: "ease",
speed: 500,
showSpinner: false,
trickleSpeed: 200,
minimum: 0.3,
});

router.beforeEach((_to, _from, next) => {
NProgress.start();
next();
});

router.afterEach(() => {
NProgress.done();
});

export default router;

0 comments on commit 3cf98fb

Please sign in to comment.