@lobehub/chat
Version:
Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.
32 lines (27 loc) • 930 B
text/typescript
import { DeepPartial } from 'utility-types';
import { LOBE_URL_IMPORT_NAME } from '@/const/url';
import { UserSettings } from '@/types/user/settings';
import { withBasePath } from '@/utils/basePath';
class ShareService {
/**
* Creates a share settings URL with the provided settings.
* @param settings - The settings object to be encoded in the URL.
* @returns The share settings URL.
*/
public createShareSettingsUrl = (settings: DeepPartial<UserSettings>) => {
return withBasePath(`/?${LOBE_URL_IMPORT_NAME}=${encodeURI(JSON.stringify(settings))}`);
};
/**
* Decode share settings from search params
* @param settings
* @returns
*/
decodeShareSettings = (settings: string) => {
try {
return { data: JSON.parse(settings) as DeepPartial<UserSettings> };
} catch (e) {
return { message: JSON.stringify(e) };
}
};
}
export const shareService = new ShareService();