mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-20 12:56:55 +08:00
### What problem does this PR solve? fix: Set the default value of Self RAG to false #1220 fix: Change all tool file names to kebab format ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
58
web/src/utils/authorization-util.ts
Normal file
58
web/src/utils/authorization-util.ts
Normal file
@ -0,0 +1,58 @@
|
||||
import { Authorization, Token, UserInfo } from '@/constants/authorization';
|
||||
import { getSearchValue } from './common-util';
|
||||
const KeySet = [Authorization, Token, UserInfo];
|
||||
|
||||
const storage = {
|
||||
getAuthorization: () => {
|
||||
return localStorage.getItem(Authorization);
|
||||
},
|
||||
getToken: () => {
|
||||
return localStorage.getItem(Token);
|
||||
},
|
||||
getUserInfo: () => {
|
||||
return localStorage.getItem(UserInfo);
|
||||
},
|
||||
getUserInfoObject: () => {
|
||||
return JSON.parse(localStorage.getItem('userInfo') || '');
|
||||
},
|
||||
setAuthorization: (value: string) => {
|
||||
localStorage.setItem(Authorization, value);
|
||||
},
|
||||
setToken: (value: string) => {
|
||||
localStorage.setItem(Token, value);
|
||||
},
|
||||
setUserInfo: (value: string | Record<string, unknown>) => {
|
||||
let valueStr = typeof value !== 'string' ? JSON.stringify(value) : value;
|
||||
localStorage.setItem(UserInfo, valueStr);
|
||||
},
|
||||
setItems: (pairs: Record<string, string>) => {
|
||||
Object.entries(pairs).forEach(([key, value]) => {
|
||||
localStorage.setItem(key, value);
|
||||
});
|
||||
},
|
||||
removeAuthorization: () => {
|
||||
localStorage.removeItem(Authorization);
|
||||
},
|
||||
removeAll: () => {
|
||||
KeySet.forEach((x) => {
|
||||
localStorage.removeItem(x);
|
||||
});
|
||||
},
|
||||
setLanguage: (lng: string) => {
|
||||
localStorage.setItem('lng', lng);
|
||||
},
|
||||
getLanguage: (): string => {
|
||||
return localStorage.getItem('lng') as string;
|
||||
},
|
||||
};
|
||||
|
||||
export const getAuthorization = () => {
|
||||
const sharedId = getSearchValue('shared_id');
|
||||
const authorization = sharedId
|
||||
? 'Bearer ' + sharedId
|
||||
: storage.getAuthorization() || '';
|
||||
|
||||
return authorization;
|
||||
};
|
||||
|
||||
export default storage;
|
||||
Reference in New Issue
Block a user