mirror of
https://github.com/haexhub/haex-hub.git
synced 2025-12-17 14:30:52 +01:00
init commit
This commit is contained in:
57
src/stores/extensions/index.ts
Normal file
57
src/stores/extensions/index.ts
Normal file
@ -0,0 +1,57 @@
|
||||
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,
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user