app.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. font-family: 'Helvetica Neue',Helvetica,'PingFang SC','Hiragino Sans GB','Microsoft YaHei',SimSun,sans-serif;
  10. font-weight: 400;
  11. -webkit-font-smoothing: antialiased;
  12. &.is-component {
  13. overflow: hidden;
  14. }
  15. }
  16. #app {
  17. height: 100%;
  18. @when component {
  19. overflow-y: hidden;
  20. .main-cnt {
  21. padding: 0;
  22. margin-top: 0;
  23. height: 100%;
  24. min-height: auto;
  25. }
  26. .headerWrapper {
  27. position: fixed;
  28. width: 100%;
  29. left: 0;
  30. top: 0;
  31. z-index: 1500;
  32. .container {
  33. padding: 0;
  34. }
  35. }
  36. }
  37. }
  38. a {
  39. color: #409EFF;
  40. text-decoration: none;
  41. }
  42. code {
  43. background-color: #f9fafc;
  44. padding: 0 4px;
  45. border: 1px solid #eaeefb;
  46. border-radius: 4px;
  47. }
  48. button, input, select, textarea {
  49. font-family: inherit;
  50. font-size: inherit;
  51. line-height: inherit;
  52. color: inherit;
  53. }
  54. .hljs {
  55. line-height: 1.8;
  56. font-family: Menlo, Monaco, Consolas, Courier, monospace;
  57. font-size: 12px;
  58. padding: 18px 24px;
  59. background-color: #fafafa;
  60. border: solid 1px #eaeefb;
  61. margin-bottom: 25px;
  62. border-radius: 4px;
  63. -webkit-font-smoothing: auto;
  64. }
  65. .main-cnt {
  66. margin-top: -80px;
  67. padding: 80px 0 120px;
  68. box-sizing: border-box;
  69. min-height: 100%;
  70. }
  71. .container,
  72. .page-container {
  73. width: 1140px;
  74. padding: 0;
  75. margin: 0 auto;
  76. }
  77. .page-container {
  78. padding-top: 55px;
  79. h2 {
  80. font-size: 28px;
  81. color: #1f2d3d;
  82. margin: 0;
  83. }
  84. h3 {
  85. font-size: 22px;
  86. }
  87. h2, h3, h4, h5 {
  88. font-weight: normal;
  89. color: #1f2f3d;
  90. &:hover a {
  91. opacity: .4;
  92. }
  93. a {
  94. float: left;
  95. margin-left: -20px;
  96. opacity: 0;
  97. cursor: pointer;
  98. &:hover {
  99. opacity: .4;
  100. }
  101. }
  102. }
  103. p {
  104. font-size: 14px;
  105. color: #5e6d82;
  106. line-height: 1.5em;
  107. }
  108. .tip {
  109. padding: 8px 16px;
  110. background-color: #ECF8FF;
  111. border-radius: 4px;
  112. border-left: #50bfff 5px solid;
  113. margin: 20px 0;
  114. code {
  115. background-color: rgba(255, 255, 255, .7);
  116. color: #445368;
  117. }
  118. }
  119. .warning {
  120. padding: 8px 16px;
  121. background-color: #fff6f7;
  122. border-radius: 4px;
  123. border-left: #FE6C6F 5px solid;
  124. margin: 20px 0;
  125. code {
  126. background-color: rgba(255, 255, 255, .7);
  127. color: #445368;
  128. }
  129. }
  130. }
  131. .demo {
  132. margin: 20px 0;
  133. }
  134. @media (max-width: 1140px) {
  135. .container,
  136. .page-container {
  137. width: 100%;
  138. }
  139. }
  140. @media (max-width: 768px) {
  141. .container,
  142. .page-container {
  143. padding: 0 20px;
  144. }
  145. #app.is-component .headerWrapper .container {
  146. padding: 0 12px;
  147. }
  148. }
  149. </style>
  150. <template>
  151. <div id="app" :class="{ 'is-component': isComponent }">
  152. <main-header v-if="lang !== 'play'"></main-header>
  153. <div class="main-cnt">
  154. <router-view></router-view>
  155. </div>
  156. <main-footer v-if="lang !== 'play' && !isComponent"></main-footer>
  157. </div>
  158. </template>
  159. <script>
  160. import { use } from 'main/locale';
  161. import zhLocale from 'main/locale/lang/zh-CN';
  162. import enLocale from 'main/locale/lang/en';
  163. use(location.href.indexOf('zh-CN') > -1 ? zhLocale : enLocale);
  164. export default {
  165. name: 'app',
  166. computed: {
  167. lang() {
  168. return this.$route.path.split('/')[1] || 'zh-CN';
  169. },
  170. isComponent() {
  171. return /^component-/.test(this.$route.name || '');
  172. }
  173. },
  174. watch: {
  175. lang() {
  176. this.localize();
  177. }
  178. },
  179. methods: {
  180. localize() {
  181. use(this.lang === 'zh-CN' ? zhLocale : enLocale);
  182. }
  183. },
  184. mounted() {
  185. this.localize();
  186. }
  187. };
  188. </script>