import { IFile } from "./interface"; export const configSrore: { userToken: string; userGroupHash: string; podspaceUrl: string; clasorUrl: string; resourceId?: number; onRefresh?: () => Promise; onError?: (err: any) => void; onSelectItem?: (fileItem: IFile) => void; } = { userToken: "", userGroupHash: "", podspaceUrl: "", clasorUrl: "", }; export const setValue = ( name: string, value: string | number | (() => Promise) | ((fileItem: IFile) => void) | ((err: any) => void), ) => { switch (name) { case "userToken": configSrore.userToken = value as string; break; case "userGroupHash": configSrore.userGroupHash = value as string; break; case "podspaceUrl": configSrore.podspaceUrl = value as string; break; case "clasorUrl": configSrore.clasorUrl = value as string; break; case "resourceId": configSrore.resourceId = value as number; break; case "onRefresh": configSrore.onRefresh = value as () => Promise; break; case "onError": configSrore.onError = value as (err: any) => void; break; case "onSelectItem": configSrore.onSelectItem = value as (fileItem: IFile) => void; break; default: console.log("Error: key not exists"); } };