index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <div id="index" ref="appRef">
  3. <div class="bg">
  4. <dv-loading v-if="loading">Loading...</dv-loading>
  5. <div v-else class="host-body">
  6. <div class="d-flex jc-center">
  7. <dv-decoration-10 class="dv-dec-10" />
  8. <div class="d-flex jc-center">
  9. <dv-decoration-8 class="dv-dec-8" :color="decorationColors" />
  10. <div class="title">
  11. <span class="title-text">{{ title }}</span>
  12. <dv-decoration-6
  13. class="dv-dec-6"
  14. :reverse="true"
  15. :color="['#50e3c2', '#67a1e5']"
  16. />
  17. </div>
  18. <dv-decoration-8
  19. class="dv-dec-8"
  20. :reverse="true"
  21. :color="decorationColors"
  22. />
  23. </div>
  24. <dv-decoration-10 class="dv-dec-10-s" />
  25. </div>
  26. <!-- 第二行 -->
  27. <div class="d-flex jc-between px-2">
  28. <div class="d-flex aside-width">
  29. <div class="react-left ml-4 react-l-s">
  30. <span class="react-before"></span>
  31. <span class="text">{{ subtitle[0] }}</span>
  32. </div>
  33. <div class="react-left ml-3">
  34. <span class="text">{{ subtitle[1] }}</span>
  35. </div>
  36. </div>
  37. <div class="d-flex aside-width">
  38. <div class="react-right bg-color-blue mr-3">
  39. <span class="text fw-b">{{ subtitle[2] }}</span>
  40. </div>
  41. <div class="react-right mr-4 react-l-s">
  42. <span class="react-after"></span>
  43. <span class="text">
  44. {{ timeInfo.dateYear }} {{ timeInfo.dateWeek }}
  45. {{ timeInfo.dateDay }}
  46. </span>
  47. </div>
  48. </div>
  49. </div>
  50. <div class="body-box">
  51. <!-- 第三行数据 -->
  52. <div class="content-box">
  53. <div>
  54. <dv-border-box-12>
  55. <center-left1 />
  56. </dv-border-box-12>
  57. </div>
  58. <!-- <div>
  59. <dv-border-box-12>
  60. <center-left2 />
  61. </dv-border-box-12>
  62. </div> -->
  63. <!-- 中间 -->
  64. <div>
  65. <center />
  66. </div>
  67. <!-- 中间 -->
  68. <!-- <div>
  69. <center-right1 />
  70. </div> -->
  71. <div>
  72. <dv-border-box-13>
  73. <center-right2 />
  74. </dv-border-box-13>
  75. </div>
  76. </div>
  77. <!-- 第四行数据 -->
  78. <div class="bototm-box">
  79. <dv-border-box-13>
  80. <bottom-left />
  81. </dv-border-box-13>
  82. <dv-border-box-12>
  83. <bottom-right />
  84. </dv-border-box-12>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. </template>
  91. <script lang="ts">
  92. import {
  93. defineComponent,
  94. ref,
  95. reactive,
  96. onMounted,
  97. onUnmounted,
  98. } from 'vue'
  99. import { formatTime } from '@/utils/index'
  100. import { WEEK } from '@/constant/index'
  101. import useDraw from '@/utils/useDraw'
  102. import { title, subtitle, moduleInfo } from '@/constant/index'
  103. import CenterLeft1 from '../centerLeft1/index.vue'
  104. import CenterLeft2 from '../centerLeft2/index.vue'
  105. import Center from '../center/index.vue'
  106. import CenterRight1 from '../centerRight1/index.vue'
  107. import CenterRight2 from '../centerRight2/index.vue'
  108. import BottomLeft from '../bottomLeft/index.vue'
  109. import BottomRight from '../bottomRight/index.vue'
  110. export default defineComponent({
  111. components: {
  112. CenterLeft1,
  113. CenterLeft2,
  114. Center,
  115. CenterRight1,
  116. CenterRight2,
  117. BottomLeft,
  118. BottomRight
  119. },
  120. setup() {
  121. // * 颜色
  122. const decorationColors = ['#568aea', '#000000']
  123. // * 加载标识
  124. const loading = ref<boolean>(true)
  125. // * 时间内容
  126. const timeInfo = reactive({
  127. setInterval: 0,
  128. dateDay: '',
  129. dateYear: '',
  130. dateWeek: ''
  131. })
  132. // * 适配处理
  133. const { appRef, calcRate, windowDraw, unWindowDraw } = useDraw()
  134. // 生命周期
  135. onMounted(() => {
  136. cancelLoading()
  137. handleTime()
  138. // todo 屏幕适应
  139. windowDraw()
  140. calcRate()
  141. })
  142. onUnmounted(() => {
  143. unWindowDraw()
  144. clearInterval(timeInfo.setInterval)
  145. })
  146. // methods
  147. // todo 处理 loading 展示
  148. const cancelLoading = () => {
  149. setTimeout(() => {
  150. loading.value = false
  151. }, 500)
  152. }
  153. // todo 处理时间监听
  154. const handleTime = () => {
  155. timeInfo.setInterval = setInterval(() => {
  156. const date = new Date()
  157. timeInfo.dateDay = formatTime(date, 'HH: mm: ss')
  158. timeInfo.dateYear = formatTime(date, 'yyyy-MM-dd')
  159. timeInfo.dateWeek = WEEK[date.getDay()]
  160. }, 1000)
  161. }
  162. // return
  163. return {
  164. loading,
  165. timeInfo,
  166. appRef,
  167. title,
  168. subtitle,
  169. moduleInfo
  170. }
  171. }
  172. })
  173. </script>
  174. <style lang="scss" scoped>
  175. @import '@/assets/scss/index.scss';
  176. </style>