History.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. <template>
  2. <section id="history" ref="timelineRef" class="history">
  3. <div
  4. class="history-container"
  5. :class="[isTimelineVisible ? 'translate-y-0 opacity-100' : 'translate-y-40px opacity-0']"
  6. >
  7. <div class="history-title pf-sc-semibold">发展历程</div>
  8. <div class="history-subtitle pf-sc-regular">从探索到引领,绘家科技每一步都坚实有力</div>
  9. <div class="history-top">
  10. <div class="history-year-wrapper">
  11. <Transition name="year-flow">
  12. <div :key="currentYearData?.year" class="history-year-content">
  13. <span class="history-year-text pf-sc-bold">
  14. {{ currentYearData?.year }}
  15. </span>
  16. </div>
  17. </Transition>
  18. </div>
  19. <div class="history-event-wrapper">
  20. <Transition name="event-fade" mode="out-in">
  21. <div
  22. :key="currentYearData?.year + '-' + currentEventIndex"
  23. class="history-event-content"
  24. >
  25. <div class="history-event-header">
  26. <span class="history-event-month pf-sc-semibold">
  27. {{ currentEventData?.month }}
  28. </span>
  29. <div
  30. v-if="(currentYearData?.events?.length ?? 0) > 1"
  31. class="history-event-controls"
  32. >
  33. <i
  34. class="i-custom-arrow-circle-left history-event-arrow"
  35. :class="[
  36. currentEventIndex === 0
  37. ? 'opacity-30 cursor-not-allowed'
  38. : 'cursor-pointer hover:i-custom-arrow-circle-left-active hover:scale-110 active:scale-95',
  39. ]"
  40. @click="prevEvent"
  41. ></i>
  42. <i
  43. class="i-custom-arrow-circle-right history-event-arrow"
  44. :class="[
  45. currentEventIndex === (currentYearData?.events?.length ?? 0) - 1
  46. ? 'opacity-30 cursor-not-allowed'
  47. : 'cursor-pointer hover:i-custom-arrow-circle-right-active hover:scale-110 active:scale-95',
  48. ]"
  49. @click="nextEvent"
  50. ></i>
  51. </div>
  52. </div>
  53. <div class="history-event-line"></div>
  54. <div class="history-event-desc pf-sc-regular">
  55. {{ currentEventData?.content }}
  56. </div>
  57. </div>
  58. </Transition>
  59. </div>
  60. </div>
  61. <div class="history-timeline lt-sm:hidden">
  62. <div class="history-timeline-track">
  63. <div class="history-timeline-progress" :style="progressStyle"></div>
  64. <div class="history-timeline-nodes">
  65. <div
  66. v-for="(item, index) in historyYears"
  67. :key="item.year"
  68. class="history-timeline-node"
  69. :style="getTimelineNodePositionStyle(index)"
  70. @click="selectYear(index)"
  71. >
  72. <div
  73. class="history-timeline-dot"
  74. :class="getTimelineDotClasses(index)"
  75. :style="getTimelineDotStyle(index)"
  76. ></div>
  77. <span class="history-timeline-year" :class="getTimelineYearTextClasses(index)">
  78. {{ item.year }}
  79. </span>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. <div class="history-timeline-mobile lt-sm:flex hidden">
  85. <i
  86. class="i-custom-button-previous-mobile history-mobile-btn"
  87. :class="[
  88. currentYearIndex === 0
  89. ? 'cursor-not-allowed i-custom-button-previous-mobile-disabled'
  90. : 'active:i-custom-button-previous-mobile-active',
  91. ]"
  92. @click="prevYear"
  93. ></i>
  94. <div class="history-mobile-track-container">
  95. <div class="history-mobile-track-line"></div>
  96. <TransitionGroup
  97. :name="'timeline-' + slideDirection"
  98. tag="div"
  99. class="history-mobile-nodes"
  100. >
  101. <div
  102. v-for="yearIndex in mobileTimelineIndices"
  103. :key="yearIndex"
  104. class="history-mobile-node"
  105. :class="{ invisible: yearIndex < 0 || yearIndex >= historyYears.length }"
  106. @click="yearIndex >= 0 && yearIndex < historyYears.length && selectYear(yearIndex)"
  107. >
  108. <div
  109. class="history-mobile-dot"
  110. :class="{ active: yearIndex === currentYearIndex }"
  111. ></div>
  112. <div class="history-mobile-year" :class="{ active: yearIndex === currentYearIndex }">
  113. {{ historyYears[yearIndex]?.year }}
  114. </div>
  115. </div>
  116. </TransitionGroup>
  117. </div>
  118. <i
  119. class="i-custom-button-next-mobile history-mobile-btn"
  120. :class="[
  121. currentYearIndex === historyYears.length - 1
  122. ? 'cursor-not-allowed i-custom-button-next-mobile-disabled'
  123. : 'active:i-custom-button-next-mobile-active',
  124. ]"
  125. @click="nextYear"
  126. ></i>
  127. </div>
  128. <div class="history-nav">
  129. <i
  130. class="i-custom-button-previous history-nav-btn"
  131. :class="{
  132. 'opacity-30 cursor-not-allowed hover:i-custom-button-previous!': currentYearIndex === 0,
  133. }"
  134. @click="prevYear"
  135. ></i>
  136. <i
  137. class="i-custom-button-next history-nav-btn"
  138. :class="{
  139. 'opacity-30 cursor-not-allowed hover:i-custom-button-next!':
  140. currentYearIndex === historyYears.length - 1,
  141. }"
  142. @click="nextYear"
  143. ></i>
  144. </div>
  145. </div>
  146. </section>
  147. </template>
  148. <script setup lang="ts">
  149. import { historyYears } from '@/constants/common'
  150. const timelineRef = ref<HTMLElement | null>(null)
  151. const { isVisible: isTimelineVisible } = useScrollReveal(timelineRef)
  152. const currentYearIndex = ref(historyYears.length - 1)
  153. const currentEventIndex = ref(0)
  154. const slideDirection = ref<'next' | 'prev'>('next')
  155. const currentYearData = computed(() => {
  156. const data = historyYears[currentYearIndex.value]
  157. return data || historyYears[0]
  158. })
  159. const currentEventData = computed(() => {
  160. const events = currentYearData.value?.events || []
  161. return events[currentEventIndex.value] || events[0]
  162. })
  163. const mobileTimelineIndices = computed(() => {
  164. const total = historyYears.length
  165. if (total <= 0) return []
  166. const prev = currentYearIndex.value - 1
  167. const curr = currentYearIndex.value
  168. const next = currentYearIndex.value + 1
  169. return [prev, curr, next]
  170. })
  171. const progressStyle = computed(() => {
  172. const totalSteps = Math.max(historyYears.length - 1, 1)
  173. if (currentYearIndex.value === totalSteps) {
  174. return {
  175. width: '100%',
  176. }
  177. }
  178. const percentage = currentYearIndex.value / totalSteps
  179. return {
  180. width: `calc(60px + ${percentage} * (100% - 120px))`,
  181. }
  182. })
  183. const nextYear = () => {
  184. if (currentYearIndex.value < historyYears.length - 1) {
  185. slideDirection.value = 'next'
  186. currentYearIndex.value++
  187. currentEventIndex.value = 0
  188. }
  189. }
  190. const prevYear = () => {
  191. if (currentYearIndex.value > 0) {
  192. slideDirection.value = 'prev'
  193. currentYearIndex.value--
  194. currentEventIndex.value = 0
  195. }
  196. }
  197. const nextEvent = () => {
  198. const events = currentYearData.value?.events || []
  199. if (currentEventIndex.value < events.length - 1) {
  200. currentEventIndex.value++
  201. }
  202. }
  203. const prevEvent = () => {
  204. if (currentEventIndex.value > 0) {
  205. currentEventIndex.value--
  206. }
  207. }
  208. const selectYear = (index: number) => {
  209. slideDirection.value = index > currentYearIndex.value ? 'next' : 'prev'
  210. currentYearIndex.value = index
  211. currentEventIndex.value = 0
  212. }
  213. const getTimelineNodePositionStyle = (index: number) => {
  214. return { left: `${(index / (historyYears.length - 1)) * 100}%` }
  215. }
  216. const getTimelineDotClasses = (index: number) => {
  217. return [
  218. index < currentYearIndex.value
  219. ? 'wh-13px'
  220. : 'wh-16px border-#0F67F8 group-hover:border-[#2563EB] border-1',
  221. index === currentYearIndex.value
  222. ? 'wh-16px scale-150 outline-6px outline-#CEE0FF outline-solid border-none'
  223. : '',
  224. ]
  225. }
  226. const getTimelineDotStyle = (index: number) => {
  227. if (index === currentYearIndex.value) {
  228. return { background: 'linear-gradient(90deg, #779EFF 0%, #0A50FF 100%)' }
  229. }
  230. if (index < currentYearIndex.value) {
  231. return { background: '#FFFFFF' }
  232. }
  233. return {}
  234. }
  235. const getTimelineYearTextClasses = (index: number) => {
  236. return [
  237. index === currentYearIndex.value
  238. ? 'text-#2563EB font-bold pf-sc-bold scale-110'
  239. : 'text-#94A3B8 group-hover:text-[#64748B]',
  240. ]
  241. }
  242. </script>
  243. <style scoped lang="scss">
  244. .history {
  245. @apply overflow-hidden relative py-60px;
  246. @apply lt-sm:pt-60px lt-sm:pb-160px lt-sm:px-32px;
  247. @extend %landing-container;
  248. background-size: cover;
  249. background-position: center;
  250. background-image: url('@/assets/images/history-bg.png');
  251. @screen lt-sm {
  252. background-image: url('@/assets/images/history-bg-mobile.png');
  253. }
  254. }
  255. .history-container {
  256. @apply flex flex-col items-center transition-all duration-1000;
  257. }
  258. .history-title {
  259. @apply font-semibold font-s-36px text-#000000 lh-60px text-center mb-4px;
  260. @apply lt-sm:font-s-48px lt-sm:lh-60px;
  261. }
  262. .history-subtitle {
  263. @apply font-s-16px text-#091221/70 text-center lh-30px mb-50px;
  264. @apply lt-sm:font-s-24px lt-sm:lh-40px lt-sm:mb-88px;
  265. }
  266. .history-top {
  267. @apply w-full h-255px flex py-50px items-center;
  268. @apply lt-sm:h-176px;
  269. }
  270. .history-year-wrapper {
  271. @apply relative pl-127px w-600px shrink-0 h-170px overflow-hidden;
  272. @apply lt-sm:hidden;
  273. }
  274. .history-year-content {
  275. @apply absolute left-127px top-0 h-full flex items-center w-full;
  276. }
  277. .history-year-text {
  278. @apply text-170px font-bold text-#0F67F8 select-none leading-none;
  279. -webkit-text-stroke: 1px #2563eb;
  280. text-shadow: 0 0 20px rgba(37, 99, 235, 0.1);
  281. }
  282. .history-event-wrapper {
  283. @apply flex-1 h-full relative overflow-hidden pt-14px;
  284. @apply lt-sm:h-176px lt-sm:pt-0;
  285. }
  286. .history-event-content {
  287. @apply absolute left-0 top-14px w-full flex flex-col pr-114px;
  288. @apply lt-sm:pr-0 static;
  289. }
  290. .history-event-header {
  291. @apply flex justify-between items-center w-full;
  292. @apply lt-sm:h-45px;
  293. }
  294. .history-event-month {
  295. @apply font-s-22px font-semibold lh-30.8px text-#091221 flex-1;
  296. @apply lt-sm:font-s-32px lt-sm:lh-30.8px;
  297. }
  298. .history-event-controls {
  299. @apply flex gap-12px relative z-10;
  300. @apply lt-sm:gap-16px;
  301. }
  302. .history-event-arrow {
  303. @apply wh-32px transition-all;
  304. @apply lt-sm:wh-45px;
  305. }
  306. .history-event-line {
  307. @apply h-2px w-34px bg-#0F67F8 mt-11px origin-left;
  308. @apply lt-sm:h-4px lt-sm:w-68px lt-sm:mt-25px;
  309. }
  310. .history-event-desc {
  311. @apply w-full font-s-20px lh-35px text-#091221/70 mt-26px;
  312. @apply lt-sm:font-s-24px lt-sm:mt-26px lt-sm:lh-normal;
  313. }
  314. .history-timeline {
  315. @apply w-full relative pt-47px pb-60px;
  316. @apply lt-sm:py-0 lt-sm:mt-70px;
  317. }
  318. .history-timeline-track {
  319. @apply relative h-16px w-full bg-white rounded-full px-60px;
  320. @apply lt-sm:h-16px lt-sm:px-60px;
  321. }
  322. .history-timeline-progress {
  323. @apply absolute left-0 top-0 h-full bg-gradient-to-r from-[#60A5FA] to-[#2563EB] rounded-full transition-all duration-500 ease-out z-1;
  324. }
  325. .history-timeline-nodes {
  326. @apply relative h-full w-full;
  327. }
  328. .history-timeline-node {
  329. @apply absolute top-1/2 -translate-y-1/2 -translate-x-1/2 flex flex-col items-center cursor-pointer group z-2;
  330. }
  331. .history-timeline-dot {
  332. @apply rounded-full transition-all duration-300 relative bg-white;
  333. @apply lt-sm:wh-14px;
  334. }
  335. .history-timeline-year {
  336. @apply absolute top-24px text-16px transition-all duration-300 whitespace-nowrap;
  337. }
  338. .history-nav {
  339. @apply flex gap-24px mt-45px;
  340. @apply lt-sm:hidden;
  341. }
  342. .history-nav-btn {
  343. @apply wh-56px flex-center cursor-pointer;
  344. }
  345. .year-flow-enter-active,
  346. .year-flow-leave-active {
  347. transition: all 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  348. }
  349. .year-flow-enter-from {
  350. opacity: 0;
  351. transform: translateY(100%) scale(0.9);
  352. }
  353. .year-flow-leave-to {
  354. opacity: 0;
  355. transform: translateY(-100%) scale(0.9);
  356. }
  357. .event-fade-enter-active,
  358. .event-fade-leave-active {
  359. transition: opacity 0.3s ease;
  360. }
  361. .event-fade-enter-from,
  362. .event-fade-leave-to {
  363. opacity: 0;
  364. }
  365. .history-timeline-mobile {
  366. @apply flex items-center justify-between w-full px-0;
  367. @apply lt-sm:mt-70px;
  368. }
  369. .history-mobile-btn {
  370. @apply shrink-0 cursor-pointer transition-all absolute;
  371. @apply lt-sm:wh-64px z-10;
  372. &.i-custom-button-previous-mobile {
  373. @apply left-0;
  374. }
  375. &.i-custom-button-next-mobile {
  376. @apply right-0;
  377. }
  378. }
  379. .history-mobile-track-container {
  380. @apply relative flex-1;
  381. }
  382. .history-mobile-track-line {
  383. @apply absolute left-0 right-0 bg-white rounded-full;
  384. @apply lt-sm:h-16px lt-sm:top-1/2 lt-sm:translate-y--1/2;
  385. }
  386. .history-mobile-nodes {
  387. @apply hidden relative w-full h-full justify-between items-center z-1;
  388. @apply lt-sm:px-100px lt-sm:h-16px lt-sm:flex;
  389. }
  390. .history-mobile-node {
  391. @apply relative flex flex-col items-center cursor-pointer;
  392. @apply lt-sm:w-60px;
  393. &.invisible {
  394. @apply transition-none;
  395. .history-mobile-dot,
  396. .history-mobile-year {
  397. @apply transition-none;
  398. }
  399. }
  400. }
  401. .history-mobile-dot {
  402. @apply rounded-full bg-white transition-all z-2 border-#0F67F8 border-1;
  403. @apply lt-sm:wh-18px;
  404. &.active {
  405. @apply scale-150 outline-#CEE0FF outline-solid border-none bg-[linear-gradient(90deg,#779EFF_0%,#0A50FF_100%)];
  406. @apply lt-sm:wh-22px lt-sm:outline-8px;
  407. }
  408. }
  409. .history-mobile-year {
  410. @apply hidden absolute text-#091221/60 pf-sc-regular transition-all whitespace-nowrap;
  411. @apply lt-sm:font-s-22px lt-sm:top-58px lt-sm:block;
  412. &.active {
  413. @apply text-#0F67F8 font-semibold scale-110;
  414. }
  415. }
  416. /* Timeline Animation */
  417. .timeline-next-move,
  418. .timeline-prev-move {
  419. transition: all 0.5s ease;
  420. }
  421. .timeline-next-enter-active,
  422. .timeline-next-leave-active,
  423. .timeline-prev-enter-active,
  424. .timeline-prev-leave-active {
  425. transition: all 0.5s ease;
  426. }
  427. .timeline-next-leave-active {
  428. position: absolute;
  429. left: 100px;
  430. }
  431. .timeline-prev-leave-active {
  432. position: absolute;
  433. right: 100px;
  434. }
  435. .timeline-next-enter-from {
  436. opacity: 0;
  437. transform: translateX(100%);
  438. }
  439. .timeline-next-leave-to {
  440. opacity: 0;
  441. transform: translateX(-100%);
  442. }
  443. .timeline-prev-enter-from {
  444. opacity: 0;
  445. transform: translateX(-100%);
  446. }
  447. .timeline-prev-leave-to {
  448. opacity: 0;
  449. transform: translateX(100%);
  450. }
  451. </style>