四零语境前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

146 lines
3.3 KiB

  1. <template>
  2. <!-- 悬浮按钮 - 只在最后一页显示 -->
  3. <div v-if="isLastPage" class="floating-buttons">
  4. <button
  5. v-if="hasNextCourse"
  6. class="floating-button next-lesson"
  7. @click="handleNextCourse"
  8. >
  9. <span class="floating-button-text">下一课</span>
  10. </button>
  11. <button
  12. class="floating-button back-to-start"
  13. @click="handleBackToStart"
  14. >
  15. <span class="floating-button-text">回到开始</span>
  16. </button>
  17. </div>
  18. </template>
  19. <script>
  20. export default {
  21. name: 'FloatingButtons',
  22. props: {
  23. // 是否为最后一页
  24. isLastPage: {
  25. type: Boolean,
  26. default: false
  27. },
  28. // 是否有下一课
  29. hasNextCourse: {
  30. type: Boolean,
  31. default: false
  32. }
  33. },
  34. methods: {
  35. // 跳转到下一课
  36. handleNextCourse() {
  37. this.$emit('next-course');
  38. },
  39. // 回到开始
  40. handleBackToStart() {
  41. this.$emit('back-to-start');
  42. }
  43. }
  44. }
  45. </script>
  46. <style scoped>
  47. /* 悬浮按钮样式 */
  48. .floating-buttons {
  49. position: fixed;
  50. top: 50%;
  51. right: 30rpx;
  52. transform: translateY(-50%);
  53. z-index: 1000;
  54. display: flex;
  55. flex-direction: column;
  56. gap: 16rpx;
  57. }
  58. .floating-button {
  59. width: 180rpx;
  60. height: 88rpx;
  61. background: linear-gradient(135deg, #06DADC 0%, #04B8BA 100%);
  62. border-radius: 44rpx;
  63. display: flex;
  64. align-items: center;
  65. justify-content: center;
  66. box-shadow: 0 6rpx 24rpx rgba(6, 218, 220, 0.25);
  67. transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  68. border: none;
  69. outline: none;
  70. position: relative;
  71. overflow: hidden;
  72. }
  73. .floating-button::before {
  74. content: '';
  75. position: absolute;
  76. top: 0;
  77. left: 0;
  78. right: 0;
  79. bottom: 0;
  80. background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.05) 100%);
  81. border-radius: 44rpx;
  82. opacity: 0;
  83. transition: opacity 0.3s ease;
  84. }
  85. .floating-button:hover::before {
  86. opacity: 1;
  87. }
  88. .floating-button:active {
  89. transform: scale(0.96);
  90. box-shadow: 0 3rpx 12rpx rgba(6, 218, 220, 0.35);
  91. }
  92. .floating-button-text {
  93. font-family: PingFang SC, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  94. font-weight: 600;
  95. font-size: 26rpx;
  96. color: #FFFFFF;
  97. text-align: center;
  98. line-height: 1;
  99. letter-spacing: 0.5rpx;
  100. position: relative;
  101. z-index: 1;
  102. }
  103. .floating-button.next-lesson {
  104. background: linear-gradient(135deg, #06DADC 0%, #04B8BA 100%);
  105. box-shadow: 0 6rpx 24rpx rgba(6, 218, 220, 0.25);
  106. }
  107. .floating-button.next-lesson:active {
  108. box-shadow: 0 3rpx 12rpx rgba(6, 218, 220, 0.35);
  109. }
  110. .floating-button.back-to-start {
  111. background: linear-gradient(135deg, #FF7B7B 0%, #FF6B6B 100%);
  112. box-shadow: 0 6rpx 24rpx rgba(255, 107, 107, 0.25);
  113. }
  114. .floating-button.back-to-start:active {
  115. box-shadow: 0 3rpx 12rpx rgba(255, 107, 107, 0.35);
  116. }
  117. /* 响应式调整 */
  118. @media (max-width: 750px) {
  119. .floating-buttons {
  120. top: 50%;
  121. right: 24rpx;
  122. transform: translateY(-50%);
  123. }
  124. .floating-button {
  125. width: 160rpx;
  126. height: 80rpx;
  127. border-radius: 40rpx;
  128. }
  129. .floating-button-text {
  130. font-size: 24rpx;
  131. }
  132. }
  133. </style>