index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <view class="container">
  3. <view class="header">
  4. <view class="language-switch" @click="handleLanguageSwitch">
  5. <text class="language-text">{{ currentLocaleName }}</text>
  6. </view>
  7. <text class="title">{{ t('home.title') }}</text>
  8. <text class="subtitle">{{ t('home.subtitle') }}</text>
  9. </view>
  10. <view class="content">
  11. <view class="card">
  12. <text class="card-title">{{ t('home.systemInfo') }}</text>
  13. <view class="info-item">
  14. <text class="label">{{ t('home.framework') }}:</text>
  15. <text class="value">{{ t('home.frameworkValue') }}</text>
  16. </view>
  17. <view class="info-item">
  18. <text class="label">{{ t('home.platform') }}:</text>
  19. <text class="value">{{ t('home.platformValue') }}</text>
  20. </view>
  21. </view>
  22. <view class="action-section">
  23. <button type="primary" @click="handleClick">{{ t('home.startButton') }}</button>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script setup>
  29. import { computed, watch } from 'vue'
  30. import { onShow } from '@dcloudio/uni-app'
  31. import { useI18n } from 'vue-i18n'
  32. import { useLocaleStore } from '@/store/locale'
  33. const { t, locale } = useI18n()
  34. const localeStore = useLocaleStore()
  35. // 获取当前语言名称
  36. const currentLocaleName = computed(() => localeStore.getCurrentLocaleName())
  37. // 设置页面标题
  38. const setPageTitle = () => {
  39. uni.setNavigationBarTitle({
  40. title: t('home.title')
  41. })
  42. }
  43. // 页面显示时设置标题
  44. onShow(() => {
  45. setPageTitle()
  46. })
  47. // 监听语言变化,更新标题
  48. watch(locale, () => {
  49. setPageTitle()
  50. })
  51. // 切换语言
  52. const handleLanguageSwitch = () => {
  53. const success = localeStore.toggleLocale()
  54. if (success) {
  55. uni.showToast({
  56. title: t('common.language.switchSuccess'),
  57. icon: 'success'
  58. })
  59. }
  60. }
  61. const handleClick = () => {
  62. uni.showToast({
  63. title: t('home.welcomeMessage'),
  64. icon: 'success'
  65. })
  66. }
  67. </script>
  68. <style lang="scss" scoped>
  69. .container {
  70. min-height: 100vh;
  71. padding: 40rpx;
  72. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  73. }
  74. .header {
  75. text-align: center;
  76. padding: 60rpx 0;
  77. position: relative;
  78. .language-switch {
  79. position: absolute;
  80. top: 40rpx;
  81. right: 32rpx;
  82. background: rgba(255, 255, 255, 0.25);
  83. padding: 16rpx 28rpx;
  84. border-radius: 40rpx;
  85. backdrop-filter: blur(10rpx);
  86. border: 1rpx solid rgba(255, 255, 255, 0.3);
  87. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  88. .language-text {
  89. font-size: 28rpx;
  90. color: #ffffff;
  91. font-weight: 500;
  92. }
  93. }
  94. .title {
  95. display: block;
  96. font-size: 48rpx;
  97. font-weight: bold;
  98. color: #ffffff;
  99. margin-bottom: 20rpx;
  100. }
  101. .subtitle {
  102. display: block;
  103. font-size: 28rpx;
  104. color: rgba(255, 255, 255, 0.8);
  105. }
  106. }
  107. .content {
  108. .card {
  109. background: #ffffff;
  110. border-radius: 20rpx;
  111. padding: 40rpx;
  112. margin-bottom: 40rpx;
  113. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
  114. .card-title {
  115. display: block;
  116. font-size: 32rpx;
  117. font-weight: bold;
  118. color: #333333;
  119. margin-bottom: 30rpx;
  120. }
  121. .info-item {
  122. display: flex;
  123. justify-content: space-between;
  124. align-items: center;
  125. padding: 20rpx 0;
  126. border-bottom: 1rpx solid #f0f0f0;
  127. &:last-child {
  128. border-bottom: none;
  129. }
  130. .label {
  131. font-size: 28rpx;
  132. color: #666666;
  133. }
  134. .value {
  135. font-size: 28rpx;
  136. color: #333333;
  137. font-weight: 500;
  138. }
  139. }
  140. }
  141. .action-section {
  142. padding: 20rpx 0;
  143. button {
  144. width: 100%;
  145. height: 88rpx;
  146. line-height: 88rpx;
  147. border-radius: 44rpx;
  148. font-size: 32rpx;
  149. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  150. }
  151. }
  152. }
  153. </style>