refactor: improve router type safety and usage

- Add explicit Router type imports across views
- Replace $router type casting with proper typing
- Use $router.back() instead of $router.go(-1) for consistency
- Add proper route and router typings to components
- Clean up router navigation methods
- Fix router push/back method calls

This commit improves type safety and consistency in router usage across
the application's view components.
This commit is contained in:
Matthew Raymer
2025-02-26 06:50:08 +00:00
parent 61da40596c
commit 03178d35e7
56 changed files with 581 additions and 251 deletions

View File

@@ -37,7 +37,11 @@
class="ml-2 mr-2 mt-4"
>
Details
<font-awesome v-if="showDidDetails" icon="chevron-down" class="text-blue-400" />
<font-awesome
v-if="showDidDetails"
icon="chevron-down"
class="text-blue-400"
/>
<font-awesome v-else icon="chevron-right" class="text-blue-400" />
</button>
<!-- Keep the dump contents directly between > and < to avoid weird spacing. -->
@@ -106,7 +110,11 @@
icon="person-circle-check"
class="fa-fw"
/>
<font-awesome v-else icon="person-circle-question" class="fa-fw" />
<font-awesome
v-else
icon="person-circle-question"
class="fa-fw"
/>
</button>
</div>
@@ -194,7 +202,10 @@
</span>
<span class="col-span-1">
<a @click="onClickLoadClaim(claim.id)" class="cursor-pointer">
<font-awesome icon="file-lines" class="pl-2 pt-1 text-blue-500" />
<font-awesome
icon="file-lines"
class="pl-2 pt-1 text-blue-500"
/>
</a>
</span>
</div>
@@ -216,7 +227,7 @@
import { AxiosError } from "axios";
import * as yaml from "js-yaml";
import { Component, Vue } from "vue-facing-decorator";
import { Router } from "vue-router";
import { RouteLocationNormalizedLoaded, Router } from "vue-router";
import QuickNav from "../components/QuickNav.vue";
import InfiniteScroll from "../components/InfiniteScroll.vue";
@@ -226,14 +237,16 @@ import { db, retrieveSettingsForActiveAccount } from "../db/index";
import { Contact } from "../db/tables/contacts";
import { BoundingBox } from "../db/tables/settings";
import {
capitalizeAndInsertSpacesBeforeCaps,
didInfoForContact,
displayAmount,
getHeaders,
GenericCredWrapper,
GenericVerifiableCredential,
GiveVerifiableCredential,
OfferVerifiableCredential,
} from "../interfaces";
import {
capitalizeAndInsertSpacesBeforeCaps,
didInfoForContact,
displayAmount,
getHeaders,
register,
setVisibilityUtil,
} from "../libs/endorserServer";
@@ -250,6 +263,8 @@ import EntityIcon from "../components/EntityIcon.vue";
})
export default class DIDView extends Vue {
$notify!: (notification: NotificationIface, timeout?: number) => void;
$route!: RouteLocationNormalizedLoaded;
$router!: Router;
libsUtil = libsUtil;
yaml = yaml;
@@ -352,7 +367,7 @@ export default class DIDView extends Vue {
},
3000,
);
(this.$router as Router).push({ name: "contacts" });
this.$router.push({ name: "contacts" });
}
// confirm to register a new contact
@@ -505,7 +520,7 @@ export default class DIDView extends Vue {
const route = {
path: "/claim/" + encodeURIComponent(jwtId),
};
(this.$router as Router).push(route);
this.$router.push(route);
}
public claimAmount(claim: GenericVerifiableCredential) {