element/examples/app.vue

367 lines
7.8 KiB
Vue
Raw Normal View History

2016-07-27 06:15:02 +00:00
<style lang="css">
2016-11-01 10:28:20 +00:00
@import 'highlight.js/styles/color-brewer.css';
2016-07-27 06:15:02 +00:00
@import 'assets/styles/common.css';
2017-01-23 08:02:58 +00:00
@import 'assets/styles/fonts/style.css';
2016-07-27 06:15:02 +00:00
html, body {
margin: 0;
padding: 0;
2016-08-23 11:15:15 +00:00
height: 100%;
2016-07-27 06:15:02 +00:00
}
2016-08-23 11:15:15 +00:00
#app {
height: 100%;
2016-08-23 08:57:58 +00:00
}
2016-08-23 11:15:15 +00:00
body {
2017-01-23 08:02:58 +00:00
font-family: 'Helvetica Neue',Helvetica,'PingFang SC','Hiragino Sans GB','Microsoft YaHei',SimSun,sans-serif;
overflow: auto;
font-weight: 400;
2016-09-20 09:09:18 +00:00
-webkit-font-smoothing: antialiased;
2016-07-27 06:15:02 +00:00
}
2017-01-12 09:24:02 +00:00
a {
color: #4078c0;
2017-01-23 08:02:58 +00:00
text-decoration: none;
}
code {
background-color: #f9fafc;
padding: 0 4px;
border: 1px solid #eaeefb;
border-radius: 4px;
}
2017-01-23 08:02:58 +00:00
button, input, select, textarea {
font-family: inherit;
font-size: inherit;
line-height: inherit;
color: inherit;
2016-09-28 04:35:24 +00:00
}
2016-08-30 11:30:58 +00:00
.hljs {
2016-09-18 14:01:26 +00:00
line-height: 1.8;
font-family: Menlo, Monaco, Consolas, Courier, monospace;
font-size: 12px;
padding: 18px 24px;
2016-08-30 11:30:58 +00:00
background-color: #f9fafc;
2016-09-18 14:01:26 +00:00
border: solid 1px #eaeefb;
2016-08-30 11:30:58 +00:00
margin-bottom: 25px;
border-radius: 4px;
2016-09-20 09:09:18 +00:00
-webkit-font-smoothing: auto;
2016-08-30 11:30:58 +00:00
}
2016-08-23 11:15:15 +00:00
.main-cnt {
margin-top: -80px;
padding: 80px 0 120px;
2016-07-27 06:15:02 +00:00
box-sizing: border-box;
2016-08-23 11:15:15 +00:00
min-height: 100%;
2016-07-27 06:15:02 +00:00
}
2016-08-25 07:54:45 +00:00
.container,
.page-container {
2016-09-13 12:02:33 +00:00
width: 1140px;
2016-11-18 08:49:07 +00:00
padding: 0 30px;
2016-08-25 07:54:45 +00: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 08:59:59 +00:00
&:hover a {
opacity: .4;
}
a {
float: left;
margin-left: -20px;
opacity: 0;
cursor: pointer;
&:hover {
opacity: .4;
}
}
2016-08-25 07:54:45 +00:00
}
2016-08-25 07:54:45 +00: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-07-20 08:09:44 +00:00
margin-top: 20px;
code {
background-color: rgba(#fff, .7);
color: #445368;
}
2016-08-25 07:54:45 +00:00
}
2016-07-27 06:15:02 +00:00
}
.demo {
margin: 20px 0;
}
2017-09-24 03:10:10 +00:00
.carbon-teaser {
border-radius: 0;
2017-09-27 04:11:51 +00:00
overflow: hidden;
2017-09-24 03:10:10 +00:00
.el-dialog__header {
display: none;
}
2017-09-27 04:11:51 +00:00
2017-09-24 03:10:10 +00:00
.el-dialog__body {
padding: 0;
2017-09-27 04:11:51 +00:00
display: flex;
justify-content: center;
2017-09-24 03:10:10 +00:00
position: relative;
2017-09-27 04:11:51 +00:00
background: #000;
2017-09-24 03:10:10 +00:00
}
2017-09-27 04:11:51 +00:00
2017-09-24 03:10:10 +00:00
.carbon-teaser__main {
2017-09-27 04:11:51 +00:00
height: 100vh;
min-height: 600px;
2017-09-24 03:10:10 +00:00
}
2017-09-27 04:11:51 +00:00
2017-09-24 03:10:10 +00:00
.carbon-teaser__close {
position: absolute;
2017-09-27 04:11:51 +00:00
width: 40px;
height: 40px;
top: 25px;
right: 45px;
text-align: center;
2017-09-24 03:10:10 +00:00
cursor: pointer;
2017-09-27 04:11:51 +00:00
opacity: .8;
transition: .2s ease-out;
&::after,
&::before {
position: absolute;
content: '';
display: inline-block;
width: 4px;
border-radius: 1px;
height: 40px;
background: #ff3737;
box-shadow: 1px 0 1px 0 rgba(255, 255, 255, .3) inset, -2px 0 1px 0 rgba(0, 0, 0, .1) inset;
transition: .2s ease-out;
}
&::after {
transform: rotate(45deg);
}
&::before {
transform: rotate(-45deg);
}
&:hover {
opacity: 1;
&::after,
&::before {
box-shadow: 2px 0 1px 0 rgba(255, 255, 255, .4) inset, -2px 0 1px 0 rgba(0, 0, 0, .1) inset, 0 0 10px 3px #ff1616;
}
}
}
.carbon-teaser__button {
position: absolute;
bottom: 12%;
display: block;
width: 400px;
height: 19.11%;
[class*=carbon-teaser__more] {
position: absolute;
top: 0;
display: block;
width: 100%;
height: 100%;
cursor: pointer;
background-repeat: no-repeat;
background-position: center;
background-size: auto 80%;
transition: .2s ease-in;
}
[class*=dark] {
background-image: url(~examples/assets/images/button-d-cn.png);
&.is-en {
background-image: url(~examples/assets/images/button-d-en.png);
}
}
[class*=light] {
opacity: 0;
background-image: url(~examples/assets/images/button-l-cn.png);
&.is-en {
background-image: url(~examples/assets/images/button-l-en.png);
}
}
&:hover {
[class*=light] {
opacity: 1;
}
[class*=dark] {
opacity: 0;
}
}
2017-09-24 03:10:10 +00:00
}
}
2016-09-14 10:38:38 +00:00
@media (max-width: 1140px) {
.container,
.page-container {
width: 100%;
}
}
2016-11-18 08:49:07 +00:00
@media (max-width: 768px) {
.container,
.page-container {
padding: 0 20px;
}
}
2016-07-27 06:15:02 +00:00
</style>
<template>
2016-07-27 09:05:28 +00:00
<div id="app">
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>
2016-11-12 18:34:39 +00:00
<main-footer v-if="lang !== 'play'"></main-footer>
2017-09-24 03:10:10 +00:00
<el-dialog
:visible.sync="dialogVisible"
2017-09-27 04:11:51 +00:00
size="full"
2017-09-24 03:10:10 +00:00
custom-class="carbon-teaser"
@close="handleDialogClose"
:close-on-press-escape="false"
:close-on-click-modal="false">
<img
2017-09-27 04:11:51 +00:00
src="https://i.loli.net/2017/09/27/59cb11edaa26d.jpg"
2017-09-24 03:10:10 +00:00
class="carbon-teaser__main">
2017-09-27 04:11:51 +00:00
<a :href="hrefOfCarbonLearnMore" target="_blank" class="carbon-teaser__button">
<span class="carbon-teaser__more-dark" :class="lang !== 'zh-CN' && 'is-en'"></span>
<span class="carbon-teaser__more-light" :class="lang !== 'zh-CN' && 'is-en'"></span>
</a>
<div class="carbon-teaser__close" @click="dialogVisible = false"></div>
2017-09-24 03:10:10 +00:00
</el-dialog>
2016-07-27 09:05:28 +00:00
</div>
2016-07-27 06:15:02 +00: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 06:15:02 +00:00
export default {
2016-09-08 10:11:18 +00:00
name: 'app',
2017-09-24 03:10:10 +00:00
data() {
return {
dialogVisible: false
};
},
computed: {
lang() {
return this.$route.path.split('/')[1] || 'zh-CN';
2017-09-27 04:11:51 +00:00
},
hrefOfCarbonLearnMore() {
return this.lang === 'zh-CN' ? 'https://github.com/ElemeFE/element/issues/7236' : 'https://github.com/ElemeFE/element/issues/7237';
}
},
watch: {
lang() {
this.localize();
}
},
2016-11-04 08:59:59 +00:00
methods: {
localize() {
use(this.lang === 'zh-CN' ? zhLocale : enLocale);
},
2016-11-04 08:59:59 +00:00
renderAnchorHref() {
2016-11-06 07:56:41 +00:00
if (/changelog/g.test(location.href)) return;
2016-11-04 08:59:59 +00:00
const anchors = document.querySelectorAll('h2 a,h3 a');
const basePath = location.href.split('#').splice(0, 2).join('#');
[].slice.call(anchors).forEach(a => {
const href = a.getAttribute('href');
a.href = basePath + href;
});
},
goAnchor() {
if (location.href.match(/#/g).length > 1) {
2016-12-20 08:38:21 +00:00
const anchor = location.href.match(/#[^#]+$/g);
if (!anchor) return;
const elm = document.querySelector(anchor[0]);
2016-11-04 08:59:59 +00:00
if (!elm) return;
setTimeout(_ => {
2016-12-20 08:38:21 +00:00
document.documentElement.scrollTop = document.body.scrollTop = elm.offsetTop + 120;
2016-11-04 08:59:59 +00:00
}, 50);
}
2017-09-24 03:10:10 +00:00
},
handleDialogClose() {
2017-09-27 04:11:51 +00:00
localStorage.setItem('CARBON_TEASER_V2', 1);
2016-11-04 08:59:59 +00:00
}
},
mounted() {
this.localize();
2016-11-04 08:59:59 +00:00
this.renderAnchorHref();
this.goAnchor();
2017-09-24 03:10:10 +00:00
2017-09-27 04:19:40 +00:00
const intrigued = localStorage.getItem('CARBON_TEASER_V2');
2017-09-24 03:10:10 +00:00
if (!intrigued) {
2017-09-24 07:32:56 +00:00
const img = new Image();
img.onload = () => {
2017-09-24 03:10:10 +00:00
this.dialogVisible = true;
2017-09-24 07:32:56 +00:00
};
2017-09-27 04:11:51 +00:00
img.src = 'https://i.loli.net/2017/09/27/59cb11edaa26d.jpg';
2017-09-24 03:10:10 +00:00
}
2016-11-04 08:59:59 +00:00
},
2016-09-08 10:11:18 +00:00
created() {
window.addEventListener('hashchange', () => {
2016-11-04 08:59:59 +00:00
if (location.href.match(/#/g).length < 2) {
document.documentElement.scrollTop = document.body.scrollTop = 0;
this.renderAnchorHref();
} else {
this.goAnchor();
}
2016-09-08 10:11:18 +00:00
});
}
2016-07-27 06:15:02 +00:00
};
</script>