refactor: extract navigator into store instead
This commit is contained in:
parent
caa3e59777
commit
6b29d3b017
10 changed files with 68 additions and 76 deletions
19
src/stores/navigator/index.ts
Normal file
19
src/stores/navigator/index.ts
Normal 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 };
|
||||
});
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue