36 lines
959 B
Plaintext
36 lines
959 B
Plaintext
import request from "./useRequest";
|
|
import type { RequestResponse } from "@/types/interfaces/request";
|
|
import type { I18nLangDto } from "@/types/interfaces/i18n";
|
|
import { I18N_SET_LANG_API } from "@/constants/i18n.constants";
|
|
|
|
export type LangMap = Record<string, string>;
|
|
|
|
// 查询语言列表
|
|
export function apiI18nLangList() {
|
|
return request<RequestResponse<I18nLangDto[]>>({
|
|
url: "/api/i18n/lang/list",
|
|
method: "GET",
|
|
});
|
|
}
|
|
|
|
// 查询语言字典
|
|
export function apiI18nQuery(lang: string = "") {
|
|
const side = "Mobile";
|
|
const query = lang
|
|
? `?lang=${encodeURIComponent(lang)}&side=${side}`
|
|
: `?side=${side}`;
|
|
return request<RequestResponse<LangMap>>({
|
|
url: `/api/i18n/query${query}`,
|
|
method: "GET",
|
|
});
|
|
}
|
|
|
|
// 设置用户语言(后端专用接口)
|
|
export function apiI18nSetLang(lang: string) {
|
|
return request<RequestResponse<any>>({
|
|
url: I18N_SET_LANG_API,
|
|
method: "POST",
|
|
data: { lang },
|
|
});
|
|
}
|