mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-10-12 08:00:34 +00:00
18 lines
694 B
Go
18 lines
694 B
Go
import { storeToRefs } from 'pinia';
|
|
import GlobalStore from '@/store/modules/global';
|
|
import { bindSearchPersistence } from '@/utils/search-persistence';
|
|
|
|
/** Restore the parent's search fields synchronously, before its initial request. */
|
|
export const useSearchPersistence = (
|
|
page: string,
|
|
fields: Parameters<typeof bindSearchPersistence>[1],
|
|
scope?: () => string | number | undefined,
|
|
) => {
|
|
const { currentNode } = storeToRefs(GlobalStore());
|
|
return bindSearchPersistence(() => {
|
|
const context = scope?.();
|
|
if (scope && context === undefined) return undefined;
|
|
return JSON.stringify([currentNode.value, page, context ?? '']);
|
|
}, fields);
|
|
};
|