History.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  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 isTimelineVisible = ref(false)
  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. onMounted(() => {
  243. const observer = new IntersectionObserver(
  244. (entries) => {
  245. entries.forEach((entry) => {
  246. if (!entry.isIntersecting) return
  247. isTimelineVisible.value = true
  248. observer.unobserve(entry.target)
  249. })
  250. },
  251. { threshold: 0.1 }
  252. )
  253. if (timelineRef.value) {
  254. observer.observe(timelineRef.value)
  255. }
  256. })
  257. </script>
  258. <style scoped lang="scss">
  259. .history {
  260. @apply overflow-hidden relative py-60px;
  261. @apply lt-sm:pt-60px lt-sm:pb-160px lt-sm:px-32px;
  262. @extend %landing-container;
  263. background-size: cover;
  264. background-position: center;
  265. background-image: url('@/assets/images/history-bg.png');
  266. @screen lt-sm {
  267. background-image: url('@/assets/images/history-bg-mobile.png');
  268. }
  269. }
  270. .history-container {
  271. @apply flex flex-col items-center transition-all duration-1000;
  272. }
  273. .history-title {
  274. @apply font-semibold font-s-36px text-#000000 lh-60px text-center mb-4px;
  275. @apply lt-sm:font-s-48px lt-sm:lh-60px;
  276. }
  277. .history-subtitle {
  278. @apply font-s-16px text-#091221/70 text-center lh-30px mb-50px;
  279. @apply lt-sm:font-s-24px lt-sm:lh-40px lt-sm:mb-88px;
  280. }
  281. .history-top {
  282. @apply w-full h-255px flex py-50px items-center;
  283. @apply lt-sm:h-176px;
  284. }
  285. .history-year-wrapper {
  286. @apply relative pl-127px w-600px shrink-0 h-170px overflow-hidden;
  287. @apply lt-sm:hidden;
  288. }
  289. .history-year-content {
  290. @apply absolute left-127px top-0 h-full flex items-center w-full;
  291. }
  292. .history-year-text {
  293. @apply text-170px font-bold text-#0F67F8 select-none leading-none;
  294. -webkit-text-stroke: 1px #2563eb;
  295. text-shadow: 0 0 20px rgba(37, 99, 235, 0.1);
  296. }
  297. .history-event-wrapper {
  298. @apply flex-1 h-full relative overflow-hidden pt-14px;
  299. @apply lt-sm:h-176px lt-sm:pt-0;
  300. }
  301. .history-event-content {
  302. @apply absolute left-0 top-14px w-full flex flex-col pr-114px;
  303. @apply lt-sm:pr-0 static;
  304. }
  305. .history-event-header {
  306. @apply flex justify-between items-center w-full;
  307. @apply lt-sm:h-45px;
  308. }
  309. .history-event-month {
  310. @apply font-s-22px font-semibold lh-30.8px text-#091221 flex-1;
  311. @apply lt-sm:font-s-32px lt-sm:lh-30.8px;
  312. }
  313. .history-event-controls {
  314. @apply flex gap-12px relative z-10;
  315. @apply lt-sm:gap-16px;
  316. }
  317. .history-event-arrow {
  318. @apply wh-32px transition-all;
  319. @apply lt-sm:wh-45px;
  320. }
  321. .history-event-line {
  322. @apply h-2px w-34px bg-#0F67F8 mt-11px origin-left;
  323. @apply lt-sm:h-4px lt-sm:w-68px lt-sm:mt-25px;
  324. }
  325. .history-event-desc {
  326. @apply w-full font-s-20px lh-35px text-#091221/70 mt-26px;
  327. @apply lt-sm:font-s-24px lt-sm:mt-26px lt-sm:lh-normal;
  328. }
  329. .history-timeline {
  330. @apply w-full relative pt-47px pb-60px;
  331. @apply lt-sm:py-0 lt-sm:mt-70px;
  332. }
  333. .history-timeline-track {
  334. @apply relative h-16px w-full bg-white rounded-full px-60px;
  335. @apply lt-sm:h-16px lt-sm:px-60px;
  336. }
  337. .history-timeline-progress {
  338. @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;
  339. }
  340. .history-timeline-nodes {
  341. @apply relative h-full w-full;
  342. }
  343. .history-timeline-node {
  344. @apply absolute top-1/2 -translate-y-1/2 -translate-x-1/2 flex flex-col items-center cursor-pointer group z-2;
  345. }
  346. .history-timeline-dot {
  347. @apply rounded-full transition-all duration-300 relative bg-white;
  348. @apply lt-sm:wh-14px;
  349. }
  350. .history-timeline-year {
  351. @apply absolute top-24px text-16px transition-all duration-300 whitespace-nowrap;
  352. }
  353. .history-nav {
  354. @apply flex gap-24px mt-45px;
  355. @apply lt-sm:hidden;
  356. }
  357. .history-nav-btn {
  358. @apply wh-56px flex-center cursor-pointer;
  359. }
  360. .year-flow-enter-active,
  361. .year-flow-leave-active {
  362. transition: all 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  363. }
  364. .year-flow-enter-from {
  365. opacity: 0;
  366. transform: translateY(100%) scale(0.9);
  367. }
  368. .year-flow-leave-to {
  369. opacity: 0;
  370. transform: translateY(-100%) scale(0.9);
  371. }
  372. .event-fade-enter-active,
  373. .event-fade-leave-active {
  374. transition: opacity 0.3s ease;
  375. }
  376. .event-fade-enter-from,
  377. .event-fade-leave-to {
  378. opacity: 0;
  379. }
  380. .history-timeline-mobile {
  381. @apply flex items-center justify-between w-full px-0;
  382. @apply lt-sm:mt-70px;
  383. }
  384. .history-mobile-btn {
  385. @apply shrink-0 cursor-pointer transition-all absolute;
  386. @apply lt-sm:wh-64px z-10;
  387. &.i-custom-button-previous-mobile {
  388. @apply left-0;
  389. }
  390. &.i-custom-button-next-mobile {
  391. @apply right-0;
  392. }
  393. }
  394. .history-mobile-track-container {
  395. @apply relative flex-1;
  396. }
  397. .history-mobile-track-line {
  398. @apply absolute left-0 right-0 bg-white rounded-full;
  399. @apply lt-sm:h-16px lt-sm:top-1/2 lt-sm:translate-y--1/2;
  400. }
  401. .history-mobile-nodes {
  402. @apply hidden relative w-full h-full justify-between items-center z-1;
  403. @apply lt-sm:px-100px lt-sm:h-16px lt-sm:flex;
  404. }
  405. .history-mobile-node {
  406. @apply relative flex flex-col items-center cursor-pointer;
  407. @apply lt-sm:w-60px;
  408. &.invisible {
  409. @apply transition-none;
  410. .history-mobile-dot,
  411. .history-mobile-year {
  412. @apply transition-none;
  413. }
  414. }
  415. }
  416. .history-mobile-dot {
  417. @apply rounded-full bg-white transition-all z-2 border-#0F67F8 border-1;
  418. @apply lt-sm:wh-18px;
  419. &.active {
  420. @apply scale-150 outline-#CEE0FF outline-solid border-none bg-[linear-gradient(90deg,#779EFF_0%,#0A50FF_100%)];
  421. @apply lt-sm:wh-22px lt-sm:outline-8px;
  422. }
  423. }
  424. .history-mobile-year {
  425. @apply hidden absolute text-#091221/60 pf-sc-regular transition-all whitespace-nowrap;
  426. @apply lt-sm:font-s-22px lt-sm:top-58px lt-sm:block;
  427. &.active {
  428. @apply text-#0F67F8 font-semibold scale-110;
  429. }
  430. }
  431. /* Timeline Animation */
  432. .timeline-next-move,
  433. .timeline-prev-move {
  434. transition: all 0.5s ease;
  435. }
  436. .timeline-next-enter-active,
  437. .timeline-next-leave-active,
  438. .timeline-prev-enter-active,
  439. .timeline-prev-leave-active {
  440. transition: all 0.5s ease;
  441. }
  442. .timeline-next-leave-active {
  443. position: absolute;
  444. left: 100px;
  445. }
  446. .timeline-prev-leave-active {
  447. position: absolute;
  448. right: 100px;
  449. }
  450. .timeline-next-enter-from {
  451. opacity: 0;
  452. transform: translateX(100%);
  453. }
  454. .timeline-next-leave-to {
  455. opacity: 0;
  456. transform: translateX(-100%);
  457. }
  458. .timeline-prev-enter-from {
  459. opacity: 0;
  460. transform: translateX(-100%);
  461. }
  462. .timeline-prev-leave-to {
  463. opacity: 0;
  464. transform: translateX(100%);
  465. }
  466. </style>