Commit a3906e5d by liuxin

切换语种

parent f055bcc6
...@@ -3,8 +3,12 @@ import VueI18n from "vue-i18n"; ...@@ -3,8 +3,12 @@ import VueI18n from "vue-i18n";
import Cookies from "js-cookie"; import Cookies from "js-cookie";
import elementEnLocale from "element-ui/lib/locale/lang/en"; // element-ui lang import elementEnLocale from "element-ui/lib/locale/lang/en"; // element-ui lang
import elementZhLocale from "element-ui/lib/locale/lang/zh-CN"; // element-ui lang import elementZhLocale from "element-ui/lib/locale/lang/zh-CN"; // element-ui lang
import elementThLocale from "element-ui/lib/locale/lang/th"; // element-ui lang
import elementViLocale from "element-ui/lib/locale/lang/vi"; // element-ui lang
import enLocale from "./local/en/"; import enLocale from "./local/en/";
import zhLocale from "./local/zh/"; import zhLocale from "./local/zh/";
import thLocale from "./local/en/"; //TODO 本地th暂无
import viLocale from "./local/en/"; //TODO 本地vi暂无
/** /**
* 详细文档 * 详细文档
...@@ -21,6 +25,14 @@ const messages = { ...@@ -21,6 +25,14 @@ const messages = {
...zhLocale, ...zhLocale,
...elementZhLocale, ...elementZhLocale,
}, },
th: {
...thLocale,
...elementThLocale,
},
vi: {
...viLocale,
...elementViLocale,
},
}; };
export function getLanguage() { export function getLanguage() {
const chooseLanguage = Cookies.get("language"); const chooseLanguage = Cookies.get("language");
......
import Api from "~/service/Api"
export function changeLang(data) {
return Api.post('/business/lang/changeLang', data)
}
\ No newline at end of file
...@@ -122,6 +122,9 @@ ...@@ -122,6 +122,9 @@
<script> <script>
import cPage from "../../components/c-page.vue"; import cPage from "../../components/c-page.vue";
import Api from "~/service/Api";
import { changeLang } from "~/service/business/lang";
export default { export default {
components: { cPage }, components: { cPage },
data() { data() {
...@@ -146,6 +149,8 @@ export default { ...@@ -146,6 +149,8 @@ export default {
languageOptions: [ languageOptions: [
{ lang: "zh", shortName: "中文", fullName: "中文" }, { lang: "zh", shortName: "中文", fullName: "中文" },
{ lang: "en", shortName: "En", fullName: "English" }, { lang: "en", shortName: "En", fullName: "English" },
{ lang: "th", shortName: "ไทย", fullName: "ภาษาไทย" },
{ lang: "vi", shortName: "Tiếng Việt", fullName: "Tiếng Việt" },
], ],
}; };
}, },
...@@ -175,10 +180,16 @@ export default { ...@@ -175,10 +180,16 @@ export default {
this.$router.push("/login"); this.$router.push("/login");
// window.location.href = "/#/login" // window.location.href = "/#/login"
}, },
handleLang(lang) { async handleLang(lang) {
const data = {
lang: lang
}
let rtnmsg = await changeLang(data)
if (rtnmsg.respCode == SUCCESS) {
this.$i18n.locale = lang; this.$i18n.locale = lang;
this.$store.dispatch("I18n/setLang", lang); this.$store.dispatch("I18n/setLang", lang);
this.langSelectVisible = false; this.langSelectVisible = false;
}
}, },
showLogoutDialog(flg) { showLogoutDialog(flg) {
// this.$refs.logoutform.show(flg); // this.$refs.logoutform.show(flg);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment