element/examples/app.vue

270 lines
5.6 KiB
Vue
Raw Normal View History

2016-07-27 14:15:02 +08:00
<style lang="css">
2016-11-01 18:28:20 +08:00
@import 'highlight.js/styles/color-brewer.css';
2016-07-27 14:15:02 +08:00
@import 'assets/styles/common.css';
2017-01-23 16:02:58 +08:00
@import 'assets/styles/fonts/style.css';
2016-07-27 14:15:02 +08:00
html, body {
margin: 0;
padding: 0;
2016-08-23 19:15:15 +08:00
height: 100%;
font-family: 'Helvetica Neue',Helvetica,'PingFang SC','Hiragino Sans GB','Microsoft YaHei',SimSun,sans-serif;
font-weight: 400;
-webkit-font-smoothing: antialiased;
&.is-component {
overflow: hidden;
}
2016-07-27 14:15:02 +08:00
}
2016-08-23 19:15:15 +08:00
#app {
height: 100%;
@when component {
overflow-y: hidden;
.main-cnt {
padding: 0;
margin-top: 0;
height: 100%;
min-height: auto;
}
.headerWrapper {
position: fixed;
width: 100%;
left: 0;
top: 0;
2017-09-29 15:37:50 +08:00
z-index: 1500;
.container {
padding: 0;
}
}
}
2016-08-23 16:57:58 +08:00
}
2017-01-12 17:24:02 +08:00
a {
color: #409EFF;
2017-01-23 16:02:58 +08:00
text-decoration: none;
}
code {
background-color: #f9fafc;
padding: 0 4px;
border: 1px solid #eaeefb;
border-radius: 4px;
}
2017-01-23 16:02:58 +08:00
button, input, select, textarea {
font-family: inherit;
font-size: inherit;
line-height: inherit;
color: inherit;
2016-09-28 12:35:24 +08:00
}
2016-08-30 19:30:58 +08:00
.hljs {
2016-09-18 22:01:26 +08:00
line-height: 1.8;
font-family: Menlo, Monaco, Consolas, Courier, monospace;
font-size: 12px;
padding: 18px 24px;
2017-09-29 15:37:50 +08:00
background-color: #fafafa;
2016-09-18 22:01:26 +08:00
border: solid 1px #eaeefb;
2016-08-30 19:30:58 +08:00
margin-bottom: 25px;
border-radius: 4px;
2016-09-20 17:09:18 +08:00
-webkit-font-smoothing: auto;
2016-08-30 19:30:58 +08:00
}
2016-08-23 19:15:15 +08:00
.main-cnt {
margin-top: -80px;
2017-10-25 11:58:58 +08:00
padding: 80px 0 340px;
2016-07-27 14:15:02 +08:00
box-sizing: border-box;
2016-08-23 19:15:15 +08:00
min-height: 100%;
2016-07-27 14:15:02 +08:00
}
2016-08-25 15:54:45 +08:00
.container,
.page-container {
2016-09-13 20:02:33 +08:00
width: 1140px;
padding: 0;
2016-08-25 15:54:45 +08:00
margin: 0 auto;
}
.page-container {
padding-top: 55px;
h2 {
font-size: 28px;
color: #1f2d3d;
margin: 0;
}
h3 {
font-size: 22px;
}
h2, h3, h4, h5 {
font-weight: normal;
color: #1f2f3d;
2016-11-04 16:59:59 +08:00
&:hover a {
opacity: .4;
}
a {
float: left;
margin-left: -20px;
opacity: 0;
cursor: pointer;
&:hover {
opacity: .4;
}
}
2016-08-25 15:54:45 +08:00
}
2016-08-25 15:54:45 +08:00
p {
font-size: 14px;
color: #5e6d82;
line-height: 1.5em;
}
.tip {
padding: 8px 16px;
background-color: #ECF8FF;
border-radius: 4px;
border-left: #50bfff 5px solid;
2017-09-29 15:37:50 +08:00
margin: 20px 0;
code {
background-color: rgba(255, 255, 255, .7);
color: #445368;
}
2016-08-25 15:54:45 +08:00
}
.warning {
2017-09-29 15:37:50 +08:00
padding: 8px 16px;
background-color: #fff6f7;
border-radius: 4px;
border-left: #FE6C6F 5px solid;
margin: 20px 0;
code {
background-color: rgba(255, 255, 255, .7);
color: #445368;
}
}
2016-07-27 14:15:02 +08:00
}
.demo {
margin: 20px 0;
}
2016-09-14 18:38:38 +08:00
@media (max-width: 1140px) {
.container,
.page-container {
width: 100%;
}
}
2016-11-18 16:49:07 +08:00
@media (max-width: 768px) {
.container,
.page-container {
padding: 0 20px;
}
2017-10-03 16:46:07 +08:00
#app.is-component .headerWrapper .container {
padding: 0 12px;
}
2016-11-18 16:49:07 +08:00
}
2016-07-27 14:15:02 +08:00
</style>
<template>
<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>
<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>
import { use } from 'main/locale';
import zhLocale from 'main/locale/lang/zh-CN';
import enLocale from 'main/locale/lang/en';
use(location.href.indexOf('zh-CN') > -1 ? zhLocale : enLocale);
2016-07-27 14:15:02 +08:00
export default {
2016-09-08 18:11:18 +08:00
name: 'app',
computed: {
lang() {
return this.$route.path.split('/')[1] || 'zh-CN';
},
isComponent() {
return /^component-/.test(this.$route.name || '');
}
},
watch: {
2017-10-28 15:54:12 +08:00
lang(val) {
if (val === 'zh-CN') {
this.suggestJump();
}
this.localize();
}
},
2016-11-04 16:59:59 +08:00
methods: {
localize() {
use(this.lang === 'zh-CN' ? zhLocale : enLocale);
2017-10-28 15:54:12 +08:00
},
suggestJump() {
const href = location.href;
const preferGithub = localStorage.getItem('PREFER_GITHUB');
if (href.indexOf('element-cn') > -1 || preferGithub) return;
setTimeout(() => {
this.$confirm('建议大陆用户访问部署在国内的站点,是否跳转?', '提示')
.then(() => {
location.href = location.href.replace('element.', 'element-cn.');
})
.catch(() => {
localStorage.setItem('PREFER_GITHUB', true);
});
}, 1000);
2016-11-04 16:59:59 +08:00
}
},
mounted() {
this.localize();
2017-10-28 15:54:12 +08:00
if (this.lang === 'zh-CN') {
this.suggestJump();
}
2017-10-27 11:30:04 +08:00
setTimeout(() => {
const notified = localStorage.getItem('RELEASE_NOTIFIED');
if (!notified) {
const h = this.$createElement;
const title = this.lang === 'zh-CN'
? '2.0 正式发布'
: '2.0 available now';
const messages = this.lang === 'zh-CN'
? ['点击', '这里', '查看详情']
: ['Click ', 'here', ' to learn more'];
this.$notify({
title,
duration: 0,
message: h('span', [
messages[0],
h('a', {
attrs: {
target: '_blank',
href: `https://github.com/ElemeFE/element/issues/${ this.lang === 'zh-CN' ? '7755' : '7756' }`
}
}, messages[1]),
messages[2]
]),
onClose() {
localStorage.setItem('RELEASE_NOTIFIED', 1);
}
});
}
}, 3500);
2016-09-08 18:11:18 +08:00
}
2016-07-27 14:15:02 +08:00
};
</script>