refactor: extract navigator into store instead

This commit is contained in:
Methapon Metanipat 2024-10-30 11:55:43 +07:00
parent caa3e59777
commit 6b29d3b017
10 changed files with 68 additions and 76 deletions

View file

@ -0,0 +1,19 @@
import { defineStore } from 'pinia';
import { ref } from 'vue';
export const useNavigator = defineStore('navigator-store', () => {
const current = ref<{
title: string;
path: {
text: string;
i18n?: boolean;
argsi18n?: Record<string, string>;
handler?: () => unknown;
}[];
}>({
title: '',
path: [{ text: '', handler: () => {} }],
});
return { current };
});

View file

@ -207,30 +207,6 @@ export function checkTabBeforeAdd(data: unknown[], except?: string[]) {
return canAdd;
}
const useUtilsStore = defineStore('utilsStore', () => {
const currentTitle = ref<{
title: string;
path: {
text: string;
i18n?: boolean;
argsi18n?: Record<string, string>;
handler?: () => unknown;
}[];
}>({
title: '',
path: [
{
text: '',
handler: () => {},
},
],
});
return {
currentTitle,
};
});
export function isRoleInclude(role2check: string[]): boolean {
const roles = getRole() ?? [];
const isIncluded = role2check.some((r) => roles.includes(r));
@ -521,5 +497,3 @@ export function createDataRefBase<T>(
pageSize: ref<number>(defaultPageSize),
};
}
export default useUtilsStore;