app.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <style lang="css">
  2. @import 'highlight.js/styles/color-brewer.css';
  3. @import 'assets/styles/common.css';
  4. @import 'assets/styles/fonts/style.css';
  5. html, body {
  6. margin: 0;
  7. padding: 0;
  8. height: 100%;
  9. }
  10. #app {
  11. height: 100%;
  12. }
  13. body {
  14. font-family: 'Helvetica Neue',Helvetica,'PingFang SC','Hiragino Sans GB','Microsoft YaHei',SimSun,sans-serif;
  15. overflow: auto;
  16. font-weight: 400;
  17. -webkit-font-smoothing: antialiased;
  18. }
  19. a {
  20. color: #4078c0;
  21. text-decoration: none;
  22. }
  23. code {
  24. background-color: #f9fafc;
  25. padding: 0 4px;
  26. border: 1px solid #eaeefb;
  27. border-radius: 4px;
  28. }
  29. button, input, select, textarea {
  30. font-family: inherit;
  31. font-size: inherit;
  32. line-height: inherit;
  33. color: inherit;
  34. }
  35. .hljs {
  36. line-height: 1.8;
  37. font-family: Menlo, Monaco, Consolas, Courier, monospace;
  38. font-size: 12px;
  39. padding: 18px 24px;
  40. background-color: #f9fafc;
  41. border: solid 1px #eaeefb;
  42. margin-bottom: 25px;
  43. border-radius: 4px;
  44. -webkit-font-smoothing: auto;
  45. }
  46. .main-cnt {
  47. margin-top: -80px;
  48. padding: 80px 0 120px;
  49. box-sizing: border-box;
  50. min-height: 100%;
  51. }
  52. .container,
  53. .page-container {
  54. width: 1140px;
  55. padding: 0 30px;
  56. margin: 0 auto;
  57. }
  58. .page-container {
  59. padding-top: 55px;
  60. h2 {
  61. font-size: 28px;
  62. color: #1f2d3d;
  63. margin: 0;
  64. }
  65. h3 {
  66. font-size: 22px;
  67. }
  68. h2, h3, h4, h5 {
  69. font-weight: normal;
  70. color: #1f2f3d;
  71. &:hover a {
  72. opacity: .4;
  73. }
  74. a {
  75. float: left;
  76. margin-left: -20px;
  77. opacity: 0;
  78. cursor: pointer;
  79. &:hover {
  80. opacity: .4;
  81. }
  82. }
  83. }
  84. p {
  85. font-size: 14px;
  86. color: #5e6d82;
  87. line-height: 1.5em;
  88. }
  89. .tip {
  90. padding: 8px 16px;
  91. background-color: #ECF8FF;
  92. border-radius: 4px;
  93. border-left: #50bfff 5px solid;
  94. margin-top: 20px;
  95. code {
  96. background-color: rgba(#fff, .7);
  97. color: #445368;
  98. }
  99. }
  100. }
  101. .demo {
  102. margin: 20px 0;
  103. }
  104. .carbon-teaser {
  105. border-radius: 0;
  106. overflow: hidden;
  107. .el-dialog__header {
  108. display: none;
  109. }
  110. .el-dialog__body {
  111. padding: 0;
  112. display: flex;
  113. justify-content: center;
  114. position: relative;
  115. background: #000;
  116. }
  117. .carbon-teaser__main {
  118. height: 100vh;
  119. min-height: 600px;
  120. }
  121. .carbon-teaser__close {
  122. position: absolute;
  123. width: 40px;
  124. height: 40px;
  125. top: 25px;
  126. right: 45px;
  127. text-align: center;
  128. cursor: pointer;
  129. opacity: .8;
  130. transition: .2s ease-out;
  131. &::after,
  132. &::before {
  133. position: absolute;
  134. content: '';
  135. display: inline-block;
  136. width: 4px;
  137. border-radius: 1px;
  138. height: 40px;
  139. background: #ff3737;
  140. box-shadow: 1px 0 1px 0 rgba(255, 255, 255, .3) inset, -2px 0 1px 0 rgba(0, 0, 0, .1) inset;
  141. transition: .2s ease-out;
  142. }
  143. &::after {
  144. transform: rotate(45deg);
  145. }
  146. &::before {
  147. transform: rotate(-45deg);
  148. }
  149. &:hover {
  150. opacity: 1;
  151. &::after,
  152. &::before {
  153. 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;
  154. }
  155. }
  156. }
  157. .carbon-teaser__button {
  158. position: absolute;
  159. bottom: 12%;
  160. display: block;
  161. width: 400px;
  162. height: 19.11%;
  163. [class*=carbon-teaser__more] {
  164. position: absolute;
  165. top: 0;
  166. display: block;
  167. width: 100%;
  168. height: 100%;
  169. cursor: pointer;
  170. background-repeat: no-repeat;
  171. background-position: center;
  172. background-size: auto 80%;
  173. transition: .2s ease-in;
  174. }
  175. [class*=dark] {
  176. background-image: url(~examples/assets/images/button-d-cn.png);
  177. &.is-en {
  178. background-image: url(~examples/assets/images/button-d-en.png);
  179. }
  180. }
  181. [class*=light] {
  182. opacity: 0;
  183. background-image: url(~examples/assets/images/button-l-cn.png);
  184. &.is-en {
  185. background-image: url(~examples/assets/images/button-l-en.png);
  186. }
  187. }
  188. &:hover {
  189. [class*=light] {
  190. opacity: 1;
  191. }
  192. [class*=dark] {
  193. opacity: 0;
  194. }
  195. }
  196. }
  197. }
  198. @media (max-width: 1140px) {
  199. .container,
  200. .page-container {
  201. width: 100%;
  202. }
  203. }
  204. @media (max-width: 768px) {
  205. .container,
  206. .page-container {
  207. padding: 0 20px;
  208. }
  209. }
  210. </style>
  211. <template>
  212. <div id="app">
  213. <main-header v-if="lang !== 'play'"></main-header>
  214. <div class="main-cnt">
  215. <router-view></router-view>
  216. </div>
  217. <main-footer v-if="lang !== 'play'"></main-footer>
  218. <el-dialog
  219. :visible.sync="dialogVisible"
  220. size="full"
  221. custom-class="carbon-teaser"
  222. @close="handleDialogClose"
  223. :close-on-press-escape="false"
  224. :close-on-click-modal="false">
  225. <img
  226. src="https://i.loli.net/2017/09/27/59cb11edaa26d.jpg"
  227. class="carbon-teaser__main">
  228. <a :href="hrefOfCarbonLearnMore" target="_blank" class="carbon-teaser__button">
  229. <span class="carbon-teaser__more-dark" :class="lang !== 'zh-CN' && 'is-en'"></span>
  230. <span class="carbon-teaser__more-light" :class="lang !== 'zh-CN' && 'is-en'"></span>
  231. </a>
  232. <div class="carbon-teaser__close" @click="dialogVisible = false"></div>
  233. </el-dialog>
  234. </div>
  235. </template>
  236. <script>
  237. import { use } from 'main/locale';
  238. import zhLocale from 'main/locale/lang/zh-CN';
  239. import enLocale from 'main/locale/lang/en';
  240. use(location.href.indexOf('zh-CN') > -1 ? zhLocale : enLocale);
  241. export default {
  242. name: 'app',
  243. data() {
  244. return {
  245. dialogVisible: false
  246. };
  247. },
  248. computed: {
  249. lang() {
  250. return this.$route.path.split('/')[1] || 'zh-CN';
  251. },
  252. hrefOfCarbonLearnMore() {
  253. return this.lang === 'zh-CN' ? 'https://github.com/ElemeFE/element/issues/7236' : 'https://github.com/ElemeFE/element/issues/7237';
  254. }
  255. },
  256. watch: {
  257. lang() {
  258. this.localize();
  259. }
  260. },
  261. methods: {
  262. localize() {
  263. use(this.lang === 'zh-CN' ? zhLocale : enLocale);
  264. },
  265. renderAnchorHref() {
  266. if (/changelog/g.test(location.href)) return;
  267. const anchors = document.querySelectorAll('h2 a,h3 a');
  268. const basePath = location.href.split('#').splice(0, 2).join('#');
  269. [].slice.call(anchors).forEach(a => {
  270. const href = a.getAttribute('href');
  271. a.href = basePath + href;
  272. });
  273. },
  274. goAnchor() {
  275. if (location.href.match(/#/g).length > 1) {
  276. const anchor = location.href.match(/#[^#]+$/g);
  277. if (!anchor) return;
  278. const elm = document.querySelector(anchor[0]);
  279. if (!elm) return;
  280. setTimeout(_ => {
  281. document.documentElement.scrollTop = document.body.scrollTop = elm.offsetTop + 120;
  282. }, 50);
  283. }
  284. },
  285. handleDialogClose() {
  286. localStorage.setItem('CARBON_TEASER_V2', 1);
  287. }
  288. },
  289. mounted() {
  290. this.localize();
  291. this.renderAnchorHref();
  292. this.goAnchor();
  293. const intrigued = localStorage.getItem('CARBON_TEASER_V2');
  294. if (!intrigued) {
  295. const img = new Image();
  296. img.onload = () => {
  297. this.dialogVisible = true;
  298. };
  299. img.src = 'https://i.loli.net/2017/09/27/59cb11edaa26d.jpg';
  300. }
  301. },
  302. created() {
  303. window.addEventListener('hashchange', () => {
  304. if (location.href.match(/#/g).length < 2) {
  305. document.documentElement.scrollTop = document.body.scrollTop = 0;
  306. this.renderAnchorHref();
  307. } else {
  308. this.goAnchor();
  309. }
  310. });
  311. }
  312. };
  313. </script>