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