Implementation:Infiniflow Ragflow Simple History Util
| Knowledge Sources | |
|---|---|
| Domains | Frontend, Routing, Infrastructure |
| Last Updated | 2026-02-12 06:00 GMT |
Overview
Concrete lightweight browser history management abstraction with event listener support for programmatic navigation in the RAGFlow frontend.
Description
The utils/simple-history-util.ts module provides a framework-agnostic browser history wrapper with push, replace, go, back, forward methods and a listener system for reacting to navigation changes. It wraps the browser History API with additional state tracking.
Usage
Import this utility for programmatic navigation in contexts outside React Router, such as HTTP interceptors or standalone utility functions.
Code Reference
Source Location
- Repository: Infiniflow_Ragflow
- File: web/src/utils/simple-history-util.ts
- Lines: 1-125
Signature
export const history: {
push(path: string, state?: any): void;
replace(path: string, state?: any): void;
go(n: number): void;
back(): void;
forward(): void;
listen(callback: (location: Location) => void): () => void;
location: Location;
};
Import
import { history } from '@/utils/simple-history-util';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| path | string | Yes | Navigation target path |
| state | any | No | History state object |
Outputs
| Name | Type | Description |
|---|---|---|
| history.location | Location | Current browser location |
| listen() returns | function | Unsubscribe function |
Usage Examples
import { history } from '@/utils/simple-history-util';
// Redirect to login from interceptor
history.push('/login');
// Listen for navigation
const unlisten = history.listen((location) => {
console.log('Navigated to:', location.pathname);
});