mirror of
https://github.com/haexhub/haex-hub.git
synced 2025-12-17 06:30:50 +01:00
58 lines
1.2 KiB
TypeScript
58 lines
1.2 KiB
TypeScript
import { getSingleRouteParam } from '~/composables/helper';
|
|
import type { RouteLocationRaw } from 'vue-router';
|
|
|
|
export interface IExtensionLink {
|
|
name: string;
|
|
icon: string;
|
|
tooltip?: string;
|
|
id: string;
|
|
}
|
|
|
|
export const useExtensionsStore = defineStore('extensionsStore', () => {
|
|
const extensions = ref<IExtensionLink[]>([
|
|
{
|
|
id: 'haex-browser',
|
|
name: 'Haex Browser',
|
|
icon: 'solar:global-outline',
|
|
},
|
|
|
|
{
|
|
id: 'extensions',
|
|
name: 'sidebar.extensions',
|
|
icon: 'gg:extension',
|
|
},
|
|
|
|
{
|
|
id: 'settings',
|
|
name: 'sidebar.settings',
|
|
icon: 'ph:gear-six',
|
|
},
|
|
]);
|
|
|
|
const currentRoute = useRouter().currentRoute.value;
|
|
|
|
const isActive = (id: string) =>
|
|
computed(
|
|
() =>
|
|
currentRoute.name === 'extension' &&
|
|
currentRoute.params.extensionId === id
|
|
);
|
|
|
|
const loadAsync = async (id: string) => {
|
|
extensions.value.some(async (extension) => {
|
|
if (extension.id === id) {
|
|
await navigateTo(
|
|
useLocalePath()({ name: 'extension', params: { extensionId: id } })
|
|
);
|
|
} else {
|
|
}
|
|
});
|
|
};
|
|
|
|
return {
|
|
extensions,
|
|
loadAsync,
|
|
isActive,
|
|
};
|
|
});
|