2016-07-27 14:15:02 +08:00
|
|
|
<template>
|
2017-09-29 11:36:38 +08:00
|
|
|
<div id="app" :class="{ 'is-component': isComponent }">
|
2016-11-13 02:34:39 +08:00
|
|
|
<main-header v-if="lang !== 'play'"></main-header>
|
2016-08-23 19:15:15 +08:00
|
|
|
<div class="main-cnt">
|
|
|
|
<router-view></router-view>
|
|
|
|
</div>
|
2017-09-29 11:36:38 +08:00
|
|
|
<main-footer v-if="lang !== 'play' && !isComponent"></main-footer>
|
2016-07-27 17:05:28 +08:00
|
|
|
</div>
|
2016-07-27 14:15:02 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2016-11-10 21:46:55 +08:00
|
|
|
import { use } from 'main/locale';
|
|
|
|
import zhLocale from 'main/locale/lang/zh-CN';
|
|
|
|
import enLocale from 'main/locale/lang/en';
|
2017-11-06 19:22:02 +08:00
|
|
|
import esLocale from 'main/locale/lang/es';
|
2019-02-12 09:08:19 +08:00
|
|
|
import frLocale from 'main/locale/lang/fr';
|
2017-11-06 19:22:02 +08:00
|
|
|
|
|
|
|
const lang = location.hash.replace('#', '').split('/')[1] || 'zh-CN';
|
|
|
|
const localize = lang => {
|
|
|
|
switch (lang) {
|
|
|
|
case 'zh-CN':
|
|
|
|
use(zhLocale);
|
|
|
|
break;
|
|
|
|
case 'es':
|
|
|
|
use(esLocale);
|
|
|
|
break;
|
2019-02-12 09:08:19 +08:00
|
|
|
case 'fr-FR':
|
|
|
|
use(frLocale);
|
|
|
|
break;
|
2017-11-06 19:22:02 +08:00
|
|
|
default:
|
|
|
|
use(enLocale);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
localize(lang);
|
2016-11-10 21:46:55 +08:00
|
|
|
|
2016-07-27 14:15:02 +08:00
|
|
|
export default {
|
2016-09-08 18:11:18 +08:00
|
|
|
name: 'app',
|
2016-11-10 21:46:55 +08:00
|
|
|
|
|
|
|
computed: {
|
|
|
|
lang() {
|
|
|
|
return this.$route.path.split('/')[1] || 'zh-CN';
|
2017-09-29 11:36:38 +08:00
|
|
|
},
|
|
|
|
isComponent() {
|
|
|
|
return /^component-/.test(this.$route.name || '');
|
2016-11-10 21:46:55 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
2017-10-28 15:54:12 +08:00
|
|
|
lang(val) {
|
|
|
|
if (val === 'zh-CN') {
|
|
|
|
this.suggestJump();
|
|
|
|
}
|
2017-11-06 19:22:02 +08:00
|
|
|
localize(val);
|
2016-11-10 21:46:55 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-11-04 16:59:59 +08:00
|
|
|
methods: {
|
2017-10-28 15:54:12 +08:00
|
|
|
suggestJump() {
|
2018-05-09 18:02:47 +08:00
|
|
|
if (process.env.NODE_ENV !== 'production') return;
|
|
|
|
|
2017-10-28 15:54:12 +08:00
|
|
|
const href = location.href;
|
|
|
|
const preferGithub = localStorage.getItem('PREFER_GITHUB');
|
2019-04-16 19:00:32 +08:00
|
|
|
const cnHref = href.indexOf('eleme.cn') > -1 || href.indexOf('element-cn') > -1 || href.indexOf('element.faas') > -1;
|
|
|
|
if (cnHref || preferGithub) return;
|
2017-10-28 15:54:12 +08:00
|
|
|
setTimeout(() => {
|
2017-11-09 15:12:55 +08:00
|
|
|
if (this.lang !== 'zh-CN') return;
|
2017-10-28 15:54:12 +08:00
|
|
|
this.$confirm('建议大陆用户访问部署在国内的站点,是否跳转?', '提示')
|
|
|
|
.then(() => {
|
2019-04-16 19:00:32 +08:00
|
|
|
location.replace('https://element.eleme.cn');
|
2017-10-28 15:54:12 +08:00
|
|
|
})
|
|
|
|
.catch(() => {
|
2018-01-14 20:40:52 +08:00
|
|
|
localStorage.setItem('PREFER_GITHUB', 'true');
|
2017-10-28 15:54:12 +08:00
|
|
|
});
|
|
|
|
}, 1000);
|
2016-11-04 16:59:59 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
2017-11-06 19:22:02 +08:00
|
|
|
localize(this.lang);
|
2017-10-28 15:54:12 +08:00
|
|
|
if (this.lang === 'zh-CN') {
|
|
|
|
this.suggestJump();
|
|
|
|
}
|
2016-09-08 18:11:18 +08:00
|
|
|
}
|
2016-07-27 14:15:02 +08:00
|
|
|
};
|
|
|
|
</script>
|