refactor: Overhaul Plugin Architecture & Playground UI (#1846)
* refactor: Move Plugins Out and Consolidate with Multisrc * feat: Overhaul Playground UI * feat: Add Filters to New UI * feat: Persist Selected Plugin * feat: Add Direct Parse Novel/Chapter Options and Feedback Toasts [skip ci] * feat: UX Improvements * chore: Update Plugin Path in Publish Workflow * fix: Add Backward Compatibility * chore: Update Plugin Publishing Script
This commit is contained in:
committed by
GitHub
parent
252beff0bf
commit
20c2b75b01
@@ -0,0 +1,36 @@
|
||||
import { useCallback } from 'react';
|
||||
|
||||
export const useQueryParams = () => {
|
||||
const getParam = useCallback((key: string): string | null => {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
return urlParams.get(key);
|
||||
}, []);
|
||||
|
||||
const setParam = useCallback((key: string, value: string) => {
|
||||
const url = new URL(window.location.href);
|
||||
url.searchParams.set(key, value);
|
||||
window.history.pushState({}, '', url);
|
||||
}, []);
|
||||
|
||||
const removeParam = useCallback((key: string) => {
|
||||
const url = new URL(window.location.href);
|
||||
url.searchParams.delete(key);
|
||||
window.history.pushState({}, '', url);
|
||||
}, []);
|
||||
|
||||
const getAllParams = useCallback((): Record<string, string> => {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const result: Record<string, string> = {};
|
||||
urlParams.forEach((value, key) => {
|
||||
result[key] = value;
|
||||
});
|
||||
return result;
|
||||
}, []);
|
||||
|
||||
return {
|
||||
getParam,
|
||||
setParam,
|
||||
removeParam,
|
||||
getAllParams,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user