You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
976 B
TypeScript
27 lines
976 B
TypeScript
import urlJoin from 'url-join';
|
|
|
|
import { appEnv } from '@/config/app';
|
|
import { DEFAULT_LANG, isLocaleNotSupport } from '@/const/locale';
|
|
import { Locales, normalizeLocale } from '@/locales/resources';
|
|
|
|
export class AssistantStore {
|
|
private readonly baseUrl: string;
|
|
|
|
constructor(baseUrl?: string) {
|
|
this.baseUrl = baseUrl || appEnv.AGENTS_INDEX_URL;
|
|
}
|
|
|
|
getAgentIndexUrl = (lang: Locales = DEFAULT_LANG) => {
|
|
if (isLocaleNotSupport(lang)) return this.baseUrl;
|
|
console.log(urlJoin(this.baseUrl, `index.${normalizeLocale(lang)}.json`),928272772727)
|
|
return urlJoin(this.baseUrl, `index.${normalizeLocale(lang)}.json`);
|
|
};
|
|
|
|
getAgentUrl = (identifier: string, lang: Locales = DEFAULT_LANG) => {
|
|
console.log(urlJoin(this.baseUrl, `${identifier}.json`),88888888888888888888)
|
|
if (isLocaleNotSupport(lang)) return urlJoin(this.baseUrl, `${identifier}.json`);
|
|
|
|
return urlJoin(this.baseUrl, `${identifier}.${normalizeLocale(lang)}.json`);
|
|
};
|
|
}
|