History.vue 15 KB

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