mirror of https://gitee.com/answerdev/answer.git
Merge branch 'ui-v0.3' of git.backyard.segmentfault.com:opensource/answer into ui-v0.3
This commit is contained in:
commit
b7e1815829
|
@ -1,5 +1,5 @@
|
|||
export const DEFAULT_LANG = 'en_US';
|
||||
export const CURRENT_LANG_STORAGE_KEY = '_a_lang__';
|
||||
export const CURRENT_LANG_STORAGE_KEY = '_a_lang_';
|
||||
export const LOGGED_USER_STORAGE_KEY = '_a_lui_';
|
||||
export const LOGGED_TOKEN_STORAGE_KEY = '_a_ltk_';
|
||||
export const REDIRECT_PATH_STORAGE_KEY = '_a_rp_';
|
||||
|
|
|
@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next';
|
|||
|
||||
import type { LangsType, FormValue, FormDataType } from '@/common/interface';
|
||||
import Progress from '../Progress';
|
||||
import { getInstallLangOptions } from '@/services';
|
||||
import { getLanguageOptions } from '@/services';
|
||||
|
||||
interface Props {
|
||||
data: FormValue;
|
||||
|
@ -18,7 +18,7 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
|
|||
const [langs, setLangs] = useState<LangsType[]>();
|
||||
|
||||
const getLangs = async () => {
|
||||
const res: LangsType[] = await getInstallLangOptions();
|
||||
const res: LangsType[] = await getLanguageOptions();
|
||||
setLangs(res);
|
||||
changeCallback({
|
||||
lang: {
|
||||
|
|
|
@ -10,6 +10,8 @@ import {
|
|||
installBaseInfo,
|
||||
checkConfigFileExists,
|
||||
} from '@/services';
|
||||
import { Storage } from '@/utils';
|
||||
import { CURRENT_LANG_STORAGE_KEY } from '@/common/constants';
|
||||
|
||||
import {
|
||||
FirstStep,
|
||||
|
@ -170,13 +172,20 @@ const Index: FC = () => {
|
|||
};
|
||||
|
||||
const handleStep = () => {
|
||||
if (step === 1) {
|
||||
Storage.set(CURRENT_LANG_STORAGE_KEY, formData.lang.value);
|
||||
handleNext();
|
||||
}
|
||||
if (step === 2) {
|
||||
submitDatabaseForm();
|
||||
} else if (step === 3) {
|
||||
}
|
||||
if (step === 3) {
|
||||
checkInstall();
|
||||
} else if (step === 4) {
|
||||
}
|
||||
if (step === 4) {
|
||||
submitSiteConfig();
|
||||
} else {
|
||||
}
|
||||
if (step > 4) {
|
||||
handleNext();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -2,7 +2,8 @@ import dayjs from 'dayjs';
|
|||
import i18next from 'i18next';
|
||||
|
||||
import { interfaceStore, loggedUserInfoStore } from '@/stores';
|
||||
import { DEFAULT_LANG } from '@/common/constants';
|
||||
import { DEFAULT_LANG, CURRENT_LANG_STORAGE_KEY } from '@/common/constants';
|
||||
import { Storage } from '@/utils';
|
||||
|
||||
const localDayjs = (langName) => {
|
||||
langName = langName.replace('_', '-').toLowerCase();
|
||||
|
@ -12,12 +13,13 @@ const localDayjs = (langName) => {
|
|||
export const getCurrentLang = () => {
|
||||
const loggedUser = loggedUserInfoStore.getState().user;
|
||||
const adminInterface = interfaceStore.getState().interface;
|
||||
const storageLang = Storage.get(CURRENT_LANG_STORAGE_KEY);
|
||||
let currentLang = loggedUser.language;
|
||||
// `default` mean use language value from admin interface
|
||||
if (/default/i.test(currentLang) && adminInterface.language) {
|
||||
currentLang = adminInterface.language;
|
||||
}
|
||||
currentLang ||= DEFAULT_LANG;
|
||||
currentLang ||= storageLang || DEFAULT_LANG;
|
||||
return currentLang;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue