设置默认语言

This commit is contained in:
wenyann 2020-05-14 18:36:09 +08:00
parent 8ca36edc88
commit e0f99b4d8a
4 changed files with 20 additions and 6 deletions

View File

@ -13,4 +13,5 @@ public interface ExtUserMapper {
int updatePassword(User record);
String getDefaultLanguage(String paramKey);
}

View File

@ -1,6 +1,7 @@
package io.metersphere.controller;
import io.metersphere.base.domain.UserRole;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.request.LoginRequest;
import io.metersphere.dto.UserDTO;
import io.metersphere.service.UserService;
@ -88,7 +89,7 @@ public class LoginController {
}
/*Get default language*/
@PostMapping(value = "/language")
@GetMapping(value = "/language")
public String getDefaultLanguage() {
return userService.getDefaultLanguage();
}

View File

@ -349,4 +349,5 @@ public class UserService {
final String key = "registry.defaultlanguage";
return extUserMapper.getDefaultLanguage(key);
}
}

View File

@ -42,6 +42,7 @@
<script>
import {saveLocalStorage} from '../common/js/utils';
import {TokenKey} from "../common/js/constants";
export default {
@ -107,20 +108,30 @@
this.$post("signin", this.form, response => {
saveLocalStorage(response);
let language = response.data.language;
if (!language) {
this.$post("language", response => {
language = response.data.language
if (language == "") {
this.$get("language", response => {
language = response.data
this.$setLang(language);
this.changeLanguage();
})
}
window.location.href = "/"
});
} else {
return false;
}
});
},
changeLanguage(language) {
let user = {
id: this.currentUser().id,
language: language
};
this.checkLanguage(language);
this.result = this.$post("/user/update/current", user, response => {
localStorage.setItem(TokenKey, JSON.stringify(response.data));
});
}
}
}