设置默认语言
This commit is contained in:
parent
8ca36edc88
commit
e0f99b4d8a
|
@ -13,4 +13,5 @@ public interface ExtUserMapper {
|
||||||
int updatePassword(User record);
|
int updatePassword(User record);
|
||||||
|
|
||||||
String getDefaultLanguage(String paramKey);
|
String getDefaultLanguage(String paramKey);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package io.metersphere.controller;
|
package io.metersphere.controller;
|
||||||
|
|
||||||
import io.metersphere.base.domain.UserRole;
|
import io.metersphere.base.domain.UserRole;
|
||||||
|
import io.metersphere.commons.utils.SessionUtils;
|
||||||
import io.metersphere.controller.request.LoginRequest;
|
import io.metersphere.controller.request.LoginRequest;
|
||||||
import io.metersphere.dto.UserDTO;
|
import io.metersphere.dto.UserDTO;
|
||||||
import io.metersphere.service.UserService;
|
import io.metersphere.service.UserService;
|
||||||
|
@ -88,7 +89,7 @@ public class LoginController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Get default language*/
|
/*Get default language*/
|
||||||
@PostMapping(value = "/language")
|
@GetMapping(value = "/language")
|
||||||
public String getDefaultLanguage() {
|
public String getDefaultLanguage() {
|
||||||
return userService.getDefaultLanguage();
|
return userService.getDefaultLanguage();
|
||||||
}
|
}
|
||||||
|
|
|
@ -349,4 +349,5 @@ public class UserService {
|
||||||
final String key = "registry.defaultlanguage";
|
final String key = "registry.defaultlanguage";
|
||||||
return extUserMapper.getDefaultLanguage(key);
|
return extUserMapper.getDefaultLanguage(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {saveLocalStorage} from '../common/js/utils';
|
import {saveLocalStorage} from '../common/js/utils';
|
||||||
|
import {TokenKey} from "../common/js/constants";
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -107,20 +108,30 @@
|
||||||
this.$post("signin", this.form, response => {
|
this.$post("signin", this.form, response => {
|
||||||
saveLocalStorage(response);
|
saveLocalStorage(response);
|
||||||
let language = response.data.language;
|
let language = response.data.language;
|
||||||
if (!language) {
|
|
||||||
this.$post("language", response => {
|
if (language == "") {
|
||||||
language = response.data.language
|
this.$get("language", response => {
|
||||||
|
language = response.data
|
||||||
this.$setLang(language);
|
this.$setLang(language);
|
||||||
|
this.changeLanguage();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
window.location.href = "/"
|
window.location.href = "/"
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return false;
|
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));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue